[fusion-commits] r2951 - in branches/fusion-mg31: . layers/MapGuide/php widgets/BufferPanel widgets/Query/classes widgets/Redline/classes widgets/Search widgets/SelectWithin

svn_fusion at osgeo.org svn_fusion at osgeo.org
Wed Jul 27 05:53:56 PDT 2016


Author: jng
Date: 2016-07-27 05:53:56 -0700 (Wed, 27 Jul 2016)
New Revision: 2951

Modified:
   branches/fusion-mg31/
   branches/fusion-mg31/layers/MapGuide/php/Buffer.php
   branches/fusion-mg31/layers/MapGuide/php/Common.php
   branches/fusion-mg31/layers/MapGuide/php/Query.php
   branches/fusion-mg31/widgets/BufferPanel/Buffer.php
   branches/fusion-mg31/widgets/Query/classes/query.php
   branches/fusion-mg31/widgets/Redline/classes/markupeditor.php
   branches/fusion-mg31/widgets/Redline/classes/markupmanager.php
   branches/fusion-mg31/widgets/Search/Search.php
   branches/fusion-mg31/widgets/SelectWithin/SelectWithin.php
Log:
Merged revision(s) 2950 from trunk:
#651: Use MgFeatureQueryOptions with explicit property lists where applicable.

This is to ensure that a "select * from featureclass" query from relational FDO providers will have its column list bounded to what is recognized in the class definition returned by the provider. Some providers are known to produce "select * from table" queries that "leak" out column types that the provider does not know how to process. Using an explicit property list from its class definition will allow us to avoid such issues.

The redline widget is exempt from this as its underlying data stores will be either SDF, SHP or SQLite. None of the aforementioned FDO providers have this problem.
........



Property changes on: branches/fusion-mg31
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/fusion-mg24:2560
/branches/fusion-mg26:2855,2869
/sandbox/adsk/2.6l:2911
/sandbox/adsk/3.1n:2925-2927
/sandbox/createruntimemap:2699-2708
/sandbox/jxlib-3.0:1957-2248
/sandbox/ol213:2801-2803
/sandbox/robust_error_handling:2818-2825
/sandbox/stamen:2873-2875
/sandbox/tiling:2845-2846
/trunk:2946
   + /branches/fusion-mg24:2560
/branches/fusion-mg26:2855,2869
/sandbox/adsk/2.6l:2911
/sandbox/adsk/3.1n:2925-2927
/sandbox/createruntimemap:2699-2708
/sandbox/jxlib-3.0:1957-2248
/sandbox/ol213:2801-2803
/sandbox/robust_error_handling:2818-2825
/sandbox/stamen:2873-2875
/sandbox/tiling:2845-2846
/trunk:2946,2950

Modified: branches/fusion-mg31/layers/MapGuide/php/Buffer.php
===================================================================
--- branches/fusion-mg31/layers/MapGuide/php/Buffer.php	2016-07-27 12:51:00 UTC (rev 2950)
+++ branches/fusion-mg31/layers/MapGuide/php/Buffer.php	2016-07-27 12:53:56 UTC (rev 2951)
@@ -123,7 +123,6 @@
     }
 
     //loop through the selection of the input layer. If no selection, select all features
-    $queryOptions = new MgFeatureQueryOptions();
     $selection = new MgSelection($map);
     $selection->Open($resourceService, $mapName);
     $selLayers = $selection->GetLayers();
@@ -143,6 +142,8 @@
         if ($filter == '') {
             continue;
         }
+        $clsDef = $selLayer->GetClassDefinition();
+        $queryOptions = BuildFeatureQueryOptions($clsDef);
         $queryOptions->SetFilter($filter);
         $featureSource = new MgResourceIdentifier($selLayer->GetFeatureSourceId());
         $featureReader = $featureService->SelectFeatures($featureSource, $featureClassName, $queryOptions);

