Compare commits
No commits in common. "59c28f544ef2985aa73f6150d3167fc6b3a4db03" and "38afb5a60d7c82b52c50c18268614fcb3a2a645b" have entirely different histories.
59c28f544e
...
38afb5a60d
|
@ -25,41 +25,22 @@ h0NmFsdzQ3emxqIn0.cyxF0h36emIMTk3cc4VqUw`;
|
||||||
const simulation = require('../tam/simulation');
|
const simulation = require('../tam/simulation');
|
||||||
const network = require('../tam/network.json');
|
const network = require('../tam/network.json');
|
||||||
|
|
||||||
const getRoutesLines = routes => routes.filter(
|
const getRouteColors = routes =>
|
||||||
|
{
|
||||||
|
const colors = routes.filter(
|
||||||
// Only consider normal routes (excluding alternate routes)
|
// Only consider normal routes (excluding alternate routes)
|
||||||
([lineRef, routeRef]) =>
|
([lineRef, routeRef]) =>
|
||||||
network.lines[lineRef].routes[routeRef].state === 'normal'
|
network.lines[lineRef].routes[routeRef].state === 'normal'
|
||||||
).map(([lineRef]) => lineRef);
|
).map(([lineRef]) => network.lines[lineRef].color);
|
||||||
|
|
||||||
const getLinesColors = lines =>
|
if (colors.length >= 1)
|
||||||
{
|
{
|
||||||
if (lines.length >= 1)
|
return colors;
|
||||||
{
|
|
||||||
return lines.map(lineRef => network.lines[lineRef].color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['#FFFFFF'];
|
return ['#FFFFFF'];
|
||||||
};
|
};
|
||||||
|
|
||||||
const lineFeaturesOrder = (feature1, feature2) =>
|
|
||||||
{
|
|
||||||
const lines1 = feature1.get('lines');
|
|
||||||
|
|
||||||
if (lines1.length === 0)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const lines2 = feature2.get('lines');
|
|
||||||
|
|
||||||
if (lines2.length === 0)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Math.min(...lines1) - Math.min(...lines2);
|
|
||||||
};
|
|
||||||
|
|
||||||
const makeDataSources = () =>
|
const makeDataSources = () =>
|
||||||
{
|
{
|
||||||
const segmentsSource = new VectorSource();
|
const segmentsSource = new VectorSource();
|
||||||
|
@ -68,8 +49,7 @@ const makeDataSources = () =>
|
||||||
segmentsSource.addFeatures(
|
segmentsSource.addFeatures(
|
||||||
Object.values(network.segments).map(({routes, nodes}) =>
|
Object.values(network.segments).map(({routes, nodes}) =>
|
||||||
new Feature({
|
new Feature({
|
||||||
lines: getRoutesLines(routes),
|
colors: getRouteColors(routes),
|
||||||
colors: getLinesColors(getRoutesLines(routes)),
|
|
||||||
geometry: new LineString(nodes.map(
|
geometry: new LineString(nodes.map(
|
||||||
({lat, lon}) => proj.fromLonLat([lon, lat])
|
({lat, lon}) => proj.fromLonLat([lon, lat])
|
||||||
)),
|
)),
|
||||||
|
@ -80,8 +60,7 @@ const makeDataSources = () =>
|
||||||
stopsSource.addFeatures(
|
stopsSource.addFeatures(
|
||||||
Object.values(network.stops).map(({routes, lon, lat}) =>
|
Object.values(network.stops).map(({routes, lon, lat}) =>
|
||||||
new Feature({
|
new Feature({
|
||||||
lines: getRoutesLines(routes),
|
colors: getRouteColors(routes),
|
||||||
colors: getLinesColors(getRoutesLines(routes)),
|
|
||||||
geometry: new Point(proj.fromLonLat([lon, lat])),
|
geometry: new Point(proj.fromLonLat([lon, lat])),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
@ -213,7 +192,6 @@ const createMap = target =>
|
||||||
|
|
||||||
const segmentsBorderLayer = new VectorLayer({
|
const segmentsBorderLayer = new VectorLayer({
|
||||||
source: segmentsSource,
|
source: segmentsSource,
|
||||||
renderOrder: lineFeaturesOrder,
|
|
||||||
style: segmentBorderStyle,
|
style: segmentBorderStyle,
|
||||||
|
|
||||||
updateWhileInteracting: true,
|
updateWhileInteracting: true,
|
||||||
|
@ -222,7 +200,6 @@ const createMap = target =>
|
||||||
|
|
||||||
const segmentsInnerLayer = new VectorLayer({
|
const segmentsInnerLayer = new VectorLayer({
|
||||||
source: segmentsSource,
|
source: segmentsSource,
|
||||||
renderOrder: lineFeaturesOrder,
|
|
||||||
style: segmentInnerStyle,
|
style: segmentInnerStyle,
|
||||||
|
|
||||||
updateWhileInteracting: true,
|
updateWhileInteracting: true,
|
||||||
|
@ -231,7 +208,6 @@ const createMap = target =>
|
||||||
|
|
||||||
const stopsLayer = new VectorLayer({
|
const stopsLayer = new VectorLayer({
|
||||||
source: stopsSource,
|
source: stopsSource,
|
||||||
renderOrder: lineFeaturesOrder,
|
|
||||||
style: stopStyle,
|
style: stopStyle,
|
||||||
|
|
||||||
minZoom: 13,
|
minZoom: 13,
|
||||||
|
|
|
@ -238,7 +238,7 @@ class Course
|
||||||
{
|
{
|
||||||
if (!(`${this.currentStop}-${stop}` in network.segments))
|
if (!(`${this.currentStop}-${stop}` in network.segments))
|
||||||
{
|
{
|
||||||
console.warn(`Course ${this.id} cannot go from stop
|
console.warn(`Course ${this.id} is cannot go from stop
|
||||||
${this.currentStop} to stop ${stop}. Teleporting to ${stop}`);
|
${this.currentStop} to stop ${stop}. Teleporting to ${stop}`);
|
||||||
this.arriveToStop(stop);
|
this.arriveToStop(stop);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue