[mapserver-commits] r10607 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Thu Oct 14 14:37:42 EDT 2010


Author: warmerdam
Date: 2010-10-14 11:37:42 -0700 (Thu, 14 Oct 2010)
New Revision: 10607

Modified:
   trunk/mapserver/mapgml.c
   trunk/mapserver/mapows.h
Log:
provide msGMLGetItem() even when WMS and WFS not enabled (#3570)

Modified: trunk/mapserver/mapgml.c
===================================================================
--- trunk/mapserver/mapgml.c	2010-10-14 18:31:30 UTC (rev 10606)
+++ trunk/mapserver/mapgml.c	2010-10-14 18:37:42 UTC (rev 10607)
@@ -33,7 +33,7 @@
 
 MS_CVSID("$Id$")
 
-/* Use only mapgml.c if WMS or WFS is available */
+/* Use only mapgml.c if WMS or WFS is available (with minor exceptions at end)*/
 
 #if defined(USE_WMS_SVR) || defined (USE_WFS_SVR)
 
@@ -783,130 +783,6 @@
   free(geometryList);
 }
 
-gmlItemListObj *msGMLGetItems(layerObj *layer, const char *metadata_namespaces) 
-{
-  int i,j;
-
-  char **xmlitems=NULL; 
-  int numxmlitems=0;
-
-  char **incitems=NULL;
-  int numincitems=0;
-
-  char **excitems=NULL;
-  int numexcitems=0;
-
-  const char *value=NULL;
-  char tag[64];
-
-  gmlItemListObj *itemList=NULL; 
-  gmlItemObj *item=NULL;
-
-  /* get a list of items that should be included in output */
-  if((value = msOWSLookupMetadata(&(layer->metadata), metadata_namespaces, "include_items")) != NULL)  
-    incitems = msStringSplit(value, ',', &numincitems);
-
-  /* get a list of items that should be excluded in output */
-  if((value = msOWSLookupMetadata(&(layer->metadata), metadata_namespaces, "exclude_items")) != NULL)  
-    excitems = msStringSplit(value, ',', &numexcitems);
-
-  /* get a list of items that need don't get encoded */
-  if((value = msOWSLookupMetadata(&(layer->metadata), metadata_namespaces, "xml_items")) != NULL)  
-    xmlitems = msStringSplit(value, ',', &numxmlitems);
-
-  /* allocate memory and iinitialize the item collection */
-  itemList = (gmlItemListObj *) malloc(sizeof(gmlItemListObj));
-  itemList->items = NULL;
-  itemList->numitems = 0;
-
-  itemList->numitems = layer->numitems;
-  itemList->items = (gmlItemObj *) malloc(sizeof(gmlItemObj)*itemList->numitems);
-  if(!itemList->items) {
-    msSetError(MS_MEMERR, "Error allocating a collection GML item structures.", "msGMLGetItems()");
-    return NULL;
-  } 
-
-  for(i=0; i<layer->numitems; i++) {
-    item = &(itemList->items[i]);
-
-    item->name = strdup(layer->items[i]);  /* initialize the item */
-    item->alias = NULL;
-    item->type = NULL;
-    item->template = NULL;
-    item->encode = MS_TRUE;
-    item->visible = MS_FALSE;
-    item->width = 0;
-    item->precision = 0;
-
-    /* check visibility, included items first... */
-    if(numincitems == 1 && strcasecmp("all", incitems[0]) == 0) {
-      item->visible = MS_TRUE;
-    } else {
-      for(j=0; j<numincitems; j++) {
-        if(strcasecmp(layer->items[i], incitems[j]) == 0)
-          item->visible = MS_TRUE;
-      }
-    }
-
-    /* ...and now excluded items */
-    for(j=0; j<numexcitems; j++) {
-      if(strcasecmp(layer->items[i], excitems[j]) == 0)
-        item->visible = MS_FALSE;
-    }
-
-    /* check encoding */
-    for(j=0; j<numxmlitems; j++) {
-      if(strcasecmp(layer->items[i], xmlitems[j]) == 0)
-        item->encode = MS_FALSE;
-    }
-
-    snprintf(tag, sizeof(tag), "%s_alias", layer->items[i]);
-    if((value = msOWSLookupMetadata(&(layer->metadata), metadata_namespaces, tag)) != NULL) 
-      item->alias = strdup(value);
-
-    snprintf(tag, sizeof(tag), "%s_type", layer->items[i]);
-    if((value = msOWSLookupMetadata(&(layer->metadata), metadata_namespaces, tag)) != NULL) 
-      item->type = strdup(value);
-
-    snprintf(tag, sizeof(tag), "%s_template", layer->items[i]);
-    if((value = msOWSLookupMetadata(&(layer->metadata), metadata_namespaces, tag)) != NULL) 
-      item->template = strdup(value);
-
-    snprintf(tag, sizeof(tag), "%s_width", layer->items[i]);
-    if((value = msOWSLookupMetadata(&(layer->metadata), metadata_namespaces, tag)) != NULL) 
-        item->width = atoi(value);
-    
-    snprintf(tag, sizeof(tag), "%s_precision", layer->items[i]);
-    if((value = msOWSLookupMetadata(&(layer->metadata), metadata_namespaces, tag)) != NULL) 
-        item->precision = atoi(value);
-  }
-
-  msFreeCharArray(incitems, numincitems);
-  msFreeCharArray(excitems, numexcitems);
-  msFreeCharArray(xmlitems, numxmlitems);
-
-  return itemList;
-}
-
-void msGMLFreeItems(gmlItemListObj *itemList)
-{
-  int i;
-
-  if(!itemList) return;
-
-  for(i=0; i<itemList->numitems; i++) {
-    msFree(itemList->items[i].name);
-    msFree(itemList->items[i].alias);
-    msFree(itemList->items[i].type);
-    msFree(itemList->items[i].template);
-  }
-
-  if( itemList->items != NULL )
-      free(itemList->items);
-
-  free(itemList);
-}
-
 static void msGMLWriteItem(FILE *stream, gmlItemObj *item, char *value, const char *namespace, const char *tab)
 {
   char *encoded_value, *tag_name;
@@ -1793,3 +1669,134 @@
 }
 
 #endif /* USE_LIBXML2 */
+
+
+/************************************************************************/
+/*      The following functions are enabled in all cases, even if       */
+/*      WMS and WFS are not available.                                  */
+/************************************************************************/
+
+gmlItemListObj *msGMLGetItems(layerObj *layer, const char *metadata_namespaces) 
+{
+  int i,j;
+
+  char **xmlitems=NULL; 
+  int numxmlitems=0;
+
+  char **incitems=NULL;
+  int numincitems=0;
+
+  char **excitems=NULL;
+  int numexcitems=0;
+
+  const char *value=NULL;
+  char tag[64];
+
+  gmlItemListObj *itemList=NULL; 
+  gmlItemObj *item=NULL;
+
+  /* get a list of items that should be included in output */
+  if((value = msOWSLookupMetadata(&(layer->metadata), metadata_namespaces, "include_items")) != NULL)  
+    incitems = msStringSplit(value, ',', &numincitems);
+
+  /* get a list of items that should be excluded in output */
+  if((value = msOWSLookupMetadata(&(layer->metadata), metadata_namespaces, "exclude_items")) != NULL)  
+    excitems = msStringSplit(value, ',', &numexcitems);
+
+  /* get a list of items that need don't get encoded */
+  if((value = msOWSLookupMetadata(&(layer->metadata), metadata_namespaces, "xml_items")) != NULL)  
+    xmlitems = msStringSplit(value, ',', &numxmlitems);
+
+  /* allocate memory and iinitialize the item collection */
+  itemList = (gmlItemListObj *) malloc(sizeof(gmlItemListObj));
+  itemList->items = NULL;
+  itemList->numitems = 0;
+
+  itemList->numitems = layer->numitems;
+  itemList->items = (gmlItemObj *) malloc(sizeof(gmlItemObj)*itemList->numitems);
+  if(!itemList->items) {
+    msSetError(MS_MEMERR, "Error allocating a collection GML item structures.", "msGMLGetItems()");
+    return NULL;
+  } 
+
+  for(i=0; i<layer->numitems; i++) {
+    item = &(itemList->items[i]);
+
+    item->name = strdup(layer->items[i]);  /* initialize the item */
+    item->alias = NULL;
+    item->type = NULL;
+    item->template = NULL;
+    item->encode = MS_TRUE;
+    item->visible = MS_FALSE;
+    item->width = 0;
+    item->precision = 0;
+
+    /* check visibility, included items first... */
+    if(numincitems == 1 && strcasecmp("all", incitems[0]) == 0) {
+      item->visible = MS_TRUE;
+    } else {
+      for(j=0; j<numincitems; j++) {
+        if(strcasecmp(layer->items[i], incitems[j]) == 0)
+          item->visible = MS_TRUE;
+      }
+    }
+
+    /* ...and now excluded items */
+    for(j=0; j<numexcitems; j++) {
+      if(strcasecmp(layer->items[i], excitems[j]) == 0)
+        item->visible = MS_FALSE;
+    }
+
+    /* check encoding */
+    for(j=0; j<numxmlitems; j++) {
+      if(strcasecmp(layer->items[i], xmlitems[j]) == 0)
+        item->encode = MS_FALSE;
+    }
+
+    snprintf(tag, sizeof(tag), "%s_alias", layer->items[i]);
+    if((value = msOWSLookupMetadata(&(layer->metadata), metadata_namespaces, tag)) != NULL) 
+      item->alias = strdup(value);
+
+    snprintf(tag, sizeof(tag), "%s_type", layer->items[i]);
+    if((value = msOWSLookupMetadata(&(layer->metadata), metadata_namespaces, tag)) != NULL) 
+      item->type = strdup(value);
+
+    snprintf(tag, sizeof(tag), "%s_template", layer->items[i]);
+    if((value = msOWSLookupMetadata(&(layer->metadata), metadata_namespaces, tag)) != NULL) 
+      item->template = strdup(value);
+
+    snprintf(tag, sizeof(tag), "%s_width", layer->items[i]);
+    if((value = msOWSLookupMetadata(&(layer->metadata), metadata_namespaces, tag)) != NULL) 
+        item->width = atoi(value);
+    
+    snprintf(tag, sizeof(tag), "%s_precision", layer->items[i]);
+    if((value = msOWSLookupMetadata(&(layer->metadata), metadata_namespaces, tag)) != NULL) 
+        item->precision = atoi(value);
+  }
+
+  msFreeCharArray(incitems, numincitems);
+  msFreeCharArray(excitems, numexcitems);
+  msFreeCharArray(xmlitems, numxmlitems);
+
+  return itemList;
+}
+
+void msGMLFreeItems(gmlItemListObj *itemList)
+{
+  int i;
+
+  if(!itemList) return;
+
+  for(i=0; i<itemList->numitems; i++) {
+    msFree(itemList->items[i].name);
+    msFree(itemList->items[i].alias);
+    msFree(itemList->items[i].type);
+    msFree(itemList->items[i].template);
+  }
+
+  if( itemList->items != NULL )
+      free(itemList->items);
+
+  free(itemList);
+}
+

