rafd / culture-map

0 stars 0 forks source link

Add missing countries to map #32

Open cannawen opened 6 years ago

cannawen commented 6 years ago
[ 
["ad" "Andorra"]
 ["ai" "Anguilla"]
 ["aq" "Antarctica"]
 ["as" "American Samoa"]
 ["aw" "Aruba"]
 ["ax" "Åland Islands"]
 ["bb" "Barbados"]
 ["bh" "Bahrain"]
 ["bl" "Saint Barthélemy"]
 ["bm" "Bermuda"]
 ["bq" "Bonaire, Sint Eustatius and Saba"]
 ["bv" "Bouvet Island"]
 ["cc" "Cocos (Keeling) Islands"]
 ["ck" "Cook Islands"]
 ["cv" "Cabo Verde"]
 ["cw" "Curaçao"]
 ["cx" "Christmas Island"]
 ["eh" "Western Sahara"]
 ["fm" "Micronesia (Federated States of)"]
 ["fo" "Faroe Islands"]
 ["gg" "Guernsey"]
 ["gi" "Gibraltar"]
 ["gs" "South Georgia and the South Sandwich Islands"]
 ["gu" "Guam"]
 ["hk" "Hong Kong"]
 ["hm" "Heard Island and McDonald Islands"]
 ["im" "Isle of Man"]
 ["io" "British Indian Ocean Territory"]
 ["je" "Jersey"]
 ["ki" "Kiribati"]
 ["km" "Comoros"]
 ["kn" "Saint Kitts and Nevis"]
 ["ky" "Cayman Islands"]
 ["li" "Liechtenstein"]
 ["lu" "Luxembourg"]
 ["mc" "Monaco"]
 ["me" "Montenegro"]
 ["mf" "Saint Martin (French part)"]
 ["mh" "Marshall Islands"]
 ["mo" "Macao"]
 ["mp" "Northern Mariana Islands"]
 ["ms" "Montserrat"]
 ["mu" "Mauritius"]
 ["mv" "Maldives"]
 ["nf" "Norfolk Island"]
 ["nr" "Nauru"]
 ["nu" "Niue"]
 ["pf" "French Polynesia"]
 ["pm" "Saint Pierre and Miquelon"]
 ["pn" "Pitcairn"]
 ["ps" "Palestine, State of"]
 ["pw" "Palau"]
 ["re" "Réunion"]
 ["sc" "Seychelles"]
 ["sg" "Singapore"]
 ["sh" "Saint Helena, Ascension and Tristan da Cunha"]
 ["sm" "San Marino"]
 ["ss" "South Sudan"]
 ["st" "Sao Tome and Principe"]
 ["sx" "Sint Maarten (Dutch part)"]
 ["tc" "Turks and Caicos Islands"]
 ["tf" "French Southern Territories"]
 ["tk" "Tokelau"]
 ["tl" "Timor-Leste"]
 ["to" "Tonga"]
 ["tv" "Tuvalu"]
 ["um" "United States Minor Outlying Islands"]
 ["va" "Holy See"]
 ["vc" "Saint Vincent and the Grenadines"]
 ["vg" "Virgin Islands (British)"]
 ["vi" "Virgin Islands (U.S.)"]
 ["vu" "Vanuatu"]
 ["wf" "Wallis and Futuna"]
 ["ws" "Samoa"]
 ["yt" "Mayotte"]
]
cannawen commented 6 years ago
(defn parse []
  (let [code->name (->> (slurp "countries.csv")
                        (clojure.data.csv/read-csv)
                        (map (fn [[name code]]
                               [(clojure.string/lower-case code) name]))
                        (into {}))

        map-codes (->> (slurp "src/culture_map/client/views/map.cljs")
                       (re-seq #":data-cc \"(..)\"")
                       (map second)
                       set)
        iso-codes (set (keys code->name))
        countries (->> map-codes
                       (map (fn [code]
                              {:id code
                               :name (code->name code)
                               :type "country"})))]
    #_(doseq [[code name] code->name]
        (save-record! {:type "country"
                       :id code
                       :name name}))
    (->> (s/difference iso-codes map-codes)
         (map (fn [code]
                [code (code->name code)]))
         (into {})
         (sort))))