Ejemplo n.º 1
0
             $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 ($oExtents) {
         $oMin = $oExtents->GetLowerLeftCoordinate();
         $oMax = $oExtents->GetUpperRightCoordinate();
         $result->extents = NULL;
         $result->extents->minx = $oMin->GetX();
Ejemplo n.º 2
0
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */
/*****************************************************************************
 * Purpose: clear active selection from the map
 *****************************************************************************/
include "Common.php";
if (InitializationErrorOccurred()) {
    DisplayInitializationErrorText();
    exit;
}
try {
    $resourceSrvc = $siteConnection->CreateService(MgServiceType::ResourceService);
    $map = new MgMap();
    $map->Open($resourceSrvc, $mapName);
    $sel = new MgSelection($map);
    $sel->Save($resourceSrvc, $mapName);
} catch (MgException $e) {
    echo "ERROR: " . $e->GetExceptionMessage() . "\n";
    echo $e->GetDetails() . "\n";
    echo $e->GetStackTrace() . "\n";
}
Ejemplo n.º 3
0
 $mappingService = $siteConnection->CreateService(MgServiceType::MappingService);
 $featureService = $siteConnection->CreateService(MgServiceType::FeatureService);
 // Get a runtime map from a map definition
 if (isset($_REQUEST['mapid'])) {
     $mapid = $_REQUEST['mapid'];
     //echo $mapid;
     $resourceID = new MgResourceIdentifier($mapid);
     $map = new MgMap();
     $mapTitle = $resourceID->GetName();
     //echo "<br> maname $mapName <br>";
     $map->Create($resourceService, $resourceID, $mapTitle);
     $mapName = uniqid($mapTitle);
     $mapStateId = new MgResourceIdentifier("Session:" . $sessionID . "//" . $mapName . "." . MgResourceType::Map);
     //create an empty selection object and store it in the session repository
     $sel = new MgSelection($map);
     $sel->Save($resourceService, $mapName);
     $map->Save($resourceService, $mapStateId);
 } else {
     $map = new MgMap();
     $map->Open($resourceService, $mapName);
     $mapTitle = $map->GetName();
     $mapid = $map->GetMapDefinition()->ToString();
 }
 //$sessionId =  $map->GetSessionId();
 //$mapName = $map->GetName() ;
 $extents = $map->GetMapExtent();
 @($oMin = $extents->GetLowerLeftCoordinate());
 @($oMax = $extents->GetUpperRightCoordinate());
 @($srs = $map->GetMapSRS());
 if ($srs != "") {
     @($csFactory = new MgCoordinateSystemFactory());
 public function CreateRuntimeMap($format)
 {
     $session = $this->app->request->params("session");
     $mapDefIdStr = $this->app->request->params("mapdefinition");
     $mapName = $this->app->request->params("targetmapname");
     $reqFeatures = $this->app->request->params("requestedfeatures");
     $iconFormat = $this->app->request->params("iconformat");
     $iconWidth = $this->app->request->params("iconwidth");
     $iconHeight = $this->app->request->params("iconheight");
     $iconsPerScaleRange = $this->app->request->params("iconsperscalerange");
     $this->EnsureAuthenticationForSite($session);
     $siteConn = new MgSiteConnection();
     $siteConn->Open($this->userInfo);
     if ($session == null) {
         $site = $siteConn->GetSite();
         $session = $site->CreateSession();
         $this->userInfo = new MgUserInformation($session);
         $siteConn->Open($this->userInfo);
     }
     $mdfId = new MgResourceIdentifier($mapDefIdStr);
     if ($mapName == null) {
         $mapName = $mdfId->GetName();
     }
     //Assign default values or coerce existing ones to their expected types
     if ($reqFeatures != null) {
         $reqFeatures = intval($reqFeatures);
     }
     if ($iconFormat == null) {
         $iconFormat = "PNG";
     }
     if ($iconWidth == null) {
         $iconWidth = 16;
     } else {
         $iconWidth = intval($iconWidth);
     }
     if ($iconHeight == null) {
         $iconHeight = 16;
     } else {
         $iconHeight = intval($iconHeight);
     }
     if ($iconsPerScaleRange == null) {
         $iconsPerScaleRange = 25;
     } else {
         $iconsPerScaleRange = intval($iconsPerScaleRange);
     }
     if ($format == null) {
         $format = "xml";
     } else {
         $format = strtolower($format);
     }
     /*
     $admin = new MgServerAdmin();
     $admin->Open($this->userInfo);
     $version = explode(".", $admin->GetSiteVersion());
     */
     $version = $this->app->MG_VERSION;
     $bCanUseNative = false;
     if (intval($version[0]) > 2) {
         //3.0 or greater
         $bCanUseNative = true;
     } else {
         if (intval($version[0]) == 2 && intval($version[1]) >= 6) {
             //2.6 or greater
             $bCanUseNative = true;
         }
     }
     if ($bCanUseNative) {
         $req = new MgHttpRequest("");
         $param = $req->GetRequestParam();
         $param->AddParameter("OPERATION", "CREATERUNTIMEMAP");
         //Hmmm, this may violate REST API design, but if we're on MGOS 3.0 or newer, we must return linked tile set
         //information to the client if applicable. Meaning this API could return 2 different results depending on the
         //underlying MGOS version.
         if (intval($version[0]) >= 3) {
             $param->AddParameter("VERSION", "3.0.0");
         } else {
             $param->AddParameter("VERSION", "2.6.0");
         }
         $param->AddParameter("SESSION", $session);
         $param->AddParameter("MAPDEFINITION", $mapDefIdStr);
         $param->AddParameter("TARGETMAPNAME", $mapName);
         $param->AddParameter("REQUESTEDFEATURES", $reqFeatures);
         $param->AddParameter("ICONSPERSCALERANGE", $iconsPerScaleRange);
         $param->AddParameter("ICONFORMAT", $iconFormat);
         $param->AddParameter("ICONWIDTH", $iconWidth);
         $param->AddParameter("ICONHEIGHT", $iconHeight);
         if ($format === "json") {
             $param->AddParameter("FORMAT", MgMimeType::Json);
         } else {
             $param->AddParameter("FORMAT", MgMimeType::Xml);
         }
         $this->ExecuteHttpRequest($req);
     } else {
         //Shim the response
         $resSvc = $siteConn->CreateService(MgServiceType::ResourceService);
         $mappingSvc = $siteConn->CreateService(MgServiceType::MappingService);
         $map = new MgMap($siteConn);
         $map->Create($mdfId, $mapName);
         $mapStateId = new MgResourceIdentifier("Session:{$session}//{$mapName}.Map");
         $sel = new MgSelection($map);
         $sel->Save($resSvc, $mapName);
         $map->Save($resSvc, $mapStateId);
         $br = $this->DescribeRuntimeMapXml($mapDefIdStr, $map, $session, $mapName, $iconFormat, $iconWidth, $iconHeight, $reqFeatures, $iconsPerScaleRange, $resSvc, $mappingSvc);
         if ($format == "json") {
             $this->OutputXmlByteReaderAsJson($br);
         } else {
             $this->OutputByteReader($br);
         }
     }
 }
Ejemplo n.º 5
0
 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);
 }