Modified: trunk/mapserver/mapows.h
===================================================================
--- trunk/mapserver/mapows.h	2010-10-14 18:31:30 UTC (rev 10606)
+++ trunk/mapserver/mapows.h	2010-10-14 18:37:42 UTC (rev 10607)
@@ -313,7 +313,7 @@
 
 outputFormatObj *msOwsIsOutputFormatValid(mapObj *map, const char *format, hashTableObj *metadata, 
                                           const char *namespaces, const char *name);
-#endif
+#endif /* #if any wxs service enabled */
 
 /*====================================================================
  *   mapgml.c
@@ -325,8 +325,6 @@
 #define OWS_GML_DEFAULT_GEOMETRY_NAME "msGeometry"
 #define OWS_GML_OCCUR_UNBOUNDED -1
 
-#if defined(USE_WMS_SVR) || defined (USE_WFS_SVR)
-
 /* TODO, there must be a better way to generalize these lists of objects... */
 
 typedef struct {
@@ -394,6 +392,8 @@
   int numnamespaces;
 } gmlNamespaceListObj;
 
+#if defined(USE_WMS_SVR) || defined (USE_WFS_SVR)
+
 MS_DLL_EXPORT int msItemInGroups(char *name, gmlGroupListObj *groupList);
 MS_DLL_EXPORT gmlItemListObj *msGMLGetItems(layerObj *layer, const char *metadata_namespaces);
 MS_DLL_EXPORT void msGMLFreeItems(gmlItemListObj *itemList);



More information about the mapserver-commits mailing list