public class WebService extends Object
Note : values for some fields are only returned with sufficient Style
. Accessing these fields (admin codes and admin names, elevation,population)
will throw an InsufficientStyleException if the Style was not
sufficient.
| Constructor and Description |
|---|
WebService() |
| Modifier and Type | Method and Description |
|---|---|
static int[] |
astergdem(double[] latitude,
double[] longitude) |
static int |
astergdem(double latitude,
double longitude) |
static ToponymSearchResult |
children(int geonameId,
String language,
Style style)
returns the children in the administrative hierarchy of a toponym.
|
static ToponymSearchResult |
children(int geonameId,
String language,
Style style,
int maxRows) |
static String |
countryCode(double latitude,
double longitude)
The iso country code of any given point.
|
static String |
countryCode(double latitude,
double longitude,
double radius)
The iso country code of any given point with radius for coastal areas.
|
static List<Toponym> |
findNearby(double latitude,
double longitude,
double radius,
FeatureClass featureClass,
String[] featureCodes,
String language,
int maxRows)
Based on the following inforamtion: Webservice Type : REST
api.geonames.org/findNearbyWikipedia?
|
static List<Toponym> |
findNearby(double latitude,
double longitude,
FeatureClass featureClass,
String[] featureCodes) |
static List<Toponym> |
findNearbyPlaceName(double latitude,
double longitude)
convenience method for
findNearbyPlaceName(double,double,double,int) |
static List<Toponym> |
findNearbyPlaceName(double latitude,
double longitude,
double radius,
int maxRows) |
static List<PostalCode> |
findNearbyPostalCodes(PostalCodeSearchCriteria postalCodeSearchCriteria)
returns a list of postal codes
|
static List<StreetSegment> |
findNearbyStreets(double latitude,
double longitude,
double radius) |
static List<StreetSegment> |
findNearbyStreetsOSM(double latitude,
double longitude,
double radius) |
static WeatherObservation |
findNearByWeather(double latitude,
double longitude) |
static List<WikipediaArticle> |
findNearbyWikipedia(double latitude,
double longitude,
double radius,
String language,
int maxRows)
Based on the following inform: Webservice Type : REST
api.geonames.org/findNearbyWikipedia?
|
static List<WikipediaArticle> |
findNearbyWikipedia(double latitude,
double longitude,
String language) |
static Address |
findNearestAddress(double latitude,
double longitude) |
static Intersection |
findNearestIntersection(double latitude,
double longitude) |
static Intersection |
findNearestIntersection(double latitude,
double longitude,
double radius) |
static Toponym |
get(int geoNameId,
String language,
String style) |
static int |
getConnectTimeOut() |
static Style |
getDefaultStyle() |
static String |
getGeoNamesServer() |
static String |
getGeoNamesServerFailover() |
static Proxy |
getProxy() |
static int |
getReadTimeOut() |
static String |
getToken() |
static String |
getUserName() |
static int |
gtopo30(double latitude,
double longitude)
GTOPO30 is a global digital elevation model (DEM) with a horizontal grid
spacing of 30 arc seconds (approximately 1 kilometer).
|
static List<Toponym> |
hierarchy(int geonameId,
String language,
Style style)
returns the hierarchy for a geonameId
|
static boolean |
isAndroid() |
static ToponymSearchResult |
neighbours(int geonameId,
String language,
Style style)
returns the neighbours of a toponym.
|
static String |
ocean(double latitude,
double longitude) |
static List<PostalCode> |
postalCodeSearch(PostalCodeSearchCriteria postalCodeSearchCriteria)
returns a list of postal codes for the given search criteria matching a
full text search on the GeoNames postal codes database.
|
static List<PostalCode> |
postalCodeSearch(String postalCode,
String placeName,
String countryCode)
returns a list of postal codes for the given parameters.
|
static void |
saveTags(String[] tags,
Toponym toponym,
String username,
String password) |
static ToponymSearchResult |
search(String q,
String countryCode,
String name,
String[] featureCodes,
int startRow)
convenience method for
search(ToponymSearchCriteria) |
static ToponymSearchResult |
search(String q,
String countryCode,
String name,
String[] featureCodes,
int startRow,
String language,
Style style,
String exactName)
convenience method for
search(ToponymSearchCriteria)
The string fields will be transparently utf8 encoded within the call. |
static ToponymSearchResult |
search(ToponymSearchCriteria searchCriteria)
full text search on the GeoNames database.
|
static void |
setConnectTimeOut(int connectTimeOut) |
static void |
setDefaultStyle(Style defaultStyle) |
static void |
setGeoNamesServer(String pGeoNamesServer)
sets the server name for the GeoNames server to be used for the requests.
|
static void |
setGeoNamesServerFailover(String geoNamesServerFailover)
sets the default failover server for requests in case the main server is
not accessible.
|
static void |
setProxy(Proxy proxy) |
static void |
setReadTimeOut(int readTimeOut) |
static void |
setToken(String token)
sets the token to be used to authenticate the requests.
|
static void |
setUserName(String userName)
Sets the user name to be used for the requests.
|
static int[] |
srtm3(double[] latitude,
double[] longitude) |
static int |
srtm3(double latitude,
double longitude)
Shuttle Radar Topography Mission (SRTM) elevation data.
|
static Timezone |
timezone(double latitude,
double longitude)
get the timezone for a given location
|
static WeatherObservation |
weatherIcao(String icaoCode) |
static List<WikipediaArticle> |
wikipediaSearch(String q,
String language)
full text search on geolocated wikipedia articles.
|
static List<WikipediaArticle> |
wikipediaSearchForTitle(String title,
String language)
full text search on geolocated wikipedia articles.
|
public WebService()
public static boolean isAndroid()
public static List<PostalCode> postalCodeSearch(String postalCode, String placeName, String countryCode) throws Exception
postalCode - placeName - countryCode - Exceptionpublic static List<PostalCode> postalCodeSearch(PostalCodeSearchCriteria postalCodeSearchCriteria) throws Exception
postalCodeSearchCriteria - Exceptionpublic static List<PostalCode> findNearbyPostalCodes(PostalCodeSearchCriteria postalCodeSearchCriteria) throws Exception
postalCodeSearchCriteria - Exceptionpublic static List<Toponym> findNearbyPlaceName(double latitude, double longitude) throws IOException, Exception
findNearbyPlaceName(double,double,double,int)latitude - longitude - IOExceptionExceptionpublic static List<Toponym> findNearbyPlaceName(double latitude, double longitude, double radius, int maxRows) throws IOException, Exception
IOExceptionExceptionpublic static List<Toponym> findNearby(double latitude, double longitude, FeatureClass featureClass, String[] featureCodes) throws IOException, Exception
IOExceptionExceptionpublic static List<Toponym> findNearby(double latitude, double longitude, double radius, FeatureClass featureClass, String[] featureCodes, String language, int maxRows) throws IOException, Exception
IOExceptionExceptionpublic static Toponym get(int geoNameId, String language, String style) throws IOException, Exception
geoNameId - language - - optionalstyle - - optionalIOExceptionExceptionpublic static Address findNearestAddress(double latitude, double longitude) throws IOException, Exception
IOExceptionExceptionpublic static Intersection findNearestIntersection(double latitude, double longitude) throws Exception
Exceptionpublic static Intersection findNearestIntersection(double latitude, double longitude, double radius) throws Exception
Exceptionpublic static List<StreetSegment> findNearbyStreets(double latitude, double longitude, double radius) throws Exception
latitude - longitude - radius - Exceptionpublic static List<StreetSegment> findNearbyStreetsOSM(double latitude, double longitude, double radius) throws Exception
Exceptionpublic static ToponymSearchResult search(String q, String countryCode, String name, String[] featureCodes, int startRow) throws Exception
search(ToponymSearchCriteria)q - countryCode - name - featureCodes - startRow - Exceptionpublic static ToponymSearchResult search(String q, String countryCode, String name, String[] featureCodes, int startRow, String language, Style style, String exactName) throws Exception
search(ToponymSearchCriteria)
The string fields will be transparently utf8 encoded within the call.q - search over all fieldscountryCode - name - search over name onlyfeatureCodes - startRow - language - style - exactName - Exceptionpublic static ToponymSearchResult search(ToponymSearchCriteria searchCriteria) throws Exception
searchCriteria - Exception
ToponymSearchCriteria searchCriteria = new ToponymSearchCriteria();
searchCriteria.setQ("zürich");
ToponymSearchResult searchResult = WebService.search(searchCriteria);
for (Toponym toponym : searchResult.toponyms) {
System.out.println(toponym.getName() + " " + toponym.getCountryName());
}
public static ToponymSearchResult children(int geonameId, String language, Style style) throws Exception
geonameId - language - style - Exceptionpublic static ToponymSearchResult children(int geonameId, String language, Style style, int maxRows) throws Exception
geonameId - language - style - maxRows - Exceptionpublic static ToponymSearchResult neighbours(int geonameId, String language, Style style) throws Exception
geonameId - language - style - Exceptionpublic static List<Toponym> hierarchy(int geonameId, String language, Style style) throws Exception
geonameId - language - style - Exceptionpublic static void saveTags(String[] tags, Toponym toponym, String username, String password) throws Exception
Exceptionpublic static List<WikipediaArticle> wikipediaSearch(String q, String language) throws Exception
q - language - Exceptionpublic static List<WikipediaArticle> wikipediaSearchForTitle(String title, String language) throws Exception
title - language - Exceptionpublic static List<WikipediaArticle> findNearbyWikipedia(double latitude, double longitude, String language) throws Exception
Exceptionpublic static List<WikipediaArticle> findNearbyWikipedia(double latitude, double longitude, double radius, String language, int maxRows) throws Exception
Exceptionpublic static int gtopo30(double latitude, double longitude) throws IOException, GeoNamesException
latitude - longitude - IOExceptionGeoNamesExceptionpublic static int srtm3(double latitude, double longitude) throws IOException, GeoNamesException
latitude - longitude - IOExceptionGeoNamesExceptionpublic static int[] srtm3(double[] latitude, double[] longitude) throws IOException
IOExceptionpublic static int astergdem(double latitude, double longitude) throws IOException, GeoNamesException
IOExceptionGeoNamesExceptionpublic static int[] astergdem(double[] latitude, double[] longitude) throws IOException
IOExceptionpublic static String countryCode(double latitude, double longitude) throws IOException, GeoNamesException
countryCode(double, double, double) with radius=0.0latitude - longitude - IOExceptionGeoNamesExceptionpublic static String countryCode(double latitude, double longitude, double radius) throws IOException, GeoNamesException
latitude - longitude - radius - IOExceptionGeoNamesExceptionpublic static Timezone timezone(double latitude, double longitude) throws IOException, Exception
latitude - longitude - IOExceptionExceptionpublic static String ocean(double latitude, double longitude) throws IOException, Exception
IOExceptionExceptionpublic static WeatherObservation findNearByWeather(double latitude, double longitude) throws IOException, Exception
latitude - longitude - IOExceptionExceptionpublic static WeatherObservation weatherIcao(String icaoCode) throws IOException, Exception
IOExceptionExceptionpublic static String getGeoNamesServer()
public static String getGeoNamesServerFailover()
public static void setGeoNamesServer(String pGeoNamesServer)
geoNamesServer - the geonamesServer to setpublic static void setGeoNamesServerFailover(String geoNamesServerFailover)
geoNamesServerFailover - the geoNamesServerFailover to setpublic static void setProxy(Proxy proxy)
proxy - the proxy to set
If you are behind a proxy and cannot change the java system
properties, you can use this method to set a proxy. You define
it like this:
java.net.SocketAddress sa = new java.net.InetSocketAddress("myproxyserver", 8080);
java.net.Proxy proxy = new java.net.Proxy(java.net.Proxy.Type.HTTP, sa);
public static String getUserName()
public static void setUserName(String userName)
userName - the userName to setpublic static void setToken(String token)
token - the token to setpublic static Style getDefaultStyle()
public static void setDefaultStyle(Style defaultStyle)
defaultStyle - the defaultStyle to setpublic static int getReadTimeOut()
public static void setReadTimeOut(int readTimeOut)
readTimeOut - the readTimeOut to setpublic static int getConnectTimeOut()
public static void setConnectTimeOut(int connectTimeOut)
connectTimeOut - the connectTimeOut to set