forked from zammad/zammad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeo_location.rb
51 lines (32 loc) · 868 Bytes
/
geo_location.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
module Service
class GeoLocation
include ApplicationLib
=begin
lookup lat and lng for address
result = Service::GeoLocation.geocode('Marienstrasse 13, 10117 Berlin')
returns
result = [ 4.21312, 1.3123 ]
=end
def self.geocode(address)
# load backend
backend = load_adapter_by_setting('geo_location_backend')
return if !backend
# db lookup
backend.geocode(address)
end
=begin
lookup address for lat and lng
result = GeoLocation.reverse_geocode(4.21312, 1.3123)
returns
result = 'some address'
=end
def self.reverse_geocode(lat, lng)
# load backend
backend = load_adapter_by_setting('geo_location_backend')
return if !backend
# db lookup
backend.reverse_geocode(lat, lng)
end
end
end