Example #1
0
function GenerateLegend()
{
    global $sessionID, $mapName, $width, $height, $offsetX, $offsetY, $xPad, $yPad, $iconWidth, $iconHeight, $xIndent, $groupIcon, $fontIndex, $textColor;
    $userInfo = new MgUserInformation($sessionID);
    $siteConnection = new MgSiteConnection();
    $siteConnection->Open($userInfo);
    $resourceService = $siteConnection->CreateService(MgServiceType::ResourceService);
    $mappingService = $siteConnection->CreateService(MgServiceType::MappingService);
    $map = new MgMap();
    $map->Open($resourceService, $mapName);
    $scale = $map->GetViewScale();
    $image = imagecreatetruecolor($width, $height);
    $white = imagecolorallocate($image, 255, 255, 255);
    $textColor = imagecolorallocate($image, 0, 0, 0);
    imagefilledrectangle($image, 0, 0, $width, $height, $white);
    ProcessGroupsForLegend($mappingService, $resourceService, $map, $scale, NULL, $image);
    header("Content-type: image/png");
    imagepng($image);
    //Uncomment to see what PHP-isms get spewed out that may be tripping up rendering
    //Also replace instances of "////print_r" with "//print_r" to insta-uncomment all debugging calls
    /*
    ob_start();
    imagepng($image);
    $im = base64_encode(ob_get_contents());
    ob_end_clean();
    header("Content-type: text/html", true);
    echo "<img src='data:image/png;base64,".$im."' alt='legend image'></img>";
    */
    imagecolordeallocate($image, $white);
    imagecolordeallocate($image, $textColor);
    imagedestroy($image);
}
Example #2
0
    function GetMapLayerNames()
    {
        $layerNames = array();

        $resourceService = $this->site->CreateService(MgServiceType::ResourceService);

        $map = new MgMap($this->site);
        $map->Open($this->args['MAPNAME']);
        $layers = $map->GetLayers();

        for ($i = 0; $i < $layers->GetCount(); $i++)
        {
            $layer = $layers->GetItem($i);

            //TODO: Exclude Raster and Drawing Layers???

            if((substr($layer->GetName(), 0, 1) != "_") && (substr(strtoupper($layer->GetFeatureSourceId()), 0, 7) != "SESSION") && ($layer->IsVisible()) && $layer->GetSelectable())
            {
                $layerNames[$layer->GetName()] = $layer->GetLegendLabel();
            }
        }
        asort($layerNames);

        return $layerNames;
    }
Example #3
0
function GenerateMap($size)
{
    global $sessionID, $mapName, $captureBox, $printSize, $normalizedCapture, $rotation, $scaleDenominator, $printDpi, $drawNorthArrow;
    $userInfo = new MgUserInformation($sessionID);
    $siteConnection = new MgSiteConnection();
    $siteConnection->Open($userInfo);
    $resourceService = $siteConnection->CreateService(MgServiceType::ResourceService);
    $renderingService = $siteConnection->CreateService(MgServiceType::RenderingService);
    $map = new MgMap();
    $map->Open($resourceService, $mapName);
    $selection = new MgSelection($map);
    // Calculate the generated picture size
    $envelope = $captureBox->Envelope();
    $normalizedE = $normalizedCapture->Envelope();
    $size1 = new Size($envelope->getWidth(), $envelope->getHeight());
    $size2 = new Size($normalizedE->getWidth(), $normalizedE->getHeight());
    $toSize = new Size($size1->width / $size2->width * $size->width, $size1->height / $size2->height * $size->height);
    $center = $captureBox->GetCentroid()->GetCoordinate();
    $map->SetDisplayDpi($printDpi);
    $colorString = $map->GetBackgroundColor();
    // The returned color string is in AARRGGBB format. But the constructor of MgColor needs a string in RRGGBBAA format
    $colorString = substr($colorString, 2, 6) . substr($colorString, 0, 2);
    $color = new MgColor($colorString);
    $mgReader = $renderingService->RenderMap($map, $selection, $center, $scaleDenominator, $toSize->width, $toSize->height, $color, "PNG", false);
    $tempImage = sys_get_temp_dir() . DIRECTORY_SEPARATOR . "mgo" . uniqid();
    $mgReader->ToFile($tempImage);
    $image = imagecreatefrompng($tempImage);
    unlink($tempImage);
    // Rotate the picture back to be normalized
    $normalizedImg = imagerotate($image, -$rotation, 0);
    // Free the original image
    imagedestroy($image);
    // Crop the normalized image
    $croppedImg = imagecreatetruecolor($size->width, $size->height);
    imagecopy($croppedImg, $normalizedImg, 0, 0, (imagesx($normalizedImg) - $size->width) / 2, (imagesy($normalizedImg) - $size->height) / 2, $size->width, $size->height);
    // Free the normalized image
    imagedestroy($normalizedImg);
    if ($drawNorthArrow) {
        // Draw the north arrow on the map
        DrawNorthArrow($croppedImg);
    }
    header("Content-type: image/png");
    imagepng($croppedImg);
    //Uncomment to see what PHP-isms get spewed out that may be tripping up rendering
    //Also replace instances of "////print_r" with "//print_r" to insta-uncomment all debugging calls
    /*
    ob_start();
    imagepng($croppedImg);
    $im = base64_encode(ob_get_contents());
    ob_end_clean();
    header("Content-type: text/html", true);
    echo "<img src='data:image/png;base64,".$im."' alt='legend image'></img>";
    */
    imagedestroy($croppedImg);
}
function GenerateMap($size)
{
    global $sessionID, $mapName, $captureBox, $printSize, $normalizedCapture, $rotation, $scaleDenominator, $printDpi;
    InitializeWebTier();
    $userInfo = new MgUserInformation($sessionID);
    $siteConnection = new MgSiteConnection();
    $siteConnection->Open($userInfo);
    $resourceService = $siteConnection->CreateService(MgServiceType::ResourceService);
    $renderingService = $siteConnection->CreateService(MgServiceType::RenderingService);
    $map = new MgMap();
    $map->Open($resourceService, $mapName);
    $selection = new MgSelection($map);
    // Calculate the generated picture size
    $envelope = $captureBox->Envelope();
    $normalizedE = $normalizedCapture->Envelope();
    $size1 = new Size($envelope->getWidth(), $envelope->getHeight());
    $size2 = new Size($normalizedE->getWidth(), $normalizedE->getHeight());
    $toSize = new Size($size1->width / $size2->width * $size->width, $size1->height / $size2->height * $size->height);
    $center = $captureBox->GetCentroid()->GetCoordinate();
    $map->SetDisplayDpi($printDpi);
    $colorString = $map->GetBackgroundColor();
    // The returned color string is in AARRGGBB format. But the constructor of MgColor needs a string in RRGGBBAA format
    $colorString = substr($colorString, 2, 6) . substr($colorString, 0, 2);
    $color = new MgColor($colorString);
    $mgReader = $renderingService->RenderMap($map, $selection, $center, $scaleDenominator, $toSize->width, $toSize->height, $color, "PNG", false);
    $tempImage = sys_get_temp_dir() . DIRECTORY_SEPARATOR . "mgo" . uniqid();
    $mgReader->ToFile($tempImage);
    $image = imagecreatefrompng($tempImage);
    unlink($tempImage);
    // Rotate the picture back to be normalized
    $normalizedImg = imagerotate($image, -$rotation, 0);
    // Free the original image
    imagedestroy($image);
    // Crop the normalized image
    $croppedImg = imagecreatetruecolor($size->width, $size->height);
    imagecopy($croppedImg, $normalizedImg, 0, 0, (imagesx($normalizedImg) - $size->width) / 2, (imagesy($normalizedImg) - $size->height) / 2, $size->width, $size->height);
    // Free the normalized image
    imagedestroy($normalizedImg);
    // Draw the north arrow on the map
    DrawNorthArrow($croppedImg);
    header("Content-type: image/png");
    imagepng($croppedImg);
    imagedestroy($croppedImg);
}
Example #5
0
         if (strcasecmp($_REQUEST['variant'], 'inside') == 0) {
             $variant = MgFeatureSpatialOperations::Inside;
         }
     }
 }
 /* a filter expression to apply, in the form of an FDO SQL statement */
 $filter = isset($_REQUEST['filter']) ? str_replace(array('*', '"'), array('%', "'"), html_entity_decode(urldecode($_REQUEST['filter']))) : '';
 //echo "<!-- filter: $filter -->\n";
 /* a spatial filter in the form on a WKT geometry */
 $spatialFilter = isset($_REQUEST['spatialfilter']) && $_REQUEST['spatialfilter'] != '' ? urldecode($_REQUEST['spatialfilter']) : false;
 //echo "spatial filter is $spatialFilter<BR>";
 /* we need a feature service to query the features */
 $featureService = $siteConnection->CreateService(MgServiceType::FeatureService);
 /* open the map from the session using the provided map name.  The map was
    previously created by calling LoadMap. */
 $map = new MgMap();
 $map->Open($resourceService, $mapName);
 /* add the features to the map selection and save it*/
 $selection = new MgSelection($map);
 /* if extending the current selection */
 $bExtendSelection = isset($_REQUEST['extendselection']) && strcasecmp($_REQUEST['extendselection'], 'true') == 0;
 if ($bExtendSelection) {
     $aLayerSelections = array();
     $selection->Open($resourceService, $mapName);
     $aLayers = selectionToArray($selection, array());
 }
 $bComputedProperties = isset($_REQUEST['computed']) && strcasecmp($_REQUEST['computed'], 'true') == 0;
 $bQueryHiddenLayers = isset($_REQUEST['queryHiddenLayers']) && strcasecmp($_REQUEST['queryHiddenLayers'], 'true') == 0;
 /*holds selection array*/
 $properties = NULL;
 $properties->layers = array();
Example #6
0
    <link href="../styles/globalStyles.css" rel="stylesheet"  type="text/css">
    <link href="../styles/otherStyles.css" rel="stylesheet" type="text/css">
  </head>
  <body class="AppFrame">
    <h1 class="AppHeading">Layer Visibility</h1>
    <?php 
