Prevent lines duplicate in network data

This commit is contained in:
Mattéo Delabre 2020-01-16 19:10:30 +01:00
parent 08ecd10813
commit 783f29ce68
Signed by: matteo
GPG Key ID: AE3FBD02DC583ABB
3 changed files with 18 additions and 91 deletions

View File

@ -261,12 +261,12 @@ ${joinSentence(Array.from(candidate.directions), ', ', ' or ')}
lat: stop.lat, lat: stop.lat,
lon: stop.lon, lon: stop.lon,
name: stop.tags.name, name: stop.tags.name,
lines: [lineRef], lines: new Set([lineRef]),
}; };
} }
else else
{ {
stops[stop.tags.ref].lines.push(lineRef); stops[stop.tags.ref].lines.add(lineRef);
} }
} }
} }
@ -376,7 +376,7 @@ ${joinSentence(Array.from(candidate.directions), ', ', ' or ')}
const {lat, lon} = elements[id]; const {lat, lon} = elements[id];
return {latitude: lat, longitude: lon}; return {latitude: lat, longitude: lon};
})), })),
lines: [lineRef], lines: new Set([lineRef]),
}; };
found = true; found = true;
@ -409,7 +409,7 @@ ${joinSentence(Array.from(candidate.directions), ', ', ' or ')}
} }
else else
{ {
segments[segmentId].lines.push(lineRef); segments[segmentId].lines.add(lineRef);
} }
++currentStopIndex; ++currentStopIndex;

View File

@ -195,7 +195,6 @@
"lon": 3.8955449, "lon": 3.8955449,
"name": "Moularès (Hôtel de Ville)", "name": "Moularès (Hôtel de Ville)",
"lines": [ "lines": [
"3",
"3", "3",
"1" "1"
] ]
@ -205,7 +204,6 @@
"lon": 3.8999684, "lon": 3.8999684,
"name": "Port Marianne", "name": "Port Marianne",
"lines": [ "lines": [
"3",
"3", "3",
"1" "1"
] ]
@ -279,7 +277,6 @@
"lon": 3.899234, "lon": 3.899234,
"name": "Port Marianne", "name": "Port Marianne",
"lines": [ "lines": [
"3",
"3", "3",
"1" "1"
] ]
@ -289,7 +286,6 @@
"lon": 3.8955356, "lon": 3.8955356,
"name": "Moularès (Hôtel de Ville)", "name": "Moularès (Hôtel de Ville)",
"lines": [ "lines": [
"3",
"3", "3",
"1" "1"
] ]
@ -521,7 +517,6 @@
"lon": 3.8444363, "lon": 3.8444363,
"name": "La Condamine", "name": "La Condamine",
"lines": [ "lines": [
"2",
"2" "2"
] ]
}, },
@ -604,7 +599,6 @@
"lon": 3.8842954, "lon": 3.8842954,
"name": "Place Carnot", "name": "Place Carnot",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -613,7 +607,6 @@
"lon": 3.8892253, "lon": 3.8892253,
"name": "Voltaire", "name": "Voltaire",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -622,7 +615,6 @@
"lon": 3.8940022, "lon": 3.8940022,
"name": "Rives du Lez", "name": "Rives du Lez",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -887,7 +879,6 @@
"lon": 3.8938614, "lon": 3.8938614,
"name": "Rives du Lez", "name": "Rives du Lez",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -896,7 +887,6 @@
"lon": 3.8889694, "lon": 3.8889694,
"name": "Voltaire", "name": "Voltaire",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -905,7 +895,6 @@
"lon": 3.8842324, "lon": 3.8842324,
"name": "Place Carnot", "name": "Place Carnot",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1004,7 +993,6 @@
"lon": 3.8099711, "lon": 3.8099711,
"name": "Juvignac", "name": "Juvignac",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1013,7 +1001,6 @@
"lon": 3.8196447, "lon": 3.8196447,
"name": "Mosson", "name": "Mosson",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1022,7 +1009,6 @@
"lon": 3.8259015, "lon": 3.8259015,
"name": "Celleneuve", "name": "Celleneuve",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1031,7 +1017,6 @@
"lon": 3.8321502, "lon": 3.8321502,
"name": "Pilory", "name": "Pilory",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1040,7 +1025,6 @@
"lon": 3.8351279, "lon": 3.8351279,
"name": "Hôtel du Département", "name": "Hôtel du Département",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1049,7 +1033,6 @@
"lon": 3.8397593, "lon": 3.8397593,
"name": "Pergola", "name": "Pergola",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1058,7 +1041,6 @@
"lon": 3.8397933, "lon": 3.8397933,
"name": "Tonnelles", "name": "Tonnelles",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1067,7 +1049,6 @@
"lon": 3.8467949, "lon": 3.8467949,
"name": "Jules Guesde", "name": "Jules Guesde",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1076,7 +1057,6 @@
"lon": 3.855048, "lon": 3.855048,
"name": "Astruc", "name": "Astruc",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1085,7 +1065,6 @@
"lon": 3.8624768, "lon": 3.8624768,
"name": "Arceaux", "name": "Arceaux",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1094,7 +1073,6 @@
"lon": 3.8681087, "lon": 3.8681087,
"name": "Plan Cabanes", "name": "Plan Cabanes",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1103,7 +1081,6 @@
"lon": 3.8739545, "lon": 3.8739545,
"name": "Saint-Denis", "name": "Saint-Denis",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1113,7 +1090,6 @@
"name": "Observatoire", "name": "Observatoire",
"lines": [ "lines": [
"4", "4",
"3",
"3" "3"
] ]
}, },
@ -1123,7 +1099,6 @@
"name": "Gare Saint-Roch", "name": "Gare Saint-Roch",
"lines": [ "lines": [
"4", "4",
"3",
"3" "3"
] ]
}, },
@ -1164,7 +1139,6 @@
"lon": 3.9034583, "lon": 3.9034583,
"name": "Pablo Picasso", "name": "Pablo Picasso",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1173,7 +1147,6 @@
"lon": 3.9257823, "lon": 3.9257823,
"name": "Boirargues", "name": "Boirargues",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1254,7 +1227,6 @@
"lon": 3.9256144, "lon": 3.9256144,
"name": "Boirargues", "name": "Boirargues",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1263,7 +1235,6 @@
"lon": 3.9036298, "lon": 3.9036298,
"name": "Pablo Picasso", "name": "Pablo Picasso",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1305,7 +1276,6 @@
"name": "Gare Saint-Roch", "name": "Gare Saint-Roch",
"lines": [ "lines": [
"4", "4",
"3",
"3" "3"
] ]
}, },
@ -1315,7 +1285,6 @@
"name": "Observatoire", "name": "Observatoire",
"lines": [ "lines": [
"4", "4",
"3",
"3" "3"
] ]
}, },
@ -1324,7 +1293,6 @@
"lon": 3.8727299, "lon": 3.8727299,
"name": "Saint-Denis", "name": "Saint-Denis",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1333,7 +1301,6 @@
"lon": 3.8681304, "lon": 3.8681304,
"name": "Plan Cabanes", "name": "Plan Cabanes",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1342,7 +1309,6 @@
"lon": 3.8615025, "lon": 3.8615025,
"name": "Arceaux", "name": "Arceaux",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1351,7 +1317,6 @@
"lon": 3.8548, "lon": 3.8548,
"name": "Astruc", "name": "Astruc",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1360,7 +1325,6 @@
"lon": 3.8466375, "lon": 3.8466375,
"name": "Jules Guesde", "name": "Jules Guesde",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1369,7 +1333,6 @@
"lon": 3.8395235, "lon": 3.8395235,
"name": "Tonnelles", "name": "Tonnelles",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1378,7 +1341,6 @@
"lon": 3.8391413, "lon": 3.8391413,
"name": "Pergola", "name": "Pergola",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1387,7 +1349,6 @@
"lon": 3.8349511, "lon": 3.8349511,
"name": "Hôtel du Département", "name": "Hôtel du Département",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1396,7 +1357,6 @@
"lon": 3.8319619, "lon": 3.8319619,
"name": "Pilory", "name": "Pilory",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1405,7 +1365,6 @@
"lon": 3.8258568, "lon": 3.8258568,
"name": "Celleneuve", "name": "Celleneuve",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1414,7 +1373,6 @@
"lon": 3.8196588, "lon": 3.8196588,
"name": "Mosson", "name": "Mosson",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1423,7 +1381,6 @@
"lon": 3.810219, "lon": 3.810219,
"name": "Juvignac", "name": "Juvignac",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1440,7 +1397,6 @@
"lon": 3.9139627, "lon": 3.9139627,
"name": "Cougourlude", "name": "Cougourlude",
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -1473,7 +1429,6 @@
"lon": 3.8909614, "lon": 3.8909614,
"name": "Garcia Lorca", "name": "Garcia Lorca",
"lines": [ "lines": [
"4",
"4" "4"
] ]
}, },
@ -1482,7 +1437,6 @@
"lon": 3.8911652, "lon": 3.8911652,
"name": "Garcia Lorca", "name": "Garcia Lorca",
"lines": [ "lines": [
"4",
"4" "4"
] ]
}, },
@ -2207,7 +2161,6 @@
"length": 277, "length": 277,
"lines": [ "lines": [
"4", "4",
"3",
"3" "3"
] ]
}, },
@ -8589,7 +8542,6 @@
"length": 272, "length": 272,
"lines": [ "lines": [
"4", "4",
"3",
"3" "3"
] ]
}, },
@ -16705,7 +16657,6 @@
], ],
"length": 2514, "length": 2514,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -16798,7 +16749,6 @@
], ],
"length": 668, "length": 668,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -16887,7 +16837,6 @@
], ],
"length": 352, "length": 352,
"lines": [ "lines": [
"3",
"3", "3",
"1" "1"
] ]
@ -17049,7 +16998,6 @@
], ],
"length": 478, "length": 478,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -17146,7 +17094,6 @@
], ],
"length": 399, "length": 399,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -17227,7 +17174,6 @@
], ],
"length": 405, "length": 405,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -17404,7 +17350,6 @@
], ],
"length": 508, "length": 508,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -17521,7 +17466,6 @@
], ],
"length": 460, "length": 460,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -17582,7 +17526,6 @@
], ],
"length": 451, "length": 451,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -17655,7 +17598,6 @@
], ],
"length": 563, "length": 563,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -17748,7 +17690,6 @@
], ],
"length": 548, "length": 548,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -17869,7 +17810,6 @@
], ],
"length": 683, "length": 683,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -17978,7 +17918,6 @@
], ],
"length": 636, "length": 636,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -18163,7 +18102,6 @@
], ],
"length": 637, "length": 637,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -18280,7 +18218,6 @@
], ],
"length": 610, "length": 610,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -18345,7 +18282,6 @@
], ],
"length": 358, "length": 358,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -18454,7 +18390,6 @@
], ],
"length": 732, "length": 732,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -18603,7 +18538,6 @@
], ],
"length": 608, "length": 608,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -18920,7 +18854,6 @@
], ],
"length": 1200, "length": 1200,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -19565,7 +19498,6 @@
], ],
"length": 1230, "length": 1230,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -19710,7 +19642,6 @@
], ],
"length": 618, "length": 618,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -19807,7 +19738,6 @@
], ],
"length": 728, "length": 728,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -19868,7 +19798,6 @@
], ],
"length": 362, "length": 362,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -19997,7 +19926,6 @@
], ],
"length": 692, "length": 692,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -20158,7 +20086,6 @@
], ],
"length": 559, "length": 559,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -20267,7 +20194,6 @@
], ],
"length": 629, "length": 629,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -20384,7 +20310,6 @@
], ],
"length": 695, "length": 695,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -20481,7 +20406,6 @@
], ],
"length": 608, "length": 608,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -20550,7 +20474,6 @@
], ],
"length": 482, "length": 482,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -20639,7 +20562,6 @@
], ],
"length": 573, "length": 573,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -20772,7 +20694,6 @@
], ],
"length": 325, "length": 325,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -20949,7 +20870,6 @@
], ],
"length": 516, "length": 516,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -21046,7 +20966,6 @@
], ],
"length": 416, "length": 416,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -21163,7 +21082,6 @@
], ],
"length": 390, "length": 390,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -21356,7 +21274,6 @@
], ],
"length": 476, "length": 476,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -21453,7 +21370,6 @@
], ],
"length": 420, "length": 420,
"lines": [ "lines": [
"3",
"3", "3",
"1" "1"
] ]
@ -21535,7 +21451,6 @@
], ],
"length": 578, "length": 578,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },
@ -21692,7 +21607,6 @@
], ],
"length": 2533, "length": 2533,
"lines": [ "lines": [
"3",
"3" "3"
] ]
}, },

View File

@ -11,6 +11,19 @@ const fs = require('fs');
fs.writeFileSync( fs.writeFileSync(
path.join(__dirname, '../back/data/network.json'), path.join(__dirname, '../back/data/network.json'),
JSON.stringify(data) JSON.stringify(
data,
(_, value) =>
{
if (value instanceof Set)
{
// Convert sets to arrays for JSON representation
return Array.from(value.values());
}
return value;
},
' '
)
); );
})(); })();