From 3fe48f66853abbc09cf172c311a1a43d7e65bea8 Mon Sep 17 00:00:00 2001 From: Aleksei Besogonov Date: Wed, 8 Jan 2025 19:32:29 -0800 Subject: [PATCH 1/4] Add support for Nominatim This adds support for Nominatim-based reverse geocoding, along with Photon and Geofi. To use it, set the environment variables: NOMINATIM_API_HOST - the host name of the OSM Nominatim server NOMINATIM_API_USE_HTTPS - use the HTTPS to connect NOMINATIM_API_KEY - the API key --- config/initializers/01_constants.rb | 4 ++++ config/initializers/03_dawarich_settings.rb | 6 +++++- config/initializers/geocoder.rb | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) 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 87cf4817..34a0d831 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? @@ -17,5 +17,9 @@ class DawarichSettings def geoapify_enabled? @geoapify_enabled ||= GEOAPIFY_API_KEY.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) From da2ab3b62bbe1ca7bc04e246dd30d4732272adad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 14:19:59 +0000 Subject: [PATCH 2/4] Bump database_consistency from 2.0.3 to 2.0.4 Bumps [database_consistency](https://github.com/djezzzl/database_consistency) from 2.0.3 to 2.0.4. - [Changelog](https://github.com/djezzzl/database_consistency/blob/master/CHANGELOG.md) - [Commits](https://github.com/djezzzl/database_consistency/compare/v2.0.3...v2.0.4) --- updated-dependencies: - dependency-name: database_consistency dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index e0398b56..8fa62291 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) From 509779feafd7a292d78beeb560f590882057748b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 14:20:21 +0000 Subject: [PATCH 3/4] Bump webmock from 3.24.0 to 3.25.0 Bumps [webmock](https://github.com/bblimke/webmock) from 3.24.0 to 3.25.0. - [Changelog](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md) - [Commits](https://github.com/bblimke/webmock/compare/v3.24.0...v3.25.0) --- updated-dependencies: - dependency-name: webmock dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e0398b56..fff02c54 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -326,7 +326,7 @@ 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) @@ -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) From 769c85bd15cd1665b45c9296e8883a30aab06657 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 14:20:33 +0000 Subject: [PATCH 4/4] Bump rspec-rails from 7.1.0 to 7.1.1 Bumps [rspec-rails](https://github.com/rspec/rspec-rails) from 7.1.0 to 7.1.1. - [Changelog](https://github.com/rspec/rspec-rails/blob/main/Changelog.md) - [Commits](https://github.com/rspec/rspec-rails/compare/v7.1.0...v7.1.1) --- updated-dependencies: - dependency-name: rspec-rails dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e0398b56..8fff6fa8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -331,7 +331,7 @@ GEM 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)