backend: geocoding support for warhelp dataset

This commit is contained in:
Johannes Lötzsch 2022-03-16 21:43:05 +01:00
parent 330046b55f
commit e31d2cfb92
3 changed files with 12 additions and 5 deletions

View File

@ -6,9 +6,14 @@
[beherbergung.model.ngo :as ngo])) [beherbergung.model.ngo :as ngo]))
(defn geocode [record] (defn geocode [record]
(let [params {:city (:place_city record)} (let [params (cond (not-empty (:place_city record))
result (client/get "https://nominatim.openstreetmap.org/search?format=json&limit=1" {:city (:place_city record)}
{:accept :json :as :json :query-params params}) (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)) result_ok (when (= 200 (:status result))
(first (:body result)))] (first (:body result)))]
(println (or (:display_name result_ok) (println (or (:display_name result_ok)

View File

@ -4,5 +4,5 @@
[beherbergung.model.offer-mapping.warhelp])) [beherbergung.model.offer-mapping.warhelp]))
(defn importfile->table [file] (defn importfile->table [file]
(take 5 (unify (clojure.edn/read-string (slurp file)) ;; TODO all (unify (clojure.edn/read-string (slurp file))
beherbergung.model.offer-mapping.warhelp/mapping))) beherbergung.model.offer-mapping.warhelp/mapping))

View File

@ -21,6 +21,8 @@
:place_zip (constantly nil) :place_zip (constantly nil)
:place_street (constantly nil) :place_street (constantly nil)
:place_street_number (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) :accessible (constantly nil)
:animals_allowed (constantly nil) :animals_allowed (constantly nil)