Skip to content

Commit

Permalink
Merge pull request #4840 from HSLdevcom/DT-5987
Browse files Browse the repository at this point in the history
feat: support for new speedtram type DT-5987 + DT-5988 + DT-5989
  • Loading branch information
optionsome authored Aug 23, 2023
2 parents 3465def + 8573dff commit af057cb
Show file tree
Hide file tree
Showing 34 changed files with 237 additions and 93 deletions.
28 changes: 16 additions & 12 deletions app/component/TramLeg.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import PropTypes from 'prop-types';
import React from 'react';
import { FormattedMessage } from 'react-intl';
import { getRouteMode } from '../util/modeUtils';

import TransitLeg from './TransitLeg';

const TramLeg = ({ leg, ...props }) => (
<TransitLeg mode="TRAM" leg={leg} {...props}>
<FormattedMessage
id="tram-with-route-number"
values={{
routeNumber: leg.route && leg.route.shortName,
headSign: leg.trip && leg.trip.tripHeadsign,
}}
defaultMessage="Tram {routeNumber} {headSign}"
/>
</TransitLeg>
);
const TramLeg = ({ leg, ...props }) => {
const mode = getRouteMode({ mode: leg.mode, type: leg.route.type });
return (
<TransitLeg mode={mode} leg={leg} {...props}>
<FormattedMessage
id="tram-with-route-number"
values={{
routeNumber: leg.route && leg.route.shortName,
headSign: leg.trip && leg.trip.tripHeadsign,
}}
defaultMessage="Tram {routeNumber} {headSign}"
/>
</TransitLeg>
);
};

