geocodeReverseGet method
Fetches the Reverse Geocode data from the given sources
and using
settings layers
, and returns the entire geojson
GeoJsonFeatureCollection containing the data.
GeoJsonFeatureCollection -> GeoJsonFeatureCollection.features is a list of GeoJsonFeatures whose GeoJsonFeature.properties have all the information about the result of the reverse geocoding.
Information about the endpoint, parameters, response etc. can be found at:
https://openrouteservice.org/dev/#/api-docs/geocode/reverse/get
https://github.com/pelias/documentation/blob/master/reverse.md#reverse-geocoding
Implementation
Future<GeoJsonFeatureCollection> geocodeReverseGet({
required ORSCoordinate point,
double boundaryCircleRadius = 1,
int size = 10,
List<String> layers = const <String>[],
List<String>? sources,
String? boundaryCountry,
}) async {
// Form Input from parameters.
sources ??= geocodeSourcesAvailable.toList();
final String sourcesString = _validateAndJoinList(
inputArr: sources,
availableIterable: geocodeSourcesAvailable,
);
final String layersString = _validateAndJoinList(
inputArr: layers,
availableIterable: geocodeLayersAvailable,
);
String getURIString =
'$_geocodeEndpointURL/reverse?api_key=$_apiKey&sources=$sourcesString';
if (layersString.isNotEmpty) {
getURIString += '&layers=$layersString';
}
if (boundaryCountry != null) {
getURIString += '&boundary.country=$boundaryCountry';
}
getURIString += '&point.lon=${point.longitude}&point.lat=${point.latitude}';
getURIString += '&boundary.circle.radius=$boundaryCircleRadius';
getURIString += '&size=$size';
// Build the request URL.
final Uri uri = Uri.parse(getURIString);
final Map<String, dynamic> data = await _openRouteServiceGet(uri: uri);
return GeoJsonFeatureCollection.fromJson(data);
}