[mapserver-commits] r7521 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Tue Apr 15 11:39:10 EDT 2008
Author: Assefa
Date: 2008-04-15 11:39:09 -0400 (Tue, 15 Apr 2008)
New Revision: 7521
Modified:
trunk/mapserver/mapogcfilter.c
trunk/mapserver/mapogcfilter.h
trunk/mapserver/mapogcsos.c
trunk/mapserver/mapwfs.c
Log:
Fix WFS quey usied aliased gml names (#2580)
Modified: trunk/mapserver/mapogcfilter.c
===================================================================
--- trunk/mapserver/mapogcfilter.c 2008-04-14 15:29:38 UTC (rev 7520)
+++ trunk/mapserver/mapogcfilter.c 2008-04-15 15:39:09 UTC (rev 7521)
@@ -1555,9 +1555,9 @@
/*FE 1.0 used box FE1.1 uses envelop*/
if (psBox)
- bCoordinatesValid = FTLParseGMLBox(psBox, &sBox, &pszSRS);
+ bCoordinatesValid = FLTParseGMLBox(psBox, &sBox, &pszSRS);
else if ((psEnvelope = CPLGetXMLNode(psXMLNode, "Envelope")))
- bCoordinatesValid = FTLParseGMLEnvelope(psEnvelope, &sBox, &pszSRS);
+ bCoordinatesValid = FLTParseGMLEnvelope(psEnvelope, &sBox, &pszSRS);
if (psPropertyName == NULL || !bCoordinatesValid)
psFilterNode->eType = FILTER_NODE_TYPE_UNDEFINED;
@@ -3737,11 +3737,11 @@
/************************************************************************/
-/* FTLParseGMLBox */
+/* FLTParseGMLBox */
/* */
/* Parse gml box. Used for FE 1.0 */
/************************************************************************/
-int FTLParseGMLBox(CPLXMLNode *psBox, rectObj *psBbox, char **ppszSRS)
+int FLTParseGMLBox(CPLXMLNode *psBox, rectObj *psBbox, char **ppszSRS)
{
int bCoordinatesValid = 0;
CPLXMLNode *psCoordinates = NULL, *psCoordChild=NULL;
@@ -3849,11 +3849,11 @@
return bCoordinatesValid;
}
/************************************************************************/
-/* FTLParseGMLEnvelope */
+/* FLTParseGMLEnvelope */
/* */
/* Utility function to parse a gml:Enevelop (used for SOS and FE1.1)*/
/************************************************************************/
-int FTLParseGMLEnvelope(CPLXMLNode *psRoot, rectObj *psBbox, char **ppszSRS)
+int FLTParseGMLEnvelope(CPLXMLNode *psRoot, rectObj *psBbox, char **ppszSRS)
{
CPLXMLNode *psChild=NULL;
CPLXMLNode *psUpperCorner=NULL, *psLowerCorner=NULL;
@@ -3932,6 +3932,60 @@
}
+static void FLTReplacePropertyName(FilterEncodingNode *psFilterNode,
+ const char *pszOldName, char *pszNewName)
+{
+ if (psFilterNode && pszOldName && pszNewName)
+ {
+ if (psFilterNode->eType == FILTER_NODE_TYPE_PROPERTYNAME)
+ {
+ if (psFilterNode->pszValue &&
+ strcasecmp(psFilterNode->pszValue, pszOldName) == 0)
+ {
+ msFree(psFilterNode->pszValue);
+ psFilterNode->pszValue = strdup(pszNewName);
+ }
+ }
+ if (psFilterNode->psLeftNode)
+ FLTReplacePropertyName(psFilterNode->psLeftNode, pszOldName,
+ pszNewName);
+ if (psFilterNode->psRightNode)
+ FLTReplacePropertyName(psFilterNode->psRightNode, pszOldName,
+ pszNewName);
+ }
+}
+
+
+void FLTPreParseFilterForAlias(FilterEncodingNode *psFilterNode,
+ mapObj *map, int i, const char *namespaces)
+{
+ layerObj *lp=NULL;
+ char szTmp[256];
+ const char *pszFullName = NULL;
+
+ if (psFilterNode && map && i>=0 && i<map->numlayers)
+ {
+ lp = GET_LAYER(map, i);
+ if (msLayerOpen(lp) == MS_SUCCESS && msLayerGetItems(lp) == MS_SUCCESS)
+ {
+ for(i=0; i<lp->numitems; i++)
+ {
+ if (!lp->items[i] || strlen(lp->items[i]) <= 0)
+ continue;
+ sprintf(szTmp, "%s_alias", lp->items[i]);
+ pszFullName = msOWSLookupMetadata(&(lp->metadata), namespaces, szTmp);
+ if (pszFullName)
+ {
+ FLTReplacePropertyName(psFilterNode, pszFullName,
+ lp->items[i]);
+ }
+ }
+ msLayerClose(lp);
+ }
+ }
+}
+
+
#ifdef USE_LIBXML2
xmlNodePtr FLTGetCapabilities(xmlNsPtr psNsParent, xmlNsPtr psNsOgc, int bTemporal)
Modified: trunk/mapserver/mapogcfilter.h
===================================================================
--- trunk/mapserver/mapogcfilter.h 2008-04-14 15:29:38 UTC (rev 7520)
+++ trunk/mapserver/mapogcfilter.h 2008-04-15 15:39:09 UTC (rev 7521)
@@ -121,13 +121,17 @@
MS_DLL_EXPORT FilterEncodingNode *FLTCreateFeatureIdFilterEncoding(char *pszString);
-MS_DLL_EXPORT int FTLParseGMLEnvelope(CPLXMLNode *psRoot, rectObj *psBbox, char **ppszSRS);
-MS_DLL_EXPORT int FTLParseGMLBox(CPLXMLNode *psBox, rectObj *psBbox, char **ppszSRS);
+MS_DLL_EXPORT int FLTParseGMLEnvelope(CPLXMLNode *psRoot, rectObj *psBbox, char **ppszSRS);
+MS_DLL_EXPORT int FLTParseGMLBox(CPLXMLNode *psBox, rectObj *psBbox, char **ppszSRS);
#ifdef USE_LIBXML2
MS_DLL_EXPORT xmlNodePtr FLTGetCapabilities(xmlNsPtr psNsParent, xmlNsPtr psNsOgc, int bTemporal);
#endif
+
+void FLTPreParseFilterForAlias(FilterEncodingNode *psFilterNode,
+ mapObj *map, int i, const char *namespaces);
+
#endif
Modified: trunk/mapserver/mapogcsos.c
===================================================================
--- trunk/mapserver/mapogcsos.c 2008-04-14 15:29:38 UTC (rev 7520)
+++ trunk/mapserver/mapogcsos.c 2008-04-15 15:39:09 UTC (rev 7521)
@@ -29,6 +29,7 @@
#include "mapserver.h"
+
MS_CVSID("$Id$")
#if defined(USE_SOS_SVR) && defined(USE_LIBXML2)
@@ -168,57 +169,8 @@
return MS_TRUE;
}
-static void msSOSReplacePropertyName(FilterEncodingNode *psFilterNode,
- const char *pszOldName, char *pszNewName)
-{
- if (psFilterNode && pszOldName && pszNewName)
- {
- if (psFilterNode->eType == FILTER_NODE_TYPE_PROPERTYNAME)
- {
- if (psFilterNode->pszValue &&
- strcasecmp(psFilterNode->pszValue, pszOldName) == 0)
- {
- msFree(psFilterNode->pszValue);
- psFilterNode->pszValue = strdup(pszNewName);
- }
- }
- if (psFilterNode->psLeftNode)
- msSOSReplacePropertyName(psFilterNode->psLeftNode, pszOldName,
- pszNewName);
- if (psFilterNode->psRightNode)
- msSOSReplacePropertyName(psFilterNode->psRightNode, pszOldName,
- pszNewName);
- }
-}
-static void msSOSPreParseFilterForAlias(FilterEncodingNode *psFilterNode,
- mapObj *map, int i)
-{
- layerObj *lp=NULL;
- char szTmp[256];
- const char *pszFullName = NULL;
- if (psFilterNode && map && i>=0 && i<map->numlayers)
- {
- lp = GET_LAYER(map, i);
- if (msLayerOpen(lp) == MS_SUCCESS && msLayerGetItems(lp) == MS_SUCCESS)
- {
- for(i=0; i<lp->numitems; i++)
- {
- if (!lp->items[i] || strlen(lp->items[i]) <= 0)
- continue;
- sprintf(szTmp, "%s_alias", lp->items[i]);
- pszFullName = msOWSLookupMetadata(&(lp->metadata), "S", szTmp);
- if (pszFullName)
- {
- msSOSReplacePropertyName(psFilterNode, pszFullName,
- lp->items[i]);
- }
- }
- msLayerClose(lp);
- }
- }
-}
/************************************************************************/
/* msSOSAddMetadataChildNode */
/* */
@@ -2069,7 +2021,7 @@
CPLStripXMLNamespace(psRoot, "gml", 1);
- bValid = FTLParseGMLEnvelope(psRoot, &sBbox, &pszSRS);
+ bValid = FLTParseGMLEnvelope(psRoot, &sBbox, &pszSRS);
/*TODO we should reproject the bbox to the map projection if there is an srs defined*/
if (!bValid) {
@@ -2096,7 +2048,7 @@
lp = GET_LAYER(map, i);
if (lp->status == MS_ON) {
//preparse parser so that alias for fields can be used
- msSOSPreParseFilterForAlias(psFilterNode, map, i);
+ FLTPreParseFilterForAlias(psFilterNode, map, i, "S");
//vaidate that the property names used are valid
//(there is a corresponding layer attribute)
if (msLayerOpen(lp) == MS_SUCCESS && msLayerGetItems(lp) == MS_SUCCESS) {
Modified: trunk/mapserver/mapwfs.c
===================================================================
--- trunk/mapserver/mapwfs.c 2008-04-14 15:29:38 UTC (rev 7520)
+++ trunk/mapserver/mapwfs.c 2008-04-15 15:39:09 UTC (rev 7521)
@@ -1283,6 +1283,9 @@
return msWFSException(map, "filter", "InvalidParameterValue", paramsObj->pszVersion);
}
+ /*preparse the filter for gml aliases*/
+ FLTPreParseFilterForAlias(psNode, map, iLayerIndex, "G");
+
if( FLTApplyFilterToLayer(psNode, map, iLayerIndex, MS_FALSE) != MS_SUCCESS ) {
msSetError(MS_WFSERR, "FLTApplyFilterToLayer() failed", "msWFSGetFeature()", pszFilter);
return msWFSException(map, "mapserv", "NoApplicableCode", paramsObj->pszVersion);
More information about the mapserver-commits
mailing list