Created
March 31, 2013 16:38
-
-
Save FranckSilvestre/5281208 to your computer and use it in GitHub Desktop.
OpenStreetMap search with Groovy HTTPBuilder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package osm | |
import groovyx.net.http.ContentType | |
import groovyx.net.http.HTTPBuilder | |
import groovyx.net.http.Method | |
/** | |
* | |
* @author franck Silvestre | |
*/ | |
class OSMSearchTest extends GroovyTestCase { | |
void testConnectionXMLOpenStreetMap() { | |
def status = "success" | |
def http = new HTTPBuilder("http://nominatim.openstreetmap.org/") | |
http.request(Method.GET, ContentType.XML) { | |
uri.path = 'search?q=135+pilkington+avenue,+birmingham&format=xml&polygon=1&addressdetails=1' | |
response.success = { resp, searchresults -> println ">>>>> ${searchresults.place.country.text()}" } | |
// handler for any failure status code: | |
response.failure = { resp -> | |
println "Unexpected error: ${resp.statusLine.statusCode} : ${resp.statusLine.reasonPhrase}" | |
status = "failure" | |
} | |
} | |
status | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment