Skip to content

Commit aa0f1cb

Browse files
committed
Prepare for release of gem version 1.0.0.
1 parent ed126c6 commit aa0f1cb

File tree

4 files changed

+128
-59
lines changed

4 files changed

+128
-59
lines changed

CHANGELOG.rdoc

+9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
Per-release changes to Geocoder.
44

5+
== 1.0.0 (2011 May 9)
6+
7+
* Add command line interface.
8+
* Add support for local proxy (thanks github.com/Olivier).
9+
* Add support for Yandex.ru geocoding service.
10+
* Add support for Bing geocoding service (thanks github.com/astevens).
11+
* Fix single table inheritance bug (reported by github.com/enrico).
12+
* Fix bug when Google result supplies no city (thanks github.com/jkeen).
13+
514
== 0.9.13 (2011 Apr 11)
615

716
* Fix "can't find special index: 2d" error when using Mongoid with Ruby 1.8.

README.rdoc

+117-57
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Geocoder is a complete geocoding solution for Ruby. With Rails it adds geocoding
88
* Supports multiple Ruby versions: Ruby 1.8.7, 1.9.2, and JRuby.
99
* Supports multiple databases: MySQL, PostgreSQL, SQLite, and MongoDB (1.7.0 and higher).
1010
* Supports Rails 3. If you need to use it with Rails 2 please see the <tt>rails2</tt> branch (no longer maintained, limited feature set).
11-
* Works very well outside of Rails but you'll need to install either the +json+ (for MRI) or +json_pure+ (for JRuby) gem.
11+
* Works very well outside of Rails, you just need to install either the +json+ (for MRI) or +json_pure+ (for JRuby) gem.
1212

1313

1414
== Install
@@ -208,73 +208,121 @@ Every <tt>Geocoder::Result</tt> object, +result+, provides the following data:
208208
* <tt>result.coordinates</tt> - array of the above two
209209
* <tt>result.address</tt> - string
210210
* <tt>result.city</tt> - string
211+
* <tt>result.state</tt> - string
212+
* <tt>result.state_code</tt> - string
211213
* <tt>result.postal_code</tt> - string
212214
* <tt>result.country_name</tt> - string
213215
* <tt>result.country_code</tt> - string
214216

