55 | | Code that currently calls MgSelectionBase::GenerateFilter() should be updated to use MgSelectionBase::GenerateFilters() instead, and the caller will be required to process all the filters in the collection to correctly query the complete selection set. In places where a relatively small number of features are expected in a selection (i.e. less than the value specified by SelectionFilterSize in serverconfig.ini/webconfig.ini), MgSelectionBase::GenerateFilter() can still be safely used to return correct results. |
| 55 | Code that currently calls MgSelectionBase::GenerateFilter() should be updated to use MgSelectionBase::GenerateFilters() instead, and the caller will be required to process all the filters in the collection to correctly query the complete selection set. |
| 56 | |
| 57 | PHP code example using existing MgSelectionBase::GenerateFilter() API |
| 58 | {{{ |
| 59 | $filter = $sel->GenerateFilter($selLayer, $featureClassName); |
| 60 | |
| 61 | $query = new MgFeatureQueryOptions(); |
| 62 | $query->SetFilter($filter); |
| 63 | |
| 64 | $featureSource = new MgResourceIdentifier($selLayer->GetFeatureSourceId()); |
| 65 | $features = $featureSrvc->SelectFeatures($featureSource, $featureClassName, $query); |
| 66 | if($features->ReadNext()) |
| 67 | { |
| 68 | do |
| 69 | { |
| 70 | AddFeatureToCollection($features->GetGeometry()); |
| 71 | } |
| 72 | while($features->ReadNext()); |
| 73 | $features->Close(); |
| 74 | } |
| 75 | }}} |
| 76 | |
| 77 | PHP code example using NEW MgSelectionBase::GenerateFilters() API |
| 78 | {{{ |
| 79 | $filterCollection = $sel->GenerateFilters($selLayer, $featureClassName, GetMaxSelectionSize()); |
| 80 | |
| 81 | for ($filterIndex = 0; $filterIndex < $filterCollection->GetCount(), $filterIndex++) |
| 82 | { |
| 83 | $query = new MgFeatureQueryOptions(); |
| 84 | $query->SetFilter($filterCollection->GetItem($filterIndex)); |
| 85 | |
| 86 | $featureSource = new MgResourceIdentifier($selLayer->GetFeatureSourceId()); |
| 87 | $features = $featureSrvc->SelectFeatures($featureSource, $featureClassName, $query); |
| 88 | if($features->ReadNext()) |
| 89 | { |
| 90 | do |
| 91 | { |
| 92 | AddFeatureToCollection($features->GetGeometry()); |
| 93 | } |
| 94 | while($features->ReadNext()); |
| 95 | $features->Close(); |
| 96 | } |
| 97 | } |
| 98 | }}} |
| 99 | |
| 100 | In places where a relatively small number of features are expected in a selection (i.e. less than the value specified by SelectionFilterSize in serverconfig.ini/webconfig.ini), MgSelectionBase::GenerateFilter() can still be safely used to return correct results. |