| 494 | |
| 495 | |
| 496 | char *FLTGetSpatialComparisonCommonExpression(FilterEncodingNode *psNode, layerObj *lp) |
| 497 | { |
| 498 | char *pszExpression = NULL; |
| 499 | shapeObj *psQueryShape = NULL; |
| 500 | double dfDistance = -1; |
| 501 | int nUnit = -1; |
| 502 | char *pszWktText = NULL; |
| 503 | char szBuffer[256]; |
| 504 | char *pszTmp=NULL; |
| 505 | projectionObj sProjTmp; |
| 506 | char *pszEPSG= NULL; |
| 507 | rectObj sQueryRect; |
| 508 | shapeObj *psTmpShape=NULL, *psBufferShape=NULL; |
| 509 | int bBBoxQuery = 0; |
| 510 | |
| 511 | if (psNode == NULL || lp == NULL) |
| 512 | return NULL; |
| 513 | |
| 514 | if (psNode->eType != FILTER_NODE_TYPE_SPATIAL) |
| 515 | return NULL; |
| 516 | |
| 517 | /* get the shape*/ |
| 518 | /*BBOX case: replace it with NOT DISJOINT.*/ |
| 519 | if(FLTIsBBoxFilter(psNode)) |
| 520 | { |
| 521 | pszEPSG = FLTGetBBOX(psNode, &sQueryRect); |
| 522 | /*this should be removed and bbox should parse and strore the srs properly, |
| 523 | using now legacy code*/ |
| 524 | if (pszEPSG) |
| 525 | psNode->pszSRS = msStrdup(pszEPSG); |
| 526 | |
| 527 | psTmpShape = (shapeObj *)msSmallMalloc(sizeof(shapeObj)); |
| 528 | msInitShape(psTmpShape); |
| 529 | msRectToPolygon(sQueryRect, psTmpShape); |
| 530 | bBBoxQuery = 1; |
| 531 | |
| 532 | } |
| 533 | else |
| 534 | { |
| 535 | /*other geos type operations*/ |
| 536 | |
| 537 | /*project shape to layer projection. If the proj is not part of the filter query, |
| 538 | assume that the cooredinates are in the map projection*/ |
| 539 | |
| 540 | psQueryShape = FLTGetShape(psNode, &dfDistance, &nUnit); |
| 541 | |
| 542 | if ((strcasecmp(psNode->pszValue, "DWithin") == 0 || |
| 543 | strcasecmp(psNode->pszValue, "Beyond") == 0 ) && |
| 544 | dfDistance > 0) |
| 545 | { |
| 546 | if (nUnit >=0 && nUnit != lp->map->units) |
| 547 | dfDistance *= msInchesPerUnit(nUnit,0)/msInchesPerUnit(lp->map->units,0); |
| 548 | |
| 549 | psBufferShape = msGEOSBuffer(psQueryShape, dfDistance); |
| 550 | } |
| 551 | if (psBufferShape) |
| 552 | psTmpShape = psBufferShape; |
| 553 | else |
no test coverage detected