[fusion-commits] r1767 - trunk/layers/MapGuide/php
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Tue Feb 3 14:30:17 EST 2009
Author: chrisclaydon
Date: 2009-02-03 14:30:17 -0500 (Tue, 03 Feb 2009)
New Revision: 1767
Modified:
trunk/layers/MapGuide/php/GetSelectionProperties.php
Log:
Re #199 - Handle layers with no property mappings set.
Modified: trunk/layers/MapGuide/php/GetSelectionProperties.php
===================================================================
--- trunk/layers/MapGuide/php/GetSelectionProperties.php 2009-02-03 19:24:59 UTC (rev 1766)
+++ trunk/layers/MapGuide/php/GetSelectionProperties.php 2009-02-03 19:30:17 UTC (rev 1767)
@@ -42,10 +42,10 @@
if($selText != "") {
$selection->FromXml($selText);
}
-
+
//now return a data struture which is the same as Query.php
$featureService = $siteConnection->CreateService(MgServiceType::FeatureService);
-
+
/* Get the map SRS - we use this to convert distances */
$srsFactory = new MgCoordinateSystemFactory();
//safely get an SRS ... (in Utilities)
@@ -56,7 +56,7 @@
$properties = NULL;
$properties->layers = array();
- //process
+ //process
header('Content-type: text/x-json');
header('X-JSON: true');
$layers = $selection->GetLayers();
@@ -70,20 +70,22 @@
/* select the features */
$queryOptions = new MgFeatureQueryOptions();
-
+
//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 ?
- $mappings = $_SESSION['property_mappings'][$oLayer->GetObjectId()];
- if (0 && count($mappings) > 0) {
- foreach($mappings as $name => $value) {
- $queryOptions->AddFeatureProperty($name);
- //echo "$name $value <br>\n";
+ if (isset($_SESSION['property_mappings']) && isset($_SESSION['property_mappings'][$oLayer->GetObjectId()])) {
+ $mappings = $_SESSION['property_mappings'][$oLayer->GetObjectId()];
+ if (0 && count($mappings) > 0) {
+ foreach($mappings as $name => $value) {
+ $queryOptions->AddFeatureProperty($name);
+ //echo "$name $value <br>\n";
+ }
+ $geomName = $oLayer->GetFeatureGeometryName();
+ $queryOptions->AddFeatureProperty($geomName);
}
- $geomName = $oLayer->GetFeatureGeometryName();
- $queryOptions->AddFeatureProperty($geomName);
}
-
+
$filter = $selection->GenerateFilter($oLayer, $class);
$queryOptions->SetFilter($filter);
$featureReader = $featureService->SelectFeatures($featureResId, $class, $queryOptions);
@@ -92,39 +94,39 @@
$layerName = $oLayer->GetName();
array_push($properties->layers, $layerName);
- // TODO: Check if computed properties are needed?
+ // TODO: Check if computed properties are needed?
$bComputedProperties = false;
$bNeedsTransform = false;
$srsLayer = NULL;
if ($bComputedProperties)
{
- $spatialContext = $featureService->GetSpatialContexts($featureResId, true);
- $srsLayerWkt = false;
- if($spatialContext != null && $spatialContext->ReadNext() != null) {
- $srsLayerWkt = $spatialContext->GetCoordinateSystemWkt();
- /* skip this layer if the srs is empty */
- }
- if ($srsLayerWkt == null) {
- $srsLayerWkt = $srsDefMap;
- }
- /* create a coordinate system from the layer's SRS wkt */
- $srsLayer = $srsFactory->Create($srsLayerWkt);
+ $spatialContext = $featureService->GetSpatialContexts($featureResId, true);
+ $srsLayerWkt = false;
+ if($spatialContext != null && $spatialContext->ReadNext() != null) {
+ $srsLayerWkt = $spatialContext->GetCoordinateSystemWkt();
+ /* skip this layer if the srs is empty */
+ }
+ if ($srsLayerWkt == null) {
+ $srsLayerWkt = $srsDefMap;
+ }
+ /* create a coordinate system from the layer's SRS wkt */
+ $srsLayer = $srsFactory->Create($srsLayerWkt);
- // exclude layer if:
- // the map is non-arbitrary and the layer is arbitrary or vice-versa
- // or
- // layer and map are both arbitrary but have different units
- //
- $bLayerSrsIsArbitrary = ($srsLayer->GetType() == MgCoordinateSystemType::Arbitrary);
- $bMapSrsIsArbitrary = ($srsMap->GetType() == MgCoordinateSystemType::Arbitrary);
- if (($bLayerSrsIsArbitrary != $bMapSrsIsArbitrary) ||
- ($bLayerSrsIsArbitrary && ($srsLayer->GetUnits() != $srsMap->GetUnits()))) {
- $bComputedProperties = false;
- } else {
- $srsTarget = null;
- $srsXform = null;
- $bNeedsTransform = ($srsLayer->GetUnitScale() != 1.0);
- }
+ // exclude layer if:
+ // the map is non-arbitrary and the layer is arbitrary or vice-versa
+ // or
+ // layer and map are both arbitrary but have different units
+ //
+ $bLayerSrsIsArbitrary = ($srsLayer->GetType() == MgCoordinateSystemType::Arbitrary);
+ $bMapSrsIsArbitrary = ($srsMap->GetType() == MgCoordinateSystemType::Arbitrary);
+ if (($bLayerSrsIsArbitrary != $bMapSrsIsArbitrary) ||
+ ($bLayerSrsIsArbitrary && ($srsLayer->GetUnits() != $srsMap->GetUnits()))) {
+ $bComputedProperties = false;
+ } else {
+ $srsTarget = null;
+ $srsXform = null;
+ $bNeedsTransform = ($srsLayer->GetUnitScale() != 1.0);
+ }
}
$properties = BuildSelectionArray($featureReader, $layerName, $properties,
@@ -132,7 +134,7 @@
$srsLayer, $bNeedsTransform, $oLayer);
$featureReader->Close();
}
-
+
$result = NULL;
$result->hasSelection = false;
if ($layers && $layers->GetCount() >= 0)
More information about the fusion-commits
mailing list