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.
Get the features from the feature source,<br />
// determine the centroid of each selected feature, and<br />
// add a point to the ParcelMarker layer to mark the<br />
// centroid.<br />
// Collect all the points into an MgFeatureCommandCollection,<br />
// so they can all be added in one operation.<br />
$featureResId = new MgResourceIdentifier(<br />
"Library://Samples/Sheboygan/Data/Parcels.Feature<strong>Source</strong>");<br />
$featureReader = $featureService->SelectFeatures($featureResId,<br />
"Parcels", $queryOptions);<br />
$parcelMarkerCommands = new MgFeatureCommandCollection();<br />
while ($featureReader->ReadNext())<br />
{<br />
$byteReader = $featureReader->GetGeometry('SHPGEOM');<br />
$geometry = $agfReaderWriter->Read($byteReader);<br />
$point = $geometry->GetCentroid();<br />
// Create an insert command for this parcel.<br />
$properties = new MgPropertyCollection();<br />
$properties->Add(new MgGeometryProperty('ParcelLocation',<br />
$agfReaderWriter->Write($point)));<br />
$parcelMarkerCommands->Add(<br />
new MgInsertFeatures('ParcelMarkerClass', $properties));<br />
}<br />
$featureReader->Close();<br />
if ($parcelMarkerCommands->GetCount() > 0)<br />
{<br />
$featureService->UpdateFeatures($parcelFeatureResId,<br />
$parcelMarkerCommands, false);<br />
}<br />
else<br />
{<br />
echo 'No parcels within the buffer area match.';<br />
}<br />
88 | Chapter 5 Analyzing Features