Sha256: 9ce39eb8d39490a4ac2dbf479121e3bbaa87c5631f9e946a702057c5dac24bed
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
module Graticule module Geocoder # Library for looking up coordinates with MetaCarta's GeoParser API. # # http://labs.metacarta.com/GeoParser/documentation.html class MetaCarta < Rest def initialize # :nodoc: @url = URI.parse 'http://labs.metacarta.com/GeoParser/' end # Finds +location+ and returns a Location object. def locate(location) get :q => location.is_a?(String) ? location : location_from_params(location).to_s end private def check_error(xml) # :nodoc: raise AddressError, 'bad location' unless xml.elements['Locations/Location'] end def make_url(params) # :nodoc: params[:output] = 'locations' super params end def parse_response(xml) # :nodoc: result = xml.elements['/Locations/Location[1]'] coords = result.elements['Centroid/gml:Point/gml:coordinates'].text.split ',' Location.new :latitude => coords.first.to_f, :longitude => coords.last.to_f end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
graticule-0.2.0 | lib/graticule/geocoder/meta_carta.rb |
graticule-0.2.1 | lib/graticule/geocoder/meta_carta.rb |
graticule-0.2.2 | lib/graticule/geocoder/meta_carta.rb |