Modified: branches/fusion-mg31/layers/MapGuide/php/Common.php
===================================================================
--- branches/fusion-mg31/layers/MapGuide/php/Common.php	2016-07-27 12:51:00 UTC (rev 2950)
+++ branches/fusion-mg31/layers/MapGuide/php/Common.php	2016-07-27 12:53:56 UTC (rev 2951)
@@ -309,4 +309,63 @@
     return "Fusion Viewer";
 }
 
+// Builds a MgFeatureQueryOptions with an explicit property list based
+// on the given class definition
+//
+// This is to ensure that a "select * from featureclass" query from relational
+// providers will have its column list bounded to what is recognized in the
+// class definition. Some providers are known to produce "select * from table"
+// queries that "leak" out column types that the provider does not know how to
+// process. Using an explicit property list from its class definition will
+// allow us to avoid such issues
+function BuildFeatureQueryOptions($classDef)
+{
+    $query = new MgFeatureQueryOptions();
+    $geomPropName = $classDef->GetDefaultGeometryPropertyName(); 
+    $propertyList = $classDef->GetProperties(); 
+
+    for ($i = 0; $i < $propertyList->GetCount(); $i++) 
+    {
+        $propertyDef = $propertyList->GetItem($i); 
+        $property = $propertyList->GetItem($i)->GetName(); 
+
+        if (($property != $geomPropName) && ($propertyDef->GetPropertyType() == MgFeaturePropertyType::DataProperty)) 
+        { 
+            $propertyType = $propertyList->GetItem($i)->GetDataType(); 
+            switch ($propertyType) { 
+                case MgPropertyType::Boolean: 
+                    $query->AddFeatureProperty($property); 
+                    break; 
+                case MgPropertyType::Byte: 
+                    $query->AddFeatureProperty($property); 
+                    break; 
+                case MgPropertyType::DateTime: 
+                    $query->AddFeatureProperty($property); 
+                    break; 
+                case MgPropertyType::Single: 
+                    $query->AddFeatureProperty($property); 
+                    break; 
+                case MgPropertyType::Double: 
+                    $query->AddFeatureProperty($property); 
+                    break; 
+                case MgPropertyType::Int16: 
+                    $query->AddFeatureProperty($property); 
+                    break; 
+                case MgPropertyType::Int32: 
+                    $query->AddFeatureProperty($property); 
+                    break; 
+                case MgPropertyType::Int64: 
+                    $query->AddFeatureProperty($property); 
+                    break; 
+                case MgPropertyType::String: 
+                    $query->AddFeatureProperty($property); 
+                    break; 
+            }
+        } else if ($property == $geomPropName){ 
+            $query->AddFeatureProperty($property); 
+        } 
+    }
+    return $query;
+}
+
 ?>

