Feature Query
Open($userInfo);
$map = new MgMap($siteConnection);
$map->Open($mapName);
// Get the geometry for the boundaries of District 6
$districtQuery = new MgFeatureQueryOptions();
$districtQuery->SetFilter("ID = '6'"); //ID property is string
$layer = $map->GetLayers()->GetItem('Districts');
$classDef = $layer->GetClassDefinition();
$clsIdProps = $classDef->GetIdentityProperties();
$idProp = $clsIdProps->GetItem(0);
$districtQuery->SetFilter($idProp->GetName()." = 1");
$featureReader = $layer->SelectFeatures($districtQuery);
$featureReader->ReadNext();
$districtGeometryData = $featureReader->GetGeometry($layer->GetFeatureGeometryName());
// Convert the AGF binary data to MgGeometry.
$agfReaderWriter = new MgAgfReaderWriter();
$districtGeometry = $agfReaderWriter->
Read($districtGeometryData);
// Create a filter to select the desired features.
// Combine a basic filter and a spatial filter.
$queryOptions = new MgFeatureQueryOptions();
$queryOptions->SetFilter("RNAME LIKE 'SCHMITT%'");
$queryOptions->SetSpatialFilter('SHPGEOM',
$districtGeometry,
MgFeatureSpatialOperations::Inside);
// Select the features.
$layer = $map->GetLayers()->GetItem('Parcels');
$featureReader = $layer->SelectFeatures($queryOptions);
// For each selected feature, display the address.
echo 'Properties owned by Schmitt ';
echo 'in District 6
';
while ($featureReader->ReadNext())
{
$val = $featureReader->GetString('RPROPAD');
echo $val . '
';
}
$featureReader->Close();
echo '
';
}
catch (MgException $e)
{
echo $e->getTraceAsString();
echo $e->GetExceptionMessage();
echo $e->GetDetails();
}
catch (Exception $e)
{
echo $e->getMessage();
}
?>