Going straight ahead!
This commit is contained in:
1 parent
89b07a3dc6
commit
a92eee0479
10 files changed
+315
-129
No files matched your search
@@ -0,0 +1,41 @@
|
||||
(require '[babashka.process :refer [shell process exec]]
|
||||
'[clojure.string :as strings]
|
||||
'[babashka.cli :as cli])
|
||||
|
||||
|
||||
(defn extract-data [file]
|
||||
(let [data (slurp file)
|
||||
geojson (shell {:out :string :continue true :in data} "poly2geojson")
|
||||
city-name (subs file
|
||||
(inc (strings/last-index-of file "/"))
|
||||
(strings/last-index-of file "_"))]
|
||||
{:originalFile file
|
||||
:geojson (some-> geojson
|
||||
:out
|
||||
(json/parse-string true)
|
||||
:geometry
|
||||
json/generate-string)
|
||||
:province "québec"
|
||||
:cityName city-name}))
|
||||
|
||||
;; ${osmosis}/bin/osmosis --read-pbf-fast file="${quebec-osm-data}" \
|
||||
;; --bounding-polygon file="cities/canada/quebec/westmount_quebec.poly" \
|
||||
;; --write-pbf file="cities/canada/quebec/westmount_quebec.osm.pbf"
|
||||
|
||||
(defn extract-osm-pbf [osm-file file]
|
||||
(let [output-file (strings/replace file ".poly" ".osm.pbf")]
|
||||
(println "Processing " file " file to " output-file)
|
||||
(shell {:continue true}
|
||||
"osmosis"
|
||||
"--read-pbf-fast" (str "file=" osm-file)
|
||||
"--bounding-polygon"
|
||||
(str"file=" file)
|
||||
"--write-pbf"
|
||||
(str "file=" output-file))))
|
||||
|
||||
|
||||
(def opts (cli/parse-opts *command-line-args* {:coerce {:paths []}}))
|
||||
|
||||
(doall (map
|
||||
#(extract-osm-pbf (:osm-file opts) %)
|
||||
(:paths opts)))
|
||||
Reference in new issue
Block a user