Polygons for reverse geocoding
Polygons for reverse geocoding
Combine Additional Data Provider queries with Reverse Geocoding queries to obtain extra data about specific
entity Type like:
-
Country
-
CountrySubdivision
-
CountrySecondarySubdivision
-
CountryTertiarySubdivision
-
Municipality
-
MunicipalitySubdivision
-
Neighbourhood
-
PostalCodeArea
Sample use case: You want to display Country or Municipality boundaries.
Use the code below to try this in your app:
Create TTReverseGeocoderQuery with the entityType parameter and use reverse geocoder search.
_
let query = TTReverseGeocoderQueryBuilder.create(with: coordinate).withEntityType(entityType)
.build()
reverseGeocoder.reverseGeocoder(with: query)
TTReverseGeocoderQuery *query = [[[TTReverseGeocoderQueryBuilder createWithCLLocationCoordinate2D:coordinate] withEntityType:self.entityType] build];
[self.reverseGeocoder reverseGeocoderWithQuery:query];
Get TTGeometryDataSource object from response.
_
guard let address = response.result.addresses.first else { return }
guard let additionalDataSources = address.additionalDataSources else { return }
guard let geometryDataSource = additionalDataSources.geometryDataSource else { return }
- (TTGeometryDataSource *_Nullable)geometryDataSourceFromResponse:(TTReverseGeocoderResponse *)response {
if (response.result.addresses.firstObject != nil) {
TTReverseGeocoderFullAddress *addressValue = [TTReverseGeocoderFullAddress alloc];
addressValue = response.result.addresses.firstObject;
if (addressValue.additionalDataSources) {
TTAdditionalDataSources *additionalDataSources = [TTAdditionalDataSources alloc];
additionalDataSources = addressValue.additionalDataSources;
if (additionalDataSources.geometryDataSource) {
return additionalDataSources.geometryDataSource;
}
}
}
return nil;
}
Use the TTAdditionalDataSearchQuery object for sending requests with the TTGeometryDataSource object supported by Additional Data API.
_
let query = TTAdditionalDataSearchQueryBuilder.create(with: geometryDataSource).build()
searchAdditionalData.additionalDataSearch(with: query)
if ([self geometryDataSourceFromResponse:response] != nil) {
TTAdditionalDataSearchQuery *query = [[TTAdditionalDataSearchQueryBuilder createWithDataSource:[self geometryDataSourceFromResponse:response]] build];
[_searchAdditionalData additionalDataSearchWithQuery:query];
}
Sample views utilizing entities retrieved by combining both services:
![]() Boundaries for selected country |
![]() Boundaries for selected municipality |