Dearall, If anybody worked on this earlier Please share the procedure steps for how to do it?iam struggling for this. my code is
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- // Copyright (C) 2004-2009 by Autodesk, Inc. // // This library is free software; you can redistribute it and/or // modify it under the terms of version 2.1 of the GNU Lesser // General Public License as published by the Free Software Foundation. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --> <html> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <meta http-equiv="content-script-type" content="text/javascript"> <meta http-equiv="content-style-type" content="text/css"> <link href="../styles/globalStyles.css" rel="stylesheet" type="text/css"> <link href="../styles/otherStyles.css" rel="stylesheet" type="text/css"> <script language="javascript" type="text/javascript"> function OnPageLoad() { parent.mapFrame.Refresh(); } </script> </head> <body onLoad="OnPageLoad()"> <?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, 'map'); $mapWktSrs = $map->GetMapSRS(); $FeatureResId = new MgResourceIdentifier("Session:" . $sessionId . "//layer.FeatureSource"); CreateFeatureSource($featureService, $mapWktSrs,$FeatureResId); $newLayer = CreateLayer($resourceService, $FeatureResId, $sessionId); $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"; } ?> </body> </html> and in layer functions.php <?php // Copyright (C) 2004-2009 by Autodesk, Inc. // // This library is free software; you can redistribute it and/or // modify it under the terms of version 2.1 of the GNU Lesser // General Public License as published by the Free Software Foundation. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 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('BufferLayerSchema', 'temporary schema to hold a buffer'); $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; } ////////////////////////////////////////////////////////////// ?> -- View this message in context: http://osgeo-org.1803224.n2.nabble.com/Add-layer-from-sdf-tp5017702p5068484.html Sent from the MapGuide Users mailing list archive at Nabble.com. _______________________________________________ mapguide-users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/mapguide-users
