Package org.codice.ddf.spatial.geocoding
Interface GeoEntryQueryable
public interface GeoEntryQueryable
A
GeoEntryQueryable provides methods for querying a resource containing GeoNames data.-
Method Summary
Modifier and TypeMethodDescriptiongetCountryCode(String wktLocation, int radius) Retrieves the country code for the the area defined bywktLocationin a distance of up toradiusfrom the coordinate searched.getNearestCities(String location, int radiusInKm, int maxResults) Retrieves the cities withinradiusInKmkilometers ofmetacard, sorted by population in descending order.getSuggestedNames(String queryString, int maxResults) Retrieves auto-complete suggestions based on a partial or full wordqueryStringRetrieves the top results for the given query up tomaxResultsresults.Retrieves theGeoEntrycorresponding to the supplied identifier.
-
Method Details
-
query
Retrieves the top results for the given query up tomaxResultsresults.- Parameters:
queryString- aStringcontaining search termsmaxResults- the maximum number of results to return- Returns:
- the top results for the query in descending order of relevance, or an empty
Listif no results are found - Throws:
IllegalArgumentException- ifqueryStringis null or empty, or ifmaxResultsis not a positive integerGeoEntryQueryException- if an exception occurs while querying the GeoNames resource
-
queryById
Retrieves theGeoEntrycorresponding to the supplied identifier.Suggestionids may be passed to this method to retrieve the GeoEntry for a specific suggestion.- Parameters:
id-Stringidentifier used to retrieve a specificGeoEntry- Returns:
GeoEntrymatching the identifier supplied or null if not found- Throws:
IllegalArgumentException- ifidis null or emptyGeoEntryQueryException- if an exception occurs while querying the GeoNames resource
-
getSuggestedNames
List<Suggestion> getSuggestedNames(String queryString, int maxResults) throws GeoEntryQueryException Retrieves auto-complete suggestions based on a partial or full wordqueryString- Parameters:
queryString- a partial or full search phrasemaxResults- the maximum number of results to return- Returns:
- List of
Suggestioncorresponding toqueryString - Throws:
GeoEntryQueryException- if an exception occurs while querying the GeoNames resource
-
getNearestCities
List<NearbyLocation> getNearestCities(String location, int radiusInKm, int maxResults) throws ParseException, GeoEntryQueryException Retrieves the cities withinradiusInKmkilometers ofmetacard, sorted by population in descending order.Each result is returned as a
NearbyLocation, which describes the position ofmetacardrelative to the city.- Parameters:
location- a WKT identifying the area to searchradiusInKm- the search radius, in kilometersmaxResults- the maximum number of results to return- Returns:
- the position of
metacardrelative to each of the nearest cities along with the cities' names, sorted in descending order of population - Throws:
IllegalArgumentException- ifmetacardis null, or ifradiusInKmormaxResultsis not a positive integerGeoEntryQueryException- if an exception occurs while querying the GeoNames resourceParseException- if an exceptions occurs while parsinglocation
-
getCountryCode
Optional<String> getCountryCode(String wktLocation, int radius) throws GeoEntryQueryException, ParseException Retrieves the country code for the the area defined bywktLocationin a distance of up toradiusfrom the coordinate searched.- Parameters:
wktLocation- A WKT locationradius- the radius in kilometers to search from the givenwktLocation- Returns:
- a country code in ISO 3166-1 alpha-3 format or null if not found (for example, a location in the ocean)
- Throws:
GeoEntryQueryExceptionParseException
-