From 3b210a33a2f5fb25665dd5d05fbbc92ef21f8368 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Wed, 20 Nov 2019 13:49:57 +0100 Subject: [PATCH] Disable address autocomplete where required (nominatim) Signed-off-by: Thomas Citharel --- config/config.exs | 8 ++ config/dev.exs | 2 +- docs/administration/configure/geocoders.md | 13 ++- .../components/Event/AddressAutoComplete.vue | 57 +++++++--- js/src/components/Map.vue | 17 ++- js/src/graphql/config.ts | 10 ++ js/src/types/config.model.ts | 10 ++ js/yarn.lock | 102 +++++++++--------- lib/mobilizon/config.ex | 15 +++ lib/mobilizon_web/resolvers/config.ex | 12 ++- lib/mobilizon_web/schema/config.ex | 16 +++ lib/service/geospatial/addok.ex | 4 + lib/service/geospatial/mimirsbrunn.ex | 4 + lib/service/geospatial/nominatim.ex | 4 + lib/service/geospatial/pelias.ex | 4 + lib/service/geospatial/photon.ex | 4 + schema.graphql | 18 +++- 17 files changed, 220 insertions(+), 80 deletions(-) diff --git a/config/config.exs b/config/config.exs index 0424a0342..9682b34c3 100644 --- a/config/config.exs +++ b/config/config.exs @@ -143,6 +143,14 @@ config :mobilizon, Mobilizon.Service.Geospatial.Mimirsbrunn, config :mobilizon, Mobilizon.Service.Geospatial.Pelias, endpoint: System.get_env("GEOSPATIAL_PELIAS_ENDPOINT") || nil +config :mobilizon, :maps, + tiles: [ + endpoint: + System.get_env("MAPS_TILES_ENDPOINT") || + "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", + attribution: System.get_env("MAPS_TILES_ATTRIBUTION") + ] + config :mobilizon, Oban, repo: Mobilizon.Storage.Repo, prune: {:maxlen, 10_000}, diff --git a/config/dev.exs b/config/dev.exs index ac5f5a921..8b9d4f621 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -52,7 +52,7 @@ config :mobilizon, MobilizonWeb.Endpoint, # Do not include metadata nor timestamps in development logs config :logger, :console, format: "[$level] $message\n", level: :debug -config :mobilizon, Mobilizon.Service.Geospatial, service: Mobilizon.Service.Geospatial.Nominatim +config :mobilizon, Mobilizon.Service.Geospatial, service: Mobilizon.Service.Geospatial.Mimirsbrunn # Set a higher stacktrace during development. Avoid configuring such # in production as building large stacktraces may be expensive. diff --git a/docs/administration/configure/geocoders.md b/docs/administration/configure/geocoders.md index ee9349eaf..3f636ed84 100644 --- a/docs/administration/configure/geocoders.md +++ b/docs/administration/configure/geocoders.md @@ -7,8 +7,8 @@ This is needed to set correct address for events, and more easily find events wi However, providing a geocoding service is quite expensive, especially if you want to cover the whole Earth. -!!!note - To give an idea of what hardware is required to self-host a geocoding service, we successfully used Addok, Pelias and Mimirsbrunn on a 8 core/16GB RAM machine without any issues **on French data**. +!!! note "Hardware setup" + To give an idea of what hardware is required to self-host a geocoding service, we successfully installed and used [Addok](#addok), [Pelias](#pelias) and [Mimirsbrunn](#mimirsbrunn) on a 8 cores/16GB RAM machine without any issues **importing only French addresses and data**. ## List of supported geocoders @@ -27,9 +27,12 @@ This is the list of all geocoders supported by Mobilizon. The current default on [Nominatim](https://wiki.openstreetmap.org/wiki/Nominatim) is a GPL-2.0 licenced tool to search data by name and address. It's written in C and PHP and uses PostgreSQL. It's the current default search tool on the [OpenStreetMap homepage](https://www.openstreetmap.org). -!!! warning +!!! warning "Terms" When using the official Nominatim OpenStreetMap instance (default endpoint for this geocoder if not configured otherwise), you need to read and accept the [Usage Policy](https://operations.osmfoundation.org/policies/nominatim). +!!! danger "Limitations" + Autocomplete is not possible using Nominatim, you'll obtain no suggestions while typing. + Several companies provide hosted instances of Nominatim that you can query via an API, for example see [MapQuest Open Initiative](https://developer.mapquest.com/documentation/open/nominatim-search). ### Addok @@ -37,14 +40,14 @@ Several companies provide hosted instances of Nominatim that you can query via a [Addok](https://github.com/addok/addok) is a WTFPL licenced search engine for address (and only address). It's written in Python and uses Redis. It's used by French government for [adresse.data.gouv.fr](https://adresse.data.gouv.fr). -!!! warning +!!! warning "Terms" When using France's Addok instance at `api-adresse.data.gouv.fr` (default endpoint for this geocoder if not configured otherwise), you need to read and accept the [GCU](https://adresse.data.gouv.fr/cgu) (in French). ### Photon [Photon](https://photon.komoot.de/) is an Apache 2.0 licenced search engine written in Java and powered by ElasticSearch. -!!! warning +!!! warning "Terms" The terms of use for the official instance (default endpoint for this geocoder if not configured otherwise) are simply the following: > You can use the API for your project, but please be fair - extensive usage will be throttled. We do not guarantee for the availability and usage might be subject of change in the future. diff --git a/js/src/components/Event/AddressAutoComplete.vue b/js/src/components/Event/AddressAutoComplete.vue index cef479190..2fd40f7d8 100644 --- a/js/src/components/Event/AddressAutoComplete.vue +++ b/js/src/components/Event/AddressAutoComplete.vue @@ -7,12 +7,12 @@ {{ $t('Getting location') }} @@ -24,7 +24,7 @@