public function DescribeRuntimeMap($sessionId, $mapName, $format)
 {
     $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($sessionId, false);
     $siteConn = new MgSiteConnection();
     $siteConn->Open($this->userInfo);
     //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());
     $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", "DESCRIBERUNTIMEMAP");
         $param->AddParameter("VERSION", "2.6.0");
         $param->AddParameter("SESSION", $sessionId);
         $param->AddParameter("MAPNAME", $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->Open($mapName);
         $mapDefId = $map->GetMapDefinition();
         $mapDefIdStr = $mapDefId->ToString();
         $br = $this->DescribeRuntimeMapXml($mapDefIdStr, $map, $sessionId, $mapName, $iconFormat, $iconWidth, $iconHeight, $reqFeatures, $iconsPerScaleRange, $resSvc, $mappingSvc);
         if ($format == "json") {
             $this->OutputXmlByteReaderAsJson($br);
         } else {
             $this->OutputByteReader($br);
         }
     }
 }
Beispiel #2
0
     $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;
     //$unitsType = "Meters";
 public function GetSessionMapKml($sessionId, $mapName, $format = "kml")
 {
     $fmt = $this->ValidateRepresentation($format, array("kml", "kmz"));
     $native = $this->GetBooleanRequestParameter("native", "0") == "1";
     //Internal debugging flag
     $chunk = $this->GetBooleanRequestParameter("chunk", true);
     $this->EnsureAuthenticationForSite($sessionId, true);
     $siteConn = new MgSiteConnection();
     $siteConn->Open($this->userInfo);
     $map = new MgMap($siteConn);
     $map->Open($mapName);
     if ($native) {
         $mdfId = $map->GetMapDefinition();
         $mdfIdStr = $mdfId->ToString();
         $selfUrl = MgUtils::GetSelfUrlRoot($this->app->config("SelfUrl"));
         $this->app->redirect("{$selfUrl}/../mapagent/mapagent.fcgi?OPERATION=GETMAPKML&VERSION=1.0.0&SESSION={$sessionId}&MAPDEFINITION={$mdfIdStr}&CLIENTAGENT=MapGuide REST Extension");
     } else {
         $this->_GetKmlForMap($map, $sessionId, $format, $chunk);
     }
 }
Beispiel #4
0
    $map->Open($resourceService, $mapName);
    $mappingService = $siteConnection->CreateService(MgServiceType::MappingService);
    $dwfVersion = new MgDwfVersion("6.01", "1.2");
    $plotSpec = new MgPlotSpecification(8.5, 11, MgPageUnitsType::Inches);
    $plotSpec->SetMargins(0.5, 0.5, 0.5, 0.5);
    $layout = null;
    $layoutRes = new MgResourceIdentifier("Library://Samples/Sheboygan/Layouts/SheboyganMap.PrintLayout");
    $layout = new MgLayout($layoutRes, "City of Sheboygan", MgPageUnitsType::Inches);
    $plotCollection = new MgMapPlotCollection();
    $plot1 = new MgMapPlot($map, $plotSpec, $layout);
    $plot1->SetCenterAndScale($map->GetViewCenter()->GetCoordinate(), $map->GetViewScale() * 2);
    $plotCollection->Add($plot1);
    // Create a second map for the second sheet in the DWF. This second sheet uses the print layout
    // to display a page title and legend.
    $map2 = new MgMap();
    $map2->Create($resourceService, $map->GetMapDefinition(), 'Sheet 2');
    $plot2 = new MgMapPlot($map2, $plotSpec, $layout);
    $plot2->SetCenterAndScale($map->GetViewCenter()->GetCoordinate(), $map->GetViewScale());
    // $plot2 = new MgMapPlot($map2, $map->GetViewCenter()->GetCoordinate(), $map->GetViewScale(), $plotSpec, $layout);
    $plotCollection->Add($plot2);
    $byteReader = $mappingService->GenerateMultiPlot($plotCollection, $dwfVersion);
    // Now output the resulting DWF.
    $outputBuffer = '';
    $buffer = '';
    while ($byteReader->Read($buffer, 50000) != 0) {
        $outputBuffer .= $buffer;
    }
    header('Content-Type: ' . $byteReader->GetMimeType());
    header('Content-Length: ' . strlen($outputBuffer));
    echo $outputBuffer;
} catch (MgException $e) {