geo_pack
Geo related services.
Usage
First create an instance passing the configuration file path to the constructor:
geo_pack = GeoPack.new("config.yml")
The configuration file contains this structure:
urbanmapping:
neighborhoods_apikey: jwncnt4vgs8xarc7pvap2ra7
secret: RRGxwfEn
zillow:
zwsid: X1-ZW3mlz1cqh8sej_1y8f9
Now you can transform an address into a normalized address with its coordinates, neighborhood with its coordinates/bounding box, city and state like this:
geo_pack.get_location("2114 bigelow Avenue , seattle")
=>
{
:state => { :name => "WA"},
:city => { :name => "Seattle"},
:neighborhood => { :name=>"Queen Anne", :geom=>[[47.617989, -122.378464], [47.656792, -122.34182]]},
:address => { :name => "2114 Bigelow Ave N, Seattle, WA 98109, USA", :geom => [47.637936, -122.34813]}
}
The address passed to get_location is strong enough to support weakly specified addresses. For example we can search just by zip code:
geo_pack.get_location("90210")
=>
{
:state=>{:name=>"CA"},
:city=>{:name=>"Beverly Hills"},
:neighborhood=>{:geom=>[[34.088879, -118.43866], [34.129559, -118.373741]], :name=>"Beverly Crest"},
:address=>{:geom=>[34.1030032, -118.4104684], :name=>"Beverly Hills, CA 90210, USA"}
}
If the address could not be found an empty hash will be returned:
geo_pack.get_location("supercalifragilisticexpialidocious address")
=>
{}
The neighborhood search, which uses an extra stack of api services, can be excluded if you don't need it and want faster results:
geo_pack.get_location("90210", :exclude => :neighborhood)
=>
{
:state=>{:name=>"CA"},
:city=>{:name=>"Beverly Hills"},
:address=>{:geom=>[34.1030032, -118.4104684], :name=>"Beverly Hills, CA 90210, USA"}
}
Zillow lookups are also supported:
geo_pack.get_property_details("2114 Bigelow, seattle")
=>
{
:error=>false,
:data=> {
:year_built=>1920,
:housing_type=>"house",
:square_footage=>"3470"
},
:message=>"Request successfully processed"
}
In case of error you'll get:
geo_pack.get_property_details("Somewhere")
=>
{
:error=>true,
:data=>{},
:message=>"Error: no exact match found for input address"
}