Пример #1
0
$aMargins = isset($_REQUEST['margins']) ? explode(',', $_REQUEST['margins']) : array(0, 0, 0, 0);
try {
    $mappingService = $siteConnection->CreateService(MgServiceType::MappingService);
    $renderingService = $siteConnection->CreateService(MgServiceType::RenderingService);
    $map = new MgMap();
    $map->Open($resourceService, $mapName);
    $selection = new MgSelection($map);
    $selection->Open($resourceService, $mapName);
    //get current center as a coordinate
    $center = $map->GetViewCenter()->GetCoordinate();
    //plot with the passed scale, if provided
    $scale = isset($_REQUEST['scale']) ? $_REQUEST['scale'] : $map->GetViewScale();
    if ($format == 'DWF') {
        $oLayout = null;
        if ($layout) {
            $layoutId = new MgResourceIdentifier($layout);
            $layoutId->Validate();
            $oLayout = new MgLayout($layoutId, 'Map', 'meters');
        }
        $oPlotSpec = new MgPlotSpecification($pageWidth, $pageHeight, MgPageUnitsType::Inches, $aMargins[0], $aMargins[1], $aMargins[2], $aMargins[3]);
        $dwfVersion = new MgDwfVersion('6.01', '1.2');
        $oImg = $mappingService->GeneratePlot($map, $center, $scale, $oPlotSpec, $oLayout, $dwfVersion);
    } else {
        //render as an image
        if (isset($imgHeight) && isset($imgWidth)) {
            $oImg = $renderingService->RenderMap($map, $selection, $center, $scale, $imgWidth, $imgHeight, new MgColor(255, 255, 255), $format);
        } else {
            $oImg = $renderingService->RenderMap($map, $selection, $format);
        }
    }
} catch (MgException $e) {
 public function SelectLayerFeatures($ldfId, $format)
 {
     //Check for unsupported representations
     $fmt = $this->ValidateRepresentation($format, array("xml", "geojson", "html", "czml"));
     $mimeType = $this->GetMimeTypeForFormat($fmt);
     try {
         $sessionId = "";
         if ($ldfId->GetRepositoryType() == MgRepositoryType::Session) {
             $sessionId = $ldfId->GetRepositoryName();
         }
         $this->EnsureAuthenticationForSite($sessionId, true, $mimeType);
         $siteConn = new MgSiteConnection();
         $siteConn->Open($this->userInfo);
         $featSvc = $siteConn->CreateService(MgServiceType::FeatureService);
         $query = new MgFeatureQueryOptions();
         $propList = $this->GetRequestParameter("properties", "");
         $filter = $this->GetRequestParameter("filter", "");
         $orderby = $this->GetRequestParameter("orderby", "");
         $orderOptions = $this->GetRequestParameter("orderoption", "");
         $maxFeatures = $this->GetRequestParameter("maxfeatures", "");
         $transformto = $this->GetRequestParameter("transformto", "");
         $bbox = $this->GetRequestParameter("bbox", "");
         $pageSize = $this->GetRequestParameter("pagesize", -1);
         $pageNo = $this->GetRequestParameter("page", -1);
         //Internal debugging flag
         $chunk = $this->GetBooleanRequestParameter("chunk", true);
         if ($pageNo >= 0 && $pageSize === -1) {
             $this->BadRequest($this->app->localizer->getText("E_MISSING_REQUIRED_PARAMETER", "pagesize"), $mimeType);
         } else {
             //The way that CZML output is done means we cannot support pagination
             if ($pageNo >= 0 && $pageSize > 0 && $fmt === "czml") {
                 $this->BadRequest($this->app->localizer->getText("E_CZML_PAGINATION_NOT_SUPPORTED"), $mimeType);
             }
         }
         $limit = -1;
         if ($maxFeatures !== "") {
             $limit = intval($maxFeatures);
         }
         //Load the Layer Definition document and extract the relevant bits of information
         //we're interested in
         $resSvc = $siteConn->CreateService(MgServiceType::ResourceService);
         $ldfContent = $resSvc->GetResourceContent($ldfId);
         $doc = new DOMDocument();
         $doc->loadXML($ldfContent->ToString());
         $vl = $doc->getElementsByTagName("VectorLayerDefinition");
         if ($vl->length == 1) {
             $vlNode = $vl->item(0);
             $fsId = $vlNode->getElementsByTagName("ResourceId");
             $fc = $vlNode->getElementsByTagName("FeatureName");
             $hlink = $vlNode->getElementsByTagName("Url");
             $tt = $vlNode->getElementsByTagName("ToolTip");
             $flt = $vlNode->getElementsByTagName("Filter");
             $elev = $vlNode->getElementsByTagName("ElevationSettings");
             if ($fsId->length == 1) {
                 $fsId = new MgResourceIdentifier($fsId->item(0)->nodeValue);
                 $site = $siteConn->GetSite();
                 $this->VerifyWhitelist($fsId->ToString(), $this->GetMimeTypeForFormat($fmt), "SELECTFEATURES", $fmt, $site, $this->userName);
                 if ($fc->length == 1) {
                     //Add hyperlink, tooltip and elevation as special computed properties
                     if ($hlink->length == 1 && strlen($hlink->item(0)->nodeValue) > 0) {
                         $query->AddComputedProperty(MgRestConstants::PROP_HYPERLINK, $hlink->item(0)->nodeValue);
                     }
                     if ($tt->length == 1 && strlen($tt->item(0)->nodeValue) > 0) {
                         $query->AddComputedProperty(MgRestConstants::PROP_TOOLTIP, $tt->item(0)->nodeValue);
                     }
                     if ($elev->length == 1) {
                         $elevNode = $elev->item(0);
                         $zoff = $elevNode->getElementsByTagName("ZOffset");
                         $zofftype = $elevNode->getElementsByTagName("ZOffsetType");
                         $zext = $elevNode->getElementsByTagName("ZExtrusion");
                         $unit = $elevNode->getElementsByTagName("Unit");
                         if ($zoff->length == 1 && strlen($zoff->item(0)->nodeValue) > 0) {
                             $query->AddComputedProperty(MgRestConstants::PROP_Z_OFFSET, $zoff->item(0)->nodeValue);
                         } else {
                             $query->AddComputedProperty(MgRestConstants::PROP_Z_OFFSET, "0");
                         }
                         if ($zofftype->length == 1 && strlen($zofftype->item(0)->nodeValue) > 0) {
                             $query->AddComputedProperty(MgRestConstants::PROP_Z_OFFSET_TYPE, "'" . $zofftype->item(0)->nodeValue . "'");
                         } else {
                             $query->AddComputedProperty(MgRestConstants::PROP_Z_OFFSET_TYPE, "'RelativeToGround'");
                         }
                         if ($zext->length == 1 && strlen($zext->item(0)->nodeValue) > 0) {
                             $query->AddComputedProperty(MgRestConstants::PROP_Z_EXTRUSION, $zext->item(0)->nodeValue);
                         } else {
                             $query->AddComputedProperty(MgRestConstants::PROP_Z_EXTRUSION, "0");
                         }
                         if ($unit->length == 1 && strlen($unit->item(0)->nodeValue) > 0) {
                             $query->AddComputedProperty(MgRestConstants::PROP_Z_UNITS, "'" . $unit->item(0)->nodeValue . "'");
                         } else {
                             $query->AddComputedProperty(MgRestConstants::PROP_Z_UNITS, "'Meters'");
                         }
                     }
                     $baseFilter = "";
                     //Set filter from layer if defined
                     if ($flt->length == 1 && strlen($flt->item(0)->nodeValue) > 0) {
                         if ($filter !== "") {
                             //logical AND with the layer's filter to combine them
                             $baseFilter = "(" . $flt->item(0)->nodeValue . ") AND (" . $filter . ")";
                             $query->SetFilter($baseFilter);
                         } else {
                             $baseFilter = $flt->item(0)->nodeValue;
                             $query->SetFilter($baseFilter);
                         }
                     } else {
                         if ($filter !== "") {
                             $baseFilter = $filter;
                             $query->SetFilter($baseFilter);
                         }
                     }
                     $tokens = explode(":", $fc->item(0)->nodeValue);
                     $schemaName = $tokens[0];
                     $className = $tokens[1];
                     $clsDef = NULL;
                     //Unless an explicit property list has been specified, we're explicitly adding all properties
                     //from the class definition
                     if ($propList !== "") {
                         $propNames = explode(",", $propList);
                         //If you have a comma in your property names, it's your own fault :)
                         foreach ($propNames as $propName) {
                             $query->AddFeatureProperty($propName);
                         }
                     } else {
                         if ($clsDef == NULL) {
                             $clsDef = $featSvc->GetClassDefinition($fsId, $schemaName, $className);
                         }
                         $clsProps = $clsDef->GetProperties();
                         for ($i = 0; $i < $clsProps->GetCount(); $i++) {
                             $propDef = $clsProps->GetItem($i);
                             $query->AddFeatureProperty($propDef->GetName());
                         }
                     }
                     if ($orderby !== "") {
                         $orderPropNames = explode(",", $orderby);
                         //If you have a comma in your property names, it's your own fault :)
                         $orderProps = new MgStringCollection();
                         foreach ($orderPropNames as $propName) {
                             $orderProps->Add($propName);
                         }
                         $orderOpt = MgOrderingOption::Ascending;
                         if (strtolower($orderOptions) === "desc") {
                             $orderOpt = MgOrderingOption::Descending;
                         }
                         $query->SetOrderingFilter($orderProps, $orderOpt);
                     }
                     //We must require features as LL84 for CZML output
                     if ($fmt == "czml") {
                         $transformto = "LL84";
                     }
                     $transform = null;
                     if ($transformto !== "") {
                         $transform = MgUtils::GetTransform($featSvc, $fsId, $schemaName, $className, $transformto);
                     }
                     if ($bbox !== "") {
                         $parts = explode(",", $bbox);
                         if (count($parts) == 4) {
                             $wktRw = new MgWktReaderWriter();
                             if ($clsDef == NULL) {
                                 $clsDef = $featSvc->GetClassDefinition($fsId, $schemaName, $className);
                             }
                             $geom = $wktRw->Read(MgUtils::MakeWktPolygon($parts[0], $parts[1], $parts[2], $parts[3]));
                             //Transform bbox to target cs if flag specified
                             $bboxIsTargetCs = $this->GetBooleanRequestParameter("bboxistargetcs", false);
                             if ($bboxIsTargetCs) {
                                 //Because it has been declared the bbox is in target coordiantes, we have to transform that bbox back to the
                                 //source, which means we need an inverse transform
                                 $invTx = MgUtils::GetTransform($featSvc, $fsId, $schemaName, $className, $transformto, true);
                                 $geom = $geom->Transform($invTx);
                             }
                             $query->SetSpatialFilter($clsDef->GetDefaultGeometryPropertyName(), $geom, MgFeatureSpatialOperations::EnvelopeIntersects);
                         }
                     }
                     //Ensure valid page number if specified
                     if ($pageSize > 0) {
                         if ($pageNo < 1) {
                             $pageNo = 1;
                         }
                     }
                     $owriter = null;
                     if ($chunk === "0") {
                         $owriter = new MgSlimChunkWriter($this->app);
                     } else {
                         $owriter = new MgHttpChunkWriter();
                     }
                     if ($fmt == "czml") {
                         $result = new MgCzmlResult($featSvc, $fsId, "{$schemaName}:{$className}", $query, $limit, $baseFilter, $vlNode, $owriter);
                         $result->CheckAndSetDownloadHeaders($this->app, $format);
                         if ($transform != null) {
                             $result->SetTransform($transform);
                         }
                         $result->Output($format);
                     } else {
                         $reader = $featSvc->SelectFeatures($fsId, "{$schemaName}:{$className}", $query);
                         if ($pageSize > 0) {
                             $pageReader = new MgPaginatedFeatureReader($reader, $pageSize, $pageNo, $limit);
                             $result = new MgReaderChunkedResult($featSvc, $pageReader, $limit, $owriter, $this->app->localizer);
                         } else {
                             $result = new MgReaderChunkedResult($featSvc, $reader, $limit, $owriter, $this->app->localizer);
                         }
                         $result->CheckAndSetDownloadHeaders($this->app, $format);
                         if ($transform != null) {
                             $result->SetTransform($transform);
                         }
                         if ($fmt === "html") {
                             $result->SetHtmlParams($this->app);
                         }
                         $result->Output($format);
                     }
                 } else {
                     throw new Exception($this->app->localizer->getText("E_LAYER_HAS_INVALID_FEATURE_CLASS", $ldfId->ToString()));
                 }
             } else {
                 throw new Exception($this->app->localizer->getText("E_LAYER_HAS_INVALID_FEATURE_SOURCE", $ldfId->ToString()));
             }
         }
     } catch (MgException $ex) {
         $this->OnException($ex, $mimeType);
     }
 }
Пример #3
0
function ValidateResourceId($proposedResourceId)
{
    $validResourceId = "";
    try {
        $resId = new MgResourceIdentifier($proposedResourceId);
        $validResourceId = $resId->ToString();
    } catch (MgException $ex) {
        $validResourceId = "";
    }
    return $validResourceId;
}
Пример #4
0
function GetLayerTypes($featureService, $layer)
{
    $aLayerTypes = array();
    try {
        $dataSourceId = new MgResourceIdentifier($layer->GetFeatureSourceId());
        if ($dataSourceId->GetResourceType() != MgResourceType::DrawingSource) {
            //get class definition from the featureSource
            $classDefinition = GetFeatureClassDefinition($featureService, $layer, $dataSourceId);
            //MgPropertyDefinition classProps
            $classProps = $classDefinition->GetProperties();
            $aLayerTypes = array();
            for ($i = 0; $i < $classProps->GetCount(); $i++) {
                $prop = $classProps->GetItem($i);
                if ($prop->GetPropertyType() == MgFeaturePropertyType::GeometricProperty) {
                    $featureClass = $prop->GetGeometryTypes();
                    if ($featureClass & MgFeatureGeometricType::Surface) {
                        array_push($aLayerTypes, '2');
                    }
                    if ($featureClass & MgFeatureGeometricType::Curve) {
                        array_push($aLayerTypes, '1');
                    }
                    if ($featureClass & MgFeatureGeometricType::Solid) {
                        array_push($aLayerTypes, '3');
                        //could use surface here for editing purposes?
                    }
                    if ($featureClass & MgFeatureGeometricType::Point) {
                        array_push($aLayerTypes, '0');
                    }
                    break;
                } else {
                    if ($prop->GetPropertyType() == MgFeaturePropertyType::RasterProperty) {
                        array_push($aLayerTypes, '4');
                    }
                }
            }
        } else {
            array_push($aLayerTypes, '5');
        }
    } catch (MgException $e) {
    }
    return $aLayerTypes;
}
Пример #5
0
    // (If the layer does not already exist in the map, it will be visible by default when it is added.
    // But if the user has already run this script, he or she may have set the layer to be invisible.)
    $layerCollection = $map->GetLayers();
    if ($layerCollection->Contains($layerName)) {
        $linesLayer = $layerCollection->GetItem($layerName);
        $linesLayer->SetVisible(true);
    }
    $groupCollection = $map->GetLayerGroups();
    if ($groupCollection->Contains($groupName)) {
        $analysisGroup = $groupCollection->GetItem($groupName);
        $analysisGroup->SetVisible(true);
    }
    //---------------------------------------------------//
    //  Save the map back to the session repository
    $sessionIdName = "Session:{$sessionId}//{$mapName}.Map";
    $sessionResourceID = new MgResourceIdentifier($sessionIdName);
    $sessionResourceID->Validate();
    $map->Save($resourceService, $sessionResourceID);
    //---------------------------------------------------//
} catch (MgException $e) {
    echo "<script language=\"javascript\" type=\"text/javascript\"> \n";
    echo "    alert(\" " . $e->GetExceptionMessage() . " \"); \n";
    echo "</script> \n";
}
///////////////////////////////////////////////////////////////////////////////////
function MakeLine($name, $x0, $y0, $x1, $y1)
{
    $propertyCollection = new MgPropertyCollection();
    $nameProperty = new MgStringProperty("NAME", $name);
    $propertyCollection->Add($nameProperty);
    $wktReaderWriter = new MgWktReaderWriter();
Пример #6
0
 function DownloadMarkup()
 {
     $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
     $featureService = $this->site->CreateService(MgServiceType::FeatureService);
     $markupLayerResId = new MgResourceIdentifier($this->args['MARKUPLAYER']);
     $markupFsId = new MgResourceIdentifier($this->GetResourceIdPrefix() . $markupLayerResId->GetName() . '.FeatureSource');
     $extension = $this->GetFileExtension($markupLayerResId->ToString());
     if (strcmp($extension, ".zip") == 0) {
         $dataList = $resourceService->EnumerateResourceData($markupFsId);
         $doc = DOMDocument::LoadXML($dataList->ToString());
         $dataItems = $doc->getElementsByTagName("Name");
         $tmpFiles = array();
         //Copy out all data files to a temp location
         for ($i = 0; $i < $dataItems->length; $i++) {
             $dataName = $dataItems->item($i)->nodeValue;
             $byteReader = $resourceService->GetResourceData($markupFsId, $dataName);
             //Sink to temp file
             $tmpSink = new MgByteSink($byteReader);
             $fileName = tempnam(sys_get_temp_dir(), $dataName);
             $tmpSink->ToFile($fileName);
             $tmpFiles[$dataName] = $fileName;
         }
         //Zip them up.
         $zipName = $markupLayerResId->GetName() . $extension;
         $zipPath = tempnam(sys_get_temp_dir(), $zipName);
         $zip = new ZipArchive();
         $zip->open($zipPath, ZIPARCHIVE::CREATE);
         foreach ($tmpFiles as $dataName => $filePath) {
             $dataNorm = strtolower($dataName);
             //HACK: There must be some defect in MgFeatureService::CreateFeatureSource() for SHP
             //files or the FDO provider, because even if we plug in a coord sys WKT when we create
             //it, we get a blank prj file (both Windows/Linux). Re-uploading this same zip file back into
             //the widget causes problems in Linux (markup features not rendered) because of the blank prj.
             //
             //So that's the problem. Here's the workaround: If we find a blank prj file as we're assembling
             //the zip file for download, pump our current Map's WKT into the prj file before packaging it up
             //
             //That's what we were already doing when we called MgFeatureService::CreateFeatureSource(), but it
             //or the provider didn't like it.
             if (substr($dataNorm, strlen($dataNorm) - strlen("prj")) == "prj") {
                 $content = file_get_contents($filePath);
                 if (strlen($content) == 0) {
                     $map = new MgMap();
                     $map->Open($resourceService, $this->args['MAPNAME']);
                     $content = $map->GetMapSRS();
                     file_put_contents($filePath, $content);
                 }
             }
             $zip->addFile($filePath, $dataName);
         }
         $zip->close();
         //Serve it up for download
         $bs = new MgByteSource($zipPath);
         $br = $bs->GetReader();
         $len = $br->GetLength();
         $outputBuffer = '';
         $buffer = '';
         while ($br->Read($buffer, 50000) != 0) {
             $outputBuffer .= $buffer;
         }
         header("Content-Type: application/octet-stream");
         header("Content-Disposition: attachment; filename={$zipName}");
         header("Content-Length: " . strlen($outputBuffer));
         echo $outputBuffer;
         //Let's be nice and clean up after ourselves
         unlink($zipPath);
         foreach ($tmpFiles as $dataName => $filePath) {
             unlink($filePath);
         }
     } else {
         //Single file, make things easier!
         $dataName = $markupLayerResId->GetName() . $extension;
         $byteReader = $resourceService->GetResourceData($markupFsId, $dataName);
         $len = $byteReader->GetLength();
         $outputBuffer = '';
         $buffer = '';
         while ($byteReader->Read($buffer, 50000) != 0) {
             $outputBuffer .= $buffer;
         }
         header("Content-Type: " . $byteReader->GetMimeType());
         header("Content-Disposition: attachment; filename={$dataName}");
         header("Content-Length: " . strlen($outputBuffer));
         echo $outputBuffer;
     }
 }
Пример #7
0
function BuildViewer($forDwf = true)
{
    global $debug, $webLayoutDefinition, $cmds, $locale;
    global $sessionId, $username, $password, $orgSessionId;
    global $mapName;
    global $product;
    SetLocalizedFilesPath(GetLocalizationPath());
    try {
        // Initialize web tier with the site configuration file.
        InitializeWebTier();
        //fetch the parameters for this request
        //
        GetRequestParameters();
        //Open a connection with the server
        //
        $createSession = true;
        $cred = new MgUserInformation();
        if ($sessionId != '') {
            $cred->SetMgSessionId($sessionId);
            $createSession = false;
        } else {
            if ($username != '') {
                $cred->SetMgUsernamePassword($username, $password);
            } else {
                requestAuthentication();
                return;
            }
        }
        $site = new MgSiteConnection();
        $cred->SetLocale($locale);
        $cred->SetClientIp(GetClientIp());
        $cred->SetClientAgent(GetClientAgent());
        $site->Open($cred);
        if ($createSession) {
            $site1 = $site->GetSite();
            $sessionId = $site1->CreateSession();
            if ($forDwf == false) {
                $orgSessionId = $sessionId;
            }
        }
        //Get a MgWebLayout object initialized with the specified web layout definition
        //
        $webLayout = null;
        try {
            $resourceSrvc = $site->CreateService(MgServiceType::ResourceService);
            $webLayoutId = new MgResourceIdentifier($webLayoutDefinition);
            $webLayout = new MgWebLayout($resourceSrvc, $webLayoutId);
        } catch (MgUnauthorizedAccessException $e) {
            requestAuthentication();
            return;
        } catch (MgException $e) {
            $shortError = $e->GetExceptionMessage();
            $longErrorMsg = EscapeForHtml($e->GetDetails());
            header("HTTP/1.1 559 ");
            header('Content-Type: text/html; charset=utf-8');
            header("Status: 559 {$shortError}");
            echo "<html>\n<body>\n";
            echo $longErrorMsg;
            echo "</body>\n</html>\n";
            return;
        }
        //calculate the size of the variable elements of the viewer
        //
        $toolBar = $webLayout->GetToolBar();
        $statusBar = $webLayout->GetStatusBar();
        $taskPane = $webLayout->GetTaskPane();
        $infoPane = $webLayout->GetInformationPane();
        $taskBar = $taskPane->GetTaskBar();
        $mapDef = $webLayout->GetMapDefinition();
        $startupScriptCode = $webLayout->GetStartupScript();
        $selectionColor = $webLayout->GetSelectionColor();
        $mapImgFormat = $webLayout->GetMapImageFormat();
        $selImgFormat = $webLayout->GetSelectionImageFormat();
        $pointBuffer = $webLayout->GetPointSelectionBuffer();
        $showTaskPane = $taskPane->IsVisible();
        $showTaskBar = $taskBar->IsVisible();
        $showStatusbar = $statusBar->IsVisible();
        $showToolbar = $toolBar->IsVisible();
        $taskPaneWidth = $taskPane->GetWidth();
        $toolbarHeight = 30;
        $taskbarHeight = 30;
        $statusbarHeight = 26;
        $taskWidth = $showTaskPane ? $taskPaneWidth : 0;
        $toolbarHeight = $showToolbar ? $toolbarHeight : 0;
        $taskbarHeight = $showTaskBar ? $taskbarHeight : 0;
        $statusbarHeight = $showStatusbar ? $statusbarHeight : 0;
        //Encode the initial url so that it does not trip any sub-frames (especially if this url has parameters)
        $taskPaneUrl = urlencode($taskPane->GetInitialTaskUrl());
        $vpath = GetSurroundVirtualPath();
        $defHome = false;
        if ($taskPaneUrl == "") {
            $taskPaneUrl = "gettingstarted.php";
            $defHome = true;
        }
        $mapDefinitionUrl = urlencode($mapDef);
        // NOTE:
        //
        // We don't open a MgMap because it is being created by mapframe.php that is also probably running
        // as this script is running. However the naming convention is fixed enough that we can figure out
        // what to pass to the Task Pane
        $resId = new MgResourceIdentifier($mapDef);
        $mapName = $resId->GetName();
        $title = $webLayout->GetTitle();
        $enablePingServer = $webLayout->GetEnablePingServer();
        $showLegend = $infoPane->IsLegendBandVisible();
        $showProperties = $infoPane->IsPropertiesBandVisible();
        if ($showLegend || $showProperties) {
            if ($infoPane->IsVisible()) {
                $infoWidth = $infoPane->GetWidth();
                if ($infoWidth < 5) {
                    $infoWidth = 5;
                }
                //ensure visible
            } else {
                $showProperties = $showLegend = false;
                $infoWidth = 0;
            }
        } else {
            $infoWidth = 0;
        }
        //calculate the url of the inner pages
        //
        $srcToolbar = $showToolbar ? 'src="' . $vpath . 'toolbar.php?LOCALE=' . $locale . '"' : '';
        $srcStatusbar = $showStatusbar ? 'src="' . $vpath . 'statusbar.php?LOCALE=' . $locale . '"' : "";
        $srcTaskFrame = $showTaskPane ? 'src="' . $vpath . 'taskframe.php?MAPNAME=' . $mapName . '&WEBLAYOUT=' . urlencode($webLayoutDefinition) . '&DWF=' . ($forDwf ? "1" : "0") . '&SESSION=' . ($sessionId != "" ? $sessionId : "") . '&LOCALE=' . $locale . '"' : '';
        $srcTaskBar = 'src="' . $vpath . 'taskbar.php?LOCALE=' . $locale . '"';
        //view center
        //
        $ptCenter = $webLayout->GetCenter();
        if ($ptCenter == null) {
            $center = "null";
        } else {
            $coord = $ptCenter->GetCoordinate();
            $center = sprintf("new Point(%f, %f)", $coord->GetX(), $coord->GetY());
        }
        //Process commands and declare command objects
        //
        $commands = $webLayout->GetCommands();
        $cmdObjects = "";
        $cmdObject = "";
        $navCmdIndex = 0;
        $searchCmdIndex = 0;
        $measureCmdIndex = 0;
        $printCmdIndex = 0;
        $scriptCmdIndex = 0;
        $userCode = "";
        $userCodeCalls = "\nswitch(funcIndex)\n{\n";
        $selAwareCmdCount = 0;
        $selAwareCmds = "";
        for ($i = 0; $i < $commands->GetCount(); $i++) {
            $cmd = $commands->GetItem($i);
            if (!$cmd->IsUsed()) {
                continue;
            }
            $tgtViewer = $cmd->GetTargetViewerType();
            if (($tgtViewer == MgWebTargetViewerType::Dwf) != ($forDwf == true) && $tgtViewer != MgWebTargetViewerType::All) {
                continue;
            }
            $name = $cmd->GetName();
            $action = $cmd->GetAction();
            if ($action == MgWebActions::Search) {
                $cols = "var resCols" . $searchCmdIndex . " = new Array();\n";
                if ($cmd->GetResultColumnCount() > 0) {
                    for ($j = 0; $j < $cmd->GetResultColumnCount(); $j++) {
                        $col = sprintf("resCols%d[%d] = new ResultColumn(\"%s\", \"%s\");\n", $searchCmdIndex, $j, StrEscape($cmd->GetColumnDisplayNameAt($j)), StrEscape($cmd->GetColumnPropertyNameAt($j)));
                        $cols = $cols . $col;
                    }
                }
                $cmdObjects = $cmdObjects . $cols;
                // declare a new search command object
                $cmdObject = sprintf("commands[%d] = new SearchCommand(\"%s\", \"%s\", %d, \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", resCols%d, \"%s\", %d, %d, \"%s\");\n", $i, StrEscape($name), StrEscape($cmd->GetLabel()), $cmd->GetAction(), $cmd->GetIconUrl(), $cmd->GetDisabledIconUrl(), StrEscape($cmd->GetTooltip()), StrEscape($cmd->GetDescription()), $cmd->GetLayer(), StrEscape($cmd->GetPrompt()), $searchCmdIndex, StrEscape($cmd->GetFilter()), $cmd->GetMatchLimit(), $cmd->GetTarget(), $cmd->GetTargetName());
                $searchCmdIndex++;
            } else {
                if ($action == MgWebActions::InvokeUrl) {
                    // create the parameter objects
                    $params = "var navParams" . $navCmdIndex . " = new Array();\n";
                    $layers = "var layers" . $navCmdIndex . " = new Array();\n";
                    if ($cmd->GetParameterCount() > 0) {
                        for ($j = 0; $j < $cmd->GetParameterCount(); $j++) {
                            $param = sprintf("navParams%d[%d] = new NavParam(\"%s\", \"%s\");\n", $navCmdIndex, $j, $cmd->GetParameterNameAt($j), $cmd->GetParameterValueAt($j));
                            $params = $params . $param;
                        }
                    }
                    for ($j = 0; $j < $cmd->GetLayerCount(); $j++) {
                        $layer = sprintf("layers%d[%d] = \"%s\";\n", $navCmdIndex, $j, $cmd->GetLayerNameAt($j));
                        $layers = $layers . $layer;
                    }
                    $cmdObjects = $cmdObjects . $params . $layers;
                    if ($cmd->DisabledIfSelectionEmpty() || $cmd->GetLayerCount() > 0) {
                        $selAwareCmds = $selAwareCmds . sprintf("selectionAwareCmds[%d] = %d;\n", $selAwareCmdCount, $i);
                        $selAwareCmdCount++;
                    }
                    // declare a new invokeurl command object
                    $cmdObject = sprintf("commands[%d] = new InvokeUrlCommand(\"%s\", %d, \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", navParams%d, %s, layers%d, %d, \"%s\");\n", $i, StrEscape($name), $cmd->GetAction(), $cmd->GetIconUrl(), $cmd->GetDisabledIconUrl(), StrEscape($cmd->GetTooltip()), StrEscape($cmd->GetDescription()), $cmd->GetUrl(), $navCmdIndex, $cmd->DisabledIfSelectionEmpty() ? "true" : "false", $navCmdIndex, $cmd->GetTarget(), $cmd->GetTargetName());
                    $navCmdIndex++;
                } else {
                    if ($action == MgWebActions::Buffer || $action == MgWebActions::SelectWithin || $action == MgWebActions::Measure || $action == MgWebActions::ViewOptions || $action == MgWebActions::GetPrintablePage) {
                        if ($action == MgWebActions::Measure) {
                            if ($measureCmdIndex != 0) {
                                throw new Exception(GetLocalizedString("ALREADYINMEASURE", $locale));
                            }
                            $measureCmdIndex = $i;
                        } else {
                            if ($action == MgWebActions::SelectWithin) {
                                $selAwareCmds = $selAwareCmds . sprintf("selectionAwareCmds[%d] = %d;\n", $selAwareCmdCount, $i);
                                $selAwareCmdCount++;
                            }
                        }
                        // declare a new ui target command object
                        $cmdObject = sprintf("commands[%d] = new UiTargetCommand(\"%s\", %d, \"%s\", \"%s\", \"%s\", \"%s\", %d, \"%s\");\n", $i, StrEscape($name), $cmd->GetAction(), $cmd->GetIconUrl(), $cmd->GetDisabledIconUrl(), StrEscape($cmd->GetTooltip()), StrEscape($cmd->GetDescription()), $cmd->GetTarget(), $cmd->GetTargetName());
                    } else {
                        if ($action == MgWebActions::Help) {
                            // declare a new help  command object
                            $cmdObject = sprintf("commands[%d] = new HelpCommand(\"%s\", %d, \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", %d, \"%s\");\n", $i, StrEscape($name), $cmd->GetAction(), $cmd->GetIconUrl(), $cmd->GetDisabledIconUrl(), StrEscape($cmd->GetTooltip()), StrEscape($cmd->GetDescription()), $cmd->GetUrl(), $cmd->GetTarget(), $cmd->GetTargetName());
                        } else {
                            if ($action == MgWebActions::PrintMap) {
                                // declare the print layouts
                                $layouts = "var layouts" . $printCmdIndex . " = new Array();\n";
                                for ($j = 0; $j < $cmd->GetPrintLayoutCount(); $j++) {
                                    $layout = "";
                                    $layout = sprintf("layouts%d[%d] = \"%s\";\n", $printCmdIndex, $j, $cmd->GetPrintLayoutAt($j));
                                    $layouts = $layouts . $layout;
                                }
                                $cmdObjects = $cmdObjects . $layouts;
                                // declare a new print command object
                                $cmdObject = sprintf("commands[%d] = new PrintCommand(\"%s\", %d, \"%s\", \"%s\", \"%s\", \"%s\", layouts%d);\n", $i, StrEscape($name), $cmd->GetAction(), $cmd->GetIconUrl(), $cmd->GetDisabledIconUrl(), StrEscape($cmd->GetTooltip()), StrEscape($cmd->GetDescription()), $printCmdIndex);
                                $printCmdIndex++;
                            } else {
                                if ($action == MgWebActions::InvokeScript) {
                                    // declare a new basic command object
                                    $cmdObject = sprintf("commands[%d] = new InvokeScriptCommand(\"%s\", %d, \"%s\", \"%s\", \"%s\", \"%s\", %d);\n", $i, StrEscape($name), $cmd->GetAction(), $cmd->GetIconUrl(), $cmd->GetDisabledIconUrl(), StrEscape($cmd->GetTooltip()), StrEscape($cmd->GetDescription()), $scriptCmdIndex);
                                    $userCode = $userCode . "\nfunction UserFunc" . $scriptCmdIndex . "()\n{\n" . $cmd->GetScriptCode() . "\n}\n";
                                    $userCodeCalls = $userCodeCalls . sprintf("case %d: UserFunc%d(); break;\n", $scriptCmdIndex, $scriptCmdIndex);
                                    $scriptCmdIndex++;
                                } else {
                                    // declare a new basic command object
                                    $cmdObject = sprintf("commands[%d] = new BasicCommand(\"%s\", %d, \"%s\", \"%s\", \"%s\", \"%s\");\n", $i, $name, $cmd->GetAction(), $cmd->GetIconUrl(), $cmd->GetDisabledIconUrl(), StrEscape($cmd->GetTooltip()), StrEscape($cmd->GetDescription()));
                                }
                            }
                        }
                    }
                }
            }
            $cmdObjects = $cmdObjects . $cmdObject;
            $cmds[$name] = $i;
        }
        $userCodeCalls = $userCodeCalls . "\n}\n";
        //Declare toolbar items
        //
        $toolbarDef = DeclareUiItems($toolBar->GetWidgets(), "toolbarItems");
        //Declare task items
        $taskListDef = DeclareUiItems($taskBar->GetTaskList(), "taskItems");
        //Declare context menu items
        $ctxMenu = $webLayout->GetContextMenu();
        if ($ctxMenu->IsVisible()) {
            $ctxMenuDef = DeclareUiItems($ctxMenu, "ctxMenuItems");
        } else {
            $ctxMenuDef = "";
        }
        //task items texts
        //
        $taskItemTexts = "";
        $taskButtons = $taskBar->GetTaskButtons();
        for ($i = 0; $i < 4; $i++) {
            $btn = $taskButtons->GetWidget($i);
            if ($i > 0) {
                $taskItemTexts = $taskItemTexts . ",";
            }
            $taskItemTexts = $taskItemTexts . '"' . StrEscape($btn->GetName()) . '",' . '"' . StrEscape($btn->GetTooltip()) . '",' . '"' . StrEscape($btn->GetDescription()) . '",' . '"' . StrEscape($btn->GetIconUrl()) . '",' . '"' . StrEscape($btn->GetDisabledIconUrl()) . '"';
        }
        //transmit the session to the map pane if one was specified to this request
        if ($orgSessionId != "") {
            $sessionParam = "&SESSION=" . $orgSessionId;
        } else {
            $sessionParam = "";
        }
        //load the frameset template and format it
        $frameset = "";
        $viewerType = $forDwf ? "DWF" : "HTML";
        if ($showTaskBar) {
            $frameSetTempl = file_get_contents("../viewerfiles/framesettaskbar.templ");
            $frameset = sprintf($frameSetTempl, $statusbarHeight, $taskWidth, $toolbarHeight, $srcToolbar, $vpath . "mapframe.php", $mapDefinitionUrl, $viewerType, $showLegend ? 1 : 0, $showProperties ? 1 : 0, $infoWidth, $locale, $webLayout->GetHyperlinkTarget(), $webLayout->GetHyperlinkTargetFrame(), $webLayout->IsZoomControlVisible() ? 1 : 0, $selectionColor, $mapImgFormat, $selImgFormat, $pointBuffer, $sessionParam, $vpath . "formframe.php", $taskbarHeight + 1, $srcTaskBar, $srcTaskFrame, $srcStatusbar);
        } else {
            $frameSetTempl = file_get_contents("../viewerfiles/framesetnotaskbar.templ");
            $frameset = sprintf($frameSetTempl, $toolbarHeight, $statusbarHeight, $srcToolbar, $taskWidth, $vpath . "mapframe.php", $mapDefinitionUrl, $viewerType, $showLegend ? 1 : 0, $showProperties ? 1 : 0, $infoWidth, $locale, $webLayout->GetHyperlinkTarget(), $webLayout->GetHyperlinkTargetFrame(), $webLayout->IsZoomControlVisible() ? 1 : 0, $selectionColor, $mapImgFormat, $selImgFormat, $pointBuffer, $sessionParam, $srcTaskFrame, $vpath . "formframe.php", $srcStatusbar);
        }
        $homePageUrl = urldecode($taskPaneUrl);
        if (strlen($homePageUrl) < 8 || strncasecmp($homePageUrl, "http://", 7) != 0) {
            $homePageUrl = $vpath . $homePageUrl;
        }
        //load the HTML template and format it
        //
        $templ = Localize(file_get_contents("../viewerfiles/mainframe.templ"), $locale, GetClientOS());
        print sprintf($templ, $title, GetRootVirtualFolder() . "/mapagent/mapagent.fcgi", $enablePingServer ? 1 : 0, $site->GetSite()->GetSessionTimeout(), $locale, $showToolbar ? 1 : 0, $showStatusbar ? 1 : 0, $showTaskPane ? 1 : 0, $showTaskPane ? 0 : ($showTaskBar ? 1 : 0), $homePageUrl, $defHome ? "1" : "0", $webLayoutDefinition, $mapDef, $taskWidth, $center, $webLayout->GetScale(), StrEscape($title), $forDwf ? "1" : "0", $cmdObjects, $toolbarDef, $taskListDef, $ctxMenuDef, $userCode, $taskItemTexts, $selAwareCmds, $startupScriptCode, $vpath . "quickplotpanel.php", $vpath . "measureui.php", $vpath . "searchprompt.php", $vpath . "bufferui.php", $vpath . "selectwithinui.php", $userCodeCalls, $vpath . "viewoptions.php", $frameset);
    } catch (MgUserNotFoundException $e) {
        requestAuthentication();
    } catch (MgAuthenticationFailedException $e) {
        requestAuthentication();
    } catch (MgException $e) {
        // This should be a 500 error of some sort, but
        // in order to give a nice custom error message, it looks as
        // if we shortcut things by using a 200 status.
        $shortError = $e->GetExceptionMessage();
        $longErrorMsg = EscapeForHtml($e->GetDetails());
        header("HTTP/1.1 200 ");
        header('Content-Type: text/html; charset=utf-8');
        header("Status: 200 {$shortError}");
        echo "<html>\n<body>\n";
        echo $longErrorMsg;
        echo "</body>\n</html>\n";
    } catch (Exception $ne) {
        $errorMsg = EscapeForHtml($ne->GetMessage());
        echo $errorMsg;
    }
}
Пример #8
0
 function GetMarkupName()
 {
     $resId = new MgResourceIdentifier($this->GetMarkupLayer());
     return $resId->GetName();
 }
 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);
         }
     }
 }
