Package com.example.rocket_launch
Class NominatimGeocode
java.lang.Object
com.example.rocket_launch.NominatimGeocode
Class that takes an address, passes it into a 3rd party API: NominatimGeocode
To get a JSON file to derive lat-long coordinates for osmdroid implementation
uses OkHttp to handle url and Nominatim integration
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongeocodeAddress(String address) Gets a JSON file from an address through NominatimGeocodeorg.osmdroid.util.GeoPointgetLatLongFromJson(String jsonResponse) Get the latitude and longitude values from the JSON file and create a GeoPoint
-
Constructor Details
-
NominatimGeocode
public NominatimGeocode()
-
-
Method Details
-
geocodeAddress
Gets a JSON file from an address through NominatimGeocode- Parameters:
address- address that will be geocoded- Returns:
- a responseBody (JSON file response from 3rd party)
- Throws:
IOException- exception if the responseBody is null, or an unexpected value
-
getLatLongFromJson
public org.osmdroid.util.GeoPoint getLatLongFromJson(String jsonResponse) throws org.json.JSONException Get the latitude and longitude values from the JSON file and create a GeoPoint- Parameters:
jsonResponse- JSON file containing an array of best matching results for an address- Returns:
- a GeoPoint object for an address
- Throws:
org.json.JSONException- if GeoPoint can not be made from JSON file, set to a default start point
-