215-
and if you're familiar with the results returned by the geocoding service you're using, you can access even more (see code comments for details: <tt>lib/geocoder/results/*</tt>).
217+
If you're familiar with the results returned by the geocoding service you're using you can access even more data, but you'll need to be familiar with the particular <tt>Geocoder::Result</tt> object you're using and the structure of your geocoding service's responses. (See below for links to geocoding service documentation.)
216218

217219

218220
== Geocoding Services
219221

220-
By default Geocoder uses Google's geocoding API to fetch coordinates and addresses. However if you wish to use Yahoo's geocoding API you can simply add this to an initializer:
222+
By default Geocoder uses Google's geocoding API to fetch coordinates and street addresses (FreeGeoIP is used for IP address info). However there are several other APIs supported, as well as a variety of settings. Please see the listing and comparison below for details on specific geocoding services (not all settings are supported by all services). The configuration options are:
221223

222224
# config/initializers/geocoder.rb
223-
Geocoder::Configuration.lookup = :yahoo
224-
225-
Street address geocoding services currently supported (valid settings for the above):
226-
227-
* Google: <tt>:google</tt>
228-
* Yahoo: <tt>:yahoo</tt>
229-
* Bing: <tt>:bing</tt>
230-
* Geocoder.ca: <tt>:geocoder_ca</tt> (US and Canada only)
231-
232-
Note that the result objects returned by different geocoding services all implement the methods listed above. Beyond that, however, you must be familiar with your particular subclass of <tt>Geocoder::Result</tt> and the geocoding service's result structure:
233225

234-
* Google: http://code.google.com/apis/maps/documentation/geocoding/#JSON
235-
* Yahoo: http://developer.yahoo.com/geo/placefinder/guide/responses.html
236-
* Bing: http://msdn.microsoft.com/en-us/library/ff701715.aspx
237-
* Geocoder.ca: (???)
238-
* Yandex: http://api.yandex.ru/maps/geocoder/doc/desc/concepts/response_structure.xml
239-
* FreeGeoIP: http://github.com/fiorix/freegeoip/blob/master/README.rst
240-
241-
=== API Keys
242-
243-
To use your Google API key or Yahoo app ID:
226+
# geocoding service (see below for supported options):
227+
Geocoder::Configuration.lookup = :yahoo
244228

229+
# to use an API key:
245230
Geocoder::Configuration.api_key = "..."
246231

247-
To obtain an API key:
248-
249-
* Google: http://code.google.com/apis/maps/signup.html (not required)
250-
* Yahoo: https://developer.apps.yahoo.com/wsregapp (not required)
251-
* Bing: http://www.bingmapsportal.com/ (required)
252-
* Yandex: http://api.yandex.ru/maps/intro/concepts/intro.xml#apikey (required)
253-
254-
=== Timeout
255-
256-
You can set the timeout used for connections to the geocoding service. The default is 3 seconds but if you want to set it to 5, for example, put the following in an initializer:
257-
232+
# geocoding service request timeout, in seconds (default 3):
258233
Geocoder::Configuration.timeout = 5
259234

260-
=== Language
261-
262-
You can set the language used for reverse geocoding results to German, for example, by setting the following:
235+
# use HTTPS for geocoding service connections:
236+
Geocoder::Configuration.use_https = true
263237

238+
# language to use (for search queries and reverse geocoding):
264239
Geocoder::Configuration.language = :de
265240

266-
For a list of supported languages see the documentation for the geocoding service you're using.
267-
268-
=== HTTPS
241+
# use a proxy to access the service:
242+
Geocoder::Configuration.http_proxy = "127.4.4.1"
243+
Geocoder::Configuration.https_proxy = "127.4.4.2" # only if HTTPS is needed
269244

270-
If you want to use HTTPS for geocoding service connections:
271-
272-
Geocoder::Configuration.use_https = true
273-
274-
Note that currently the only service that supports HTTPS is Google.
245+
# caching (see below for details)
246+
Geocoder::Configuration.cache = Redis.new
247+
Geocoder::Configuration.cache_prefix = "..."
275248

276249

277-
== Caching Results
250+
=== Listing and Comparison
251+
252+
The following is a comparison of the supported geocoding APIs. The "Limitations" listed for each are a very brief and incomplete summary of some special limitations beyond basic data source attribution. Please read the official Terms of Service for a service before using it.
253+
254+
==== Google (<tt>:google</tt>)
255+
256+
API key:: optional (required for Premier)
257+
Key signup:: http://code.google.com/apis/maps/signup.html
258+
Quota:: 2,500 requests/day, 100,000 with Google Maps API Premier
259+
Region:: world
260+
SSL support:: yes
261+
Languages:: ar, eu, bg, bn, ca, cs, da, de, el, en, en-AU, en-GB, es, eu, fa, fi, fil, fr, gl, gu, hi, hr, hu, id, it, iw, ja, kn, ko, lt, lv, ml, mr, nl, no, pl, pt, pt-BR, pt-PT, ro, ru, sk, sl, sr, sv, tl, ta, te, th, tr, uk, vi, zh-CN, zh-TW (see http://spreadsheets.google.com/pub?key=p9pdwsai2hDMsLkXsoM05KQ&gid=1)
262+
Documentation:: http://code.google.com/apis/maps/documentation/geocoding/#JSON
263+
Terms of Service:: http://code.google.com/apis/maps/terms.html#section_10_12
264+
Limitations:: "You must not use or display the Content without a corresponding Google map, unless you are explicitly permitted to do so in the Maps APIs Documentation, or through written permission from Google." "You must not pre-fetch, cache, or store any Content, except that you may store: (i) limited amounts of Content for the purpose of improving the performance of your Maps API Implementation..."
265+
266+
==== Yahoo (<tt>:yahoo</tt>)
267+
268+
API key:: optional in development (required for production apps)
269+
Key signup:: https://developer.apps.yahoo.com/wsregapp
270+
Quota:: 50,000 requests/day, more available by special arrangement
271+
Region:: world
272+
SSL support:: no
273+
Languages:: ?
274+
Documentation:: http://developer.yahoo.com/geo/placefinder/guide/responses.html
275+
Terms of Service:: http://info.yahoo.com/legal/us/yahoo/maps/mapsapi/mapsapi-2141.html
276+
Limitations:: "YOU SHALL NOT... (viii) store or allow end users to store map imagery, map data or geocoded location information from the Yahoo! Maps APIs for any future use; (ix) use the stand-alone geocoder for any use other than displaying Yahoo! Maps or displaying points on Yahoo! Maps;"
277+
278+
==== Bing (<tt>:bing</tt>)
279+
280+
API key:: required
281+
Key signup:: http://www.bingmapsportal.com
282+
Quota:: 50,000 requests/24 hrs
283+
Region:: world
284+
SSL support:: no
285+
Languages:: ?
286+
Documentation:: http://msdn.microsoft.com/en-us/library/ff701715.aspx
287+
Terms of Service:: http://www.microsoft.com/maps/product/terms.html
288+
Limitations:: No country codes or state names. Must be used on "public-facing, non-password protected web sites," "in conjunction with Bing Maps or an application that integrates Bing Maps."
289+
290+
==== Yandex (<tt>:yandex</tt>)
291+
292+
API key:: required
293+
Key signup:: http://api.yandex.ru/maps/intro/concepts/intro.xml#apikey
294+
Quota:: ?
295+
Region:: Russia
296+
SSL support:: no
297+
Languages:: Russian, Belarusian, and Ukrainian
298+
Documentation:: http://api.yandex.ru/maps/geocoder/doc/desc/concepts/response_structure.xml
299+
Terms of Service:: http://api.yandex.com/direct/eula.xml?ncrnd=8453
300+
Limitations:: ?
301+
302+
==== Geocoder.ca (<tt>:geocoder_ca</tt>)
303+
304+
API key:: none
305+
Quota:: ?
306+
Region:: US and Canada
307+
SSL support:: no
308+
Languages:: English
309+
Documentation:: ?
310+
Terms of Service:: http://geocoder.ca/?terms=1
311+
Limitations:: "Under no circumstances can our data be re-distributed or re-sold by anyone to other parties without our written permission."
312+
313+
==== FreeGeoIP
314+
315+
API key:: none
316+
Quota:: ?
317+
Region:: world
318+
SSL support:: no
319+
Languages:: English
320+
Documentation:: http://github.com/fiorix/freegeoip/blob/master/README.rst
321+
Terms of Service:: ?
322+
Limitations:: ?
323+
324+
325+
== Caching
278326

279327
It's a good idea, when relying on any external service, to cache retrieved data. When implemented correctly it improves your app's response time and stability. It's easy to cache geocoding results with Geocoder, just configure a cache store:
280328

@@ -301,6 +349,8 @@ If you need to expire cached content:
301349

302350
Do *not* include the prefix when passing a URL to be expired. Expiring <tt>:all</tt> will only expire keys with the configured prefix (won't kill every entry in your key/value store).
303351

352+
<i>Before you implement caching in your app please be sure that doing so does not violate the Terms of Service for your geocoding service.</i>
353+
304354

305355
== Forward and Reverse Geocoding in the Same Model
306356

@@ -343,6 +393,23 @@ You can use Geocoder outside of Rails by calling the <tt>Geocoder.search</tt> me
343393
This returns an array of <tt>Geocoder::Result</tt> objects with all information provided by the geocoding service. Please see above and in the code for details.
344394

345395

396+
== Command Line Interface
397+
398+
When you install the Geocoder gem it adds a +geocode+ command to your shell. You can search for a street address, IP address, postal code, coordinates, etc just like you can with the Geocoder.search method for example:
399+
400+
$ geocode 29.951,-90.081
401+
Latitude: 29.952211
402+
Longitude: -90.080563
403+
Full address: 1500 Sugar Bowl Dr, New Orleans, LA 70112, USA
404+
City: New Orleans
405+
State/province: Louisiana
406+
Postal code: 70112
407+
Country: United States
408+
Google map: http://maps.google.com/maps?q=29.952211,-90.080563
409+
410+
There are also a number of options for setting the geocoding API, key, and language, viewing the raw JSON reponse, and more. Please run <tt>geocode -h</tt> for details.
411+
412+
346413
== Notes on Mongoid
347414

348415
=== The Near Method
@@ -351,7 +418,7 @@ Mongoid document classes have a built-in +near+ scope, but since it only works t
351418

352419
=== Latitude/Longitude Order
353420

354-
Coordinates are generally printed and spoken as latitude, then logitude ([lat,lon]). Geocoder respects this convention and always expects method arguments to be given in [lat,lon] order. However, MongoDB requires that coordinates be stored in [lon,lat] order as per the GeoJSON spec (http://geojson.org/geojson-spec.html#positions), so internally they are stored "backwards." However, this does not affect order of arguments to methods when using Mongoid. I mention this only in case you notice it and freak out. Don't worry. Everything is going to be OK.
421+
Coordinates are generally printed and spoken as latitude, then logitude ([lat,lon]). Geocoder respects this convention and always expects method arguments to be given in [lat,lon] order. However, MongoDB requires that coordinates be stored in [lon,lat] order as per the GeoJSON spec (http://geojson.org/geojson-spec.html#positions), so internally they are stored "backwards." However, this does not affect order of arguments to methods when using Mongoid.
355422

356423

357424
== Distance Queries in SQLite
@@ -381,19 +448,12 @@ http://github.com/alexreisner/geocoder_test
381448

382449
== Known Issue
383450

384-
You cannot use the +near+ scope with another scope that provides an +includes+ option because the +SELECT+ clause generated by +near+ will overwrite it (or vice versa). Instead, try using +joins+ and pass a <tt>:select</tt> option to the +near+ scope to get the columns you want. For example, in Rails 2 syntax:
451+
You cannot use the +near+ scope with another scope that provides an +includes+ option because the +SELECT+ clause generated by +near+ will overwrite it (or vice versa). Instead, try using +joins+ and pass a <tt>:select</tt> option to the +near+ scope to get the columns you want. For example:
385452

386-
# instead of :includes => :venues:
387-
City.near("Omaha, NE", 20, :select => "venues.*").all(:joins => :venues)
453+
# instead of City.near(...).includes(:venues)
454+
City.near("Omaha, NE", 20, :select => "cities.*, venues.*").joins(:venues)
388455

389456
If anyone has a more elegant solution to this problem I am very interested in seeing it.
390457

391458

392-
== Roadmap
393-
394-
* add support for more ORMs (Mongoid, DataMapper)
395-
* add support for more geocoding services
396-
* maintain the same simple interface
397-
398-
399459
Copyright (c) 2009-11 Alex Reisner, released under the MIT license

geocoder.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
1111
s.homepage = "http://www.rubygeocoder.com"
1212
s.date = Date.today.to_s
1313
s.summary = "Complete geocoding solution for Ruby."
14-
s.description = "Provides object geocoding (by street or IP address), reverse geocoding (coordinates to street address), and distance queries for ActiveRecord and Mongoid. Designed for Rails but works with other Rack frameworks too."
14+
s.description = "Provides object geocoding (by street or IP address), reverse geocoding (coordinates to street address), distance queries for ActiveRecord and Mongoid, result caching, and more. Designed for Rails but works with Sinatra and other Rack frameworks too."
1515
s.files = `git ls-files`.split("\n") - %w[geocoder.gemspec Gemfile init.rb]
1616
s.require_paths = ["lib"]
1717
s.executables = ["geocode"]

lib/geocoder/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Geocoder
2-
VERSION = "0.9.13"
2+
VERSION = "1.0.0"
33
end

0 commit comments

Comments
 (0)