summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMischa Untaga <99098079+MischaU8@users.noreply.github.com>2023-09-26 14:05:17 +0200
committerMischa Untaga <99098079+MischaU8@users.noreply.github.com>2023-09-26 14:05:17 +0200
commit0c448a725a49f2cb620f97c661200f3d9d1d05dd (patch)
tree6d7c4382b3759a5484bf53b02d4e81ac6645bfcb
parent14feff197da20070678dc6f8c15d4fa90262bef9 (diff)
downloadalgeria-0c448a725a49f2cb620f97c661200f3d9d1d05dd.tar.gz
track adjecency, add ids
-rw-r--r--tools/gendata.js117
1 files changed, 77 insertions, 40 deletions
diff --git a/tools/gendata.js b/tools/gendata.js
index 75c7348..104681e 100644
--- a/tools/gendata.js
+++ b/tools/gendata.js
@@ -27,61 +27,97 @@ def_location("III")
def_location("IV")
def_location("V")
def_location("VI")
-def_location("France")
-def_location("Morocco")
-def_location("Tunisia")
-
-function def_area(name, type, zone, x, y, w, h) {
- let id = 0
- if (name in locations) {
- id = locations[name]
+// def_location("France")
+// def_location("Morocco")
+// def_location("Tunisia")
+
+function def_area(id, name, type, zone, x, y, w, h) {
+ let loc = 0
+ if (id in locations) {
+ loc = locations[id]
} else {
- id = def_location(name)
+ loc = def_location(id)
}
- areas.push({id, name, type, zone, x, y, w, h})
+ areas.push({loc, id, name, type, zone, x, y, w, h})
if (zone) {
if (!(zone in zones)) {
zones[zone] = []
}
- zones[zone].push(name)
+ zones[zone].push(id)
}
}
-def_area("Oran", URBAN, "V", 430.6, 588.8)
-def_area("Algiers", URBAN, "IV", 1185.6, 346.8)
-def_area("Constantine", URBAN, "II", 2066.6, 315.8)
-
-def_area("France", COUNTRY, null, 1605, 185.3, 266, 212.4)
-def_area("Morocco", COUNTRY, null, 109, 1765, 94, 94)
-def_area("Tunisia", COUNTRY, null, 2499.9, 1667.6, 94, 94)
+def_area("FRANCE", "France", COUNTRY, null, 1605, 185.3, 266, 212.4)
+def_area("TUNISIA", "Tunisia", COUNTRY, null, 2499.9, 1667.6, 94, 94)
+def_area("MOROCCO", "Morocco", COUNTRY, null, 109, 1765, 94, 94)
+
+def_area("I-1", "Barika", RURAL, "I", 1708.1, 1117.9)
+def_area("I-2", "Batna", REMOTE, "I", 2185.6, 1390.9)
+def_area("I-3", "Biskra", REMOTE, "I", 1853.6, 1620.9)
+def_area("I-4", "Tebessa", RURAL, "I", 2299.6, 1120.9)
+
+def_area("CONSTANTINE", "Constantine", URBAN, "II", 2066.6, 315.8)
+def_area("II-1", "Setif", RURAL, "II", 1917.6, 800.8)
+def_area("II-2", "Phillippeville", RURAL, "II", 2200.6, 584.9)
+def_area("II-3", "Souk Ahras", RURAL, "II", 2347.6, 848.9)
+
+def_area("III-1", "Tizi Ouzou", RURAL, "III", 1473.6, 578.9)
+def_area("III-2", "Bordj Bou Arreridj", RURAL, "III", 1465.6, 832.9)
+def_area("III-3", "Bougie", RURAL, "III", 1703.6, 616.9)
+
+def_area("ALGIERS", "Algiers", URBAN, "IV", 1185.6, 346.8)
+def_area("IV-1", "Medea", RURAL, "IV", 1212, 727)
+def_area("IV-2", "Orleansville", RURAL, "IV", 982, 780.2)
+
+def_area("ORAN", "Oran", URBAN, "V", 430.6, 588.8)
+def_area("V-1", "Mecheria", REMOTE, "V", 234, 1485.7)
+def_area("V-2", "Tlemcen", RURAL, "V", 173, 1140.9)
+def_area("V-3", "Sidi Bel Abbes", RURAL, "V", 476, 1038)
+def_area("V-4", "Mostaganem", RURAL, "V", 741, 863.9)
+def_area("V-5", "Saida", REMOTE, "V", 501, 1419.1)
+def_area("V-6", "Mascara", REMOTE, "V", 785, 1302.9)
+def_area("V-7", "Ain Sefra", REMOTE, "V", 752, 1670.9)
+def_area("V-8", "Laghouat", REMOTE, "V", 1191, 1615.6)
+
+def_area("VI-1", "Sidi Aissa", REMOTE, "VI", 1385, 1186)
+def_area("VI-2", "Ain Qussera", RURAL, "VI", 1070.6, 1235.6)
+
+
+let adjecents = {}
+
+function def_adjecent(id, neighbours) {
+ function add_adjecent(from, to) {
+ const from_id = locations[from]
+ if (!(from_id in adjecents)) {
+ adjecents[from_id] = []
+ }
+ adjecents[from_id].push(locations[to])
+ }
+ for (const n of neighbours) {
+ add_adjecent(id, n)
+ add_adjecent(n, id)
+ }
+}
-def_area("Barika", RURAL, "I", 1708.1, 1117.9)
-def_area("Batna", REMOTE, "I", 2185.6, 1390.9)
-def_area("Biskra", REMOTE, "I", 1853.6, 1620.9)
-def_area("Tebessa", RURAL, "I", 2299.6, 1120.9)
+// only adjecent with neighbour zones are tracked, defined one way but they are bidirectional
+def_adjecent("TUNISIA", ["I-2", "I-3", "I-4", "II-3"])
+def_adjecent("MOROCCO", ["V-1", "V-2", "V-7"])
-def_area("Setif", RURAL, "II", 1917.6, 800.8)
-def_area("Souk Ahras", RURAL, "II", 2347.6, 848.9)
-def_area("Phillippeville", RURAL, "II", 2200.6, 584.9)
+def_adjecent("I-1", ["II-1", "III-2", "VI-1"])
+def_adjecent("I-3", ["V-8", "VI-1"])
+def_adjecent("I-4", ["II-1", "II-2", "II-3"])
-def_area("Tizi Ouzou", RURAL, "III", 1473.6, 578.9)
-def_area("Bordj Bou Arreridj", RURAL, "III", 1465.6, 832.9)
-def_area("Bougie", RURAL, "III", 1703.6, 616.9)
+def_adjecent("II-1", ["III-2", "III-3"])
-def_area("Medea", RURAL, "IV", 1212, 727)
-def_area("Orleansville", RURAL, "IV", 982, 780.2)
+def_adjecent("III-1", ["IV-1"])
+def_adjecent("III-2", ["IV-1", "VI-1"])
-def_area("Mecheria", REMOTE, "V", 234, 1485.7)
-def_area("Tlemcen", RURAL, "V", 173, 1140.9)
-def_area("Sidi Bel Abbes", RURAL, "V", 476, 1038)
-def_area("Mostaganem", RURAL, "V", 741, 863.9)
-def_area("Saida", REMOTE, "V", 501, 1419.1)
-def_area("Mascara", REMOTE, "V", 785, 1302.9)
-def_area("Ain Sefra", REMOTE, "V", 752, 1670.9)
-def_area("Laghouat", REMOTE, "V", 1191, 1615.6)
+def_adjecent("IV-1", ["VI-1", "VI-2"])
+def_adjecent("IV-2", ["V-4", "VI-2"])
-def_area("Sidi Aissa", REMOTE, "VI", 1385, 1186)
-def_area("Ain Qussera", RURAL, "VI", 1070.6, 1235.6)
+def_adjecent("V-4", ["VI-2"])
+def_adjecent("V-6", ["VI-2"])
+def_adjecent("V-8", ["VI-1", "VI-2"])
// XXX not sure about this
@@ -93,6 +129,7 @@ for (let l of ["I", "II", "III", "IV", "V", "VI"]) {
data.areas = areas
data.zones = zones
data.locations = locations
+data.adjecents = adjecents
data.free_deploy_locations = free_deploy_locations
let units = []