[mapguide-users] Re: Reprojet Oracle layer

navya024 navya.gudupi at gmail.com
Wed May 5 04:54:58 EDT 2010


Dear all,
iam trying to do reproject the sdf files to existing map projection.


so i have taken the  sample united states sdf file and created a layout and
displayed it on ajaxviewer (using maestro).
Now i want to add other sdf file (canada) on the fly to the existing map and
want to display with the same projection system.


here is my code 
-----------------------------

In taskpane i wrote the following code


<?php
require_once('../common/common.php');
require_once('layer_functions.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);
    $resourceService =
$siteConnection->CreateService(MgServiceType::ResourceService);
$featureService =
$siteConnection->CreateService(MgServiceType::FeatureService);

    $map = new MgMap();
    $map->Open($resourceService, $mapName);
 $mapWktSrs = $map->GetMapSRS();


       $FeatureResId = new MgResourceIdentifier("Session:" . $sessionId .
"//layer.FeatureSource");
CreateFeatureSource($featureService, $mapWktSrs,$FeatureResId);



 $newLayer = CreateLayer($resourceService, $FeatureResId, $sessionId);

	 $map->GetLayers()->Insert(0,  $newLayer);
         $map->Save($resourceService);
$map->Refresh();
}
catch (MgException $e)
{
  echo "<script language=\"javascript\" type=\"text/javascript\"> \n";
  $message = $e->GetMessage();
  $message = str_replace("\n", " ", $message);
  echo "    alert(\" " . $message . " \"); \n";
  echo "</script> \n";
}
?>

and in layer_function.php

require_once('../common/common.php');
function CreateFeatureSource($featureService, $wkt, $FeatureResId)
{
    $bufferClass = new MgClassDefinition();
    $bufferClass->SetName('BufferClass');
    $properties = $bufferClass->GetProperties();

    $idProperty = new MgDataPropertyDefinition('ID');
    $idProperty->SetDataType(MgPropertyType::Int32);
    $idProperty->SetReadOnly(true);
    $idProperty->SetNullable(false);
    $idProperty->SetAutoGeneration(true);
    $properties->Add($idProperty);
    $polygonProperty = new MgGeometricPropertyDefinition('Geometry');
    $polygonProperty->SetGeometryTypes(MgFeatureGeometricType::Surface);
    $polygonProperty->SetHasElevation(false);
    $polygonProperty->SetHasMeasure(false);
    $polygonProperty->SetReadOnly(false);
    $polygonProperty->SetSpatialContextAssociation('defaultSrs');
    $properties->Add($polygonProperty);
    $idProperties = $bufferClass->GetIdentityProperties();
    $idProperties->Add($idProperty);
    $bufferClass->SetDefaultGeometryPropertyName('Geometry');
    $bufferSchema = new MgFeatureSchema('LayerSchema', 'temporary schema to
hold a layer');
    $bufferSchema->GetClasses()->Add($bufferClass);

    $sdfParams = new MgCreateSdfParams('defaultSrs', $wkt, $bufferSchema);

    $featureService->CreateFeatureSource($FeatureResId, $sdfParams);

}

function CreateLayer($resourceService, $FeatureResId, $sessionId)
{
    $doc = DOMDocument::load('cities.xml');
    $featureSourceNode = $doc->getElementsByTagName('ResourceId')->item(0);
    $featureSourceNode->nodeValue = $FeatureResId->ToString();
    $layerDefinition = $doc->saveXML();
    $byteSource = new MgByteSource($layerDefinition,
strlen($layerDefinition));
    $byteSource->SetMimeType(MgMimeType::Xml);
    $tempLayerResId = new MgResourceIdentifier("Session:" . $sessionId .
"//layer.LayerDefinition");
    $resourceService->SetResource($tempLayerResId, $byteSource->GetReader(),
null);
    $bufferLayer = new MgLayer($tempLayerResId, $resourceService);
    $bufferLayer->SetName("Cities");
    $bufferLayer->SetLegendLabel("Cities");
    $bufferLayer->SetDisplayInLegend(true);
    $bufferLayer->SetSelectable(false);

    return $bufferLayer;
}

the layer is not displaying on the map.but it is added to the legend.Is
anything  need to be changed . (in maestro i saved the cities layer as
cities.xml).
1)but i want to use the sdf file on the fly?how to use it directly in
coding?
-- 
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Reprojet-Oracle-layer-tp4978013p5007883.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list