[fusion-commits] r2438 - trunk/widgets/SelectWithin
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Tue Oct 11 22:14:39 EDT 2011
Author: liuar
Date: 2011-10-11 19:14:38 -0700 (Tue, 11 Oct 2011)
New Revision: 2438
Modified:
trunk/widgets/SelectWithin/SelectWithin.php
Log:
Fix Ticket #475 SelectWithIn does't work while the map cs doesn't consist with layer cs.
SelectWithIn bases on the MapGuide API QueryFeatures which accepts a geometry parameter. The geometry represents a spatial filter to perform the query whose coordinates should base on the Map CS. However, in SelectionWith.php, the coordinates are based on Layer CS, which causes this defect.
Modified: trunk/widgets/SelectWithin/SelectWithin.php
===================================================================
--- trunk/widgets/SelectWithin/SelectWithin.php 2011-10-10 05:47:12 UTC (rev 2437)
+++ trunk/widgets/SelectWithin/SelectWithin.php 2011-10-12 02:14:38 UTC (rev 2438)
@@ -173,8 +173,8 @@
}
else if($type != MgGeometryType::Polygon)
continue;
-
- $geomColl->Add($geom);
+ $trans = GetLayerToMapCSTrans($classDef, $geomPropName, $featureSrvc, $featureSource, $map);
+ $geomColl->Add($geom->Transform($trans));
}
$features->Close();
}
@@ -194,6 +194,33 @@
return $gf->CreateMultiGeometry($geomColl);
}
+function GetLayerToMapCSTrans($classDef, $geomPropName, $featureSrvc, $fsId, $map)
+{
+ $props = $classDef->GetProperties();
+ $geomProp = $props->GetItem($geomPropName);
+ $scAssociation = $geomProp->GetSpatialContextAssociation();
+ $csrdr = $featureSrvc->GetSpatialContexts($fsId, false);
+ $layerwkt = '';
+
+ while($csrdr->ReadNext())
+ {
+ $csrName = $csrdr->GetName();
+ if($csrName == $scAssociation)
+ {
+ // Match found for the association
+ $layerwkt = $csrdr->GetCoordinateSystemWkt();
+ break;
+ }
+ }
+ $csrdr->Close();
+ $cf = new MgCoordinateSystemFactory();
+ $layerCS = $cf->Create($layerwkt);
+ $mapCS = $cf->Create($map->GetMapSRS());
+ $trans = $cf->GetTransform ($layerCS, $mapCS);
+
+ return $trans;
+}
+
function GetParameters($params)
{
global $layers, $mapName, $sessionId, $queryInfo;
More information about the fusion-commits
mailing list