MCPcopy Create free account
hub / github.com/MapServer/MapServer / FLTGetBinaryComparisonExpresssion

Function FLTGetBinaryComparisonExpresssion

mapogcfilter.c:2382–2471  ·  view source on GitHub ↗

/ FLTGetBinaryComparisonExpresssion */ / Return the expression for a binary comparison filter node. */ /

Source from the content-addressed store, hash-verified

2380/* Return the expression for a binary comparison filter node. */
2381/************************************************************************/
2382char *FLTGetBinaryComparisonExpresssion(FilterEncodingNode *psFilterNode, layerObj *lp)
2383{
2384 const size_t bufferSize = 1024;
2385 char szBuffer[1024];
2386 int bString=0;
2387 char szTmp[256];
2388
2389 szBuffer[0] = '\0';
2390 if (!psFilterNode || !FLTIsBinaryComparisonFilterType(psFilterNode->pszValue))
2391 return NULL;
2392
2393/* -------------------------------------------------------------------- */
2394/* check if the value is a numeric value or alphanumeric. If it */
2395/* is alphanumeric, add quotes around attribute and values. */
2396/* -------------------------------------------------------------------- */
2397 bString = 0;
2398 if (psFilterNode->psRightNode->pszValue)
2399 {
2400 const char* pszOFGType;
2401 snprintf(szTmp, sizeof(szTmp), "%s_type", psFilterNode->psLeftNode->pszValue);
2402 pszOFGType = msOWSLookupMetadata(&(lp->metadata), "OFG", szTmp);
2403 if (pszOFGType!= NULL && strcasecmp(pszOFGType, "Character") == 0)
2404 bString = 1;
2405 else if (FLTIsNumeric(psFilterNode->psRightNode->pszValue) == MS_FALSE)
2406 bString = 1;
2407 }
2408
2409 /* specical case to be able to have empty strings in the expression. */
2410 if (psFilterNode->psRightNode->pszValue == NULL)
2411 bString = 1;
2412
2413
2414 if (bString)
2415 strlcat(szBuffer, " (\"[", bufferSize);
2416 else
2417 strlcat(szBuffer, " ([", bufferSize);
2418 /* attribute */
2419
2420 strlcat(szBuffer, psFilterNode->psLeftNode->pszValue, bufferSize);
2421 if (bString)
2422 strlcat(szBuffer, "]\" ", bufferSize);
2423 else
2424 strlcat(szBuffer, "] ", bufferSize);
2425
2426
2427 /* logical operator */
2428 if (strcasecmp(psFilterNode->pszValue,
2429 "PropertyIsEqualTo") == 0)
2430 {
2431 /*case insensitive set ? */
2432 if (psFilterNode->psRightNode->pOther &&
2433 (*(int *)psFilterNode->psRightNode->pOther) == 1)
2434 {
2435 strlcat(szBuffer, "IEQ", bufferSize);
2436 }
2437 else
2438 strlcat(szBuffer, "=", bufferSize);
2439 }

Callers 2

FLTGetNodeExpressionFunction · 0.85

Calls 6

msOWSLookupMetadataFunction · 0.85
strcasecmpFunction · 0.85
FLTIsNumericFunction · 0.85
strlcatFunction · 0.85
msStrdupFunction · 0.85

Tested by

no test coverage detected