コード例 #1
0
 $responseType = 'text/plain';
 $response = '';
 $site = new MgSiteConnection();
 $site->Open(new MgUserInformation($args['SESSION']));
 $resourceService = $site->CreateService(MgServiceType::ResourceService);
 $featureService = $site->CreateService(MgServiceType::FeatureService);
 $layerName = $args['LAYERNAME'];
 $mapName = $args['MAPNAME'];
 $map = new MgMap($site);
 $map->Open($mapName);
 $layer = $map->GetLayers()->GetItem($layerName);
 $className = $layer->GetFeatureClassName();
 $selection = new MgSelection($map);
 $selection->Open($resourceService, $mapName);
 $properties = new stdClass();
 if ($selection->Contains($layer, $className)) {
     $featureReader = $selection->GetSelectedFeatures($layer, $className, new MgStringCollection());
     /* Get the map SRS - we use this to convert distances */
     $srsFactory = new MgCoordinateSystemFactory();
     //safely get an SRS ... (in Utilities)
     $srsDefMap = GetMapSRS($map);
     $srsMap = $srsFactory->Create($srsDefMap);
     $featureResId = new MgResourceIdentifier($layer->GetFeatureSourceId());
     $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;