require_once '../common/common.php';
try {
    MgInitializeWebTier($webconfigFilePath);
    $args = $_SERVER['REQUEST_METHOD'] == "POST" ? $_POST : $_GET;
    $sessionId = $args['SESSION'];
    $mapName = $args['MAPNAME'];
    $userInfo = new MgUserInformation($sessionId);
    $siteConnection = new MgSiteConnection();
    $siteConnection->Open($userInfo);
    $map = new MgMap($siteConnection);
    $map->Open($mapName);
    $layers = $map->GetLayers();
    // Get layer collection
    echo "<p>Layers, in draw order:</p>";
    echo '<table class="taskPane" cellspacing="0">';
    echo '<tr><th class="rowHead">Layer</th><th>GetVisible()</th><th>IsVisible()</th></tr>';
    $count = $layers->GetCount();
    for ($i = 0; $i < $count; $i++) {
        $layer = $layers->GetItem($i);
        echo "<tr><td class=\"rowHead\">" . $layer->GetName() . "</td><td>" . ($layer->GetVisible() ? 'on' : 'off') . "</td><td>" . ($layer->IsVisible() ? 'on' : 'off') . "</td></tr>\n";
    }
    echo '</table>';
} catch (MgException $e) {
    echo "<p><strong>Error:</strong> ";
    echo $e->GetDetails();
Example #7
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";
}
Example #8
0
 // --------------------------------------------------//
 // Basic initialization needs to be done every time.
 MgInitializeWebTier($webconfigFilePath);
 // Get the session information passed from the viewer.
 $sessionId = $_SERVER['REQUEST_METHOD'] == "POST" ? $_POST['SESSION'] : $_GET['SESSION'];
 // 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);
 $featureService = $siteConnection->CreateService(MgServiceType::FeatureService);
 //---------------------------------------------------//
 // Open the map
 $map = new MgMap($siteConnection);
 $map->Open($mapName);
 $layerName = "Lines";
 $layerLegendLabel = "New Lines";
 $groupName = "Analysis";
 $groupLegendLabel = "Analysis";
 //---------------------------------------------------//
 // Does the temporary feature source already exist?
 // If not, create it
 $featureSourceName = "Session:{$sessionId}//TemporaryLines.FeatureSource";
 $resourceIdentifier = new MgResourceIdentifier($featureSourceName);
 $featureSourceExists = DoesResourceExist($resourceIdentifier, $resourceService);
 if (!$featureSourceExists) {
     // Create a temporary feature source to draw the lines on
     // Create a feature class definition for the new feature
     // source
Example #9
0
//Browsers that do not support data URIs will not pass "true" and thus no pre-caching is performed.
$preCacheIcons = false;
//This is used by pre-caching to determine how many legend icons to pre-cache up-front (if $preCacheIcons = true)
//$maxScaleRangeDepth = 3; //The maximum number of scale ranges to go through (topmost to bottom)
$maxIconsPerScaleRange = 25;
//The maximum number of icons to pre-cache per scale range. If the number of rules exceeds this value, the themed result will be compressed.
//$maxLegendHeight = 800; //The maximum screen space available to pre-cache icons
//$legendPos = 0; //Indicates how much screen space has already been allocated by pre-cached icons. Pre-caching stops after this value exceeds $maxLegendHeight
//$advanceHeight = 20; //16px with 4px padding. This is just a logical guess of how much actual space one legend icon occupies in the legend widget
//$maxGroupIndex = 5; //An initial guess of how many groups whose layer icons we can pre-cache.
// Determine if we should pre-cache legend icons
if (isset($_REQUEST['preCacheIcons']) && ($_REQUEST['preCacheIcons'] == "1" || strtolower($_REQUEST['preCacheIcons']) == "true")) {
    $preCacheIcons = true;
}
$mappingService = $siteConnection->CreateService(MgServiceType::MappingService);
$map = new MgMap();
$map->Open($resourceService, $mapName);
$layers = $map->GetLayers();
$scaleObj = NULL;
$scaleObj->layers = array();
for ($i = 0; $i < $layers->GetCount(); $i++) {
    $layer = $layers->GetItem($i);
    if (isset($_SESSION['scale_ranges']) && isset($_SESSION['scale_ranges'][$layer->GetObjectId()])) {
        $scaleranges = $_SESSION['scale_ranges'][$layer->GetObjectId()];
        $layerObj = NULL;
        $layerObj->uniqueId = $layer->GetObjectId();
        $layerObj = NULL;
        $layerObj->uniqueId = $layer->GetObjectId();
        $ldfId = $layer->GetLayerDefinition();
        foreach ($scaleranges as $sr) {
            $scaleVal = 42;
Example #10
0
 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());
     @($cs = $csFactory->Create($srs));
     @($metersPerUnit = $cs->ConvertCoordinateSystemUnitsToMeters(1.0));
     //  $unitsType = $cs->GetUnits();
Example #11
0
require_once '../common/common.php';
require_once 'layer_functions.php';
try {
    // --------------------------------------------------//
    // Initialize
    MgInitializeWebTier($webconfigFilePath);
    $args = $_SERVER['REQUEST_METHOD'] == "POST" ? $_POST : $_GET;
    $sessionId = $args['SESSION'];
    $mapName = $args['MAPNAME'];
    $userInfo = new MgUserInformation($sessionId);
    $siteConnection = new MgSiteConnection();
    $siteConnection->Open($userInfo);
    $resourceService = $siteConnection->CreateService(MgServiceType::ResourceService);
    // --------------------------------------------------//
    // Open the map
    $map = new MgMap($siteConnection);
    $map->Open($mapName);
    // ...
    // --------------------------------------------------//
    // Load a layer from XML, and use the DOM to change it
    // Load the prototype layer definition into
    // a PHP DOM object.
    $domDocument = DOMDocument::load('RecentlyBuilt.LayerDefinition');
    if ($domDocument == NULL) {
        echo "The layer definition\r\n          'RecentlyBuilt.LayerDefinition' could not be\r\n          found.<BR>\n";
        return;
    }
    // Change the filter
    $xpath = new DOMXPath($domDocument);
    $query = '//AreaRule/Filter';
    // Get a list of all the <AreaRule><Filter> elements in
Example #12
0
    <h1 class="AppHeading">Select features</h1>

    <?php 
include '../common/common.php';
$args = $_SERVER['REQUEST_METHOD'] == "POST" ? $_POST : $_GET;
$sessionId = $args['SESSION'];
$mapName = $args['MAPNAME'];
try {
    // Initialize the Web Extensions and connect to the Server using
    // the Web Extensions session identifier stored in PHP session state.
    MgInitializeWebTier($webconfigFilePath);
    $userInfo = new MgUserInformation($sessionId);
    $siteConnection = new MgSiteConnection();
    $siteConnection->Open($userInfo);
    $map = new MgMap($siteConnection);
    $map->Open($mapName);
    // Get the geometry for the boundaries of District 1
    $districtQuery = new MgFeatureQueryOptions();
    $districtQuery->SetFilter("Autogenerated_SDF_ID = 1");
    $layer = $map->GetLayers()->GetItem('Districts');
    $featureReader = $layer->SelectFeatures($districtQuery);
    $featureReader->ReadNext();
    $districtGeometryData = $featureReader->GetGeometry('Data');
    // Convert the AGF binary data to MgGeometry.
    $agfReaderWriter = new MgAgfReaderWriter();
    $districtGeometry = $agfReaderWriter->Read($districtGeometryData);
    // Create a filter to select the desired features. Combine
    // a basic filter and a spatial filter.
    $queryOptions = new MgFeatureQueryOptions();
    $queryOptions->SetFilter("RNAME LIKE 'SCHMITT%'");
Example #13
0
    <h1 class="AppHeading">Selected Parcels</h1>

    <?php 
include '../common/common.php';
$args = $_SERVER['REQUEST_METHOD'] == 'POST' ? $_POST : $_GET;
$sessionId = $args['SESSION'];
$mapName = $args['MAPNAME'];
try {
    // Initialize the Web Extensions and connect to the Server using
    // the Web Extensions session identifier stored in PHP session state.
    MgInitializeWebTier($webconfigFilePath);
    $userInfo = new MgUserInformation($sessionId);
    $siteConnection = new MgSiteConnection();
    $siteConnection->Open($userInfo);
    $featureService = $siteConnection->CreateService(MgServiceType::FeatureService);
    $map = new MgMap($siteConnection);
    $map->Open($mapName);
    // ----------------------------------------------------------
    // Use the following code for AJAX or DWF Viewers
    // This requires passing selection data via HTTP POST
    if (isset($_POST['SELECTION']) && $_POST['SELECTION'] != '') {
        $selection = new MgSelection($map, $_POST['SELECTION']);
        $layers = $selection->GetLayers();
    } else {
        $layers = 0;
    }
    // ---------------------------------------------------------
    // ---------------------------------------------------------
    // Use the following code for AJAX Viewers only.
    // This does not require passing selection data via HTTP POST.
    //
Example #14
0
 include "Common.php";
 if (InitializationErrorOccurred()) {
     DisplayInitializationErrorText();
     exit;
 }
 include '../../../common/php/Utilities.php';
 include 'Utilities.php';
 /* the name of the layer in the map to query */
 if ($_REQUEST['layerindex'] != '') {
     $layers = explode(',', $_REQUEST['layerindex']);
 } else {
     $layers = array();
 }
 /* open the map from the session using the provided map name.  The map was
    previously created by calling LoadMap. */
 $map = new MgMap();
 $map->Open($resourceService, $mapName);
 $mapLayers = $map->GetLayers();
 $nIndex = count($layers);
 $nLayers = $mapLayers->GetCount();
 for ($i = 0; $i < $nLayers; $i++) {
     if ($layers[$i] == $i) {
         continue;
     }
     $found = -1;
     for ($j = $i + 1; $j < $nIndex; ++$j) {
         if ($layers[$j] == $i) {
             $found = $j;
             break;
         }
     }
Example #15
0
$matchLimit = 0;
GetRequestParameters();
SetLocalizedFilesPath(GetLocalizationPath());
$searchError = GetLocalizedString("SEARCHERROR", $locale);
try {
    InitializeWebTier();
    $cred = new MgUserInformation($sessionId);
    $cred->SetClientIp(GetClientIp());
    $cred->SetClientAgent(GetClientAgent());
    //connect to the site and get a feature service and a resource service instances
    $site = new MgSiteConnection();
    $site->Open($cred);
    $featureSrvc = $site->CreateService(MgServiceType::FeatureService);
    $resourceSrvc = $site->CreateService(MgServiceType::ResourceService);
    //Create a temporary map runtime object, locate the layer
    $map = new MgMap();
    $map->Open($resourceSrvc, $mapName);
    $layers = $map->GetLayers();
    $layer = null;
    for ($i = 0; $i < $layers->GetCount(); $i++) {
        $layer = $layers->GetItem($i);
        if ($layer->GetName() == $layerName) {
            break;
        }
    }
    if ($layer == null) {
        trigger_error(FormatMessage("SEARCHLAYERNOTFOUND", $locale, array($layerName)));
    }
    //unescape strings
    //
    if (ini_get("magic_quotes_sybase") == "1") {
Example #16
0
 function ApplyTheme()
 {
     $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
     $featureService = $this->site->CreateService(MgServiceType::FeatureService);
     $map = new MgMap();
     $map->Open($resourceService, $this->args['MAPNAME']);
     $layers = $map->GetLayers();
     $layer = $layers->GetItem($this->args['LAYERNAME']);
     $resId = new MgResourceIdentifier($layer->GetFeatureSourceId());
     $layerDefResId = $layer->GetLayerDefinition();
     $byteReader = $resourceService->GetResourceContent($layerDefResId);
     // Load the Layer Definition and Navigate to the specified <VectorScaleRange>
     $doc = DOMDocument::loadXML($byteReader->ToString());
     $nodeList = $doc->getElementsByTagName('VectorScaleRange');
     $vectorScaleRangecElement = $nodeList->item($this->args['SCALERANGEINDEX']);
     $areaTypeStyle = $vectorScaleRangecElement->getElementsByTagName('AreaTypeStyle')->item(0);
     // Remove any existing <AreaRule> elements.
     $areaRuleList = $areaTypeStyle->getElementsByTagName('AreaRule');
     $ruleCount = $areaRuleList->length;
     for ($index = 0; $index < $ruleCount; $index++) {
         $areaTypeStyle->removeChild($areaRuleList->item(0));
     }
     // Now create the new <AreaRule> elements.
     $areaRuleTemplate = file_get_contents("templates/arearuletemplate.xml");
     $aggregateOptions = new MgFeatureAggregateOptions();
     $portion = 0.0;
     $increment = $this->args['NUMRULES'] > 1 ? $increment = 1.0 / ($this->args['NUMRULES'] - 1) : 1.0;
     if ($this->args['DISTRO'] == 'INDIV_DIST') {
         $aggregateOptions->AddFeatureProperty($this->args['PROPERTYNAME']);
         $aggregateOptions->SelectDistinct(true);
         $dataReader = $featureService->SelectAggregate($resId, $layer->GetFeatureClassName(), $aggregateOptions);
         while ($dataReader->ReadNext()) {
             $value = $this->GetFeaturePropertyValue($dataReader, $this->args['PROPERTYNAME']);
             $filterText = '&quot;' . $this->args['PROPERTYNAME'] . '&quot; = ';
             if ($this->args['DATATYPE'] == MgPropertyType::String) {
                 $filterText .= "'" . $value . "'";
             } else {
                 $filterText .= $value;
             }
             $areaRuleXML = sprintf($areaRuleTemplate, $this->args['PROPERTYNAME'] . ': ' . $value, $filterText, $this->InterpolateColor($portion, $this->args['FILLFROM'], $this->args['FILLTO'], $this->args['FILLTRANS']), $this->InterpolateColor($portion, $this->args['LINEFROM'], $this->args['LINETO'], 0));
             $areaDoc = DOMDocument::loadXML($areaRuleXML);
             $areaNode = $doc->importNode($areaDoc->documentElement, true);
             $areaTypeStyle->appendChild($areaNode);
             $portion += $increment;
         }
         $dataReader->Close();
     } else {
         $values = array();
         $aggregateOptions->AddComputedProperty('THEME_VALUE', $this->args['DISTRO'] . '("' . $this->args['PROPERTYNAME'] . '",' . $this->args['NUMRULES'] . ',' . $this->args['MINVALUE'] . ',' . $this->args['MAXVALUE'] . ')');
         $dataReader = $featureService->SelectAggregate($resId, $layer->GetFeatureClassName(), $aggregateOptions);
         while ($dataReader->ReadNext()) {
             $value = $this->GetFeaturePropertyValue($dataReader, 'THEME_VALUE');
             array_push($values, $value);
         }
         $dataReader->Close();
         for ($i = 0; $i < count($values) - 1; $i++) {
             $filterText = '&quot;' . $this->args['PROPERTYNAME'] . '&quot; &gt;= ' . $values[$i] . ' AND &quot;' . $this->args['PROPERTYNAME'];
             if ($i == count($values) - 1) {
                 $filterText .= '&quot; &lt;= ' . $values[$i + 1];
             } else {
                 $filterText .= '&quot; &lt; ' . $values[$i + 1];
             }
             $areaRuleXML = sprintf($areaRuleTemplate, $this->args['PROPERTYNAME'] . ': ' . $values[$i] . ' - ' . $values[$i + 1], $filterText, $this->InterpolateColor($portion, $this->args['FILLFROM'], $this->args['FILLTO'], $this->args['FILLTRANS']), $this->InterpolateColor($portion, $this->args['LINEFROM'], $this->args['LINETO'], 0));
             $areaDoc = DOMDocument::loadXML($areaRuleXML);
             $areaNode = $doc->importNode($areaDoc->documentElement, true);
             $areaTypeStyle->appendChild($areaNode);
             $portion += $increment;
         }
     }
     // Now save our new layer definition to the session and add it to the map.
     $layerDefinition = $doc->saveXML();
     $uniqueName = $this->MakeUniqueLayerName($map, $this->args['LAYERNAME'], $this->args['THEMENAME']);
     $legendLabel = $layer->GetLegendLabel();
     if (strlen(trim($this->args['THEMENAME'])) > 0) {
         $legendLabel .= ' (' . $this->args['THEMENAME'] . ')';
     }
     $layerResId = new MgResourceIdentifier('Session:' . $this->args['SESSION'] . '//' . $uniqueName . '.LayerDefinition');
     $byteSource = new MgByteSource($layerDefinition, strlen($layerDefinition));
     $resourceService->SetResource($layerResId, $byteSource->GetReader(), null);
     $newLayer = new MgLayer($layerResId, $resourceService);
     $newLayer->SetName($uniqueName);
     $newLayer->SetLegendLabel($legendLabel);
     $newLayer->SetDisplayInLegend($layer->GetDisplayInLegend());
     $newLayer->SetVisible(true);
     $newLayer->SetSelectable($layer->GetLegendLabel());
     $layers->Insert($layers->IndexOf($layer), $newLayer);
     $map->Save($resourceService);
     return $uniqueName;
 }
Example #17
0
 function GetOpenMarkup()
 {
     $openMarkup = array();
     $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
     $map = new MgMap();
     $map->Open($resourceService, $this->args['MAPNAME']);
     $layerGroups = $map->GetLayerGroups();
     if ($layerGroups->Contains('_Markup')) {
         $layers = $map->GetLayers();
         for ($i = 0; $i < $layers->GetCount(); $i++) {
             $layer = $layers->GetItem($i);
             if ($layer->GetGroup() != null and $layer->GetGroup()->GetName() == '_Markup') {
                 $openMarkup[$this->GetResourceIdPrefix() . $layer->GetLegendLabel() . '.LayerDefinition'] = $layer->GetLegendLabel();
             }
         }
         asort($openMarkup);
     }
     return $openMarkup;
 }
Example #18
0
include '../common/common.php';
$args = $_SERVER['REQUEST_METHOD'] == "POST" ? $_POST : $_GET;
$sessionId = $args['SESSION'];
$mapName = $args['MAPNAME'];
$mapName = $_SERVER['REQUEST_METHOD'] == "POST" ? $_POST['MAPNAME'] : $_GET['MAPNAME'];
try {
    // Initialize the Web Extensions and connect to the Server using
    // the Web Extensions session identifier stored in PHP session state.
    MgInitializeWebTier($webconfigFilePath);
    $userInfo = new MgUserInformation($sessionId);
    $siteConnection = new MgSiteConnection();
    $siteConnection->Open($userInfo);
    $resourceService = $siteConnection->CreateService(MgServiceType::ResourceService);
    $featureService = $siteConnection->CreateService(MgServiceType::FeatureService);
    $queryOptions = new MgFeatureQueryOptions();
    $map = new MgMap($siteConnection);
    $map->Open($mapName);
    // Check for selection data passed via HTTP POST
    if (isset($_POST['SELECTION']) && $_POST['SELECTION'] != '') {
        $selection = new MgSelection($map, $_POST['SELECTION']);
        $selectedLayers = $selection->GetLayers();
    } else {
        $selectedLayers = 0;
    }
    if ($selectedLayers) {
        include 'bufferfunctions.php';
        $bufferRingSize = 100;
        // measured in metres
        $bufferRingCount = 5;
        // Set up some objects for coordinate conversion
        $mapWktSrs = $map->GetMapSRS();
Example #19
0
$updateType = -1;
$output = "\nvar layerData = new Array();\n";
try {
    InitializeWebTier();
    // connect to the site and get a resource service instance
    //
    $userInfo = new MgUserInformation();
    $userInfo->SetMgSessionId($sessionId);
    $userInfo->SetClientIp(GetClientIp());
    $userInfo->SetClientAgent(GetClientAgent());
    $site = new MgSiteConnection();
    $site->Open($userInfo);
    $resourceSrvc = $site->CreateService(MgServiceType::ResourceService);
    //Load the map runtime state.
    //
    $map = new MgMap();
    $map->Open($resourceSrvc, $mapName);
    $layerMap = null;
    $tree = BuildLayerTree($map, $resourceSrvc);
    if ($summary) {
        $updateType = 0;
        // return only the layer structure, that is mainly groups/layers/layer-ids. Do not parse layer definitions.
        //
        BuildClientSideTree($tree, null, "null", false, "layerData", null, null);
    } else {
        if ($layerCount == 0) {
            $updateType = 1;
        } else {
            $updateType = 2;
            $layerMap = BuildLayerMap($map);
        }
Example #20
0
 $rsvc->SetResource($rid, $src->GetReader(), null);
 echo "Deleting existing feature source\n";
 $rsvc->DeleteResource($id);
 echo "Creating new feature source\n";
 $fsvc->CreateFeatureSource($id, $params);
 // We need to add some data to the sdf before using it.  The spatial context
 // reader must have an extent.
 $cmdColl = new MgFeatureCommandCollection();
 for ($i = 1; $i <= 20; $i++) {
     $insert = $intFeature->InsertCommand($i);
     $cmdColl->Add($insert);
 }
 echo "Updating features\n";
 $fsvc->UpdateFeatures($id, $cmdColl, false);
 $mapId = new MgResourceIdentifier("Library://TrevorWekel/NewSdf.MapDefinition");
 $map = new MgMap();
 $map->Create($rsvc, $mapId, "NewMap");
 echo "Building Selection from Add()\n";
 $sel = new MgSelection($map);
 $slayer = $map->GetLayers()->GetItem(0);
 $sel->AddFeatureIdInt32($slayer, "IntKey", 1);
 $sel->AddFeatureIdInt32($slayer, "IntKey", 10);
 $sel->AddFeatureIdInt32($slayer, "IntKey", 20);
 echo "XML FeatureSet is\n" . $sel->ToXml() . "\n";
 echo "\nString Filter: " . $sel->GenerateFilter($slayer, "StringKey") . "\n\n";
 echo "Building Selection from XML\n";
 $sel2 = new MgSelection($map, $sel->ToXml());
 // Test basic methods
 $layerColl = $sel2->GetLayers();
 $newLayer = $layerColl->GetItem(0);
 echo "First layer selected is " . $newLayer->GetName() . "\n";
Example #21
0
include '../utilityfunctions.php';
include 'findaddressfunctions.php';
$mgSessionId = $_SERVER['REQUEST_METHOD'] == "POST" ? $_POST['SESSION'] : $_GET['SESSION'];
$showPreviousResults = false;
try {
    // Initialize the Web Extensions and connect to the Server using
    // the Web Extensions session identifier stored in PHP session state.
    MgInitializeWebTier($configFilePath);
    $userInfo = new MgUserInformation($mgSessionId);
    $siteConnection = new MgSiteConnection();
    $siteConnection->Open($userInfo);
    // Create a ReserviceService object and use it to open the Map
    // object from the sessions repository. Use the Map object to
    // determine if the "AddressMarker" layer is visible.
    $resourceService = $siteConnection->CreateService(MgServiceType::ResourceService);
    $map = new MgMap();
    $map->Open($resourceService, 'Sheboygan');
    $addressLayer = GetLayerByName($map, 'AddressMarker');
    if ($addressLayer != null) {
        $showPreviousResults = $addressLayer->GetVisible();
    }
} catch (MgException $e) {
    echo $e->GetExceptionMessage();
    echo $e->GetDetails();
}
?>

<form id="addressForm" action="findaddress.php" method="get" target="_self">
    <input name="SESSION" type="hidden" value="<?php 
echo $mgSessionId;
?>
 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);
     }
 }
Example #23
0
 * DEALINGS IN THE SOFTWARE.
 */
include 'Common.php';
if (InitializationErrorOccurred()) {
    DisplayInitializationErrorText();
    exit;
}
include '../../../common/php/Utilities.php';
include 'Utilities.php';
$selText = "";
$getExtents = false;
GetRequestParameters();
try {
    //load the map runtime state
    //
    $map = new MgMap();
    $map->Open($resourceService, $mapName);
    // Create the selection set and save it
    $selection = new MgSelection($map);
    if ($selText != "") {
        $selection->FromXml($selText);
    }
    $selection->Save($resourceService, $mapName);
    //now return a data struture which is the same as Query.php
    //process
    header('Content-type: application/json');
    header('X-JSON: true');
    $layers = $selection->GetLayers();
    $result = new stdClass();
    $result->hasSelection = false;
    if ($layers && $layers->GetCount() >= 0) {
Example #24
0
//
require_once '../common/common.php';
$args = $_SERVER['REQUEST_METHOD'] == "POST" ? $_POST : $_GET;
$sessionId = $args['SESSION'];
$mapName = $args['MAPNAME'];
try {
    // Initialize the Web Extensions and connect to the server using
    // the Web Extensions session identifier stored in PHP session state.
    MgInitializeWebTier($webconfigFilePath);
    $userInfo = new MgUserInformation($sessionId);
    $siteConnection = new MgSiteConnection();
    $siteConnection->Open($userInfo);
    // Create an instance of ResourceService and use that to open the
    // current map instance stored in session state.
    $resourceService = $siteConnection->CreateService(MgServiceType::ResourceService);
    $map = new MgMap();
    $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);
    $layoutRes = new MgResourceIdentifier("Library://Samples/Sheboygan/Layouts/SheboyganMap.PrintLayout");
    $layout = new MgLayout($layoutRes, "City of Sheboygan", MgPageUnitsType::Inches);
    $byteReader = $mappingService->GeneratePlot($map, $plotSpec, $layout, $dwfVersion);
    // Now output the resulting DWF.
    $outputBuffer = '';
    $buffer = '';
    while ($byteReader->Read($buffer, 50000) != 0) {
        $outputBuffer .= $buffer;
    }
    header('Content-Type: ' . $byteReader->GetMimeType());
Example #25
0
// is generated by the plot.php script.
$mgSessionId = $_SERVER['REQUEST_METHOD'] == "POST" ? $_POST['SESSION'] : $_GET['SESSION'];
$currentScale = 0;
try {
    // Initialize the Web Extensions and connect to the Server using
    // the Web Extensions session identifier stored in PHP session state.
    MgInitializeWebTier($configFilePath);
    $userInfo = new MgUserInformation($mgSessionId);
    $siteConnection = new MgSiteConnection();
    $siteConnection->Open($userInfo);
    // Create a ReserviceService object and use it to open the Map
    // object from the sessions repository. Use the Map object to
    // determine the current scale of the map for display on this
    // page.
    $resourceService = $siteConnection->CreateService(MgServiceType::ResourceService);
    $map = new MgMap();
    $map->Open($resourceService, 'Sheboygan');
    $viewCenter = $map->GetViewCenter();
    $viewScale = $map->GetViewScale();
} catch (MgException $e) {
    echo $e->GetExceptionMessage();
    echo $e->GetDetails();
}
?>

<form id="plotForm" action="plot.php" method="get" target="_blank">
    <input name="SESSION" type="hidden" value="<?php 
echo $mgSessionId;
?>
">
    <input name="Scale" id="scaleValue" type="hidden" value="0">
Example #26
0
GetRequestParameters();
try {
    InitializeWebTier();
    $cred = new MgUserInformation($sessionId);
    $cred->SetClientIp(GetClientIp());
    $cred->SetClientAgent(GetClientAgent());
    //connect to the site and get an instance of each service used in this script
    //
    $site = new MgSiteConnection();
    $site->Open($cred);
    $featureSrvc = $site->CreateService(MgServiceType::FeatureService);
    $renderingSrvc = $site->CreateService(MgServiceType::RenderingService);
    $resourceSrvc = $site->CreateService(MgServiceType::ResourceService);
    //load the map runtime state
    //
    $map = new MgMap();
    $map->Open($resourceSrvc, $mapName);
    $layers = explode(",", $layers);
    if (count($layers) > 0) {
        $layerNames = new MgStringCollection();
        for ($i = 0; $i < count($layers); $i++) {
            $layerNames->Add($layers[$i]);
        }
        // create a multi-polygon or a multi-geometry containing the input selected features
        //
        $inputGeom = MultiGeometryFromSelection($featureSrvc, $map, $inputSel);
        if ($inputGeom) {
            // Query all the features belonging the the layer list that intersects with the input geometries
            //
            $fi = $renderingSrvc->QueryFeatures($map, $layerNames, $inputGeom, MgFeatureSpatialOperations::Intersects, -1);
            if ($fi) {
Example #27
0
 function GetSelectionXML()
 {
     $json = new Services_JSON();
     $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
     $featureService = $this->site->CreateService(MgServiceType::FeatureService);
     $map = new MgMap();
     $map->Open($resourceService, $this->args['MAPNAME']);
     $layer = $map->GetLayers()->GetItem($this->args['LAYERNAME']);
     $resId = new MgResourceIdentifier($layer->GetFeatureSourceId());
     $featureClass = $layer->GetFeatureClassName();
     $schemaAndClass = explode(":", $featureClass);
     $classDef = $featureService->GetClassDefinition($resId, $schemaAndClass[0], $schemaAndClass[1]);
     $properties = new MgPropertyCollection();
     $idList = $json->decode($this->args['IDLIST']);
     foreach ($idList as $key => $value) {
         switch ($classDef->GetProperties()->GetItem($key)->GetDataType()) {
             case MgPropertyType::Boolean:
                 $properties->Add(new MgBooleanProperty($key, $value));
                 break;
             case MgPropertyType::Byte:
                 $properties->Add(new MgByteProperty($key, $value));
                 break;
             case MgPropertyType::Single:
                 $properties->Add(new MgSingleProperty($key, $value));
                 break;
             case MgPropertyType::Double:
                 $properties->Add(new MgDoubleProperty($key, $value));
                 break;
             case MgPropertyType::Int16:
                 $properties->Add(new MgInt16Property($key, $value));
                 break;
             case MgPropertyType::Int32:
                 $properties->Add(new MgInt32Property($key, $value));
                 break;
             case MgPropertyType::Int64:
                 $properties->Add(new MgInt64Property($key, $value));
                 break;
             case MgPropertyType::String:
                 $properties->Add(new MgStringProperty($key, $value));
                 break;
             case MgPropertyType::DateTime:
                 $properties->Add(new MgDateTimeProperty($key, $value));
                 break;
             case MgPropertyType::Null:
             case MgPropertyType::Blob:
             case MgPropertyType::Clob:
             case MgPropertyType::Feature:
             case MgPropertyType::Geometry:
             case MgPropertyType::Raster:
                 break;
         }
     }
     $selection = new MgSelection($map);
     $selection->AddFeatureIds($layer, $featureClass, $properties);
     return $selection->ToXml();
 }
Example #28
0
 function GetSelectionXML()
 {
     $resourceService = $this->site->CreateService(MgServiceType::ResourceService);
     $map = new MgMap();
     $map->Open($resourceService, $this->args['MAPNAME']);
     $markupLayer = $map->GetLayers()->GetItem('_' . $this->GetMarkupName());
     $selection = new MgSelection($map);
     $className = $markupLayer->GetFeatureClassName();
     $ids = $this->args['MARKUPFEATURE'];
     if (is_array($ids)) {
         foreach ($ids as $id) {
             $selection->AddFeatureIdInt32($markupLayer, $className, (int) $id);
         }
     } else {
         $selection->AddFeatureIdInt32($markupLayer, $className, (int) $ids);
     }
     return $selection->ToXML();
 }
Example #29
0
if (InitializationErrorOccurred()) {
    DisplayInitializationErrorText();
    exit;
}
$format = isset($_REQUEST['format']) ? $_REQUEST['format'] : 'PNG';
$layout = isset($_REQUEST['layout']) ? $_REQUEST['layout'] : null;
$scale = isset($_REQUEST['scale']) ? $_REQUEST['scale'] : null;
$imgWidth = isset($_REQUEST['width']) ? $_REQUEST['width'] : null;
$imgHeight = isset($_REQUEST['height']) ? $_REQUEST['height'] : null;
$pageHeight = isset($_REQUEST['pageheight']) ? $_REQUEST['pageheight'] : 11;
$pageWidth = isset($_REQUEST['pagewidth']) ? $_REQUEST['pagewidth'] : 8.5;
$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]);
 public function GeneratePlot($sessionId, $mapName, $format)
 {
     $fmt = $this->ValidateRepresentation($format, array("dwf", "pdf"));
     $this->EnsureAuthenticationForSite($sessionId);
     $siteConn = new MgSiteConnection();
     $siteConn->Open($this->userInfo);
     $map = new MgMap($siteConn);
     $map->Open($mapName);
     $mappingSvc = $siteConn->CreateService(MgServiceType::MappingService);
     $title = $this->GetRequestParameter("title", "");
     $paperSize = $this->GetRequestParameter("papersize", 'A4');
     $orientation = $this->GetRequestParameter("orientation", 'P');
     $marginLeft = floatval($this->GetRequestParameter("marginleft", 0.5));
     $marginRight = floatval($this->GetRequestParameter("marginright", 0.5));
     $marginTop = floatval($this->GetRequestParameter("margintop", $title == "" ? 0.5 : 1.0));
     $marginBottom = floatval($this->GetRequestParameter("marginbottom", 0.5));
     if ($fmt == "dwf") {
         $size = MgUtils::GetPaperSize($this->app, $paperSize);
         //If landscape, flip the width/height
         $width = $orientation == 'L' ? MgUtils::MMToIn($size[1]) : MgUtils::MMToIn($size[0]);
         $height = $orientation == 'L' ? MgUtils::MMToIn($size[0]) : MgUtils::MMToIn($size[1]);
         $printLayoutStr = $this->GetRequestParameter("printlayout", null);
         $dwfVersion = new MgDwfVersion("6.01", "1.2");
         $plotSpec = new MgPlotSpecification($width, $height, MgPageUnitsType::Inches);
         $plotSpec->SetMargins($marginLeft, $marginTop, $marginRight, $marginBottom);
         $layout = null;
         if ($printLayoutStr != null) {
             $layoutRes = new MgResourceIdentifier($printLayoutStr);
             $layout = new MgLayout($layoutRes, $title, MgPageUnitsType::Inches);
         }
         $br = $mappingSvc->GeneratePlot($map, $plotSpec, $layout, $dwfVersion);
         //Apply download headers
         $downloadFlag = $this->app->request->params("download");
         if ($downloadFlag && ($downloadFlag === "1" || $downloadFlag === "true")) {
             $name = $this->app->request->params("downloadname");
             if (!$name) {
                 $name = "download";
             }
             $name .= ".dwf";
             $this->app->response->header("Content-Disposition", "attachment; filename=" . $name);
         }
         $this->OutputByteReader($br);
     } else {
         //pdf
         $bLayered = $this->app->request->params("layeredpdf");
         if ($bLayered == null) {
             $bLayered = false;
         } else {
             $bLayered = $bLayered == "1" || $bLayered == "true";
         }
         $renderingService = $siteConn->CreateService(MgServiceType::RenderingService);
         $plotter = new MgPdfPlotter($this->app, $renderingService, $map);
         $plotter->SetTitle($title);
         $plotter->SetPaperType($paperSize);
         $plotter->SetOrientation($orientation);
         $plotter->ShowCoordinates(true);
         $plotter->ShowNorthArrow(true);
         $plotter->ShowScaleBar(true);
         $plotter->ShowDisclaimer(true);
         $plotter->SetLayered($bLayered);
         $plotter->SetMargins($marginTop, $marginBottom, $marginLeft, $marginRight);
         $mapCenter = $map->GetViewCenter();
         //Apply download headers
         $downloadFlag = $this->app->request->params("download");
         if ($downloadFlag && ($downloadFlag === "1" || $downloadFlag === "true")) {
             $name = $this->app->request->params("downloadname");
             if (!$name) {
                 $name = "download";
             }
             $name .= ".pdf";
             $plotter->Plot($mapCenter->GetCoordinate(), $map->GetViewScale(), $name);
         } else {
             $plotter->Plot($mapCenter->GetCoordinate(), $map->GetViewScale());
         }
     }
 }