Skip to content

Instantly share code, notes, and snippets.

@axeda
Created July 26, 2011 14:29
Show Gist options
  • Save axeda/1106893 to your computer and use it in GitHub Desktop.
Save axeda/1106893 to your computer and use it in GitHub Desktop.
MobileLocation Object script
import groovyx.net.http.RESTClient
String rmdHostname = "http://ws.geonames.org";
if (mobileLocation != null)
{
rmd = new RESTClient(rmdHostname);
try {
def resp = rmd.get( path: 'findNearestAddress',
query:[lat:mobileLocation.lat , lng:mobileLocation.lng] )
streetnum = resp.data.address.streetNumber.text()
street = resp.data.address.street.text()
town = resp.data.address.adminName2.text()
state = resp.data.address.adminCode1.text()
postalcode = resp.data.address.postalcode.text()
return streetnum + " " + street + " " + town + " " + state + " " + postalcode
} catch (groovyx.net.http.HttpResponseException e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment