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

Function FLTGetIsBetweenComparisonCommonExpresssion

mapogcfiltercommon.c:199–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197
198
199char *FLTGetIsBetweenComparisonCommonExpresssion(FilterEncodingNode *psFilterNode,
200 layerObj *lp)
201{
202 const size_t bufferSize = 1024;
203 char szBuffer[1024];
204 char **aszBounds = NULL;
205 int nBounds = 0;
206 int bString=0;
207 char *pszExpression=NULL;
208
209 if (!psFilterNode ||
210 !(strcasecmp(psFilterNode->pszValue, "PropertyIsBetween") == 0))
211 return NULL;
212
213 if (psFilterNode->psLeftNode == NULL || psFilterNode->psRightNode == NULL )
214 return NULL;
215
216/* -------------------------------------------------------------------- */
217/* Get the bounds value which are stored like boundmin;boundmax */
218/* -------------------------------------------------------------------- */
219 aszBounds = msStringSplit(psFilterNode->psRightNode->pszValue, ';', &nBounds);
220 if (nBounds != 2)
221 {
222 if (aszBounds)
223 msFreeCharArray(aszBounds, nBounds);
224 return NULL;
225 }
226/* -------------------------------------------------------------------- */
227/* check if the value is a numeric value or alphanumeric. If it */
228/* is alphanumeric, add quotes around attribute and values. */
229/* -------------------------------------------------------------------- */
230 bString = 0;
231 if (aszBounds[0])
232 {
233 snprintf(szBuffer, bufferSize, "%s_type", psFilterNode->psLeftNode->pszValue);
234 if (msOWSLookupMetadata(&(lp->metadata), "OFG", szBuffer) != NULL &&
235 (strcasecmp(msOWSLookupMetadata(&(lp->metadata), "G", szBuffer), "Character") == 0))
236 bString = 1;
237 else if (FLTIsNumeric(aszBounds[0]) == MS_FALSE)
238 bString = 1;
239 }
240 if (!bString)
241 {
242 if (aszBounds[1])
243 {
244 if (FLTIsNumeric(aszBounds[1]) == MS_FALSE)
245 bString = 1;
246 }
247 }
248
249
250/* -------------------------------------------------------------------- */
251/* build expresssion. */
252/* -------------------------------------------------------------------- */
253 /* attribute */
254 if (bString)
255 sprintf(szBuffer, "%s", " (\"[");
256 else

Callers 1

FLTGetCommonExpressionFunction · 0.85

Calls 6

strcasecmpFunction · 0.85
msStringSplitFunction · 0.85
msFreeCharArrayFunction · 0.85
msOWSLookupMetadataFunction · 0.85
FLTIsNumericFunction · 0.85
msStringConcatenateFunction · 0.85

Tested by

no test coverage detected