Generating import queries now working

This commit is contained in:
Simon Brooke 2018-06-29 08:24:02 +01:00
parent 668baaedaf
commit 600620a51d

View file

@ -476,47 +476,32 @@
"`filename` is expected to be the path name of a JSON file containing records as documented "`filename` is expected to be the path name of a JSON file containing records as documented
[here](https://apidocs.os.uk/docs/os-places-dpa-output)." [here](https://apidocs.os.uk/docs/os-places-dpa-output)."
[filename] [filename]
(map (s/join
(fn [a] "\n\n"
(let [location (.geopoint (OsGrid. (:x_coordinate a) (:y_coordinate a)) :WGS84)] (map
(s/join (fn [a]
(list (let [location (.geopoint (OsGrid. (:x_coordinate a) (:y_coordinate a)) :WGS84)]
"insert into addresses (address:ellipsoid postcode}} latitude, longitude) values ('" (s/join
(:address a) "', '" (:postcode a) "\n"
"', " (.latitude location) "," (.longitude location) ");")) (list
)) (str
(filter "insert into addresses (address, postcode, latitude, longitude) values ('"
#(= (:classification_code_description %) "Dwelling") (:address a) "', '" (:postcode a)
(map "', " (.latitude location) "," (.longitude location) ");")
:dpa ;; TODO: doesn't deal intelligently with flats and tenements.
(:results (str
(json/read-str "insert into dwellings (address_id, sub_address) "
(slurp filename) "values ((select id from addresses where addresses.address = '"
:key-fn #(keyword (.toLowerCase %)))))))) (:address a)
"'), '');")))
))
;; (def home (GeoPoint. 54.8240911 -3.9170342 :WGS84)) (filter
#(= (:classification_code_description %) "Dwelling")
;; ;; (map
:dpa
;; ;; (:datum home) (:results
;; (datums (:datum home)) (json/read-str
;; (:ellipsoid (datums (:datum home))) (slurp filename)
:key-fn #(keyword (.toLowerCase %)))))))))
;; ;; @@
;; (osgrid home :WGS84)
;; (def hazelfield (OsGrid. 277656 549165))
;; (apply-transform
;; (apply-transform
;; (Vector3d. 1 1 1)
;; { :tx 89.5, :ty 93.8 :tz 123.1 :s -1.2 :rx 0.0 :ry 0.0 :rz 0.156 })
;; (inverse-transform { :tx 89.5, :ty 93.8 :tz 123.1 :s -1.2 :rx 0.0 :ry 0.0 :rz 0.156 }))
;; (inverse-transform { :tx 89.5, :ty 93.8 :tz 123.1 :s -1.2 :rx 0.0 :ry 0.0 :rz 0.156 })
;; (geopoint (osgrid->geopoint hazelfield :froboz) :WGS84)