public function UpdateSelectionFromXml($sessionId, $mapName) { $this->EnsureAuthenticationForSite($sessionId); $siteConn = new MgSiteConnection(); $siteConn->Open($this->userInfo); $resSvc = $siteConn->CreateService(MgServiceType::ResourceService); $map = new MgMap($siteConn); $map->Open($mapName); $xml = trim($this->app->request->getBody()); $selection = new MgSelection($map); $selection->FromXml($xml); $selection->Save($resSvc, $mapName); }
exit; } include '../../../common/php/Utilities.php'; include 'Utilities.php'; $selText = ""; $getExtents = false; GetRequestParameters(); try { //load the map runtime state // $map = new MgMap(); $map->Open($resourceService, $mapName); // Create the selection set and save it $selection = new MgSelection($map); if ($selText != "") { $selection->FromXml($selText); } $selection->Save($resourceService, $mapName); //now return a data struture which is the same as Query.php //process header('Content-type: application/json'); header('X-JSON: true'); $layers = $selection->GetLayers(); $result = new stdClass(); $result->hasSelection = false; if ($layers && $layers->GetCount() >= 0) { $result->hasSelection = true; $result->extents = new stdClass(); if ($getExtents) { $featureService = $siteConnection->CreateService(MgServiceType::FeatureService); $oExtents = $selection->GetExtents($featureService);
$cred = new MgUserInformation($sessionId); $cred->SetClientIp(GetClientIp()); $cred->SetClientAgent(GetClientAgent()); //connect to the site and get an instance of the resoucre service // $site = new MgSiteConnection(); $site->Open($cred); $resourceSrvc = $site->CreateService(MgServiceType::ResourceService); //load the map runtime state // $map = new MgMap(); $map->Open($resourceSrvc, $mapName); // Create the selection set and save it $sel = new MgSelection($map); if ($selText != "") { $sel->FromXml($selText); } $sel->Save($resourceSrvc, $mapName); if ($queryInfo) { //Query feature info for the feature in the selection set. This will return the current set //along with property info //There must be only one feature in the feature set $layers = $sel->GetLayers(); if ($layers == null || $layers->GetCount() != 1) { echo "Error: There must be exactly one feature in the set."; ///NOXLATE dbg report only return; } $layer = $layers->GetItem(0); $featureClassName = $layer->GetFeatureClassName(); $filter = $sel->GenerateFilter($layer, $featureClassName);