Developer's Guide - MapGuide Open Source - OSGeo
Developer's Guide - MapGuide Open Source - OSGeo
Developer's Guide - MapGuide Open Source - OSGeo
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
function CreateBufferFeature<strong>Source</strong>($featureService, $wkt,<br />
$bufferFeatureResId)<br />
{<br />
$bufferClass = new MgClassDefinition();<br />
$bufferClass->SetName('BufferClass');<br />
$properties = $bufferClass->GetProperties();<br />
$idProperty = new MgDataPropertyDefinition('ID');<br />
$idProperty->SetDataType(MgPropertyType::Int32);<br />
$idProperty->SetReadOnly(true);<br />
$idProperty->SetNullable(false);<br />
$idProperty->SetAutoGeneration(true);<br />
$properties->Add($idProperty);<br />
$polygonProperty = new<br />
MgGeometricPropertyDefinition('BufferGeometry');<br />
$polygonProperty-><br />
SetGeometryTypes(MgFeatureGeometricType::Surface);<br />
$polygonProperty->SetHasElevation(false);<br />
$polygonProperty->SetHasMeasure(false);<br />
$polygonProperty->SetReadOnly(false);<br />
$polygonProperty->SetSpatialContextAssociation('defaultSrs');<br />
$properties->Add($polygonProperty);<br />
$idProperties = $bufferClass->GetIdentityProperties();<br />
$idProperties->Add($idProperty);<br />
$bufferClass-><br />
SetDefaultGeometryPropertyName('BufferGeometry');<br />
$bufferSchema = new MgFeatureSchema('BufferLayerSchema',<br />
'temporary schema to hold a buffer');<br />
$bufferSchema->GetClasses()->Add($bufferClass);<br />
$sdfParams = new MgCreateSdfParams('defaultSrs', $wkt,<br />
$bufferSchema);<br />
$featureService->CreateFeature<strong>Source</strong>($bufferFeatureResId,<br />
$sdfParams);<br />
}<br />
function CreateBufferLayer($resourceService,<br />
$bufferFeatureResId, $sessionId)<br />
{<br />
// Load the layer definition template into<br />
// a PHP DOM object, find the "ResourceId" element, and<br />
// modify its content to reference the temporary<br />
// feature source.<br />
$doc = DOMDocument::load('bufferlayerdefinition.xml');<br />
$feature<strong>Source</strong>Node = $doc->getElementsByTagName(<br />
86 | Chapter 5 Analyzing Features