-
Notifications
You must be signed in to change notification settings - Fork 2
/
clj_data.cljs
26 lines (24 loc) · 1.07 KB
/
clj_data.cljs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(ns js2clj2js.clj-data)
(defn- bigmac-etc->feature [{:keys [bigmac-index country-name points]}]
(let [{polygon-type :type open-coordinates :coordinates} points
{:keys [dollar_price local_price]} bigmac-index
close-polygon (fn [coords]
[(conj coords (first coords))])
coordinates (if (= "polygon" polygon-type)
(close-polygon open-coordinates)
(map (fn [coords]
(close-polygon coords))
open-coordinates))]
{:type "Feature"
:geometry {:type (if (= "polygon" polygon-type)
"Polygon"
"MultiPolygon")
:coordinates coordinates}
:properties (assoc bigmac-index
:country-name country-name
:dollar-price (js/Number dollar_price)
:local-price (js/Number local_price))}))
(defn ->geo-json [data]
(let [features (map bigmac-etc->feature data)]
{:type "FeatureCollection"
:features features}))