14.01.2013 Views

Developer's Guide - MapGuide Open Source - OSGeo

Developer's Guide - MapGuide Open Source - OSGeo

Developer's Guide - MapGuide Open Source - OSGeo

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

'ResourceId')->item(0);<br />

$feature<strong>Source</strong>Node->nodeValue =<br />

$bufferFeatureResId->ToString();<br />

// Get the updated layer definition from the DOM object<br />

// and save it to the session repository using the<br />

// ResourceService object.<br />

$layerDefinition = $doc->saveXML();<br />

$byte<strong>Source</strong> = new MgByte<strong>Source</strong>($layerDefinition,<br />

strlen($layerDefinition));<br />

$byte<strong>Source</strong>->SetMimeType(MgMimeType::Xml);<br />

$tempLayerResId = new MgResourceIdentifier("Session:" .<br />

$sessionId . "//Buffer.LayerDefinition");<br />

$resourceService->SetResource($tempLayerResId,<br />

$byte<strong>Source</strong>->GetReader(), null);<br />

// Create an MgLayer object based on the new layer definition<br />

// and return it to the caller.<br />

$bufferLayer = new MgLayer($tempLayerResId, $resourceService);<br />

$bufferLayer->SetName("Buffer");<br />

$bufferLayer->SetLegendLabel("Buffer");<br />

$bufferLayer->SetDisplayInLegend(true);<br />

$bufferLayer->SetSelectable(false);<br />

return $bufferLayer;<br />

There is an additional example in the Developer’s <strong>Guide</strong> samples. It queries<br />

the parcels in the buffer area and selects parcels that match certain criteria.<br />

The selection is done using a query that combines a basic filter and a spatial<br />

filter.<br />

$bufferDist = $srs-><br />

ConvertMetersToCoordinateSystemUnits($bufferRingSize);<br />

$bufferGeometry = $mergedGeometries->Buffer($bufferDist,<br />

$srsMeasure);<br />

// Create a filter to select parcels within the buffer. Combine<br />

// a basic filter and a spatial filter to select all parcels<br />

// within the buffer that are of type "MFG".<br />

$queryOptions = new MgFeatureQueryOptions();<br />

$queryOptions->SetFilter("RTYPE = 'MFG'");<br />

$queryOptions->SetSpatialFilter('SHPGEOM', $bufferGeometry,<br />

MgFeatureSpatialOperations::Inside);<br />

It creates an additional feature source that contains point markers for each of<br />

the selected parcels.<br />

Example | 87

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!