|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwinterwell.jgeoplanet.GeoPlanet
public class GeoPlanet
Java client library for the Yahoo! GeoPlanet service as described at: http://developer.yahoo.com/geo/geoplanet/
All applications require a valid application ID. These can be obtained from: http://developer.yahoo.com/wsregapp/. The application ID is checked when you construct a GeoPlanet object. This requires network access.
Example:
String mySecretAppId = "abc123"; WhereOnEarth woe = new WhereOnEarth(mySecretAppId); Place earth = woe.get(1); List<Place> countries = earth.getChildren().type("Country").get();
Spatial entities provided by Yahoo! GeoPlanet are referenced by a 32-bit identifier: the Where On Earth ID (WOEID). WOEIDs are unique and non-repetitive, and are assigned to all entities within the system. A WOEID, once assigned, is never changed or recycled. If a WOEID is deprecated it is mapped to its successor or parent WOEID, so that requests to the service using a deprecated WOEID are served transparently.
Field Summary | |
---|---|
static java.lang.String |
appIdUrl
|
static java.lang.String |
defaultLanguage
Default language for convenience constructors. |
static java.lang.String |
defaultServiceUri
Default serviceURI (the Yahoo! implementation) for convenience constructors. |
Constructor Summary | |
---|---|
GeoPlanet(java.lang.String appId)
Convenience constructor for English language GeoPlanet applications. |
|
GeoPlanet(java.lang.String appId,
java.lang.String language)
Create a client for the GeoPlanet service using the specified application ID and language. |
|
GeoPlanet(java.lang.String appId,
java.lang.String language,
java.lang.String serviceUri)
Create a client for the GeoPlanet service using the specified application ID, language and service URI. |
Method Summary | |
---|---|
java.lang.String |
getApplicationId()
Return the Yahoo! application ID used by this client. |
java.lang.String |
getLanguage()
Returns the language used by this client such as "en-gb". |
Place |
getPlace(long woeId)
|
Place |
getPlace(java.lang.String query)
Returns the first Place whose name matches the query
to some extent. |
PlaceCollection |
getPlaces(java.lang.String query)
Returns a PlaceCollection of places whose names match the query
to some extent. |
PlaceType |
getPlaceType(int placeTypeCode)
Look up a PlaceType by code. |
PlaceType |
getPlaceType(java.lang.String placeTypeName)
Look up a PlaceType by name. |
java.util.Collection<PlaceType> |
getPlaceTypes()
|
java.lang.String |
getServiceUri()
Returns the base URI used by the client e.g. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static java.lang.String appIdUrl
public static final java.lang.String defaultServiceUri
public static final java.lang.String defaultLanguage
Constructor Detail |
---|
public GeoPlanet(java.lang.String appId) throws GeoPlanetException
GeoPlanetException
GeoPlanet(String, String, String)
public GeoPlanet(java.lang.String appId, java.lang.String language) throws GeoPlanetException
appId
- your application IDlanguage
- code for the language to use
GeoPlanetException
GeoPlanet(String, String, String)
public GeoPlanet(java.lang.String appId, java.lang.String language, java.lang.String serviceUri) throws GeoPlanetException
appId
- your application IDlanguage
- code for the language to useserviceUri
- base URI for GeoPlanet requests
GeoPlanetException
Method Detail |
---|
public java.lang.String getApplicationId()
public java.lang.String getLanguage()
public java.lang.String getServiceUri()
public Place getPlace(long woeId) throws GeoPlanetException
PlaceNotFoundException
- if the ID is invalid
GeoPlanetException
- for general errorspublic Place getPlace(java.lang.String query) throws GeoPlanetException
Place
whose name matches the query
to some extent.
Roughly equivalent to calling getPlaces(String).get(0)
except that it throws a PlaceNotFoundException
if
there were no matching places.
PlaceNotFoundException
- if there are no matches for the query
GeoPlanetException
- on general errorspublic PlaceCollection getPlaces(java.lang.String query)
PlaceCollection
of places whose names match the query
to some extent.
The query may include an country code to adjust the ordering
e.g. getPlaces("Edinburgh, UK")
vs. getPlaces("Edinburgh, USA")
PlaceCollection
of places matching the querypublic java.util.Collection<PlaceType> getPlaceTypes()
public PlaceType getPlaceType(java.lang.String placeTypeName) throws InvalidPlaceType
InvalidPlaceType
- if the name is invalidpublic PlaceType getPlaceType(int placeTypeCode) throws InvalidPlaceType
placeTypeCode
- a valid place type code
InvalidPlaceType
- if the code is invalidpublic java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |