geomap 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/geomap.rb +9 -5
- metadata +1 -1
data/lib/geomap.rb
CHANGED
@@ -7,14 +7,14 @@ class Place < ActiveRecord::Base
|
|
7
7
|
attr_accessor :latitude, :longitude, :address
|
8
8
|
|
9
9
|
def reverse_geocode lat, lng
|
10
|
-
|
11
|
-
|
10
|
+
self.latitude, self.longitude = lat, lng
|
11
|
+
self.address = get_results [lat, lng], true
|
12
12
|
end
|
13
13
|
|
14
14
|
def geocode address
|
15
|
-
|
15
|
+
self.address = address
|
16
16
|
address = address.gsub(/\s/, '+')
|
17
|
-
|
17
|
+
self.latitude, self.longitude = get_results [address], false
|
18
18
|
end
|
19
19
|
|
20
20
|
|
@@ -31,7 +31,11 @@ class Place < ActiveRecord::Base
|
|
31
31
|
data = resp.body
|
32
32
|
|
33
33
|
result = JSON.parse(data)
|
34
|
-
|
34
|
+
|
35
|
+
if result.nil?
|
36
|
+
raise "Error --- invalid input"
|
37
|
+
end
|
38
|
+
|
35
39
|
if result.has_key? 'Error'
|
36
40
|
raise "web service error"
|
37
41
|
end
|