/ FLTGetIsBetweenComparisonSQLExpresssion */ / Build an SQL expresssion for IsBteween Filter. */ /
| 2611 | /* Build an SQL expresssion for IsBteween Filter. */ |
| 2612 | /************************************************************************/ |
| 2613 | char *FLTGetIsBetweenComparisonSQLExpresssion(FilterEncodingNode *psFilterNode, |
| 2614 | layerObj *lp) |
| 2615 | { |
| 2616 | const size_t bufferSize = 1024; |
| 2617 | char szBuffer[1024]; |
| 2618 | char **aszBounds = NULL; |
| 2619 | int nBounds = 0; |
| 2620 | int bString=0; |
| 2621 | char szTmp[256]; |
| 2622 | char* pszEscapedStr; |
| 2623 | |
| 2624 | szBuffer[0] = '\0'; |
| 2625 | if (!psFilterNode || |
| 2626 | !(strcasecmp(psFilterNode->pszValue, "PropertyIsBetween") == 0)) |
| 2627 | return NULL; |
| 2628 | |
| 2629 | if (!psFilterNode->psLeftNode || !psFilterNode->psRightNode ) |
| 2630 | return NULL; |
| 2631 | |
| 2632 | /* -------------------------------------------------------------------- */ |
| 2633 | /* Get the bounds value which are stored like boundmin;boundmax */ |
| 2634 | /* -------------------------------------------------------------------- */ |
| 2635 | aszBounds = msStringSplit(psFilterNode->psRightNode->pszValue, ';', &nBounds); |
| 2636 | if (nBounds != 2) |
| 2637 | return NULL; |
| 2638 | /* -------------------------------------------------------------------- */ |
| 2639 | /* check if the value is a numeric value or alphanumeric. If it */ |
| 2640 | /* is alphanumeric, add quotes around attribute and values. */ |
| 2641 | /* -------------------------------------------------------------------- */ |
| 2642 | bString = 0; |
| 2643 | if (aszBounds[0]) |
| 2644 | { |
| 2645 | const char* pszOFGType; |
| 2646 | snprintf(szTmp, sizeof(szTmp), "%s_type", psFilterNode->psLeftNode->pszValue); |
| 2647 | pszOFGType = msOWSLookupMetadata(&(lp->metadata), "OFG", szTmp); |
| 2648 | if (pszOFGType!= NULL && strcasecmp(pszOFGType, "Character") == 0) |
| 2649 | bString = 1; |
| 2650 | else if (FLTIsNumeric(aszBounds[0]) == MS_FALSE) |
| 2651 | bString = 1; |
| 2652 | } |
| 2653 | if (!bString) |
| 2654 | { |
| 2655 | if (aszBounds[1]) |
| 2656 | { |
| 2657 | if (FLTIsNumeric(aszBounds[1]) == MS_FALSE) |
| 2658 | bString = 1; |
| 2659 | } |
| 2660 | } |
| 2661 | |
| 2662 | |
| 2663 | /* -------------------------------------------------------------------- */ |
| 2664 | /* build expresssion. */ |
| 2665 | /* -------------------------------------------------------------------- */ |
| 2666 | /*opening paranthesis */ |
| 2667 | strlcat(szBuffer, " (", bufferSize); |
| 2668 | |
| 2669 | /* attribute */ |
| 2670 | pszEscapedStr = msLayerEscapePropertyName(lp, psFilterNode->psLeftNode->pszValue); |
no test coverage detected