Modified: branches/fusion-mg31/layers/MapGuide/php/Query.php
===================================================================
--- branches/fusion-mg31/layers/MapGuide/php/Query.php	2016-07-27 12:51:00 UTC (rev 2950)
+++ branches/fusion-mg31/layers/MapGuide/php/Query.php	2016-07-27 12:53:56 UTC (rev 2951)
@@ -288,16 +288,18 @@
 
     if ($bExtendSelection) {
         $selection = new MgSelection($map);
-        $queryOptions = new MgFeatureQueryOptions();
         $layers = $map->GetLayers();
         foreach($aLayers as $szLayer => $aLayer) {
             $oLayer = $layers->GetItem($szLayer);
             foreach($aLayer as $szClass => $aFilter) {
+                $clsDef = $oLayer->GetClassDefinition();
+                $queryOptions = BuildFeatureQueryOptions($clsDef);
+
                 /* get the feature source from the layer */
                 $featureResId = new MgResourceIdentifier($oLayer->GetFeatureSourceId());
                 $featureGeometryName = $oLayer->GetFeatureGeometryName();
                 $szFilter = implode(' OR ', $aFilter);
-                $queryOptions->setFilter($szFilter);
+                $queryOptions->SetFilter($szFilter);
                 /* the class that is used for this layer will be used to select
                    features */
                 $class = $oLayer->GetFeatureClassName();

Modified: branches/fusion-mg31/widgets/BufferPanel/Buffer.php
===================================================================
--- branches/fusion-mg31/widgets/BufferPanel/Buffer.php	2016-07-27 12:51:00 UTC (rev 2950)
+++ branches/fusion-mg31/widgets/BufferPanel/Buffer.php	2016-07-27 12:53:56 UTC (rev 2951)
@@ -253,7 +253,8 @@
             if($filter == "")
                 continue;
 
-            $query = new MgFeatureQueryOptions();
+            $clsDef = $selLayer->GetClassDefinition();
+            $query = BuildFeatureQueryOptions($clsDef);
             $query->SetFilter($filter);
 
             $featureSource = new MgResourceIdentifier($selLayer->GetFeatureSourceId());

Modified: branches/fusion-mg31/widgets/Query/classes/query.php
===================================================================
--- branches/fusion-mg31/widgets/Query/classes/query.php	2016-07-27 12:51:00 UTC (rev 2950)
+++ branches/fusion-mg31/widgets/Query/classes/query.php	2016-07-27 12:53:56 UTC (rev 2951)
@@ -253,7 +253,8 @@
         // Execute the query
 
         $queryMax = (int) $this->args['QUERYMAX'];
-        $queryOptions = new MgFeatureQueryOptions();
+        $clsDef = $layer->GetClassDefinition();
+        $queryOptions = BuildFeatureQueryOptions($clsDef);
 
         $propertyFilter = '';
         if ($this->args['USEPROPERTYFILTER'] == 'true')

Modified: branches/fusion-mg31/widgets/Redline/classes/markupeditor.php
===================================================================
--- branches/fusion-mg31/widgets/Redline/classes/markupeditor.php	2016-07-27 12:51:00 UTC (rev 2950)
+++ branches/fusion-mg31/widgets/Redline/classes/markupeditor.php	2016-07-27 12:53:56 UTC (rev 2951)
@@ -56,7 +56,13 @@
         $featureService = $this->site->CreateService(MgServiceType::FeatureService);
         $featureSourceId = $this->GetFeatureSource();
 
+        //NOTE: Normally we'd always pass in a MgFeatureQueryOptions with an explicit property
+        //list, but we're dealing with a series of FDO providers (SDF,SHP,SQLite) that are known
+        //to *not* have the issue of potentially leaking out column types in the query result that
+        //the underlying FDO provider doesn't know how to translate to FDO logical properties, so
+        //passing null is acceptable here
         $featureReader = $featureService->SelectFeatures($featureSourceId, 'Markup', null);
+
         //HACK: Another leaky abstraction. SHP will always choose FeatId, so once again
         //use the class definition to determine the identity property name
         $clsDef = $featureReader->GetClassDefinition();

Modified: branches/fusion-mg31/widgets/Redline/classes/markupmanager.php
===================================================================
--- branches/fusion-mg31/widgets/Redline/classes/markupmanager.php	2016-07-27 12:51:00 UTC (rev 2950)
+++ branches/fusion-mg31/widgets/Redline/classes/markupmanager.php	2016-07-27 12:53:56 UTC (rev 2951)
@@ -103,6 +103,11 @@
         $featureService = $this->site->CreateService(MgServiceType::FeatureService);
         $query = new MgFeatureQueryOptions();
         $query->SetFilter("LayerDefinition = '$layerDefinitionId'");
+        //NOTE: Normally we'd always pass in a MgFeatureQueryOptions with an explicit property
+        //list, but we're dealing an FDO provider (SDF) that is known to *not* have the issue of 
+        //potentially leaking out column types in the query result that the underlying FDO provider 
+        //doesn't know how to translate to FDO logical properties, so passing the MgFeatureQueryOptions 
+        //as-is is fine here.
         $fr = $featureService->SelectFeatures($this->markupRegistryId, "Default:MarkupRegistry", $query);
 
         $fsId = "";
@@ -118,6 +123,11 @@
         $featureService = $this->site->CreateService(MgServiceType::FeatureService);
         $query = new MgFeatureQueryOptions();
         $query->SetFilter("LayerDefinition = '$markupLayerResId'");
+        //NOTE: Normally we'd always pass in a MgFeatureQueryOptions with an explicit property
+        //list, but we're dealing an FDO provider (SDF) that is known to *not* have the issue of 
+        //potentially leaking out column types in the query result that the underlying FDO provider 
+        //doesn't know how to translate to FDO logical properties, so passing the MgFeatureQueryOptions 
+        //as-is is fine here.
         $fr = $featureService->SelectFeatures($this->markupRegistryId, "Default:MarkupRegistry", $query);
 
         $fdoProvider = "";
@@ -144,6 +154,11 @@
         //Query the markup registry
         $featureService = $this->site->CreateService(MgServiceType::FeatureService);
         $query = new MgFeatureQueryOptions();
+        //NOTE: Normally we'd always pass in a MgFeatureQueryOptions with an explicit property
+        //list, but we're dealing an FDO provider (SDF) that is known to *not* have the issue of 
+        //potentially leaking out column types in the query result that the underlying FDO provider 
+        //doesn't know how to translate to FDO logical properties, so passing the MgFeatureQueryOptions 
+        //as-is is fine here.
         $fr = $featureService->SelectFeatures($this->markupRegistryId, "Default:MarkupRegistry", $query);
         while($fr->ReadNext())
         {

Modified: branches/fusion-mg31/widgets/Search/Search.php
===================================================================
--- branches/fusion-mg31/widgets/Search/Search.php	2016-07-27 12:51:00 UTC (rev 2950)
+++ branches/fusion-mg31/widgets/Search/Search.php	2016-07-27 12:53:56 UTC (rev 2951)
@@ -115,7 +115,8 @@
         $displayAll = (count($resProps) == 0);
 
         //query the features
-        $opts = new MgFeatureQueryOptions();
+        $clsDef = $layer->GetClassDefinition();
+        $opts = BuildFeatureQueryOptions($clsDef);
         $opts->SetFilter($filter);
         $featureClassName = $layer->GetFeatureClassName();
         $srcId = new MgResourceIdentifier($layer->GetFeatureSourceId());

Modified: branches/fusion-mg31/widgets/SelectWithin/SelectWithin.php
===================================================================
--- branches/fusion-mg31/widgets/SelectWithin/SelectWithin.php	2016-07-27 12:51:00 UTC (rev 2950)
+++ branches/fusion-mg31/widgets/SelectWithin/SelectWithin.php	2016-07-27 12:53:56 UTC (rev 2951)
@@ -108,8 +108,9 @@
               for ($i=0; $i<$layers->GetCount(); $i++) {
                 $layer = $layers->GetItem($i);
                 $layerName = $layer->GetName();
+                $clsDef = $layer->GetClassDefinition();
                 $layerClassName = $layer->GetFeatureClassName();
-                $options = new MgFeatureQueryOptions();
+                $options = BuildFeatureQueryOptions($clsDef);
                 $options->SetFilter($resultSel->GenerateFilter($layer, $layerClassName));
                 $resourceId = new MgResourceIdentifier($layer->GetFeatureSourceId());
                 $featureReader = $featureSrvc->SelectFeatures($resourceId, $layerClassName, $options);
@@ -159,7 +160,8 @@
     {
         $layer = $selLayers->GetItem($i);
         $filter = $sel->GenerateFilter($layer, $layer->GetFeatureClassName());
-        $query = new MgFeatureQueryOptions();
+        $clsDef = $layer->GetClassDefinition();
+        $query = BuildFeatureQueryOptions($clsDef);
         $query->SetFilter($filter);
         $featureSource = new MgResourceIdentifier($layer->GetFeatureSourceId());
         $features = $featureSrvc->SelectFeatures($featureSource, $layer->GetFeatureClassName(), $query);



More information about the fusion-commits mailing list