[mapguide-commits] r9005 - trunk/MgDev/Web/src/mapviewerphp
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Wed Jul 27 06:46:08 PDT 2016
Author: jng
Date: 2016-07-27 06:46:08 -0700 (Wed, 27 Jul 2016)
New Revision: 9005
Modified:
trunk/MgDev/Web/src/mapviewerphp/buffer.php
trunk/MgDev/Web/src/mapviewerphp/common.php
trunk/MgDev/Web/src/mapviewerphp/search.php
trunk/MgDev/Web/src/mapviewerphp/selectwithin.php
Log:
#2732: Use explicit property lists where MgFeatureQueryOptions is used.
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.
This is for the PHP implementation of the AJAX viewer
Modified: trunk/MgDev/Web/src/mapviewerphp/buffer.php
===================================================================
--- trunk/MgDev/Web/src/mapviewerphp/buffer.php 2016-07-27 13:40:44 UTC (rev 9004)
+++ trunk/MgDev/Web/src/mapviewerphp/buffer.php 2016-07-27 13:46:08 UTC (rev 9005)
@@ -241,7 +241,8 @@
if($filter == "")
continue;
- $query = new MgFeatureQueryOptions();
+ $clsDef = $selLayer->GetClassDefinition();
+ $query = BuildFeatureQueryOptions($clsDef);
$query->SetFilter($filter);
$featureSource = new MgResourceIdentifier($selLayer->GetFeatureSourceId());
Modified: trunk/MgDev/Web/src/mapviewerphp/common.php
===================================================================
--- trunk/MgDev/Web/src/mapviewerphp/common.php 2016-07-27 13:40:44 UTC (rev 9004)
+++ trunk/MgDev/Web/src/mapviewerphp/common.php 2016-07-27 13:46:08 UTC (rev 9005)
@@ -282,4 +282,54 @@
return $paramValue;
}
+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: trunk/MgDev/Web/src/mapviewerphp/search.php
===================================================================
--- trunk/MgDev/Web/src/mapviewerphp/search.php 2016-07-27 13:40:44 UTC (rev 9004)
+++ trunk/MgDev/Web/src/mapviewerphp/search.php 2016-07-27 13:46:08 UTC (rev 9005)
@@ -103,7 +103,8 @@
$displayAll = (count($resProps) == 0);
//query the features
- $opts = new MgFeatureQueryOptions();
+ $clsDef = $layer->GetClassDefinition();
+ $opts = BuildFeatureQueryOptions($clsDef);
$opts->SetFilter($filter);
$featureClassName = $layer->GetFeatureClassName();
$features = $layer->SelectFeatures($opts);
Modified: trunk/MgDev/Web/src/mapviewerphp/selectwithin.php
===================================================================
--- trunk/MgDev/Web/src/mapviewerphp/selectwithin.php 2016-07-27 13:40:44 UTC (rev 9004)
+++ trunk/MgDev/Web/src/mapviewerphp/selectwithin.php 2016-07-27 13:46:08 UTC (rev 9005)
@@ -99,7 +99,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 mapguide-commits
mailing list