Class: UrbanMapping::Interface
Constant Summary collapse
- ENDPOINT =
'http://api1.urbanmapping.com/neighborhoods/rest'
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#shared_secret ⇒ Object
readonly
Returns the value of attribute shared_secret.
Instance Method Summary collapse
-
#get_nearest_neighborhood(latitude, longitude) ⇒ Object
Returns the neighborhood whose centroid is nearest to the requested latitude and longitude within a 20 linear mile range.
-
#get_neighborhood_detail(id) ⇒ Object
Returns neighborhood details for the requested neighborhood ID.
-
#get_neighborhood_relationships(id) ⇒ Object
Returns neighborhood relationship attributes for the requested neighborhood ID.
-
#get_neighborhoods_by_address(street, city, state, country = 'USA') ⇒ Object
This method first geocodes the input address, then returns the geocode and lists neighborhoods containing the point in a single response.
-
#get_neighborhoods_by_city_state_country(city, state, country = 'USA') ⇒ Object
Returns a list of neighborhood for the requested city.
-
#get_neighborhoods_by_extent(southwest_latitude, southwest_longitude, northeast_latitude, northeast_longitude) ⇒ Object
Returns a list of neighborhoods within a bounding box extent defined by southwestern and northeastern corners.
-
#get_neighborhoods_by_lat_lng(latitude, longitude) ⇒ Object
Returns a list of neighborhoods whose boundaries contain the requested latitude and longitude.
-
#get_neighborhoods_by_name(name) ⇒ Object
Returns a list of neighborhoods for the requested neighborhood name.
-
#get_neighborhoods_by_postal_code(postal_code) ⇒ Object
Returns a list of neighborhoods whose areas intersect that of the requested postal code.
-
#initialize(api_key, options = {}) ⇒ Interface
constructor
Create a new instance.
-
#premium_api? ⇒ Boolean
Returns true if a shard_secret was provided to the constructor.
Constructor Details
#initialize(api_key, options = {}) ⇒ Interface
Create a new instance. Requeres an api_key. A shared key needs to be provided for access to premium API methods.
26 27 28 29 30 31 32 33 |
# File 'lib/urban-mapping-api.rb', line 26 def initialize(api_key, = {}) = { :raw => false }.merge() @api_key = api_key @shared_secret = .delete(:shared_secret) @options = end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
21 22 23 |
# File 'lib/urban-mapping-api.rb', line 21 def api_key @api_key end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
21 22 23 |
# File 'lib/urban-mapping-api.rb', line 21 def @options end |
#shared_secret ⇒ Object (readonly)
Returns the value of attribute shared_secret.
21 22 23 |
# File 'lib/urban-mapping-api.rb', line 21 def shared_secret @shared_secret end |
Instance Method Details
#get_nearest_neighborhood(latitude, longitude) ⇒ Object
Returns the neighborhood whose centroid is nearest to the requested latitude and longitude within a 20 linear mile range.
48 49 50 |
# File 'lib/urban-mapping-api.rb', line 48 def get_nearest_neighborhood(latitude, longitude) perform('getNearestNeighborhood', :lat => latitude, :lng => longitude) end |
#get_neighborhood_detail(id) ⇒ Object
Returns neighborhood details for the requested neighborhood ID.
91 92 93 |
# File 'lib/urban-mapping-api.rb', line 91 def get_neighborhood_detail(id) perform('getNeighborhoodDetail', :neighborhoodId => id) end |
#get_neighborhood_relationships(id) ⇒ Object
Returns neighborhood relationship attributes for the requested neighborhood ID.
96 97 98 |
# File 'lib/urban-mapping-api.rb', line 96 def get_neighborhood_relationships(id) perform('getNeighborhoodRelationships', :neighborhoodId => id) end |
#get_neighborhoods_by_address(street, city, state, country = 'USA') ⇒ Object
This method first geocodes the input address, then returns the geocode and lists neighborhoods containing the point in a single response. This is technically executed in a single request, but for the purposes of account administration a single invocation is counted as two calls.
66 67 68 69 70 71 |
# File 'lib/urban-mapping-api.rb', line 66 def get_neighborhoods_by_address(street, city, state, country = 'USA') perform('getNeighborhoodsByAddress', :street => street, :city => city, :state => state, :country => country) end |
#get_neighborhoods_by_city_state_country(city, state, country = 'USA') ⇒ Object
Returns a list of neighborhood for the requested city.
74 75 76 77 78 |
# File 'lib/urban-mapping-api.rb', line 74 def get_neighborhoods_by_city_state_country(city, state, country = 'USA') perform('getNeighborhoodsByCityStateCountry', :city => city, :state => state, :country => country) end |
#get_neighborhoods_by_extent(southwest_latitude, southwest_longitude, northeast_latitude, northeast_longitude) ⇒ Object
Returns a list of neighborhoods within a bounding box extent defined by southwestern and northeastern corners. Note query extents covering more than 45 square miles will be rejected.
55 56 57 58 59 60 |
# File 'lib/urban-mapping-api.rb', line 55 def get_neighborhoods_by_extent(southwest_latitude, southwest_longitude, northeast_latitude, northeast_longitude) perform('getNeighborhoodsByExtent', :swlat => southwest_latitude, :swlng => southwest_longitude, :nelat => northeast_latitude, :nelng => northeast_longitude) end |
#get_neighborhoods_by_lat_lng(latitude, longitude) ⇒ Object
Returns a list of neighborhoods whose boundaries contain the requested latitude and longitude.
42 43 44 |
# File 'lib/urban-mapping-api.rb', line 42 def get_neighborhoods_by_lat_lng(latitude, longitude) perform('getNeighborhoodsByLatLng', :lat => latitude, :lng => longitude) end |
#get_neighborhoods_by_name(name) ⇒ Object
Returns a list of neighborhoods for the requested neighborhood name.
86 87 88 |
# File 'lib/urban-mapping-api.rb', line 86 def get_neighborhoods_by_name(name) perform('getNeighborhoodsByName', :name => name) end |
#get_neighborhoods_by_postal_code(postal_code) ⇒ Object
Returns a list of neighborhoods whose areas intersect that of the requested postal code.
81 82 83 |
# File 'lib/urban-mapping-api.rb', line 81 def get_neighborhoods_by_postal_code(postal_code) perform('getNeighborhoodsByPostalCode', :postalCode => postal_code) end |
#premium_api? ⇒ Boolean
Returns true if a shard_secret was provided to the constructor.
36 37 38 |
# File 'lib/urban-mapping-api.rb', line 36 def premium_api? !shared_secret.nil? end |