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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

$districtQuery->SetFilter("Autogenerated_SDF_ID = 1");<br />

$districtResId = new MgResourceIdentifier(<br />

"Library://Samples/Sheboygan/Data/VotingDistricts.Feature<strong>Source</strong>");<br />

$featureReader = $featureService->SelectFeatures($districtResId,<br />

"VotingDistricts", $districtQuery);<br />

$featureReader->ReadNext();<br />

$districtGeometryData = $featureReader->GetGeometry('Data');<br />

$agfReaderWriter = new MgAgfReaderWriter();<br />

$districtGeometry = $agfReaderWriter->Read($districtGeometryData);<br />

To convert an MgGeometry object into its WKT representation, use the<br />

MgWktReaderWriter::Write() method, as in the following example:<br />

$wktReaderWriter = new MgWktReaderWriter();<br />

$districtWkt = $wktReaderWriter->Write($districtGeometry);<br />

Examples<br />

The following examples assume that $testArea is an MgGeometry object<br />

defining a polygon, and $testAreaWkt is a WKT description of the polygon.<br />

To create a filter to find all properties owned by Schmitt in the area, use either<br />

of the following sequences:<br />

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

$queryOptions->SetFilter("RNAME LIKE 'Schmitt%'");<br />

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

MgFeatureSpatialOperations::Inside);<br />

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

$queryOptions->SetFilter("RNAME LIKE 'Schmitt%'<br />

AND SHPGEOM inside GEOMFROMTEXT('$testAreaWkt')";<br />

Example: Listing Selected Features<br />

The following example creates a selection, then lists properties from the<br />

selected features.<br />

It selects parcels within the boundaries of District 1 that are owned by Schmitt.<br />

This requires a spatial filter and a basic filter.<br />

Example: Listing Selected Features | 39

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

Saved successfully!

Ooh no, something went wrong!