Permalink
Browse files

WFS: add support for PropertyName/ValueReference/Filter parameters in…

… gml_groups
  • Loading branch information...
rouault committed Nov 3, 2013
1 parent 598e223 commit 7c7fdcf300157bc78d00e0f1e7a38a2bbfcffd18
Showing with 313 additions and 82 deletions.
  1. +20 −7 mapgml.c
  2. +50 −1 mapogcfilter.c
  3. +2 −2 mapows.h
  4. +240 −71 mapwfs.c
  5. +1 −1 msautotest
View
@@ -37,7 +37,7 @@
#if defined(USE_WMS_SVR) || defined (USE_WFS_SVR)
static int msGMLGeometryLookup(gmlGeometryListObj *geometryList, char *type);
static int msGMLGeometryLookup(gmlGeometryListObj *geometryList, const char *type);
/*
** Functions that write the feature boundary geometry (i.e. a rectObj).
@@ -734,7 +734,7 @@ static int gmlWriteGeometry(FILE *stream, gmlGeometryListObj *geometryList,
** GML specific metadata handling functions.
*/
int msItemInGroups(char *name, gmlGroupListObj *groupList)
int msItemInGroups(const char *name, gmlGroupListObj *groupList)
{
int i, j;
gmlGroupObj *group;
@@ -751,7 +751,7 @@ int msItemInGroups(char *name, gmlGroupListObj *groupList)
return MS_FALSE;
}
static int msGMLGeometryLookup(gmlGeometryListObj *geometryList, char *type)
static int msGMLGeometryLookup(gmlGeometryListObj *geometryList, const char *type)
{
int i;
@@ -761,10 +761,13 @@ static int msGMLGeometryLookup(gmlGeometryListObj *geometryList, char *type)
if(geometryList->geometries[i].type && (strcasecmp(geometryList->geometries[i].type, type) == 0))
return i;
if( geometryList->numgeometries == 1 && geometryList->geometries[0].type == NULL )
return 0;
return -1; /* not found */
}
gmlGeometryListObj *msGMLGetGeometries(layerObj *layer, const char *metadata_namespaces)
gmlGeometryListObj *msGMLGetGeometries(layerObj *layer, const char *metadata_namespaces, int bWithDefaultGeom)
{
int i;
@@ -826,6 +829,14 @@ gmlGeometryListObj *msGMLGetGeometries(layerObj *layer, const char *metadata_nam
msFreeCharArray(names, numnames);
}
else if( bWithDefaultGeom ) {
geometryList->numgeometries = 1;
geometryList->geometries = (gmlGeometryObj *) calloc(1, sizeof(gmlGeometryObj));
geometryList->geometries[0].name = msStrdup(OWS_GML_DEFAULT_GEOMETRY_NAME);
geometryList->geometries[0].type = NULL;
geometryList->geometries[0].occurmin = 0;
geometryList->geometries[0].occurmax = 1;
}
return geometryList;
}
@@ -1070,7 +1081,8 @@ gmlGroupListObj *msGMLGetGroups(layerObj *layer, const char *metadata_namespaces
groupList->numgroups = 0;
/* list of groups (TODO: make this automatic by parsing metadata) */
if((value = msOWSLookupMetadata(&(layer->metadata), metadata_namespaces, "groups")) != NULL) {
if((value = msOWSLookupMetadata(&(layer->metadata), metadata_namespaces, "groups")) != NULL &&
value[0] != '\0' ) {
names = msStringSplit(value, ',', &numnames);
/* allocation an array of gmlGroupObj's */
@@ -1117,6 +1129,7 @@ void msGMLFreeGroups(gmlGroupListObj *groupList)
msFreeCharArray(groupList->groups[i].items, groupList->groups[i].numitems);
msFree(groupList->groups[i].type);
}
msFree(groupList->groups);
free(groupList);
}
@@ -1255,7 +1268,7 @@ int msGMLWriteQuery(mapObj *map, char *filename, const char *namespaces)
itemList = msGMLGetItems(lp, namespaces);
constantList = msGMLGetConstants(lp, namespaces);
groupList = msGMLGetGroups(lp, namespaces);
geometryList = msGMLGetGeometries(lp, namespaces);
geometryList = msGMLGetGeometries(lp, namespaces, MS_FALSE);
if (itemList == NULL || constantList == NULL || groupList == NULL || geometryList == NULL) {
msSetError(MS_MISCERR, "Unable to populate item and group metadata structures", "msGMLWriteQuery()");
return MS_FAILURE;
@@ -1448,7 +1461,7 @@ int msGMLWriteWFSQuery(mapObj *map, FILE *stream, const char *default_namespace_
itemList = msGMLGetItems(lp, "G");
constantList = msGMLGetConstants(lp, "G");
groupList = msGMLGetGroups(lp, "G");
geometryList = msGMLGetGeometries(lp, "GFO");
geometryList = msGMLGetGeometries(lp, "GFO", MS_FALSE);
if (itemList == NULL || constantList == NULL || groupList == NULL || geometryList == NULL) {
msSetError(MS_MISCERR, "Unable to populate item and group metadata structures", "msGMLWriteWFSQuery()");
return MS_FAILURE;
View
@@ -3224,6 +3224,48 @@ static void FLTStripNameSpacesFromPropertyName(FilterEncodingNode *psFilterNode)
}
static void FLTRemoveGroupName(FilterEncodingNode *psFilterNode,
gmlGroupListObj* groupList)
{
int i;
if (psFilterNode) {
if (psFilterNode->eType == FILTER_NODE_TYPE_PROPERTYNAME) {
if( psFilterNode->pszValue != NULL )
{
const char* pszPropertyName = psFilterNode->pszValue;
const char* pszSlash = strchr(pszPropertyName, '/');
if( pszSlash != NULL ) {
const char* pszColon = strchr(pszPropertyName, ':');
if( pszColon != NULL && pszColon < pszSlash )
pszPropertyName = pszColon + 1;
for(i=0;i<groupList->numgroups;i++) {
const char* pszGroupName = groupList->groups[i].name;
size_t nGroupNameLen = strlen(pszGroupName);
if(strncasecmp(pszPropertyName, pszGroupName, nGroupNameLen) == 0 &&
pszPropertyName[nGroupNameLen] == '/') {
char* pszTmp;
pszPropertyName = pszPropertyName + nGroupNameLen + 1;
pszColon = strchr(pszPropertyName, ':');
if( pszColon != NULL )
pszPropertyName = pszColon + 1;
pszTmp = msStrdup(pszPropertyName);
msFree(psFilterNode->pszValue);
psFilterNode->pszValue = pszTmp;
break;
}
}
}
}
}
if (psFilterNode->psLeftNode)
FLTRemoveGroupName(psFilterNode->psLeftNode, groupList);
if (psFilterNode->psRightNode)
FLTRemoveGroupName(psFilterNode->psRightNode, groupList);
}
}
/************************************************************************/
/* FLTPreParseFilterForAlias */
/* */
@@ -3241,12 +3283,19 @@ void FLTPreParseFilterForAlias(FilterEncodingNode *psFilterNode,
#if defined(USE_WMS_SVR) || defined (USE_WFS_SVR) || defined (USE_WCS_SVR) || defined(USE_SOS_SVR)
if (psFilterNode && map && i>=0 && i<map->numlayers) {
/*strip name speces befor hand*/
/*strip name spaces before hand*/
FLTStripNameSpacesFromPropertyName(psFilterNode);
lp = GET_LAYER(map, i);
layerWasOpened = msLayerIsOpen(lp);
if (msLayerOpen(lp) == MS_SUCCESS && msLayerGetItems(lp) == MS_SUCCESS) {
/* Remove group names from property names if using groupname/itemname syntax */
gmlGroupListObj* groupList = msGMLGetGroups(lp, "G");
if( groupList && groupList->numgroups > 0 )
FLTRemoveGroupName(psFilterNode, groupList);
msGMLFreeGroups(groupList);
for(i=0; i<lp->numitems; i++) {
if (!lp->items[i] || strlen(lp->items[i]) <= 0)
continue;
View
@@ -386,12 +386,12 @@ typedef struct {
#if defined(USE_WMS_SVR) || defined (USE_WFS_SVR)
MS_DLL_EXPORT int msItemInGroups(char *name, gmlGroupListObj *groupList);
MS_DLL_EXPORT int msItemInGroups(const char *name, gmlGroupListObj *groupList);
MS_DLL_EXPORT gmlItemListObj *msGMLGetItems(layerObj *layer, const char *metadata_namespaces);
MS_DLL_EXPORT void msGMLFreeItems(gmlItemListObj *itemList);
MS_DLL_EXPORT gmlConstantListObj *msGMLGetConstants(layerObj *layer, const char *metadata_namespaces);
MS_DLL_EXPORT void msGMLFreeConstants(gmlConstantListObj *constantList);
MS_DLL_EXPORT gmlGeometryListObj *msGMLGetGeometries(layerObj *layer, const char *metadata_namespaces);
MS_DLL_EXPORT gmlGeometryListObj *msGMLGetGeometries(layerObj *layer, const char *metadata_namespaces, int bWithDefaultGeom);
MS_DLL_EXPORT void msGMLFreeGeometries(gmlGeometryListObj *geometryList);
MS_DLL_EXPORT gmlGroupListObj *msGMLGetGroups(layerObj *layer, const char *metadata_namespaces);
MS_DLL_EXPORT void msGMLFreeGroups(gmlGroupListObj *groupList);
Oops, something went wrong.

0 comments on commit 7c7fdcf

Please sign in to comment.