diff --git a/Gemfile.lock b/Gemfile.lock index e0398b56..63875f90 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -118,7 +118,7 @@ GEM data_migrate (11.2.0) activerecord (>= 6.1) railties (>= 6.1) - database_consistency (2.0.3) + database_consistency (2.0.4) activerecord (>= 3.2) date (3.4.1) debug (1.10.0) @@ -160,7 +160,7 @@ GEM rake groupdate (6.5.1) activesupport (>= 7) - hashdiff (1.1.1) + hashdiff (1.1.2) httparty (0.22.0) csv mini_mime (>= 1.0.0) @@ -224,18 +224,18 @@ GEM net-smtp (0.5.0) net-protocol nio4r (2.7.4) - nokogiri (1.18.1) + nokogiri (1.18.2) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.18.1-aarch64-linux-gnu) + nokogiri (1.18.2-aarch64-linux-gnu) racc (~> 1.4) - nokogiri (1.18.1-arm-linux-gnu) + nokogiri (1.18.2-arm-linux-gnu) racc (~> 1.4) - nokogiri (1.18.1-arm64-darwin) + nokogiri (1.18.2-arm64-darwin) racc (~> 1.4) - nokogiri (1.18.1-x86_64-darwin) + nokogiri (1.18.2-x86_64-darwin) racc (~> 1.4) - nokogiri (1.18.1-x86_64-linux-gnu) + nokogiri (1.18.2-x86_64-linux-gnu) racc (~> 1.4) oj (3.16.9) bigdecimal (>= 3.0) @@ -273,7 +273,7 @@ GEM activesupport (>= 3.0.0) raabro (1.4.0) racc (1.8.1) - rack (3.1.8) + rack (3.1.9) rack-session (2.1.0) base64 (>= 0.1.0) rack (>= 3.0.0) @@ -312,7 +312,7 @@ GEM zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.2.1) - rdoc (6.11.0) + rdoc (6.12.0) psych (>= 4.0.0) redis (5.3.0) redis-client (>= 0.22.0) @@ -326,12 +326,12 @@ GEM responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) - rexml (3.3.8) + rexml (3.4.0) rgeo (3.0.1) rgeo-activerecord (8.0.0) activerecord (>= 7.0) rgeo (>= 3.0) - rspec-core (3.13.2) + rspec-core (3.13.3) rspec-support (~> 3.13.0) rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) @@ -339,7 +339,7 @@ GEM rspec-mocks (3.13.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-rails (7.1.0) + rspec-rails (7.1.1) actionpack (>= 7.0) activesupport (>= 7.0) railties (>= 7.0) @@ -347,7 +347,7 @@ GEM rspec-expectations (~> 3.13) rspec-mocks (~> 3.13) rspec-support (~> 3.13) - rspec-support (3.13.1) + rspec-support (3.13.2) rswag-api (2.16.0) activesupport (>= 5.2, < 8.1) railties (>= 5.2, < 8.1) @@ -442,7 +442,7 @@ GEM useragent (0.16.11) warden (1.2.9) rack (>= 2.0.9) - webmock (3.24.0) + webmock (3.25.0) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) diff --git a/config/initializers/01_constants.rb b/config/initializers/01_constants.rb index ce760238..bd5cbca2 100644 --- a/config/initializers/01_constants.rb +++ b/config/initializers/01_constants.rb @@ -13,5 +13,9 @@ PHOTON_API_HOST = ENV.fetch('PHOTON_API_HOST', nil) PHOTON_API_KEY = ENV.fetch('PHOTON_API_KEY', nil) PHOTON_API_USE_HTTPS = ENV.fetch('PHOTON_API_USE_HTTPS', 'true') == 'true' +NOMINATIM_API_HOST = ENV.fetch('NOMINATIM_API_HOST', nil) +NOMINATIM_API_KEY = ENV.fetch('NOMINATIM_API_KEY', nil) +NOMINATIM_API_USE_HTTPS = ENV.fetch('NOMINATIM_API_USE_HTTPS', 'true') == 'true' + GEOAPIFY_API_KEY = ENV.fetch('GEOAPIFY_API_KEY', nil) # /Reverse geocoding settings diff --git a/config/initializers/03_dawarich_settings.rb b/config/initializers/03_dawarich_settings.rb index 589d9ef1..8d34fe8a 100644 --- a/config/initializers/03_dawarich_settings.rb +++ b/config/initializers/03_dawarich_settings.rb @@ -3,7 +3,7 @@ class DawarichSettings class << self def reverse_geocoding_enabled? - @reverse_geocoding_enabled ||= photon_enabled? || geoapify_enabled? + @reverse_geocoding_enabled ||= photon_enabled? || geoapify_enabled? || nominatim_enabled? end def photon_enabled? @@ -24,5 +24,9 @@ class DawarichSettings ENV['PROMETHEUS_EXPORTER_HOST'].present? && ENV['PROMETHEUS_EXPORTER_PORT'].present? end + + def nominatim_enabled? + @nominatim_enabled ||= NOMINATIM_API_HOST.present? + end end end diff --git a/config/initializers/geocoder.rb b/config/initializers/geocoder.rb index eb1a7fc4..46cd433d 100644 --- a/config/initializers/geocoder.rb +++ b/config/initializers/geocoder.rb @@ -19,6 +19,12 @@ if PHOTON_API_HOST.present? elsif GEOAPIFY_API_KEY.present? settings[:lookup] = :geoapify settings[:api_key] = GEOAPIFY_API_KEY +elsif NOMINATIM_API_HOST.present? + settings[:lookup] = :nominatim + settings[:nominatim] = { use_https: NOMINATIM_API_USE_HTTPS, host: NOMINATIM_API_HOST } + if NOMINATIM_API_KEY.present? + settings[:api_key] = NOMINATIM_API_KEY + end end Geocoder.configure(settings)