yannski-geokit 1.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt ADDED
@@ -0,0 +1,22 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.markdown
4
+ Rakefile
5
+ geokit.gemspec
6
+ lib/geokit.rb
7
+ lib/geokit/geocoders.rb
8
+ lib/geokit/mappable.rb
9
+ test/test_base_geocoder.rb
10
+ test/test_bounds.rb
11
+ test/test_ca_geocoder.rb
12
+ test/test_fakegeocoder.rb
13
+ test/test_geoloc.rb
14
+ test/test_geoplugin_geocoder.rb
15
+ test/test_google_geocoder.rb
16
+ test/test_google_reverse_geocoder.rb
17
+ test/test_inflector.rb
18
+ test/test_ipgeocoder.rb
19
+ test/test_latlng.rb
20
+ test/test_multi_geocoder.rb
21
+ test/test_us_geocoder.rb
22
+ test/test_yahoo_geocoder.rb
data/README.markdown ADDED
@@ -0,0 +1,189 @@
1
+ ## GEOKIT GEM DESCRIPTION
2
+
3
+ The Geokit gem provides:
4
+
5
+ * Distance calculations between two points on the earth. Calculate the distance in miles, kilometers, or nautical miles, with all the trigonometry abstracted away by GeoKit.
6
+ * Geocoding from multiple providers. It supports Google, Yahoo, Geocoder.us, and Geocoder.ca geocoders, and others. It provides a uniform response structure from all of them.
7
+ It also provides a fail-over mechanism, in case your input fails to geocode in one service.
8
+ * Rectangular bounds calculations: is a point within a given rectangular bounds?
9
+ * Heading and midpoint calculations
10
+
11
+ Combine this gem with the [geokit-rails plugin](http://github.com/andre/geokit-rails/tree/master) to get location-based finders for your Rails app.
12
+
13
+ * Geokit Documentation at Rubyforge [http://geokit.rubyforge.org](http://geokit.rubyforge.org).
14
+ * Repository at Github: [http://github.com/andre/geokit-gem/tree/master](http://github.com/andre/geokit-gem/tree/master).
15
+ * Follow the Google Group for updates and discussion on Geokit: [http://groups.google.com/group/geokit](http://groups.google.com/group/geokit)
16
+
17
+ ## INSTALL
18
+
19
+ sudo gem install geokit
20
+
21
+ ## QUICK START
22
+
23
+ irb> require 'rubygems'
24
+ irb> require 'geokit'
25
+ irb> a=Geokit::Geocoders::YahooGeocoder.geocode '140 Market St, San Francisco, CA'
26
+ irb> a.ll
27
+ => 37.79363,-122.396116
28
+ irb> b=Geokit::Geocoders::YahooGeocoder.geocode '789 Geary St, San Francisco, CA'
29
+ irb> b.ll
30
+ => 37.786217,-122.41619
31
+ irb> a.distance_to(b)
32
+ => 1.21120007413626
33
+ irb> a.heading_to(b)
34
+ => 244.959832435678
35
+ irb(main):006:0> c=a.midpoint_to(b) # what's halfway from a to b?
36
+ irb> c.ll
37
+ => "37.7899239257175,-122.406153503469"
38
+ irb(main):008:0> d=c.endpoint(90,10) # what's 10 miles to the east of c?
39
+ irb> d.ll
40
+ => "37.7897825005142,-122.223214776155"
41
+
42
+ FYI, that `.ll` method means "latitude longitude".
43
+
44
+ See the RDOC more more ... there are also operations on rectangular bounds (e.g., determining if a point is within bounds, find the center, etc).
45
+
46
+ ## CONFIGURATION
47
+
48
+ If you're using this gem by itself, here are the configuration options:
49
+
50
+ # These defaults are used in Geokit::Mappable.distance_to and in acts_as_mappable
51
+ Geokit::default_units = :miles
52
+ Geokit::default_formula = :sphere
53
+
54
+ # This is the timeout value in seconds to be used for calls to the geocoder web
55
+ # services. For no timeout at all, comment out the setting. The timeout unit
56
+ # is in seconds.
57
+ Geokit::Geocoders::timeout = 3
58
+
59
+ # These settings are used if web service calls must be routed through a proxy.
60
+ # These setting can be nil if not needed, otherwise, addr and port must be
61
+ # filled in at a minimum. If the proxy requires authentication, the username
62
+ # and password can be provided as well.
63
+ Geokit::Geocoders::proxy_addr = nil
64
+ Geokit::Geocoders::proxy_port = nil
65
+ Geokit::Geocoders::proxy_user = nil
66
+ Geokit::Geocoders::proxy_pass = nil
67
+
68
+ # This is your yahoo application key for the Yahoo Geocoder.
69
+ # See http://developer.yahoo.com/faq/index.html#appid
70
+ # and http://developer.yahoo.com/maps/rest/V1/geocode.html
71
+ Geokit::Geocoders::yahoo = 'REPLACE_WITH_YOUR_YAHOO_KEY'
72
+
73
+ # This is your Google Maps geocoder key.
74
+ # See http://www.google.com/apis/maps/signup.html
75
+ # and http://www.google.com/apis/maps/documentation/#Geocoding_Examples
76
+ Geokit::Geocoders::google = 'REPLACE_WITH_YOUR_GOOGLE_KEY'
77
+
78
+ # This is your username and password for geocoder.us.
79
+ # To use the free service, the value can be set to nil or false. For
80
+ # usage tied to an account, the value should be set to username:password.
81
+ # See http://geocoder.us
82
+ # and http://geocoder.us/user/signup
83
+ Geokit::Geocoders::geocoder_us = false
84
+
85
+ # This is your authorization key for geocoder.ca.
86
+ # To use the free service, the value can be set to nil or false. For
87
+ # usage tied to an account, set the value to the key obtained from
88
+ # Geocoder.ca.
89
+ # See http://geocoder.ca
90
+ # and http://geocoder.ca/?register=1
91
+ Geokit::Geocoders::geocoder_ca = false
92
+
93
+ # This is the order in which the geocoders are called in a failover scenario
94
+ # If you only want to use a single geocoder, put a single symbol in the array.
95
+ # Valid symbols are :google, :yahoo, :us, and :ca.
96
+ # Be aware that there are Terms of Use restrictions on how you can use the
97
+ # various geocoders. Make sure you read up on relevant Terms of Use for each
98
+ # geocoder you are going to use.
99
+ Geokit::Geocoders::provider_order = [:google,:us]
100
+
101
+ If you're using this gem with the [geokit-rails plugin](http://github.com/andre/geokit-rails/tree/master), the plugin
102
+ creates a template with these settings and places it in `config/initializers/geokit_config.rb`.
103
+
104
+ ## SUPPORTED GEOCODERS
105
+
106
+ ### "regular" address geocoders
107
+ * Yahoo Geocoder - requires an API key.
108
+ * Geocoder.us - may require authentication if performing more than the free request limit.
109
+ * Geocoder.ca - for Canada; may require authentication as well.
110
+ * Geonames - a free geocoder
111
+
112
+ ### address geocoders that also provide reverse geocoding
113
+ * Google Geocoder - requires an API key. Also supports multiple results.
114
+
115
+ ### IP address geocoders
116
+ * IP Geocoder - geocodes an IP address using hostip.info's web service.
117
+ * Geoplugin.net -- another IP address geocoder
118
+
119
+ ### The Multigeocoder
120
+ * Multi Geocoder - provides failover for the physical location geocoders.
121
+
122
+ ## MULTIPLE RESULTS
123
+ Some geocoding services will return multple results if the there isn't one clear result.
124
+ Geoloc can capture multiple results through its "all" method. Currently only the Google geocoder
125
+ supports multiple results:
126
+
127
+ irb> geo=Geokit::Geocoders::GoogleGeocoder.geocode("900 Sycamore Drive")
128
+ irb> geo.full_address
129
+ => "900 Sycamore Dr, Arkadelphia, AR 71923, USA"
130
+ irb> geo.all.size
131
+ irb> geo.all.each { |e| puts e.full_address }
132
+ 900 Sycamore Dr, Arkadelphia, AR 71923, USA
133
+ 900 Sycamore Dr, Burkburnett, TX 76354, USA
134
+ 900 Sycamore Dr, TN 38361, USA
135
+ ....
136
+
137
+ geo.all is just an array of additional Geolocs, so do what you want with it. If you call .all on a
138
+ geoloc that doesn't have any additional results, you will get an array of one.
139
+
140
+
141
+ ## NOTES ON WHAT'S WHERE
142
+
143
+ mappable.rb contains the Mappable module, which provides basic
144
+ distance calculation methods, i.e., calculating the distance
145
+ between two points.
146
+
147
+ mappable.rb also contains LatLng, GeoLoc, and Bounds.
148
+ LatLng is a simple container for latitude and longitude, but
149
+ it's made more powerful by mixing in the above-mentioned Mappable
150
+ module -- therefore, you can calculate easily the distance between two
151
+ LatLng ojbects with `distance = first.distance_to(other)`
152
+
153
+ GeoLoc (also in mappable.rb) represents an address or location which
154
+ has been geocoded. You can get the city, zipcode, street address, etc.
155
+ from a GeoLoc object. GeoLoc extends LatLng, so you also get lat/lng
156
+ AND the Mappable modeule goodness for free.
157
+
158
+ geocoders.rb contains all the geocoder implemenations. All the gercoders
159
+ inherit from a common base (class Geocoder) and implement the private method
160
+ do_geocode.
161
+
162
+ ## GOOGLE GROUP
163
+
164
+ Follow the Google Group for updates and discussion on Geokit: http://groups.google.com/group/geokit
165
+
166
+ ## LICENSE
167
+
168
+ (The MIT License)
169
+
170
+ Copyright (c) 2007-2009 Andre Lewis and Bill Eisenhauer
171
+
172
+ Permission is hereby granted, free of charge, to any person obtaining
173
+ a copy of this software and associated documentation files (the
174
+ 'Software'), to deal in the Software without restriction, including
175
+ without limitation the rights to use, copy, modify, merge, publish,
176
+ distribute, sublicense, and/or sell copies of the Software, and to
177
+ permit persons to whom the Software is furnished to do so, subject to
178
+ the following conditions:
179
+
180
+ The above copyright notice and this permission notice shall be
181
+ included in all copies or substantial portions of the Software.
182
+
183
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
184
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
185
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
186
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
187
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
188
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
189
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './lib/geokit.rb'
6
+
7
+ project=Hoe.new('geokit', Geokit::VERSION) do |p|
8
+ #p.rubyforge_name = 'geokit' # if different than lowercase project name
9
+ p.developer('Andre Lewis', 'andre@earthcode.com')
10
+ p.summary="Geokit provides geocoding and distance calculation in an easy-to-use API"
11
+ end
12
+
13
+
14
+ # vim: syntax=Ruby