Esempio n. 1
0
    // 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();
    $agfReaderWriter = new MgAgfReaderWriter();
Esempio n. 2
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) {
    echo "ERROR: " . $e->GetExceptionMessage() . "\n";
Esempio n. 3
0
function CreateSessionResourceId($originalResourceId, $suffix)
{
    $newResourceID = new MgResourceIdentifier('Library://');
    $newResourceID->SetRepositoryType("Session");
    $newResourceID->SetRepositoryName($GLOBALS['sessionID']);
    $newResourceID->SetPath($originalResourceId->GetPath());
    $newResourceID->SetName($originalResourceId->GetName() . $suffix);
    $newResourceID->SetResourceType($originalResourceId->GetResourceType());
    //TODO: trap errors
    try {
        $newResourceID->Validate();
    } catch (MgException $e) {
        echo "ERROR: " . $e->GetExceptionMessage() . "n";
        echo $e->GetDetails() . "n";
        echo $e->GetStackTrace() . "n";
    }
    return $newResourceID;
}