[mapserver-commits] r7831 - branches/branch-5-2/mapserver
svn at osgeo.org
svn at osgeo.org
Mon Jul 28 09:47:55 EDT 2008
Author: Assefa
Date: 2008-07-28 09:47:55 -0400 (Mon, 28 Jul 2008)
New Revision: 7831
Modified:
branches/branch-5-2/mapserver/HISTORY.TXT
branches/branch-5-2/mapserver/mapogcfilter.c
branches/branch-5-2/mapserver/mapserver.h
Log:
Support reading projection parameter for OFC filters (#2712)
Modified: branches/branch-5-2/mapserver/HISTORY.TXT
===================================================================
--- branches/branch-5-2/mapserver/HISTORY.TXT 2008-07-23 03:38:08 UTC (rev 7830)
+++ branches/branch-5-2/mapserver/HISTORY.TXT 2008-07-28 13:47:55 UTC (rev 7831)
@@ -13,6 +13,8 @@
Current Version (SVN branch-5-2)
--------------------------------
+- Support reading projection parameter for OFC filters (#2712)
+
- Stop configure execution with an error if path to one of the -config
scripts is invalid (#2710)
Modified: branches/branch-5-2/mapserver/mapogcfilter.c
===================================================================
--- branches/branch-5-2/mapserver/mapogcfilter.c 2008-07-23 03:38:08 UTC (rev 7830)
+++ branches/branch-5-2/mapserver/mapogcfilter.c 2008-07-28 13:47:55 UTC (rev 7831)
@@ -50,8 +50,9 @@
return msOGRGeometryToShape(hGeometry, psShape, nType);
}
-int FLTShapeFromGMLTree(CPLXMLNode *psTree, shapeObj *psShape)
+int FLTShapeFromGMLTree(CPLXMLNode *psTree, shapeObj *psShape, char **ppszSRS)
{
+ char *pszSRS = NULL;
if (psTree && psShape)
{
CPLXMLNode *psNext = psTree->psNext;
@@ -66,6 +67,11 @@
FLTogrConvertGeometry(hGeometry, psShape,
OGR_G_GetGeometryType(hGeometry));
}
+
+ pszSRS = (char *)CPLGetXMLValue(psTree, "srsName", NULL);
+ if (ppszSRS && pszSRS)
+ *ppszSRS = strdup(pszSRS);
+
return MS_TRUE;
}
@@ -110,6 +116,59 @@
return MS_TRUE;
}
+int FTLParseEpsgString(char *pszEpsg, projectionObj *psProj)
+{
+ int nStatus = MS_FALSE;
+ int nTokens = 0;
+ char **tokens = NULL;
+ int nEpsgTmp=0;
+
+#ifdef USE_PROJ
+ if (pszEpsg && psProj)
+ {
+ nTokens = 0;
+ tokens = msStringSplit(pszEpsg,'#', &nTokens);
+ if (tokens && nTokens == 2)
+ {
+ char szTmp[32];
+ sprintf(szTmp, "init=epsg:%s",tokens[1]);
+ msInitProjection(psProj);
+ if (msLoadProjectionString(psProj, szTmp) == 0)
+ nStatus = MS_TRUE;
+ }
+ else if (tokens && nTokens == 1)
+ {
+ if (tokens)
+ msFreeCharArray(tokens, nTokens);
+ nTokens = 0;
+
+ tokens = msStringSplit(pszEpsg,':', &nTokens);
+ nEpsgTmp = -1;
+ if (tokens && nTokens == 1)
+ {
+ nEpsgTmp = atoi(tokens[0]);
+
+ }
+ else if (tokens && nTokens == 2)
+ {
+ nEpsgTmp = atoi(tokens[1]);
+ }
+ if (nEpsgTmp > 0)
+ {
+ char szTmp[32];
+ sprintf(szTmp, "init=epsg:%d",nEpsgTmp);
+ msInitProjection(psProj);
+ if (msLoadProjectionString(psProj, szTmp) == 0)
+ nStatus = MS_TRUE;
+ }
+ }
+ if (tokens)
+ msFreeCharArray(tokens, nTokens);
+#endif
+ }
+ return nStatus;
+}
+
/************************************************************************/
/* FLTGetQueryResultsForNode */
/* */
@@ -123,13 +182,11 @@
int bOnlySpatialFilter)
{
char *szExpression = NULL;
- int bIsBBoxFilter =0, nEpsgTmp = 0, i=0;
+ int bIsBBoxFilter =0, i=0;
char *szEPSG = NULL;
rectObj sQueryRect = map->extent;
layerObj *lp = NULL;
char *szClassItem = NULL;
- char **tokens = NULL;
- int nTokens = 0;
projectionObj sProjTmp;
int bPointQuery = 0, bShapeQuery=0;
shapeObj *psQueryShape = NULL;
@@ -270,57 +327,23 @@
/* -------------------------------------------------------------------- */
if(szEPSG && map->projection.numargs > 0)
{
-#ifdef USE_PROJ
- nTokens = 0;
- tokens = msStringSplit(szEPSG,'#', &nTokens);
- if (tokens && nTokens == 2)
- {
- char szTmp[32];
- sprintf(szTmp, "init=epsg:%s",tokens[1]);
- msInitProjection(&sProjTmp);
- if (msLoadProjectionString(&sProjTmp, szTmp) == 0)
- msProjectRect(&sProjTmp, &map->projection, &sQueryRect);
- }
- else if (tokens && nTokens == 1)
- {
- if (tokens)
- msFreeCharArray(tokens, nTokens);
- nTokens = 0;
-
- tokens = msStringSplit(szEPSG,':', &nTokens);
- nEpsgTmp = -1;
- if (tokens && nTokens == 1)
- {
- nEpsgTmp = atoi(tokens[0]);
-
- }
- else if (tokens && nTokens == 2)
- {
- nEpsgTmp = atoi(tokens[1]);
- }
- if (nEpsgTmp > 0)
- {
- char szTmp[32];
- sprintf(szTmp, "init=epsg:%d",nEpsgTmp);
- msInitProjection(&sProjTmp);
- if (msLoadProjectionString(&sProjTmp, szTmp) == 0)
- msProjectRect(&sProjTmp, &map->projection, &sQueryRect);
- }
- }
- if (tokens)
- msFreeCharArray(tokens, nTokens);
-#endif
+ if (FTLParseEpsgString(szEPSG, &sProjTmp))
+ msProjectRect(&sProjTmp, &map->projection, &sQueryRect);
}
+
if (szExpression || bIsBBoxFilter ||
(bOnlySpatialFilter && !bIsBBoxFilter && !bPointQuery && !bShapeQuery))
status = msQueryByRect(map, lp->index, sQueryRect);
else if (bPointQuery && psQueryShape && psQueryShape->numlines > 0
&& psQueryShape->line[0].numpoints > 0) /* && dfDistance >=0) */
{
+ if (psNode->pszSRS && map->projection.numargs > 0 &&
+ FTLParseEpsgString(psNode->pszSRS, &sProjTmp))
+ msProjectShape(&sProjTmp, &map->projection, psQueryShape);
- if (bUseGeos)
+ if (bUseGeos)
{
if ((strcasecmp(psNode->pszValue, "DWithin") == 0 ||
strcasecmp(psNode->pszValue, "Beyond") == 0 ) &&
@@ -365,6 +388,11 @@
else if (bShapeQuery && psQueryShape && psQueryShape->numlines > 0
&& psQueryShape->line[0].numpoints > 0)
{
+ /*reproject shape if epsg was set*/
+ if (psNode->pszSRS && map->projection.numargs > 0 &&
+ FTLParseEpsgString(psNode->pszSRS, &sProjTmp))
+ msProjectShape(&sProjTmp, &map->projection, psQueryShape);
+
if (bUseGeos)
{
if ((strcasecmp(psNode->pszValue, "DWithin") == 0 ||
@@ -1327,6 +1355,9 @@
if( psFilterNode->pszValue )
free( psFilterNode->pszValue );
+ if (psFilterNode->pszSRS)
+ free( psFilterNode->pszSRS);
+
if( psFilterNode->pOther )
{
#ifdef notdef
@@ -1359,9 +1390,10 @@
psFilterNode->eType = FILTER_NODE_TYPE_UNDEFINED;
psFilterNode->pszValue = NULL;
psFilterNode->pOther = NULL;
+ psFilterNode->pszSRS = NULL;
psFilterNode->psLeftNode = NULL;
psFilterNode->psRightNode = NULL;
-
+
return psFilterNode;
}
@@ -1613,8 +1645,8 @@
shapeObj *psShape = NULL;
int bPoint = 0, bLine = 0, bPolygon = 0;
char *pszUnits = NULL;
+ char *pszSRS = NULL;
-
CPLXMLNode *psGMLElement = NULL, *psDistance=NULL;
@@ -1643,9 +1675,13 @@
pszUnits = (char *)CPLGetXMLValue(psDistance, "units", NULL);
psShape = (shapeObj *)malloc(sizeof(shapeObj));
msInitShape(psShape);
- if (FLTShapeFromGMLTree(psGMLElement, psShape))
+ if (FLTShapeFromGMLTree(psGMLElement, psShape, &pszSRS))
/* if (FLTGML2Shape_XMLNode(psPoint, psShape)) */
{
+ /*set the srs if available*/
+ if (pszSRS)
+ psFilterNode->pszSRS = pszSRS;
+
psFilterNode->psLeftNode = FLTCreateFilterEncodingNode();
/* not really using the property name anywhere ?? Is is always */
/* Geometry ? */
@@ -1686,7 +1722,7 @@
{
shapeObj *psShape = NULL;
int bLine = 0, bPolygon = 0, bPoint=0;
-
+ char *pszSRS = NULL;
CPLXMLNode *psGMLElement = NULL;
@@ -1712,9 +1748,13 @@
{
psShape = (shapeObj *)malloc(sizeof(shapeObj));
msInitShape(psShape);
- if (FLTShapeFromGMLTree(psGMLElement, psShape))
+ if (FLTShapeFromGMLTree(psGMLElement, psShape, &pszSRS))
/* if (FLTGML2Shape_XMLNode(psPoint, psShape)) */
{
+ /*set the srs if available*/
+ if (pszSRS)
+ psFilterNode->pszSRS = pszSRS;
+
psFilterNode->psLeftNode = FLTCreateFilterEncodingNode();
/* not really using the property name anywhere ?? Is is always */
/* Geometry ? */
@@ -2457,6 +2497,7 @@
msFreeCharArray(tokens, nTokens);
nTokens = 0;
tokens = msStringSplit(szUnitStr,'#', &nTokens);
+ msFree(szUnitStr);
if (tokens && nTokens >= 1)
{
if (nTokens ==1)
@@ -3759,7 +3800,7 @@
if (psBox)
{
pszSRS = (char *)CPLGetXMLValue(psBox, "srsName", NULL);
- if (*ppszSRS)
+ if (ppszSRS && pszSRS)
*ppszSRS = strdup(pszSRS);
psCoordinates = CPLGetXMLNode(psBox, "coordinates");
Modified: branches/branch-5-2/mapserver/mapserver.h
===================================================================
--- branches/branch-5-2/mapserver/mapserver.h 2008-07-23 03:38:08 UTC (rev 7830)
+++ branches/branch-5-2/mapserver/mapserver.h 2008-07-28 13:47:55 UTC (rev 7831)
@@ -381,7 +381,7 @@
FilterNodeType eType;
char *pszValue;
void *pOther;
-
+ char *pszSRS;
struct _FilterNode *psLeftNode;
struct _FilterNode *psRightNode;
} FilterEncodingNode;
More information about the mapserver-commits
mailing list