Sha256: 79e59506ea3937003915bb14c9d071aef00da0132af5f34ab150c98fd4f6c770
Contents?: true
Size: 983 Bytes
Versions: 6
Compression:
Stored size: 983 Bytes
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, :output => 'locations' end private def check_error(xml) # :nodoc: raise AddressError, 'bad location' unless xml.elements['Locations/Location'] end def parse_response(parse_type, 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
6 entries across 6 versions & 2 rubygems