Skip to content

Commit

Permalink
L rail updates (#797)
Browse files Browse the repository at this point in the history
* L-rail updates

* L-rail updates

* codegen
  • Loading branch information
ahjyrkia authored Nov 1, 2023
1 parent 2b41a5c commit 414bdbc
Show file tree
Hide file tree
Showing 15 changed files with 151 additions and 9 deletions.
1 change: 1 addition & 0 deletions .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ REACT_APP_TIMEZONE=Europe/Helsinki
# API key for weather data
REACT_APP_FMI_APIKEY=4a22a195-10be-404f-8056-e8aaf5f7506a

REACT_APP_DIGITRANSIT_URL=https://api.digitransit.fi/
REACT_APP_MAPILLARY_CLIENT_TOKEN=MLY|4648891498509284|8e5e3395c54d64ca14b62c79ceb3e16c
REACT_APP_DIGITRANSIT_API_KEY=
1 change: 1 addition & 0 deletions .env.local
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ REACT_APP_PRODUCTION_URL=https://reittiloki.hsl.fi
# transport networks. All times will be converted into this timezone.
REACT_APP_TIMEZONE=Europe/Helsinki

REACT_APP_DIGITRANSIT_URL=https://api.digitransit.fi/
REACT_APP_MAPILLARY_CLIENT_TOKEN=MLY|4417181845065987|5e7cb47b1a13698f243e25f0cfdbf31f
REACT_APP_DIGITRANSIT_API_KEY=
1 change: 1 addition & 0 deletions .env.prod
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ REACT_APP_TIMEZONE=Europe/Helsinki
# API key for weather data
REACT_APP_FMI_APIKEY=4a22a195-10be-404f-8056-e8aaf5f7506a

REACT_APP_DIGITRANSIT_URL=https://api.digitransit.fi/
REACT_APP_MAPILLARY_CLIENT_TOKEN=MLY|4699140670124156|c0617576966bc69ea39fb284a78df199
REACT_APP_DIGITRANSIT_API_KEY=
4 changes: 3 additions & 1 deletion .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ REACT_APP_TIMEZONE=Europe/Helsinki
# API key for weather data
REACT_APP_FMI_APIKEY=4a22a195-10be-404f-8056-e8aaf5f7506a

REACT_APP_MAPILLARY_CLIENT_TOKEN=MLY|4699140670124156|c0617576966bc69ea39fb284a78df199
REACT_APP_DIGITRANSIT_URL=https://api.digitransit.fi/
REACT_APP_MAPILLARY_CLIENT_TOKEN=MLY|4699140670124156|c0617576966bc69ea39fb284a78df199
REACT_APP_DIGITRANSIT_API_KEY=
37 changes: 33 additions & 4 deletions graphql.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2443,6 +2443,12 @@
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "CHARGING_SERVICE",
"description": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
Expand Down Expand Up @@ -3540,6 +3546,18 @@
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "OTHER_CHARGING_SERVICE",
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "OPERATOR_CHARGING_SERVICE",
"description": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
Expand Down Expand Up @@ -9789,7 +9807,11 @@
{
"name": "skip",
"description": "Directs the executor to skip this field or fragment when the `if` argument is true.",
"locations": ["FIELD", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"],
"locations": [
"FIELD",
"FRAGMENT_SPREAD",
"INLINE_FRAGMENT"
],
"args": [
{
"name": "if",
Expand All @@ -9810,7 +9832,11 @@
{
"name": "include",
"description": "Directs the executor to include this field or fragment only when the `if` argument is true.",
"locations": ["FIELD", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"],
"locations": [
"FIELD",
"FRAGMENT_SPREAD",
"INLINE_FRAGMENT"
],
"args": [
{
"name": "if",
Expand All @@ -9831,7 +9857,10 @@
{
"name": "deprecated",
"description": "Marks an element of a GraphQL schema as no longer supported.",
"locations": ["FIELD_DEFINITION", "ENUM_VALUE"],
"locations": [
"FIELD_DEFINITION",
"ENUM_VALUE"
],
"args": [
{
"name": "reason",
Expand All @@ -9847,4 +9876,4 @@
}
]
}
}
}
7 changes: 5 additions & 2 deletions schema-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ export enum AlertCategory {
PowerFailure = 'POWER_FAILURE',
MisparkedVehicle = 'MISPARKED_VEHICLE',
PublicEvent = 'PUBLIC_EVENT',
Hidden = 'HIDDEN'
Hidden = 'HIDDEN',
ChargingService = 'CHARGING_SERVICE'
}

export enum AlertDistribution {
Expand Down Expand Up @@ -209,7 +210,9 @@ export enum CancellationSubcategory {
OtherOperatorReason = 'OTHER_OPERATOR_REASON',
DoorMalfunction = 'DOOR_MALFUNCTION',
UnknownCause = 'UNKNOWN_CAUSE',
Hidden = 'HIDDEN'
Hidden = 'HIDDEN',
OtherChargingService = 'OTHER_CHARGING_SERVICE',
OperatorChargingService = 'OPERATOR_CHARGING_SERVICE'
}

export enum CancellationType {
Expand Down
5 changes: 5 additions & 0 deletions src/components/LineIcon.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@
background-image: url("../icon-subway.svg");
color: var(--orange);
}

.L_RAIL:before {
background-image: url("../icon-L-rail.svg");
color: #0098a1;
}
2 changes: 1 addition & 1 deletion src/components/map/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const Map = decorate(({state, UI, children, className, detailsOpen}) => {
}, [leafletMap]);

const apikey = `?digitransit-subscription-key=${process.env.REACT_APP_DIGITRANSIT_API_KEY}`;
const mapUrl = `https://dev-api.digitransit.fi/map/v2/hsl-map/{z}/{x}/{y}@2x.png${apikey}`;
const mapUrl = `${process.env.REACT_APP_DIGITRANSIT_URL}map/v2/hsl-map/{z}/{x}/{y}@2x.png${apikey}`;
return (
<MapContainer className={className}>
<LeafletMap
Expand Down
13 changes: 12 additions & 1 deletion src/components/transportModes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import BusIcon from "../icons/Bus";
import TramIcon from "../icons/Tram";
import RailIcon from "../icons/Rail";
import LRailIcon from "../icons/LRail";
import SubwayIcon from "../icons/Subway";
import FerryIcon from "../icons/Ferry";
import React from "react";
Expand All @@ -9,6 +10,7 @@ import ReactDOMServer from "react-dom/server";
import BusRectangle from "../icons/BusRectangle";
import TramRectangle from "../icons/TramRectangle";
import RailRectangle from "../icons/RailRectangle";
import LRailRectangle from "../icons/LRailRectangle";
import FerryRectangle from "../icons/FerryRectangle";
import SubwaySign from "../icons/SubwaySign";

Expand Down Expand Up @@ -50,6 +52,14 @@ export const transportIconsHtml = {
fill={{inner: "white", outer: "var(--purple)"}}
/>
),
L_RAIL: (size = 20) =>
ReactDOMServer.renderToStaticMarkup(
<LRailRectangle
width={size}
height={size}
fill={{inner: "white", outer: "var(--l_rail-green)"}}
/>
),
SUBWAY: (size = 20) =>
ReactDOMServer.renderToStaticMarkup(
<SubwaySign
Expand Down Expand Up @@ -86,7 +96,6 @@ export const transportIconsHtml = {

export const getTransportIconHtml = (name, size) => {
let icon = getCachedIcon(name, size);

if (icon) {
return icon;
}
Expand All @@ -102,6 +111,7 @@ export const transportIcons = {
TRUNK: BusIcon,
TRAM: TramIcon,
RAIL: RailIcon,
L_RAIL: LRailIcon,
SUBWAY: SubwayIcon,
METRO: SubwayIcon,
FERRY: FerryIcon,
Expand All @@ -112,6 +122,7 @@ export const transportColor = {
TRUNK: "var(--orange)",
TRAM: "var(--green)",
RAIL: "var(--purple)",
L_RAIL: "var(--l_rail-green)",
SUBWAY: "var(--orange)",
METRO: "var(--orange)",
FERRY: "var(--light-blue)",
Expand Down
8 changes: 8 additions & 0 deletions src/helpers/getTransportType.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ function getTransportType(lineId = "", numeric = false, trunk = false) {
return "TRAM";
}

if (lineType == 2015) {
if (numeric) {
return 0;
}

return "L_RAIL";
}

// The only ferry routes are 1019 and 1019E.
if (lineId.startsWith("1019")) {
if (numeric) {
Expand Down
1 change: 1 addition & 0 deletions src/helpers/vehicleColor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const vehicleColors = {
SUBWAY: "var(--orange)",
METRO: "var(--orange)",
FERRY: "var(--light-blue)",
L_RAIL: "var(--l_rail-green)",
default: "var(--blue)",
unsigned: "var(--grey)",
};
Expand Down
5 changes: 5 additions & 0 deletions src/icon-L-rail.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions src/icons/LRail.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions src/icons/LRailRectangle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from "react";
import {Svg, G, Path, Rect} from "react-primitives-svg";
import PropTypes from "prop-types";
import {svgSize} from "../helpers/svg";
import {Colors} from "./HSL_COLORS";

export default function Icon({fill, height, width, ...rest}) {
return (
<Svg
{...rest}
{...svgSize(height, width)}
viewBox="0 0 35 35"
version="1.1"
preserveAspectRatio="xMidYMid meet">
<G>
<Rect fill={fill.inner} x="3" y="3" width="30" height="30" />
<Path
fill={fill.outer}
d="M 23.847656 19.917969 L 22.183594 8.308594 C 22.085938 7.5 21.585938 6.792969 20.855469 6.429688 C 19.582031 5.855469 18.226562 5.480469 16.835938 5.324219 L 16.835938 3.917969 L 19.777344 3.917969 C 20.214844 3.917969 20.566406 3.5625 20.566406 3.128906 C 20.566406 2.691406 20.214844 2.339844 19.777344 2.339844 L 12.269531 2.339844 C 11.832031 2.339844 11.480469 2.691406 11.480469 3.128906 C 11.480469 3.5625 11.832031 3.917969 12.269531 3.917969 L 15.214844 3.917969 L 15.214844 5.324219 C 13.824219 5.480469 12.464844 5.851562 11.1875 6.429688 C 10.457031 6.792969 9.960938 7.5 9.863281 8.308594 L 8.203125 19.917969 C 8.078125 20.789062 8.160156 21.679688 8.441406 22.515625 C 8.605469 23.007812 8.914062 24.003906 9.101562 24.492188 C 9.367188 25.160156 9.941406 25.660156 10.644531 25.835938 C 11.878906 26.15625 13.722656 26.433594 16.023438 26.433594 C 18.320312 26.433594 20.167969 26.15625 21.402344 25.835938 C 22.105469 25.660156 22.675781 25.160156 22.945312 24.492188 C 23.132812 24.003906 23.441406 23.007812 23.605469 22.515625 C 23.886719 21.679688 23.96875 20.789062 23.847656 19.917969 Z M 22.351562 21.546875 L 21.933594 22.835938 C 21.867188 23.089844 21.65625 23.28125 21.398438 23.324219 C 20.8125 23.5 18.347656 23.917969 16.023438 23.9375 C 13.699219 23.917969 11.238281 23.5 10.652344 23.324219 C 10.394531 23.28125 10.183594 23.089844 10.117188 22.835938 L 9.699219 21.546875 C 9.601562 21.253906 9.84375 21.046875 10.171875 21.136719 C 11.175781 21.40625 12.296875 21.636719 13.226562 21.820312 C 13.511719 21.871094 13.757812 22.046875 13.894531 22.300781 C 14.03125 22.59375 14.316406 22.792969 14.636719 22.820312 C 15.0625 22.847656 15.554688 22.863281 16.023438 22.863281 C 16.503906 22.863281 16.984375 22.847656 17.410156 22.820312 C 17.730469 22.792969 18.011719 22.59375 18.152344 22.300781 C 18.289062 22.046875 18.535156 21.871094 18.820312 21.820312 C 19.75 21.636719 20.875 21.410156 21.878906 21.136719 C 22.207031 21.046875 22.449219 21.253906 22.351562 21.546875 Z M 21.710938 19.289062 C 19.871094 19.867188 17.953125 20.167969 16.023438 20.183594 C 14.09375 20.167969 12.179688 19.867188 10.339844 19.289062 C 10.042969 19.195312 9.855469 18.898438 9.902344 18.589844 L 11.078125 10.382812 C 11.113281 10.113281 11.316406 9.898438 11.578125 9.847656 C 14.511719 9.230469 17.539062 9.230469 20.46875 9.847656 C 20.734375 9.898438 20.933594 10.113281 20.972656 10.382812 L 22.148438 18.589844 C 22.191406 18.898438 22.007812 19.195312 21.710938 19.289062 Z M 20.566406 27.214844 C 20.011719 27.328125 19.386719 27.417969 18.746094 27.488281 C 18.746094 27.488281 19.957031 28.925781 20.277344 29.304688 C 20.6875 29.796875 21.019531 29.953125 21.488281 29.953125 C 22.019531 29.953125 22.492188 29.558594 21.933594 28.859375 C 21.660156 28.519531 20.566406 27.214844 20.566406 27.214844 Z M 11.480469 27.214844 C 12.039062 27.328125 12.664062 27.417969 13.300781 27.488281 C 13.300781 27.488281 12.089844 28.925781 11.773438 29.304688 C 11.363281 29.796875 11.03125 29.953125 10.558594 29.953125 C 10.027344 29.953125 9.554688 29.558594 10.113281 28.859375 C 10.390625 28.519531 11.480469 27.214844 11.480469 27.214844 Z M 11.480469 27.214844 "
id="L-Rail-1"
fillRule="nonzero"
/>
</G>
</Svg>
);
}

Icon.propTypes = {
fill: PropTypes.shape({
inner: PropTypes.string,
outer: PropTypes.string,
}),
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
};

Icon.defaultProps = {
fill: {
inner: Colors.primary.hslWhite,
outer: Colors.transport.rail,
},
};

Icon.displayName = "Icons.LRailRectangle";
1 change: 1 addition & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
--bus-blue: #0079c9;
--green: #00985f;
--purple: #8c4799;
--l_rail-green: #0098a1;
--orange: #ff6319;
--light-orange: #ffedf0;
--teal: #00b2a9;
Expand Down

0 comments on commit 414bdbc

Please sign in to comment.