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.
32 33 34 35 36 37 38 39 |
# File 'lib/urban-mapping-api.rb', line 32 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.
27 28 29 |
# File 'lib/urban-mapping-api.rb', line 27 def api_key @api_key end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
27 28 29 |
# File 'lib/urban-mapping-api.rb', line 27 def @options end |
#shared_secret ⇒ Object (readonly)
Returns the value of attribute shared_secret.
27 28 29 |
# File 'lib/urban-mapping-api.rb', line 27 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.
54 55 56 |
# File 'lib/urban-mapping-api.rb', line 54 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.
97 98 99 |
# File 'lib/urban-mapping-api.rb', line 97 def get_neighborhood_detail(id) perform('getNeighborhoodDetail', :neighborhoodId => id) end |
#get_neighborhood_relationships(id) ⇒ Object
Returns neighborhood relationship attributes for the requested neighborhood ID.
102 103 104 |
# File 'lib/urban-mapping-api.rb', line 102 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.
72 73 74 75 76 77 |
# File 'lib/urban-mapping-api.rb', line 72 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.
80 81 82 83 84 |
# File 'lib/urban-mapping-api.rb', line 80 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.
61 62 63 64 65 66 |
# File 'lib/urban-mapping-api.rb', line 61 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.
48 49 50 |
# File 'lib/urban-mapping-api.rb', line 48 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.
92 93 94 |
# File 'lib/urban-mapping-api.rb', line 92 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.
87 88 89 |
# File 'lib/urban-mapping-api.rb', line 87 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.
42 43 44 |
# File 'lib/urban-mapping-api.rb', line 42 def premium_api? !shared_secret.nil? end |