Пример #10
0
include '../../../common/php/Utilities.php';
//Get the folder to search within
$root = isset($_REQUEST['folder']) ? $_REQUEST['folder'] : 'Library://';
$rootId = new MgResourceIdentifier($root);
//Enumerate elements of type MapDefinition
$maps = $resourceService->EnumerateResources($rootId, -1, 'MapDefinition');
//make a list of maps to query for names
$mapListXml = DOMDocument::loadXML(ByteReaderToString($maps));
//$aMapAssoc = Array();
$aMapIds = $mapListXml->getElementsByTagName('ResourceId');
//iterate over mapIds to retrieve names
//output map list as JSON
$result = NULL;
$result->maps = array();
for ($i = 0; $i < $aMapIds->length; $i++) {
    $mapId = new MgResourceIdentifier($aMapIds->item($i)->nodeValue);
    $md = NULL;
    $md->path = $aMapIds->item($i)->nodeValue;
    $md->name = $mapId->GetName();
    array_push($result->maps, $md);
}
header('Content-type: application/json');
echo var2json($result);
exit;
function ByteReaderToString($byteReader)
{
    $buffer = '';
    do {
        $data = str_pad("", 50000, "");
        $len = $byteReader->Read($data, 50000);
        if ($len > 0) {
Пример #11
0
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */
/*****************************************************************************
 * Purpose: get map initial information
 *****************************************************************************/
include 'Common.php';
include 'Utilities.php';
try {
    $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();
Пример #12
0
try {
    InitializeWebTier();
    // create the map instance and store it with the session
    //
    $userInfo = new MgUserInformation();
    $userInfo->SetMgSessionId($sessionId);
    $userInfo->SetClientIp(GetClientIp());
    $userInfo->SetClientAgent(GetClientAgent());
    $site = new MgSiteConnection();
    $site->Open($userInfo);
    $tileSrvc = $site->CreateService(MgServiceType::TileService);
    $tileSizeX = $tileSrvc->GetDefaultTileSizeX();
    $tileSizeY = $tileSrvc->GetDefaultTileSizeY();
    $resourceSrvc = $site->CreateService(MgServiceType::ResourceService);
    $map = new MgMap();
    $resId = new MgResourceIdentifier($mapDefinition);
    $mapName = $resId->GetName();
    $map->Create($resourceSrvc, $resId, $mapName);
    //create an empty selection object and store it in the session repository
    $sel = new MgSelection($map);
    $sel->Save($resourceSrvc, $mapName);
    //get the map extent and calculate the scale factor
    //
    $mapExtent = $map->GetMapExtent();
    $srs = $map->GetMapSRS();
    if ($srs != "") {
        $csFactory = new MgCoordinateSystemFactory();
        $cs = $csFactory->Create($srs);
        $metersPerUnit = $cs->ConvertCoordinateSystemUnitsToMeters(1.0);
        $unitsType = $cs->GetUnits();
    } else {
Пример #13
0
function GetLayerTypesFromResourceContent($layer, $xmldoc = NULL)
{
    $aLayerTypes = array();
    global $resourceService;
    try {
        $dataSourceId = new MgResourceIdentifier($layer->GetFeatureSourceId());
        if ($dataSourceId->GetResourceType() == MgResourceType::DrawingSource) {
            array_push($aLayerTypes, '5');
        } else {
            if ($xmldoc == NULL) {
                $resID = $layer->GetLayerDefinition();
                $layerContent = $resourceService->GetResourceContent($resID);
                $xmldoc = DOMDocument::loadXML(ByteReaderToString($layerContent));
            }
            $gridlayers = $xmldoc->getElementsByTagName('GridLayerDefinition');
            if ($gridlayers->length > 0) {
                array_push($aLayerTypes, '4');
            }
            // raster
            $scaleRanges = $xmldoc->getElementsByTagName('VectorScaleRange');
            $typeStyles = array("PointTypeStyle", "LineTypeStyle", "AreaTypeStyle", "CompositeTypeStyle");
            for ($sc = 0; $sc < $scaleRanges->length; $sc++) {
                $scaleRange = $scaleRanges->item($sc);
                for ($ts = 0, $count = count($typeStyles); $ts < $count; $ts++) {
                    $typeStyle = $scaleRange->getElementsByTagName($typeStyles[$ts]);
                    if ($typeStyle->length > 0) {
                        array_push($aLayerTypes, $ts);
                    }
                }
            }
        }
    } catch (MgException $e) {
        echo "ERROR: " . $e->GetExceptionMessage() . "\n";
        echo $e->GetDetails() . "\n";
        echo $e->GetStackTrace() . "\n";
    }
    $aLayerTypes = array_unique($aLayerTypes);
    return $aLayerTypes;
}
Пример #14
0
/*****************************************************************************
 * Purpose: a list of map definitions within a given repository folder
 *****************************************************************************/
include "Common.php";
//Get the folder to search within
$root = isset($_REQUEST['folder']) ? $_REQUEST['folder'] : 'Library://';
$rootId = new MgResourceIdentifier($root);
//Enumerate elements of type MapDefinition
$maps = $resourceService->EnumerateResources($rootId, -1, 'MapDefinition');
//make a list of maps to query for names
$mapListXml = DOMDocument::loadXML(ByteReaderToString($maps));
//$aMapAssoc = Array();
$aMapIds = $mapListXml->getElementsByTagName('ResourceId');
//iterate over mapIds to retrieve names
for ($i = 0; $i < $aMapIds->length; $i++) {
    $mapId = new MgResourceIdentifier($aMapIds->item($i)->nodeValue);
    $aPair['id'] = $aMapIds->item($i)->nodeValue;
    $aPair['name'] = $mapId->GetName();
    //Alternative - get the map description from the MapDefinition
    //$map = $resourceService->GetResourceContent($mapId);
    //$mapXml = DOMDocument::loadXML(ByteReaderToString($map));
    //$name = $mapXml->getElementsByTagName('Name')->item(0)->nodeValue;
    //$aPair['name'] = $name;
    $aMapAssoc[] = $aPair;
}
//output map list as xml
header('content-type: text/xml');
echo "<maps>";
for ($i = 0; $i < count($aMapAssoc); $i++) {
    echo "<MapDefinition>";
    echo "<ResourceId>" . $aMapAssoc[$i]['id'] . "</ResourceId>";
Пример #15
0
     $args["LABELFONTSIZE"] = DefaultStyle::LABEL_FONT_SIZE;
     
     //Omission is considered false, which is the default. If you ever change
     //the default style values, uncomment the matching "true" values
     //$args["LABELBOLD"] = DefaultStyle::LABEL_BOLD;
     //$args["LABELITALIC"] = DefaultStyle::LABEL_ITALIC;
     //$args["LABELUNDERLINE"] = DefaultStyle::LABEL_UNDERLINE;
     
     $args["LABELFORECOLOR"] = DefaultStyle::LABEL_FORE_COLOR;
     $args["LABELBACKCOLOR"] = DefaultStyle::LABEL_BACK_COLOR;
     $args["LABELBACKSTYLE"] = DefaultStyle::LABEL_BACK_STYLE;
     
     $markupManager = new MarkupManager($args);
     $layerDef = $markupManager->CreateMarkup();
     
     $resId = new MgResourceIdentifier($layerDef);
     $layerName = $resId->GetName();
     $markupManager->SetArgument("MARKUPLAYER", $layerDef);
     $markupManager->OpenMarkup();
     $responseJson = "{ success: true, refreshMap: true, layerDefinition: '$layerDef', layerName: '$layerName' }";
 }
 catch (MgException $mge)
 {
     $errorMsg = $mge->GetExceptionMessage();
     $errorDetail = $mge->GetDetails();
     $stackTrace = $mge->GetStackTrace();
     $responseJson = "{success: false, refreshMap: false, message:'$errorMsg\nDetail: $errorDetail\nStack Trace: $stackTrace'}";
 }
 catch (Exception $e)
 {
     $errorMsg = $e->GetMessage();
Пример #16
0
 public function CreateMap($resId)
 {
     $mdfIdStr = $this->app->request->params("mapdefinition");
     if ($mdfIdStr == null) {
         $this->BadRequest($this->app->localizer->getText("E_MISSING_REQUIRED_PARAMETER", "mapdefinition"), $this->GetMimeTypeForFormat($format));
     } else {
         $mdfId = new MgResourceIdentifier($mdfIdStr);
         if ($mdfId->GetResourceType() != MgResourceType::MapDefinition) {
             $this->BadRequest($this->app->localizer->getText("E_INVALID_MAP_DEFINITION_PARAMETER", "mapdefinition"), $this->GetMimeTypeForFormat($format));
         } else {
             //$this->EnsureAuthenticationForSite();
             $userInfo = new MgUserInformation($resId->GetRepositoryName());
             $siteConn = new MgSiteConnection();
             $siteConn->Open($userInfo);
             $resSvc = $siteConn->CreateService(MgServiceType::ResourceService);
             $map = new MgMap();
             $map->Create($resSvc, $mdfId, $resId->GetName());
             $sel = new MgSelection($map);
             $sel->Save($resSvc, $resId->GetName());
             $map->Save($resSvc, $resId);
             $this->app->response->setStatus(201);
             $this->app->response->setBody(MgUtils::GetNamedRoute($this->app, "/session", "session_resource_id", array("sessionId" => $resId->GetRepositoryName(), "resName" => $resId->GetName() . "." . $resId->GetResourceType())));
         }
     }
 }