[fusion-commits] r2641 - sandbox/adsk/2.5k/layers/MapGuide/php
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Mon Feb 18 22:33:34 PST 2013
Author: liuar
Date: 2013-02-18 22:33:33 -0800 (Mon, 18 Feb 2013)
New Revision: 2641
Modified:
sandbox/adsk/2.5k/layers/MapGuide/php/GetSelectionProperties.php
sandbox/adsk/2.5k/layers/MapGuide/php/Utilities.php
Log:
Submit on behalf of Andy Zhang.
Update GetSelectionProperties.php to use MgSelectionBase::GenerateFilter.
In previous change #2630, I updated the file to Use API MgSelectionBase::GenerateFilters instead of MgSelectionBase::GenerateFilter to avoid the filter text exceed the SQL length limit. We find the performance of 'select features' degrades a lot when selecting many features after this change. The reason is that previous change will result in multiple DB queries + multiple request/response traffic between Web Server and Map Server, which will impact the performance a lot.
Because the case that 'filter text exceed the SQL length limit' only happens when the PK of a feature class has more than one columns, and most databases support very long SQL statement, we decide to partially revert the change #2630. I added a comment to indicate user to use selection.GenerateFilters if filter length exceeds DB limitation.
This submission also other 2 things:
1. Fixed a defect that Geometry property may be added twice to query options.
2. Don't call GetExtents() because it is time-consuming and it seems the extents are not used in other places.
Modified: sandbox/adsk/2.5k/layers/MapGuide/php/GetSelectionProperties.php
===================================================================
--- sandbox/adsk/2.5k/layers/MapGuide/php/GetSelectionProperties.php 2013-02-17 04:25:14 UTC (rev 2640)
+++ sandbox/adsk/2.5k/layers/MapGuide/php/GetSelectionProperties.php 2013-02-19 06:33:33 UTC (rev 2641)
@@ -60,7 +60,6 @@
/*holds selection array*/
$properties = NULL;
$properties->layers = array();
- $properties->envelope = NULL;
//process
header('Content-type: application/json');
@@ -76,7 +75,7 @@
/* select the features */
$queryOptions = new MgFeatureQueryOptions();
-
+ $geomName = $oLayer->GetFeatureGeometryName();
//TODO : seems that property mapping breaks the selection ????
//could it be that $selection->AddFeatures($layerObj, $featureReader, 0) is
//the one causing a problem when the properies are limited ?
@@ -84,26 +83,32 @@
$mappings = $_SESSION['property_mappings'][$oLayer->GetObjectId()];
if (count($mappings) > 0) {
foreach($mappings as $name => $value) {
- $queryOptions->AddFeatureProperty($name);
- //echo "$name $value <br>\n";
+ // Don't add geometry property twice.
+ if ($name != $geomName) {
+ $queryOptions->AddFeatureProperty($name);
+ //echo "$name $value <br>\n";
+ }
}
}
}
//Add geometry property in all cases.
- $geomName = $oLayer->GetFeatureGeometryName();
$queryOptions->AddFeatureProperty($geomName);
- $filters = $selection->GenerateFilters($oLayer, $class, MgSelectionBatchSize::RenderSelectionBatchSize);
- $featureReaders = NULL;
- $featureReaders = array();
- for ($j = 0; $j < $filters->GetCount(); $j++) {
- $queryOptions->SetFilter($filters->GetItem($j));
- $featureReader = $featureService->SelectFeatures($featureResId, $class, $queryOptions);
- array_push($featureReaders, $featureReader);
- }
- //$featureReader = $selection->GetSelectedFeatures($oLayer, $class, true );//this doesn't seem to work but would replace much of the above code
+ //Please use selection.GenerateFilters if filter length exceeds DB limitation.
+ //$filters = $selection->GenerateFilters($oLayer, $class, MgSelectionBatchSize::RenderSelectionBatchSize);
+ //$featureReaders = NULL;
+ //$featureReaders = array();
+ //for ($j = 0; $j < $filters->GetCount(); $j++) {
+ // $queryOptions->SetFilter($filters->GetItem($j));
+ // $featureReader = $featureService->SelectFeatures($featureResId, $class, $queryOptions);
+ // array_push($featureReaders, $featureReader);
+ //}
+ $filter = $selection->GenerateFilter($oLayer, $class);
+ $queryOptions->SetFilter($filter);
+ $featureReader = $featureService->SelectFeatures($featureResId, $class, $queryOptions);
+
$layerName = $oLayer->GetName();
array_push($properties->layers, $layerName);
@@ -142,12 +147,11 @@
}
}
- $properties = BuildSelectionArrayEx($featureReaders, $layerName, $properties,
+ $properties = BuildSelectionArray($featureReader, $layerName, $properties,
$bComputedProperties,
$srsLayer, $bNeedsTransform, $oLayer, true);
- foreach ($featureReaders as $featureReader) {
- $featureReader->Close();
- }
+
+ $featureReader->Close();
}
$result = NULL;
@@ -155,7 +159,9 @@
if ($layers && $layers->GetCount() >= 0)
{
$result->hasSelection = true;
- $oExtents = $properties->envelope;
+ //Don't call GetExtents() because it is time-consuming and it seems the extents is not used in other places.
+ //$oExtents = $selection->GetExtents($featureService);
+ $oExtents = NULL;
if ($oExtents)
{
$oMin = $oExtents->GetLowerLeftCoordinate();
Modified: sandbox/adsk/2.5k/layers/MapGuide/php/Utilities.php
===================================================================
--- sandbox/adsk/2.5k/layers/MapGuide/php/Utilities.php 2013-02-17 04:25:14 UTC (rev 2640)
+++ sandbox/adsk/2.5k/layers/MapGuide/php/Utilities.php 2013-02-19 06:33:33 UTC (rev 2641)
@@ -1013,25 +1013,16 @@
$numproperties = count($properties->$layerName->propertynames);
for($j=0; $j<$numproperties; $j++) {
$propname = $properties->$layerName->propertynames[$j];
- $propType = $properties->$layerName->propertytypes[$j];
if ($propname == '')
continue;
- if ($propType == MgPropertyType::Geometry) {
- $geomByteReader = $featureReader->GetGeometry($geomName);
- $geom = $agf->Read($geomByteReader);
- $geomEnv = $geom->Envelope();
- $properties->envolope->ExpandToInclude($geomEnv);
- }
- else {
- $value = GetPropertyValueFromFeatReader($featureReader,
- $properties->$layerName->propertytypes[$j],
- $propname);
- $value = htmlentities($value, ENT_COMPAT, 'UTF-8');
- $value = addslashes($value);
- $value = preg_replace( "/\r?\n/", "<br>", $value );
- array_push($properties->$layerName->values[$properties->$layerName->numelements], $value);
- //$properties->$layerName->values[$properties->$layerName->numelements][$propname] = $value;
- }
+ $value = GetPropertyValueFromFeatReader($featureReader,
+ $properties->$layerName->propertytypes[$j],
+ $propname);
+ $value = htmlentities($value, ENT_COMPAT, 'UTF-8');
+ $value = addslashes($value);
+ $value = preg_replace( "/\r?\n/", "<br>", $value );
+ array_push($properties->$layerName->values[$properties->$layerName->numelements], $value);
+ //$properties->$layerName->values[$properties->$layerName->numelements][$propname] = $value;
}
$properties->$layerName->numelements= $properties->$layerName->numelements+1;
}
More information about the fusion-commits
mailing list