[mapguide-commits] r9250 - in sandbox/jng/ogc: Server/src/Wms Web/src/HttpHandler

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Fri Nov 10 08:57:37 PST 2017


Author: jng
Date: 2017-11-10 08:57:36 -0800 (Fri, 10 Nov 2017)
New Revision: 9250

Modified:
   sandbox/jng/ogc/Server/src/Wms/1.0.0.xml.awd
   sandbox/jng/ogc/Server/src/Wms/1.1.0.xml.awd
   sandbox/jng/ogc/Server/src/Wms/1.1.1.xml.awd
   sandbox/jng/ogc/Server/src/Wms/1.3.0.xml.awd
   sandbox/jng/ogc/Web/src/HttpHandler/OgcWmsServer.cpp
   sandbox/jng/ogc/Web/src/HttpHandler/WmsFeatureProperties.cpp
   sandbox/jng/ogc/Web/src/HttpHandler/WmsFeatureProperties.h
Log:
Now that we support geometry output for WMS GetFeatureInfo, we don't want to always enable this unconditionally. Sometimes we do want to only return attribute data for certain layers.

Geometry output is now controllable via a new _EnableGeometry WMS metadata parameter. If set to 1 and _Queryable is also set to 1, the WMS GetFeatureInfo operation will include geometry data in its response (rendered based on the specified format template). If _EnableGeometry is set to 0 or not specified, then no geometry data is rendered.

_EnableGeometry has no effect if _Queryable is 0 or not specified.

Modified: sandbox/jng/ogc/Server/src/Wms/1.0.0.xml.awd
===================================================================
--- sandbox/jng/ogc/Server/src/Wms/1.0.0.xml.awd	2017-11-10 16:01:53 UTC (rev 9249)
+++ sandbox/jng/ogc/Server/src/Wms/1.0.0.xml.awd	2017-11-10 16:57:36 UTC (rev 9250)
@@ -103,8 +103,8 @@
   -->
  <Define item="FeatureInfo.json">{
     "type": "Feature",
-    "properties": {<?EnumFeatureProperties using="&FeatureProperty.json;" ?>},
-    "geometry": <?EnumFeatureGeometries using="&FeatureGeometry.json;" ?>
+    "properties": {<?EnumFeatureProperties using="&FeatureProperty.json;" ?>}
+    <?EnumFeatureGeometries using="&FeatureGeometry.json;" ?>
 }</Define>
  <Define item="FeatureProperty.xml">
   <Property name="&FeatureProperty.Name;" value="&FeatureProperty.Value;"></Property>
@@ -133,7 +133,7 @@
  <Define item="FeatureProperty.json">"&FeatureProperty.Name;": "&FeatureProperty.Value;"<?If l="&FeatureProperty.IsLast" op="eq" r="0"?>,<?Endif?></Define>
 
  <!-- Only output if property name is the designated geometry -->
- <Define item="FeatureGeometry.json">&FeatureGeometry.Value;</Define>
+ <Define item="FeatureGeometry.json">,"geometry": &FeatureGeometry.Value;</Define>
 
  <!-- Only output if property name is the designated geometry -->
  <Define item="FeatureGeometry.text">Geometry=&FeatureGeometry.Value;</Define>

Modified: sandbox/jng/ogc/Server/src/Wms/1.1.0.xml.awd
===================================================================
--- sandbox/jng/ogc/Server/src/Wms/1.1.0.xml.awd	2017-11-10 16:01:53 UTC (rev 9249)
+++ sandbox/jng/ogc/Server/src/Wms/1.1.0.xml.awd	2017-11-10 16:57:36 UTC (rev 9250)
@@ -105,8 +105,8 @@
   -->
  <Define item="FeatureInfo.json">{
     "type": "Feature",
-    "properties": {<?EnumFeatureProperties using="&FeatureProperty.json;" ?>},
-    "geometry": <?EnumFeatureGeometries using="&FeatureGeometry.json;" ?>
+    "properties": {<?EnumFeatureProperties using="&FeatureProperty.json;" ?>}
+    <?EnumFeatureGeometries using="&FeatureGeometry.json;" ?>
 }</Define>
 
  <Define item="FeatureProperty.xml">
@@ -140,7 +140,7 @@
  <Define item="FeatureProperty.json">"&FeatureProperty.Name;": "&FeatureProperty.Value;"<?If l="&FeatureProperty.IsLast" op="eq" r="0"?>,<?Endif?></Define>
 
  <!-- Only output if property name is the designated geometry -->
- <Define item="FeatureGeometry.json">&FeatureGeometry.Value;</Define>
+ <Define item="FeatureGeometry.json">,"geometry": &FeatureGeometry.Value;</Define>
 
  <!-- Only output if property name is the designated geometry -->
  <Define item="FeatureGeometry.text">Geometry=&FeatureGeometry.Value;</Define>

Modified: sandbox/jng/ogc/Server/src/Wms/1.1.1.xml.awd
===================================================================
--- sandbox/jng/ogc/Server/src/Wms/1.1.1.xml.awd	2017-11-10 16:01:53 UTC (rev 9249)
+++ sandbox/jng/ogc/Server/src/Wms/1.1.1.xml.awd	2017-11-10 16:57:36 UTC (rev 9250)
@@ -106,8 +106,8 @@
   -->
  <Define item="FeatureInfo.json">{
     "type": "Feature",
-    "properties": {<?EnumFeatureProperties using="&FeatureProperty.json;" ?>},
-    "geometry": <?EnumFeatureGeometries using="&FeatureGeometry.json;" ?>
+    "properties": {<?EnumFeatureProperties using="&FeatureProperty.json;" ?>}
+    <?EnumFeatureGeometries using="&FeatureGeometry.json;" ?>
 }</Define>
 
  <Define item="FeatureProperty.xml">
@@ -126,7 +126,7 @@
  <Define item="FeatureProperty.json">"&FeatureProperty.Name;": "&FeatureProperty.Value;"<?If l="&FeatureProperty.IsLast" op="eq" r="0"?>,<?Endif?></Define>
 
  <!-- Only output if property name is the designated geometry -->
- <Define item="FeatureGeometry.json">&FeatureGeometry.Value;</Define>
+ <Define item="FeatureGeometry.json">,"geometry": &FeatureGeometry.Value;</Define>
 
  <!-- Only output if property name is the designated geometry -->
  <Define item="FeatureGeometry.text">Geometry=&FeatureGeometry.Value;</Define>

Modified: sandbox/jng/ogc/Server/src/Wms/1.3.0.xml.awd
===================================================================
--- sandbox/jng/ogc/Server/src/Wms/1.3.0.xml.awd	2017-11-10 16:01:53 UTC (rev 9249)
+++ sandbox/jng/ogc/Server/src/Wms/1.3.0.xml.awd	2017-11-10 16:57:36 UTC (rev 9250)
@@ -116,8 +116,8 @@
   -->
  <Define item="FeatureInfo.json">{
     "type": "Feature",
-    "properties": {<?EnumFeatureProperties using="&FeatureProperty.json;" ?>},
-    "geometry": <?EnumFeatureGeometries using="&FeatureGeometry.json;" ?>
+    "properties": {<?EnumFeatureProperties using="&FeatureProperty.json;" ?>}
+    <?EnumFeatureGeometries using="&FeatureGeometry.json;" ?>
 }</Define>
 
  <Define item="FeatureProperty.xml">
@@ -136,7 +136,7 @@
  <Define item="FeatureProperty.json">"&FeatureProperty.Name;": "&FeatureProperty.Value;"<?If l="&FeatureProperty.IsLast" op="eq" r="0"?>,<?Endif?></Define>
 
  <!-- Only output if property name is the designated geometry -->
- <Define item="FeatureGeometry.json">&FeatureGeometry.Value;</Define>
+ <Define item="FeatureGeometry.json">,"geometry": &FeatureGeometry.Value;</Define>
 
  <!-- Only output if property name is the designated geometry -->
  <Define item="FeatureGeometry.text">Geometry=&FeatureGeometry.Value;</Define>

Modified: sandbox/jng/ogc/Web/src/HttpHandler/OgcWmsServer.cpp
===================================================================
--- sandbox/jng/ogc/Web/src/HttpHandler/OgcWmsServer.cpp	2017-11-10 16:01:53 UTC (rev 9249)
+++ sandbox/jng/ogc/Web/src/HttpHandler/OgcWmsServer.cpp	2017-11-10 16:57:36 UTC (rev 9250)
@@ -876,6 +876,39 @@
     if (!PIEnum.GetAttribute(kpszPiAttributeUsing, sFormat))
         sFormat = kpszPiEnumFeaturePropertiesDefaultFormat;
 
+    bool bIsGeometryEnabled = false;
+    if (m_pFeatureInfo != NULL && m_pLayers != NULL)
+    {
+        STRING layerName;
+        Ptr<MgWmsFeatureProperties> pProps = m_pFeatureInfo->GetCurrentProperties();
+        if (pProps != NULL)
+        {
+            layerName = pProps->GetLayerName();
+        }
+
+        //This will have been iterated previously, so rewind
+        m_pLayers->Reset();
+
+        while (m_pLayers->Next()) 
+        {
+            MgUtilDictionary currentDef(NULL);
+            m_pLayers->GenerateDefinitions(currentDef);
+
+            //We're at the layer of interest
+            CPSZ pszCurrentLayerName = currentDef[L"Layer.Name"];
+            if (SZ_EQ(pszCurrentLayerName, layerName.c_str()))
+            {
+                //Geometry data is only emitted if permitted by Layer.EnableGeometry
+                CPSZ pszEnableGeometry = currentDef[L"Layer.EnableGeometry"];
+                if (pszEnableGeometry != NULL && SZ_EQ(pszEnableGeometry, _("1")))
+                {
+                    bIsGeometryEnabled = true;
+                    break;
+                }
+            }
+        }
+    }
+
     CDictionaryStackFrame forFeatureGeometries(this);
 
     if (m_pFeatureInfo != NULL)
@@ -883,11 +916,14 @@
         Ptr<MgWmsFeatureProperties> pProps = m_pFeatureInfo->GetCurrentProperties();
         if (pProps != NULL)
         {
-            Ptr<MgWmsFeatureGeometry> geom = pProps->GetGeometry();
-            while (geom->Next())
+            if (bIsGeometryEnabled)
             {
-                geom->GenerateDefinitions(*m_pTopOfDefinitions);
-                ProcessExpandableText(sFormat);
+                Ptr<MgWmsFeatureGeometry> geom = pProps->GetGeometry();
+                while (geom->Next())
+                {
+                    geom->GenerateDefinitions(*m_pTopOfDefinitions);
+                    ProcessExpandableText(sFormat);
+                }
             }
         }
     }

Modified: sandbox/jng/ogc/Web/src/HttpHandler/WmsFeatureProperties.cpp
===================================================================
--- sandbox/jng/ogc/Web/src/HttpHandler/WmsFeatureProperties.cpp	2017-11-10 16:01:53 UTC (rev 9249)
+++ sandbox/jng/ogc/Web/src/HttpHandler/WmsFeatureProperties.cpp	2017-11-10 16:57:36 UTC (rev 9250)
@@ -35,6 +35,28 @@
     m_format = format;
 }
 
+STRING MgWmsFeatureProperties::GetLayerName()
+{
+    STRING ret;
+    if (m_propertyCollection != NULL)
+    {
+        INT32 gidx = m_propertyCollection->IndexOf(_("_MgLayerName"));
+        if (gidx >= 0)
+        {
+            Ptr<MgProperty> prop = m_propertyCollection->GetItem(gidx);
+            if (prop->GetPropertyType() == MgPropertyType::String)
+            {
+                MgStringProperty* sp = static_cast<MgStringProperty*>(prop.p);
+                if (!sp->IsNull())
+                {
+                    ret = sp->GetValue();
+                }
+            }
+        }
+    }
+    return ret;
+}
+
 MgWmsFeatureGeometry* MgWmsFeatureProperties::GetGeometry()
 {
     Ptr<MgWmsFeatureGeometry> ret;

Modified: sandbox/jng/ogc/Web/src/HttpHandler/WmsFeatureProperties.h
===================================================================
--- sandbox/jng/ogc/Web/src/HttpHandler/WmsFeatureProperties.h	2017-11-10 16:01:53 UTC (rev 9249)
+++ sandbox/jng/ogc/Web/src/HttpHandler/WmsFeatureProperties.h	2017-11-10 16:57:36 UTC (rev 9250)
@@ -37,6 +37,7 @@
     bool Next();
     void GenerateDefinitions(MgUtilDictionary& Dictionary);
     MgWmsFeatureGeometry* GetGeometry();
+    STRING GetLayerName();
 
 protected:
     virtual void Dispose()



More information about the mapguide-commits mailing list