Update front for new back network format
This commit is contained in:
parent
944207ed8a
commit
dd154afa9d
|
@ -42,31 +42,25 @@ fetch(SERVER + '/network').then(res => res.json()).then(network =>
|
||||||
{
|
{
|
||||||
const stopPoints = Object.entries(network.stops)
|
const stopPoints = Object.entries(network.stops)
|
||||||
.map(([stopId, stop]) =>
|
.map(([stopId, stop]) =>
|
||||||
{
|
new Feature({
|
||||||
const feature = new Feature({
|
|
||||||
type: 'stop',
|
type: 'stop',
|
||||||
color: network.lines[stop.lines[0]].color,
|
color: network.lines[stop.lines[0]].color,
|
||||||
geometry: new Point(proj.fromLonLat([stop.lon, stop.lat])),
|
geometry: new Point(proj.fromLonLat([stop.lon, stop.lat])),
|
||||||
});
|
})
|
||||||
|
);
|
||||||
|
|
||||||
feature.setId(stopId);
|
const segmentLines = Object.values(network.lines)
|
||||||
return feature;
|
.flatMap(({color, routes}) =>
|
||||||
});
|
routes.map(({segments}) =>
|
||||||
|
new Feature({
|
||||||
const segmentLines = Object.entries(network.segments)
|
|
||||||
.map(([segmentId, segment]) =>
|
|
||||||
{
|
|
||||||
const feature = new Feature({
|
|
||||||
type: 'segment',
|
type: 'segment',
|
||||||
color: network.lines[segment.lines[0]].color,
|
color,
|
||||||
geometry: new LineString(segment.nodes.map(
|
geometry: new LineString(segments.flat().map(
|
||||||
({lat, lon}) => proj.fromLonLat([lon, lat])
|
({lat, lon}) => proj.fromLonLat([lon, lat])
|
||||||
)),
|
)),
|
||||||
});
|
})
|
||||||
|
)
|
||||||
feature.setId(segmentId);
|
);
|
||||||
return feature;
|
|
||||||
});
|
|
||||||
|
|
||||||
dataSource.addFeatures(
|
dataSource.addFeatures(
|
||||||
stopPoints.concat(segmentLines)
|
stopPoints.concat(segmentLines)
|
||||||
|
|
Loading…
Reference in New Issue