public class GeoNamesQueryLuceneDirectoryIndex extends GeoNamesQueryLuceneIndex
Constructor and Description |
---|
GeoNamesQueryLuceneDirectoryIndex() |
Modifier and Type | Method and Description |
---|---|
protected org.apache.lucene.index.IndexReader |
createIndexReader(org.apache.lucene.store.Directory directory) |
protected org.apache.lucene.search.IndexSearcher |
createIndexSearcher(org.apache.lucene.index.IndexReader indexReader) |
Optional<String> |
getCountryCode(String wktLocation,
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 location,
int radiusInKm,
int maxResults)
Retrieves the cities within
radiusInKm kilometers of metacard , sorted by
population in descending order. |
protected org.apache.lucene.store.Directory |
openDirectory() |
List<GeoEntry> |
query(String queryString,
int maxResults)
Retrieves the top results for the given query up to
maxResults results. |
void |
setIndexLocation(String indexLocation) |
createQuery, doGetCountryCode, doGetNearestCities, doQuery, indexExists
public void setIndexLocation(String indexLocation)
protected org.apache.lucene.store.Directory openDirectory() throws IOException
openDirectory
in class GeoNamesQueryLuceneIndex
IOException
protected org.apache.lucene.index.IndexReader createIndexReader(org.apache.lucene.store.Directory directory) throws IOException
createIndexReader
in class GeoNamesQueryLuceneIndex
IOException
protected org.apache.lucene.search.IndexSearcher createIndexSearcher(org.apache.lucene.index.IndexReader indexReader)
createIndexSearcher
in class GeoNamesQueryLuceneIndex
public List<GeoEntry> query(String queryString, int maxResults) throws GeoEntryQueryException
GeoEntryQueryable
maxResults
results.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 location, 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.
location
- 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 wktLocation, int radius) throws GeoEntryQueryException, ParseException
GeoEntryQueryable
wktLocation
in a distance of up
to radius
from the coordinate searched.wktLocation
- A WKT locationradius
- the radius in kilometers to search from the given wktLocation
GeoEntryQueryException
ParseException
This work is licensed under a Creative Commons Attribution 4.0 International License.