$properties->extents->miny = $oMin->GetY(); $properties->extents->maxx = $oMax->GetX(); $properties->extents->maxy = $oMax->GetY(); } else { echo "<Message>no extents</Message>"; } //get properties for individual features $result->layers = array(); for ($i=0; $i<$layers->GetCount(); $i++) { $layer = $layers->GetItem($i); $layerName = $layer->GetName(); $layerClassName = $layer->GetFeatureClassName(); $options = new MgFeatureQueryOptions(); $options->SetFilter($resultSel->GenerateFilter($layer, $layerClassName)); $resourceId = new MgResourceIdentifier($layer->GetFeatureSourceId()); $featureReader = $featureSrvc->SelectFeatures($resourceId, $layerClassName, $options); $properties = BuildSelectionArray($featureReader, $layerName, $properties, false, NULL, false, $layer, true); $featureReader->Close(); array_push($result->layers, $layerName); array_push($properties->layers, $layerName); $count = $resultSel->GetSelectedFeaturesCount($layer, $layerClassName); $result->$layerName->featureCount = $count; } /*save selection in the session*/ $_SESSION['selection_array'] = $properties; echo str_replace("</FeatureSet>", "</FeatureSet></FeatureInformation>", str_replace("<FeatureSet", "<FeatureInformation><FeatureSet", $resultSel->ToXml())); } else { echo "<Message>layers false or 0</Message>"; } } else { echo "<Message>no resultsel</Message>"; } } else { echo "<Message>no fi</Message>"; } } else { echo "<Message>no multi geom</Message>"; } } else { echo "<Message>no layers</Message>"; }
// 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; $bNeedsTransform = false; 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, $bComputedProperties, $srsLayer, $bNeedsTransform, $oLayer, true); $featureReader->Close(); } } } $selection->Save($resourceService, $mapName); //print_r($properties); //echo "/* SelectionXML:".$selection->ToXML()."*/"; header('Content-type: application/json'); header('X-JSON: true'); $layers = $selection->GetLayers(); $result = NULL; $result->hasSelection = false; if ($layers && $layers->GetCount() >= 0) { $result->hasSelection = true; $oExtents = $selection->GetExtents($featureService);
} 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; $bNeedsTransform = false; 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, true, $srsLayer, $bNeedsTransform, $layer, false); } $response = json_encode($properties); } catch (MgException $e) { echo "ERROR: " . $e->GetExceptionMessage() . "\n"; echo $e->GetDetails() . "\n"; echo $e->GetStackTrace() . "\n"; } header('Content-Type: ' . $responseType); echo trim($response);