Beispiel #1
0
     //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());
     @($cs = $csFactory->Create($srs));
     @($metersPerUnit = $cs->ConvertCoordinateSystemUnitsToMeters(1.0));
     //  $unitsType = $cs->GetUnits();
 } else {
     $metersPerUnit = 1.0;
    MgInitializeWebTier($webconfigFilePath);
    // Get the session information passed from the viewer.
    $args = $_SERVER['REQUEST_METHOD'] == "POST" ? $_POST : $_GET;
    $sessionId = $args['SESSION'];
    $mapName = $args['MAPNAME'];
    // Get the user information using the session id,
    // and set up a connection to the site server.
    $userInfo = new MgUserInformation($sessionId);
    $siteConnection = new MgSiteConnection();
    $siteConnection->Open($userInfo);
    // Get an instance of the required service(s).
    $resourceService = $siteConnection->CreateService(MgServiceType::ResourceService);
    // Finished basic initialization.
    // --------------------------------------------------//
    // Query the spatial reference system used for the map.
    $map = new MgMap($siteConnection);
    $map->Open($mapName);
    $srs = $map->GetMapSRS();
    // Format it and display it in the task pane.
    echo '<p>Map <strong>' . $map->GetName() . '</strong> uses this reference system: </p>';
    $srs = chunk_split($srs, 30);
    echo '<pre style="padding: 2px; border: 1px solid black; background-color: #eee">' . $srs . '</pre>';
} catch (MgException $e) {
    echo "<p><strong>Error:</strong> ";
    echo $e->GetDetails();
    echo "</p>";
}
?>

</body>
</html>