Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
</ng-template>
<ng-template #stationTemplate let-station>
<div class="station-title">{{ station.properties.name }}</div>
<div class="station-subtitle">{{ station.properties.sbb_id }}</div>
<div class="station-subtitle">
{{ station.properties.sbb_id || station.properties.didokCode }}
</div>
</ng-template>
<ng-template #routeTemplate let-route>
<div class="route-title">{{ route.properties.routeId }}</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export const bielLyssRoutes: SbbSelectableFeatureCollection[] = [
transportType: 'rail',
type: 'endpoint',
endpointType: 'to',
sbb_id: 8504300,
didokCode: 8504300,
},
geometry: {
type: 'Point',
Expand Down
44 changes: 25 additions & 19 deletions src/journey-maps/angular/services/map/map-station-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export const SBB_STATION_LAYER = 'rokas-station-hover';
const MAP_ENDPOINT_LAYERS_V1 = ['rokas-walk-from', 'rokas-walk-to'];
const MAP_ENDPOINT_LAYERS_V2 = ['rokas-route-transfer-ending', 'rokas-route-stopover-circle'];
const MAP_SOURCE_LAYER_OSM_POINTS = 'osm_points';
const FEATURE_SBB_ID_FIELD_NAME = 'sbb_id';
const FEATURE_SBB_ID_FIELD_NAME = 'sbb_id'; // old name in journey-maps response (v1)
const FEATURE_DIDOK_CODE_FIELD_NAME = 'didokCode'; // new name in journey-routes response (v2)

@Injectable({ providedIn: 'root' })
export class SbbMapStationService {
Expand Down Expand Up @@ -62,7 +63,9 @@ export class SbbMapStationService {
layers: isV1Style(map) ? MAP_ENDPOINT_LAYERS_V1 : MAP_ENDPOINT_LAYERS_V2,
})
.filter((f) => {
return FEATURE_SBB_ID_FIELD_NAME in f.properties;
return (
FEATURE_SBB_ID_FIELD_NAME in f.properties || FEATURE_DIDOK_CODE_FIELD_NAME in f.properties
);
})
.map(this._mapToFeature);

Expand All @@ -71,23 +74,26 @@ export class SbbMapStationService {
}

return endpoints
.map(
(p) =>
map
.querySourceFeatures('base', {
sourceLayer: MAP_SOURCE_LAYER_OSM_POINTS,
filter: [
'in',
FEATURE_SBB_ID_FIELD_NAME,
String(p.properties[FEATURE_SBB_ID_FIELD_NAME]),
],
})
.map((sourceFeature) => ({
...this._mapToFeature(sourceFeature),
geometry: p.geometry, // get endpoint location not the tile source
}))
.pop(), // There might be multiple stations in the tile source
)
.map((p) => {
// Get the ID value from either sbb_id or didokCode field
const idValue =
p.properties[FEATURE_SBB_ID_FIELD_NAME] || p.properties[FEATURE_DIDOK_CODE_FIELD_NAME];

return map
.querySourceFeatures('base', {
sourceLayer: MAP_SOURCE_LAYER_OSM_POINTS,
filter: [
'any',
['in', FEATURE_SBB_ID_FIELD_NAME, String(idValue)],
['in', FEATURE_DIDOK_CODE_FIELD_NAME, String(idValue)],
],
})
.map((sourceFeature) => ({
...this._mapToFeature(sourceFeature),
geometry: p.geometry, // get endpoint location not the tile source
}))
.pop(); // There might be multiple stations in the tile source
})
.filter((s) => s!!) as Feature[];
}

Expand Down