TramLeg.propTypes = {
leg: PropTypes.object.isRequired,
Expand Down
3 changes: 3 additions & 0 deletions app/component/itinerary.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ $itinerary-tab-switch-height: 48px;
&.bus-express {
@include getCircleSvg($bus-express-color, $fill);
}
&.tram-local {
@include getCircleSvg($tram-local-color, $fill);
}
&.airplane {
@include getCircleSvg($airplane-color, $fill);
}
Expand Down
11 changes: 9 additions & 2 deletions app/component/map/VehicleMarkerContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const MODES_WITH_ICONS = [
'rail',
'subway',
'ferry',
'tram-local',
];

function getVehicleIcon(
Expand Down Expand Up @@ -80,8 +81,14 @@ function VehicleMarkerContainer(props) {
return visibleVehicles.map(([id, message]) => {
const type = props.topics?.find(t => t.shortName === message.shortName)
?.type;
const mode =
type === ExtendedRouteTypes.BusExpress ? 'bus-express' : message.mode;
let mode;
if (type === ExtendedRouteTypes.BusExpress) {
mode = 'bus-express';
} else if (type === ExtendedRouteTypes.TramLocal) {
mode = 'tram-local';
} else {
mode = message.mode;
}
return (
<IconMarker
key={id}
Expand Down
3 changes: 3 additions & 0 deletions app/component/map/popups/marker-popup.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
.funicular-stop {
color: $funicular-color;
}
.tram-local-stop {
color: $tram-local-color;
}
}

.choose-row-center-column {
Expand Down
1 change: 1 addition & 0 deletions app/component/map/tile-layer/MarkerSelectPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function MarkerSelectPopup(props) {
{...option.feature.properties}
key={option.feature.properties.gtfsId}
colors={props.colors}
routes={option.feature.properties.routes}
/>
);
}
Expand Down
19 changes: 14 additions & 5 deletions app/component/map/tile-layer/SelectStopRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ function isNull(val) {
}

function SelectStopRow(
{ code, type, desc, gtfsId, name, patterns, terminal, colors },
{ code, type, desc, gtfsId, name, terminal, colors, routes },
{ config },
) {
let mode = type;
if (patterns && type === 'BUS' && config.useExtendedRouteTypes) {
const patternArray = JSON.parse(patterns);
if (patternArray.some(p => p.gtfsType === ExtendedRouteTypes.BusExpress)) {
if (routes && type === 'BUS' && config.useExtendedRouteTypes) {
const routesArray = JSON.parse(routes);
if (routesArray.some(p => p.gtfsType === ExtendedRouteTypes.BusExpress)) {
mode = 'bus-express';
}
} else if (routes && type === 'TRAM' && config.useExtendedRouteTypes) {
const routesArray = JSON.parse(routes);
if (routesArray.some(p => p.gtfsType === ExtendedRouteTypes.TramLocal)) {
mode = 'tram-local';
}
}
const iconOptions = {};
switch (mode) {
Expand Down Expand Up @@ -58,6 +63,10 @@ function SelectStopRow(
iconOptions.iconId = 'icon-icon_funicular-stop-lollipop';
iconOptions.className = 'funicular-stop';
break;
case 'tram-local':
iconOptions.iconId = 'icon-icon_tram-local-stop-lollipop';
iconOptions.className = 'tram-local-stop';
break;
case 'FERRY':
iconOptions.iconId = !isNull(code)
? 'icon-icon_ferry'
Expand Down Expand Up @@ -113,7 +122,7 @@ SelectStopRow.propTypes = {
gtfsId: PropTypes.string.isRequired,
type: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
patterns: PropTypes.string,
routes: PropTypes.string,
code: PropTypes.string,
desc: PropTypes.string,
terminal: PropTypes.bool,
Expand Down
20 changes: 19 additions & 1 deletion app/component/map/tile-layer/Stops.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Stops {
this.tile.hilightedStops &&
this.tile.hilightedStops.includes(feature.properties.gtfsId);
let hasTrunkRoute = false;
let hasLocalTramRoute = false;
if (
feature.properties.type === 'BUS' &&
this.config.useExtendedRouteTypes
Expand All @@ -44,6 +45,15 @@ class Stops {
hasTrunkRoute = true;
}
}
if (
feature.properties.type === 'TRAM' &&
this.config.useExtendedRouteTypes
) {
const routes = JSON.parse(feature.properties.routes);
if (routes.some(p => p.gtfsType === ExtendedRouteTypes.TramLocal)) {
hasLocalTramRoute = true;
}
}
const ignoreMinZoomLevel =
feature.properties.type === 'FERRY' ||
feature.properties.type === 'RAIL' ||
Expand All @@ -60,10 +70,18 @@ class Stops {
return;
}

let mode = feature.properties.type;
if (hasTrunkRoute) {
mode = 'bus-express';
}
if (hasLocalTramRoute) {
mode = 'tram-local';
}

drawStopIcon(
this.tile,
feature.geom,
hasTrunkRoute ? 'bus-express' : feature.properties.type,
mode,
!isNull(feature.properties.platform)
? feature.properties.platform
: false,
Expand Down
30 changes: 30 additions & 0 deletions app/configurations/config.hsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export default {
'mode-metro': '#CA4000',
'mode-citybike': '#f2b62d',
'mode-citybike-secondary': '#333333',
'mode-tram-local': '#007E79',
},
},
getAutoSuggestIcons: {
Expand Down Expand Up @@ -642,6 +643,35 @@ export default {
sv: 'hsl.fi/matkustaminen/lahibussit',
},
},
{
showForRoute: route => route.type === 902,
header: {
fi: 'Raide-Jokeri',
en: 'Jokeri Light Rail',
sv: 'Spårjokern',
},
content: {
fi: [
'Sed nibh ante, sodales non tortor vel, ullamcorper auctor massa. Nulla facilisi. Sed pharetra malesuada mauris, et auctor diam luctus at.',
],
en: [
'Sed nibh ante, sodales non tortor vel, ullamcorper auctor massa. Nulla facilisi. Sed pharetra malesuada mauris, et auctor diam luctus at.',
],
sv: [
'Sed nibh ante, sodales non tortor vel, ullamcorper auctor massa. Nulla facilisi. Sed pharetra malesuada mauris, et auctor diam luctus at.',
],
},
closeButtonLabel: {
fi: 'Mitä lähibussi tarkoittaa?',
en: 'What does a neigbourhood route mean?',
sv: 'Vad betyder en närbuss?',
},
link: {
fi: 'hsl.fi/matkustaminen/lahibussit',
en: 'hsl.fi/matkustaminen/lahibussit',
sv: 'hsl.fi/matkustaminen/lahibussit',
},
},
],

embeddedSearch: {
Expand Down
1 change: 1 addition & 0 deletions app/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export const AlertEntityType = Object.freeze({
export const ExtendedRouteTypes = Object.freeze({
BusExpress: 702,
BusLocal: 704,
TramLocal: 902,
});

export const ParkTypes = {
Expand Down
3 changes: 3 additions & 0 deletions app/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,7 @@ const translations = {
'track-short-no-num': 'Track',
traficom: 'Traficom',
tram: 'Tram',
'tram-local': 'Jokeri Light Rail',
'tram-with-route-number': 'Tram {routeNumber} {headSign}',
transfer: 'Transfer',
transfers: 'Number of transfers',
Expand Down Expand Up @@ -2710,6 +2711,7 @@ const translations = {
'track-short-no-num': 'Raide',
traficom: 'Traficom',
tram: 'Raitiovaunu',
'tram-local': 'Raide-Jokeri',
'tram-with-route-number': 'Raitiovaunu {routeNumber} {headSign}',
transfer: 'Vaihto',
transfers: 'Vaihtojen määrä',
Expand Down Expand Up @@ -4627,6 +4629,7 @@ const translations = {
'track-short-no-num': 'Spår',
traficom: 'Traficom',
tram: 'Spårvagn',
'tram-local': 'Spårjokern',
'tram-with-route-number': 'Spårvagn {routeNumber} {headSign}',
transfer: 'Byte',
transfers: 'Antal byten',
Expand Down
2 changes: 2 additions & 0 deletions app/util/modeUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ export const getRouteMode = route => {
return 'bus-express';
case ExtendedRouteTypes.BusLocal:
return 'bus-local';
case ExtendedRouteTypes.TramLocal:
return 'tram-local';
default:
return route.mode?.toLowerCase();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@digitransit-component/digitransit-component-autosuggest-panel",
"version": "2.0.4",
"version": "2.0.5",
"description": "digitransit-component autosuggest-panel module",
"main": "index.js",
"files": [
Expand Down Expand Up @@ -28,8 +28,8 @@
"author": "Digitransit Authors",
"license": "(AGPL-3.0 OR EUPL-1.2)",
"peerDependencies": {
"@digitransit-component/digitransit-component-autosuggest": "^1.9.8",
"@digitransit-component/digitransit-component-icon": "^0.2.1",
"@digitransit-component/digitransit-component-autosuggest": "^1.9.9",
"@digitransit-component/digitransit-component-icon": "^0.2.2",
"@hsl-fi/sass": "^0.2.0",
"classnames": "2.2.6",
"i18next": "^19.3.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@digitransit-component/digitransit-component-autosuggest",
"version": "1.9.8",
"version": "1.9.9",
"description": "digitransit-component autosuggest module",
"main": "index.js",
"files": [
Expand Down Expand Up @@ -36,8 +36,8 @@
},
"peerDependencies": {
"@digitransit-component/digitransit-component-dialog-modal": "^0.3.4",
"@digitransit-component/digitransit-component-icon": "^0.2.1",
"@digitransit-component/digitransit-component-suggestion-item": "^1.1.2",
"@digitransit-component/digitransit-component-icon": "^0.2.2",
"@digitransit-component/digitransit-component-suggestion-item": "^1.1.3",
"@hsl-fi/sass": "^0.2.0",
"classnames": "2.2.6",
"i18next": "^19.3.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@digitransit-component/digitransit-component-control-panel",
"version": "1.1.2",
"version": "1.1.3",
"description": "digitransit-component control-panel module",
"main": "index.js",
"files": [
Expand Down Expand Up @@ -29,7 +29,7 @@
"author": "Digitransit Authors",
"license": "(AGPL-3.0 OR EUPL-1.2)",
"peerDependencies": {
"@digitransit-component/digitransit-component-icon": "^0.2.1",
"@digitransit-component/digitransit-component-icon": "^0.2.2",
"@hsl-fi/sass": "~0.2.0",
"classnames": "2.2.6",
"i18next": "^19.3.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@digitransit-component/digitransit-component-datetimepicker",
"version": "0.7.3",
"version": "0.7.4",
"description": "digitransit-component datetimepicker module",
"main": "index.js",
"files": [
Expand Down Expand Up @@ -29,7 +29,7 @@
"author": "Digitransit Authors",
"license": "(AGPL-3.0 OR EUPL-1.2)",
"peerDependencies": {
"@digitransit-component/digitransit-component-icon": "^0.2.1",
"@digitransit-component/digitransit-component-icon": "^0.2.2",
"i18next": "^19.3.3",
"lodash": "4.17.21",
"lodash-es": "4.17.21",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@digitransit-component/digitransit-component-favourite-bar",
"version": "1.1.2",
"version": "1.1.3",
"description": "digitransit-component favourite-bar module",
"main": "index.js",
"files": [
Expand Down Expand Up @@ -32,8 +32,8 @@
"@digitransit-search-util/digitransit-search-util-uniq-by-label": "^1.1.0"
},
"peerDependencies": {
"@digitransit-component/digitransit-component-icon": "^0.2.1",
"@digitransit-component/digitransit-component-suggestion-item": "^1.1.2",
"@digitransit-component/digitransit-component-icon": "^0.2.2",
"@digitransit-component/digitransit-component-suggestion-item": "^1.1.3",
"@hsl-fi/sass": "^0.2.0",
"@hsl-fi/shimmer": "0.1.2",
"classnames": "2.2.6",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@digitransit-component/digitransit-component-favourite-editing-modal",
"version": "1.1.3",
"version": "1.1.4",
"description": "digitransit-component favourite-editing-modal module",
"main": "index.js",
"files": [
Expand Down Expand Up @@ -33,7 +33,7 @@
},
"peerDependencies": {
"@digitransit-component/digitransit-component-dialog-modal": "^0.3.4",
"@digitransit-component/digitransit-component-icon": "^0.2.1",
"@digitransit-component/digitransit-component-icon": "^0.2.2",
"@hsl-fi/container-spinner": "0.3.1",
"@hsl-fi/modal": "^0.3.1",
"@hsl-fi/sass": "^0.2.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@digitransit-component/digitransit-component-favourite-modal",
"version": "1.0.1",
"version": "1.0.2",
"description": "digitransit-component favourite-modal module",
"main": "index.js",
"files": [
Expand Down Expand Up @@ -29,7 +29,7 @@
"author": "Digitransit Authors",
"license": "(AGPL-3.0 OR EUPL-1.2)",
"peerDependencies": {
"@digitransit-component/digitransit-component-icon": "^0.2.1",
"@digitransit-component/digitransit-component-icon": "^0.2.2",
"@hsl-fi/modal": "^0.3.1",
"@hsl-fi/sass": "^0.2.0",
"classnames": "2.2.6",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@digitransit-component/digitransit-component-icon",
"version": "0.2.1",
"version": "0.2.2",
"description": "digitransit-component icon module",
"main": "index.js",
"files": [
Expand Down
Loading

0 comments on commit af057cb

Please sign in to comment.