dreamcat4-geokit 1.3.0

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
+ .project
2
+ History.txt
3
+ Manifest.txt
4
+ README.markdown
5
+ Rakefile
6
+ geokit.gemspec
7
+ lib/geokit.rb
8
+ lib/geokit/geocoders.rb
9
+ lib/geokit/mappable.rb
10
+ test/test_base_geocoder.rb
11
+ test/test_bounds.rb
12
+ test/test_ca_geocoder.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,195 @@
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
+ # You can also set multiple API KEYS for different domains that may be directed to this same application.
79
+ # The domain from which the current user is being directed will automatically be updated for Geokit via
80
+ # the GeocoderControl class, which gets it's begin filter mixed into the ActionController.
81
+ # You define these keys with a Hash as follows:
82
+ #Geokit::Geocoders::google = { 'rubyonrails.org' => 'RUBY_ON_RAILS_API_KEY', 'ruby-docs.org' => 'RUBY_DOCS_API_KEY' }
83
+
84
+ # This is your username and password for geocoder.us.
85
+ # To use the free service, the value can be set to nil or false. For
86
+ # usage tied to an account, the value should be set to username:password.
87
+ # See http://geocoder.us
88
+ # and http://geocoder.us/user/signup
89
+ Geokit::Geocoders::geocoder_us = false
90
+
91
+ # This is your authorization key for geocoder.ca.
92
+ # To use the free service, the value can be set to nil or false. For
93
+ # usage tied to an account, set the value to the key obtained from
94
+ # Geocoder.ca.
95
+ # See http://geocoder.ca
96
+ # and http://geocoder.ca/?register=1
97
+ Geokit::Geocoders::geocoder_ca = false
98
+
99
+ # This is the order in which the geocoders are called in a failover scenario
100
+ # If you only want to use a single geocoder, put a single symbol in the array.
101
+ # Valid symbols are :google, :yahoo, :us, and :ca.
102
+ # Be aware that there are Terms of Use restrictions on how you can use the
103
+ # various geocoders. Make sure you read up on relevant Terms of Use for each
104
+ # geocoder you are going to use.
105
+ Geokit::Geocoders::provider_order = [:google,:us]
106
+
107
+ If you're using this gem with the [geokit-rails plugin](http://github.com/andre/geokit-rails/tree/master), the plugin
108
+ creates a template with these settings and places it in `config/initializers/geokit_config.rb`.
109
+
110
+ ## SUPPORTED GEOCODERS
111
+
112
+ ### "regular" address geocoders
113
+ * Yahoo Geocoder - requires an API key.
114
+ * Geocoder.us - may require authentication if performing more than the free request limit.
115
+ * Geocoder.ca - for Canada; may require authentication as well.
116
+ * Geonames - a free geocoder
117
+
118
+ ### address geocoders that also provide reverse geocoding
119
+ * Google Geocoder - requires an API key. Also supports multiple results.
120
+
121
+ ### IP address geocoders
122
+ * IP Geocoder - geocodes an IP address using hostip.info's web service.
123
+ * Geoplugin.net -- another IP address geocoder
124
+
125
+ ### The Multigeocoder
126
+ * Multi Geocoder - provides failover for the physical location geocoders.
127
+
128
+ ## MULTIPLE RESULTS
129
+ Some geocoding services will return multple results if the there isn't one clear result.
130
+ Geoloc can capture multiple results through its "all" method. Currently only the Google geocoder
131
+ supports multiple results:
132
+
133
+ irb> geo=Geokit::Geocoders::GoogleGeocoder.geocode("900 Sycamore Drive")
134
+ irb> geo.full_address
135
+ => "900 Sycamore Dr, Arkadelphia, AR 71923, USA"
136
+ irb> geo.all.size
137
+ irb> geo.all.each { |e| puts e.full_address }
138
+ 900 Sycamore Dr, Arkadelphia, AR 71923, USA
139
+ 900 Sycamore Dr, Burkburnett, TX 76354, USA
140
+ 900 Sycamore Dr, TN 38361, USA
141
+ ....
142
+
143
+ geo.all is just an array of additional Geolocs, so do what you want with it. If you call .all on a
144
+ geoloc that doesn't have any additional results, you will get an array of one.
145
+
146
+
147
+ ## NOTES ON WHAT'S WHERE
148
+
149
+ mappable.rb contains the Mappable module, which provides basic
150
+ distance calculation methods, i.e., calculating the distance
151
+ between two points.
152
+
153
+ mappable.rb also contains LatLng, GeoLoc, and Bounds.
154
+ LatLng is a simple container for latitude and longitude, but
155
+ it's made more powerful by mixing in the above-mentioned Mappable
156
+ module -- therefore, you can calculate easily the distance between two
157
+ LatLng ojbects with `distance = first.distance_to(other)`
158
+
159
+ GeoLoc (also in mappable.rb) represents an address or location which
160
+ has been geocoded. You can get the city, zipcode, street address, etc.
161
+ from a GeoLoc object. GeoLoc extends LatLng, so you also get lat/lng
162
+ AND the Mappable modeule goodness for free.
163
+
164
+ geocoders.rb contains all the geocoder implemenations. All the gercoders
165
+ inherit from a common base (class Geocoder) and implement the private method
166
+ do_geocode.
167
+
168
+ ## GOOGLE GROUP
169
+
170
+ Follow the Google Group for updates and discussion on Geokit: http://groups.google.com/group/geokit
171
+
172
+ ## LICENSE
173
+
174
+ (The MIT License)
175
+
176
+ Copyright (c) 2007-2009 Andre Lewis and Bill Eisenhauer
177
+
178
+ Permission is hereby granted, free of charge, to any person obtaining
179
+ a copy of this software and associated documentation files (the
180
+ 'Software'), to deal in the Software without restriction, including
181
+ without limitation the rights to use, copy, modify, merge, publish,
182
+ distribute, sublicense, and/or sell copies of the Software, and to
183
+ permit persons to whom the Software is furnished to do so, subject to
184
+ the following conditions:
185
+
186
+ The above copyright notice and this permission notice shall be
187
+ included in all copies or substantial portions of the Software.
188
+
189
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
190
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
191
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
192
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
193
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
194
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
195
+ 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