From e31d2cfb9282323d9c5fe3277a88c51a73321525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20L=C3=B6tzsch?= Date: Wed, 16 Mar 2022 21:43:05 +0100 Subject: [PATCH] backend: geocoding support for warhelp dataset --- backend/src/beherbergung/db/import/offer/helper.clj | 11 ++++++++--- .../src/beherbergung/db/import/offer/ngo/warhelp.clj | 4 ++-- .../src/beherbergung/model/offer_mapping/warhelp.clj | 2 ++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/backend/src/beherbergung/db/import/offer/helper.clj b/backend/src/beherbergung/db/import/offer/helper.clj index dd47126..f0dc59d 100644 --- a/backend/src/beherbergung/db/import/offer/helper.clj +++ b/backend/src/beherbergung/db/import/offer/helper.clj @@ -6,9 +6,14 @@ [beherbergung.model.ngo :as ngo])) (defn geocode [record] - (let [params {:city (:place_city record)} - result (client/get "https://nominatim.openstreetmap.org/search?format=json&limit=1" - {:accept :json :as :json :query-params params}) + (let [params (cond (not-empty (:place_city record)) + {:city (:place_city record)} + (not-empty (:place_str record)) + {:q (:place_str record)}) + result (when params + (prn params) + (client/get "https://nominatim.openstreetmap.org/search?format=json&limit=1" + {:accept :json :as :json :query-params params})) result_ok (when (= 200 (:status result)) (first (:body result)))] (println (or (:display_name result_ok) diff --git a/backend/src/beherbergung/db/import/offer/ngo/warhelp.clj b/backend/src/beherbergung/db/import/offer/ngo/warhelp.clj index 7477c65..0f90968 100644 --- a/backend/src/beherbergung/db/import/offer/ngo/warhelp.clj +++ b/backend/src/beherbergung/db/import/offer/ngo/warhelp.clj @@ -4,5 +4,5 @@ [beherbergung.model.offer-mapping.warhelp])) (defn importfile->table [file] - (take 5 (unify (clojure.edn/read-string (slurp file)) ;; TODO all - beherbergung.model.offer-mapping.warhelp/mapping))) + (unify (clojure.edn/read-string (slurp file)) + beherbergung.model.offer-mapping.warhelp/mapping)) diff --git a/backend/src/beherbergung/model/offer_mapping/warhelp.clj b/backend/src/beherbergung/model/offer_mapping/warhelp.clj index c5d9f9b..0cd998a 100644 --- a/backend/src/beherbergung/model/offer_mapping/warhelp.clj +++ b/backend/src/beherbergung/model/offer_mapping/warhelp.clj @@ -21,6 +21,8 @@ :place_zip (constantly nil) :place_street (constantly nil) :place_street_number (constantly nil) + :place_str #(or (not-empty (get % "Address (+ zip code!)")) + (get % "Address (+ zip code!) / Adresse (+ PLZ)")) :accessible (constantly nil) :animals_allowed (constantly nil)