andre-geokit 1.2.4 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +6 -1
- data/lib/geokit/geocoders.rb +3 -3
- data/lib/geokit/mappable.rb +1 -1
- data/test/test_geoloc.rb +10 -0
- metadata +1 -1
data/README.markdown
CHANGED
@@ -8,10 +8,11 @@ The Geokit gem provides:
|
|
8
8
|
* Rectangular bounds calculations: is a point within a given rectangular bounds?
|
9
9
|
* Heading and midpoint calculations
|
10
10
|
|
11
|
-
Combine this
|
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
12
|
|
13
13
|
* Geokit Documentation at Rubyforge [http://geokit.rubyforge.org](http://geokit.rubyforge.org).
|
14
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)
|
15
16
|
|
16
17
|
## INSTALL
|
17
18
|
|
@@ -159,6 +160,10 @@ geocoders.rb contains all the geocoder implemenations. All the gercoders
|
|
159
160
|
inherit from a common base (class Geocoder) and implement the private method
|
160
161
|
do_geocode.
|
161
162
|
|
163
|
+
## GOOGLE GROUP
|
164
|
+
|
165
|
+
Follow the Google Group for updates and discussion on Geokit: http://groups.google.com/group/geokit
|
166
|
+
|
162
167
|
## LICENSE
|
163
168
|
|
164
169
|
(The MIT License)
|
data/lib/geokit/geocoders.rb
CHANGED
@@ -389,10 +389,10 @@ module Geokit
|
|
389
389
|
return GeoLoc.new if !res.is_a?(Net::HTTPSuccess)
|
390
390
|
xml = res.body
|
391
391
|
logger.debug "Google geocoding. Address: #{address}. Result: #{xml}"
|
392
|
-
return self.xml2GeoLoc(xml)
|
392
|
+
return self.xml2GeoLoc(xml, address)
|
393
393
|
end
|
394
394
|
|
395
|
-
def self.xml2GeoLoc(xml)
|
395
|
+
def self.xml2GeoLoc(xml, address="")
|
396
396
|
doc=REXML::Document.new(xml)
|
397
397
|
|
398
398
|
if doc.elements['//kml/Response/Status/code'].text == '200'
|
@@ -402,7 +402,7 @@ module Geokit
|
|
402
402
|
doc.each_element('//Placemark') do |e|
|
403
403
|
extracted_geoloc = extract_placemark(e) # g is now an instance of Geoloc
|
404
404
|
if geoloc.nil?
|
405
|
-
# first time through, geoloc is still
|
405
|
+
# first time through, geoloc is still nil, so we make it the geoloc we just extracted
|
406
406
|
geoloc = extracted_geoloc
|
407
407
|
else
|
408
408
|
# second (and subsequent) iterations, we push additional
|
data/lib/geokit/mappable.rb
CHANGED
data/test/test_geoloc.rb
CHANGED
@@ -51,4 +51,14 @@ class GeoLocTest < Test::Unit::TestCase #:nodoc: all
|
|
51
51
|
assert_equal [@loc], @loc.all
|
52
52
|
end
|
53
53
|
|
54
|
+
def test_to_yaml
|
55
|
+
@loc.city = 'San Francisco'
|
56
|
+
@loc.state = 'CA'
|
57
|
+
@loc.zip = '94105'
|
58
|
+
@loc.country_code = 'US'
|
59
|
+
assert_equal(
|
60
|
+
"--- !ruby/object:Geokit::GeoLoc \ncity: San Francisco\ncountry_code: US\nfull_address: \nlat: \nlng: \nprecision: unknown\nstate: CA\nstreet_address: \nsuccess: false\nzip: \"94105\"\n",
|
61
|
+
@loc.to_yaml)
|
62
|
+
end
|
63
|
+
|
54
64
|
end
|