MCPcopy Index your code
hub / github.com/MapServer/MapServer / FLTGetIsBetweenComparisonExpresssion

Function FLTGetIsBetweenComparisonExpresssion

mapogcfilter.c:2715–2818  ·  view source on GitHub ↗

/ FLTGetIsBetweenComparisonExpresssion */ / Build expresssion for IsBteween Filter. */ /

Source from the content-addressed store, hash-verified

2713/* Build expresssion for IsBteween Filter. */
2714/************************************************************************/
2715char *FLTGetIsBetweenComparisonExpresssion(FilterEncodingNode *psFilterNode,
2716 layerObj *lp)
2717{
2718 const size_t bufferSize = 1024;
2719 char szBuffer[1024];
2720 char **aszBounds = NULL;
2721 int nBounds = 0;
2722 int bString=0;
2723 char szTmp[256];
2724
2725
2726 szBuffer[0] = '\0';
2727 if (!psFilterNode ||
2728 !(strcasecmp(psFilterNode->pszValue, "PropertyIsBetween") == 0))
2729 return NULL;
2730
2731 if (!psFilterNode->psLeftNode || !psFilterNode->psRightNode )
2732 return NULL;
2733
2734/* -------------------------------------------------------------------- */
2735/* Get the bounds value which are stored like boundmin;boundmax */
2736/* -------------------------------------------------------------------- */
2737 aszBounds = msStringSplit(psFilterNode->psRightNode->pszValue, ';', &nBounds);
2738 if (nBounds != 2)
2739 {
2740 msFreeCharArray(aszBounds, nBounds);
2741 return NULL;
2742 }
2743/* -------------------------------------------------------------------- */
2744/* check if the value is a numeric value or alphanumeric. If it */
2745/* is alphanumeric, add quotes around attribute and values. */
2746/* -------------------------------------------------------------------- */
2747 bString = 0;
2748 if (aszBounds[0])
2749 {
2750 const char* pszOFGType;
2751 snprintf(szTmp, sizeof(szTmp), "%s_type", psFilterNode->psLeftNode->pszValue);
2752 pszOFGType = msOWSLookupMetadata(&(lp->metadata), "OFG", szTmp);
2753 if (pszOFGType!= NULL && strcasecmp(pszOFGType, "Character") == 0)
2754 bString = 1;
2755 else if (FLTIsNumeric(aszBounds[0]) == MS_FALSE)
2756 bString = 1;
2757 }
2758 if (!bString)
2759 {
2760 if (aszBounds[1])
2761 {
2762 if (FLTIsNumeric(aszBounds[1]) == MS_FALSE)
2763 bString = 1;
2764 }
2765 }
2766
2767
2768/* -------------------------------------------------------------------- */
2769/* build expresssion. */
2770/* -------------------------------------------------------------------- */
2771 if (bString)
2772 strlcat(szBuffer, " (\"[", bufferSize);

Callers 2

FLTGetNodeExpressionFunction · 0.85

Calls 7

strcasecmpFunction · 0.85
msStringSplitFunction · 0.85
msFreeCharArrayFunction · 0.85
msOWSLookupMetadataFunction · 0.85
FLTIsNumericFunction · 0.85
strlcatFunction · 0.85
msStrdupFunction · 0.85

Tested by

no test coverage detected