|
1 'use strict'; |
|
2 |
|
3 const path = require('path'); |
|
4 const Q = require('q'); |
|
5 const request = require('request'); |
|
6 const _ = require('lodash'); |
|
7 const fs = require('fs'); |
|
8 |
|
9 const continentGeonamesIds = { |
|
10 'africa': '6255146', |
|
11 'asia': '6255147', |
|
12 'europe': '6255148', |
|
13 'north_america': '6255149', |
|
14 'australia': '6255151', |
|
15 'south_america': '6255150', |
|
16 'antarctica': '6255152' |
|
17 }; |
|
18 |
|
19 const regionsGeonamesIds = { |
|
20 'FR-A' : '11071622', // Alsace-Champagne-Ardenne-Lorraine |
|
21 'FR-B' : '11071620', // Aquitaine-Limousin-Poitou-Charentes |
|
22 'FR-C' : '11071625', // Auvergne-Rhône-Alpes |
|
23 'FR-D' : '11071619', // Bourgogne-Franche-Comté |
|
24 'FR-E' : '3030293', // Bretagne |
|
25 'FR-F' : '3027939', // Centre-Val de Loire |
|
26 'FR-G' : '3023519', // Corse |
|
27 'FR-H' : '3012874', // Île-de-France |
|
28 'FR-I' : '11071623', // Languedoc-Roussillon-Midi-Pyrénées |
|
29 'FR-J' : '11071624', // Nord-Pas-de-Calais-Picardie |
|
30 'FR-K' : '11071621', // Normandie |
|
31 'FR-L' : '2988289', // Pays-de-la-Loire |
|
32 'FR-M' : '2985244', // Provence-Alpes-Côte d'Azur |
|
33 }; |
|
34 |
|
35 const contriesGeonamesIds = { |
|
36 "AD": "3041565", "AE": "290557", "AF": "1149361", "AG": "3576396", "AI": "3573511", |
|
37 "AL": "783754", "AM": "174982", "AO": "3351879", "AQ": "6697173", "AR": "3865483", |
|
38 "AS": "5880801", "AT": "2782113", "AU": "2077456", "AW": "3577279", "AX": "661882", |
|
39 "AZ": "587116", "BA": "3277605", "BB": "3374084", "BD": "1210997", "BE": "2802361", |
|
40 "BF": "2361809", "BG": "732800", "BH": "290291", "BI": "433561", "BJ": "2395170", |
|
41 "BL": "3578476", "BM": "3573345", "BN": "1820814", "BO": "3923057", "BQ": "7626844", |
|
42 "BR": "3469034", "BS": "3572887", "BT": "1252634", "BV": "3371123", "BW": "933860", |
|
43 "BY": "630336", "BZ": "3582678", "CA": "6251999", "CC": "1547376", "CD": "203312", |
|
44 "CF": "239880", "CG": "2260494", "CH": "2658434", "CI": "2287781", "CK": "1899402", |
|
45 "CL": "3895114", "CM": "2233387", "CN": "1814991", "CO": "3686110", "CR": "3624060", |
|
46 "CU": "3562981", "CV": "3374766", "CW": "7626836", "CX": "2078138", "CY": "146669", |
|
47 "CZ": "3077311", "DE": "2921044", "DJ": "223816", "DK": "2623032", "DM": "3575830", |
|
48 "DO": "3508796", "DZ": "2589581", "EC": "3658394", "EE": "453733", "EG": "357994", |
|
49 "EH": "2461445", "ER": "338010", "ES": "2510769", "ET": "337996", "FI": "660013", |
|
50 "FJ": "2205218", "FK": "3474414", "FM": "2081918", "FO": "2622320", "FR": "3017382", |
|
51 "GA": "2400553", "GB": "2635167", "GD": "3580239", "GE": "614540", "GF": "3381670", |
|
52 "GG": "3042362", "GH": "2300660", "GI": "2411586", "GL": "3425505", "GM": "2413451", |
|
53 "GN": "2420477", "GP": "3579143", "GQ": "2309096", "GR": "390903", "GS": "3474415", |
|
54 "GT": "3595528", "GU": "4043988", "GW": "2372248", "GY": "3378535", "HK": "1819730", |
|
55 "HM": "1547314", "HN": "3608932", "HR": "3202326", "HT": "3723988", "HU": "719819", |
|
56 "ID": "1643084", "IE": "2963597", "IL": "294640", "IM": "3042225", "IN": "1269750", |
|
57 "IO": "1282588", "IQ": "99237", "IR": "130758", "IS": "2629691", "IT": "3175395", |
|
58 "JE": "3042142", "JM": "3489940","JO": "248816", "JP": "1861060", "KE": "192950", |
|
59 "KG": "1527747", "KH": "1831722", "KI": "4030945", "KM": "921929", "KN": "3575174", |
|
60 "KP": "1873107", "KR": "1835841", "XK": "831053", "KW": "285570", "KY": "3580718", |
|
61 "KZ": "1522867", "LA": "1655842", "LB": "272103", "LC": "3576468", "LI": "3042058", |
|
62 "LK": "1227603", "LR": "2275384", "LS": "932692", "LT": "597427", "LU": "2960313", |
|
63 "LV": "458258", "LY": "2215636", "MA": "2542007", "MC": "2993457", "MD": "617790", |
|
64 "ME": "3194884", "MF": "3578421", "MG": "1062947", "MH": "2080185", "MK": "718075", |
|
65 "ML": "2453866", "MM": "1327865", "MN": "2029969", "MO": "1821275", "MP": "4041468", |
|
66 "MQ": "3570311", "MR": "2378080", "MS": "3578097", "MT": "2562770", "MU": "934292", |
|
67 "MV": "1282028", "MW": "927384", "MX": "3996063", "MY": "1733045", "MZ": "1036973", |
|
68 "NA": "3355338", "NC": "2139685", "NE": "2440476", "NF": "2155115", "NG": "2328926", |
|
69 "NI": "3617476", "NL": "2750405", "NO": "3144096", "NP": "1282988", "NR": "2110425", |
|
70 "NU": "4036232", "NZ": "2186224", "OM": "286963", "PA": "3703430", "PE": "3932488", |
|
71 "PF": "4030656", "PG": "2088628", "PH": "1694008","PK": "1168579", "PL": "798544", |
|
72 "PM": "3424932", "PN": "4030699", "PR": "4566966", "PS": "6254930", "PT": "2264397", |
|
73 "PW": "1559582", "PY": "3437598","QA": "289688", "RE": "935317", "RO": "798549", |
|
74 "RS": "6290252", "RU": "2017370", "RW": "49518", "SA": "102358", "SB": "2103350", |
|
75 "SC": "241170", "SD": "366755", "SS": "7909807", "SE": "2661886", "SG": "1880251", |
|
76 "SH": "3370751", "SI": "3190538", "SJ": "607072", "SK": "3057568", "SL": "2403846", |
|
77 "SM": "3168068", "SN": "2245662", "SO": "51537", "SR": "3382998", "ST": "2410758", |
|
78 "SV": "3585968", "SX": "7609695", "SY": "163843", "SZ": "934841", "TC": "3576916", |
|
79 "TD": "2434508", "TF": "1546748", "TG": "2363686", "TH": "1605651", "TJ": "1220409", |
|
80 "TK": "4031074", "TL": "1966436", "TM": "1218197", "TN": "2464461", "TO": "4032283", |
|
81 "TR": "298795", "TT": "3573591", "TV": "2110297", "TW": "1668284", "TZ": "149590", |
|
82 "UA": "690791", "UG": "226074", "UM": "5854968", "US": "6252001", "UY": "3439705", |
|
83 "UZ": "1512440", "VA": "3164670", "VC": "3577815", "VE": "3625428", "VG": "3577718", |
|
84 "VI": "4796775", "VN": "1562822", "VU": "2134431", "WF": "4034749", "WS": "4034894", |
|
85 "YE": "69543", "YT": "1024031", "ZA": "953987", "ZM": "895949", "ZW": "878675", |
|
86 "CS": "8505033", "AN": "8505032" |
|
87 } |
|
88 |
|
89 global.AmCharts = {'maps': { |
|
90 'worldLow': null, |
|
91 'continentsLow': null, |
|
92 'france2016Low': null |
|
93 }}; |
|
94 |
|
95 require(path.join(__dirname,'..','..', 'bower_components/ammap3/ammap/maps/js/worldLow.js')); |
|
96 require(path.join(__dirname,'..','..', 'bower_components/ammap3/ammap/maps/js/continentsLow.js')); |
|
97 require(path.join(__dirname,'..','..', 'bower_components/ammap3/ammap/maps/js/france2016Low.js')); |
|
98 |
|
99 |
|
100 function convert_path_id(map, ids) { |
|
101 map['svg']['g']['path'] = _.map(map['svg']['g']['path'], function(path) { |
|
102 return _.defaults( { 'id': ids[path['id']] } ,path ); |
|
103 }) |
|
104 return map; |
|
105 } |
|
106 |
|
107 fs.writeFileSync( |
|
108 path.join(__dirname,'..','..','vendor/data/maps/france2016Low.js'), |
|
109 "AmCharts.maps.france2016Low=" + JSON.stringify(convert_path_id(AmCharts.maps.france2016Low, regionsGeonamesIds), null, '\t') |
|
110 ); |
|
111 |
|
112 fs.writeFileSync( |
|
113 path.join(__dirname,'..','..','vendor/data/maps/continentsLow.js'), |
|
114 "AmCharts.maps.continentsLow=" + JSON.stringify(convert_path_id(AmCharts.maps.continentsLow, continentGeonamesIds), null, '\t') |
|
115 ); |
|
116 |
|
117 fs.writeFileSync( |
|
118 path.join(__dirname,'..','..','vendor/data/maps/worldLow.js'), |
|
119 "AmCharts.maps.worldLow=" + JSON.stringify(convert_path_id(AmCharts.maps.worldLow, contriesGeonamesIds), null, '\t') |
|
120 ); |