public class GeoNamesWebService extends Object implements GeoEntryQueryable
Constructor and Description |
---|
GeoNamesWebService() |
Modifier and Type | Method and Description |
---|---|
Optional<String> |
getCountryCode(String locationWkt,
int radius)
Retrieves the country code for the the area defined by
wktLocation in a distance of up
to radius from the coordinate searched. |
List<NearbyLocation> |
getNearestCities(String locationWkt,
int radiusInKm,
int maxResults)
Retrieves the cities within
radiusInKm kilometers of metacard , sorted by
population in descending order. |
List<GeoEntry> |
query(String queryString,
int maxResults)
Retrieves the top results for the given query up to
maxResults results. |
public List<GeoEntry> query(String queryString, int maxResults) throws GeoEntryQueryException
GeoEntryQueryable
maxResults
results.query
in interface GeoEntryQueryable
queryString
- a String
containing search termsmaxResults
- the maximum number of results to returnList
if no results are foundGeoEntryQueryException
- if an exception occurs while querying the GeoNames resourcepublic List<NearbyLocation> getNearestCities(String locationWkt, int radiusInKm, int maxResults) throws ParseException, GeoEntryQueryException
GeoEntryQueryable
radiusInKm
kilometers of metacard
, sorted by
population in descending order.
Each result is returned as a NearbyLocation
, which describes the position of metacard
relative to the city.
getNearestCities
in interface GeoEntryQueryable
locationWkt
- a WKT identifying the area to searchradiusInKm
- the search radius, in kilometersmaxResults
- the maximum number of results to returnmetacard
relative to each of the nearest cities along with the
cities' names, sorted in descending order of populationParseException
- if an exceptions occurs while parsing location
GeoEntryQueryException
- if an exception occurs while querying the GeoNames resourcepublic Optional<String> getCountryCode(String locationWkt, int radius)
GeoEntryQueryable
wktLocation
in a distance of up
to radius
from the coordinate searched.getCountryCode
in interface GeoEntryQueryable
locationWkt
- A WKT locationradius
- the radius in kilometers to search from the given wktLocation
This work is licensed under a Creative Commons Attribution 4.0 International License.