Skip to content

Commit

Permalink
Merge pull request #215 from City-of-Turku/develop
Browse files Browse the repository at this point in the history
Release v1.7.3
  • Loading branch information
juhomakkonen authored Nov 30, 2023
2 parents 1286abe + d022882 commit bab4100
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SERVICEMAP_API_VERSION="/v2"
#EVENTS_API="https://linkedevents-api.turku.fi/v1"
RESERVATIONS_API="https://respa.turku.fi/v1"
FEEDBACK_URL="https://palvelukartta-api.turku.fi/open311/"
DIGITRANSIT_API="https://api.digitransit.fi/routing/v2/routers/waltti/index/graphql"
DIGITRANSIT_API="https://api.digitransit.fi/routing/v1/routers/waltti/index/graphql"
# This is key for DIGITRANSIT API. There are separate urls and keys for prod (api.digitransit.fi) and dev (dev-api.digitransit.fi) digitransit apis.
#DIGITRANSIT_API_KEY=
#HEARING_MAP_API="https://kuulokuvat.fi/api/v1/servicemap-url"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const TransitStopInfo = ({
const externalTheme = config.themePKG;
const isExternalTheme = !externalTheme || externalTheme === 'undefined' ? null : externalTheme;

const getAccessibilityIcon = (value) => {
const getAccessibilityIcon = value => {
if (value === 'POSSIBLE') {
return <Accessible className={classes.infoIcon} />;
}
Expand All @@ -33,7 +33,7 @@ const TransitStopInfo = ({
useEffect(() => {
if (type === 'bikeStation') return;
fetchStopData(stop)
.then((stopData) => {
.then(stopData => {
if (stopData) {
let departureTimes = stopData.data.stop.stoptimesWithoutPatterns;
departureTimes.sort(
Expand Down Expand Up @@ -64,12 +64,15 @@ const TransitStopInfo = ({
case 1: // Subway stops
icon = <span className={`${classes.infoIcon} ${classes.metroIconColor} icon-icon-hsl-metro`} />;
break;
case -999: case 4: // Ferry stops
case 4: // Ferry stops
icon = <span className={`${classes.infoIcon} ${classes.ferryIconColor} icon-icon-hsl-ferry`} />;
break;
default:
case -999:
icon = <span className={`${classes.infoIcon} ${isExternalTheme ? classes.busIconColorDark : classes.busIconColor} icon-icon-hsl-bus`} />;
break;
default:
icon = <span className={`${classes.infoIcon} ${classes.busIconColor} icon-icon-hsl-bus`} />;
break;
}

if (stopData.departureTimes && stopData.departureTimes.length) {
Expand Down Expand Up @@ -100,7 +103,6 @@ const TransitStopInfo = ({
} return null;
};


return (
<div aria-hidden className={classes.transitInfoContainer}>
<ButtonBase onClick={() => onCloseClick()} className={classes.closeButton}>
Expand Down
13 changes: 8 additions & 5 deletions src/views/MapView/components/TransitStops/TransitStops.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const TransitStops = ({ mapObject, classes }) => {

const fetchTransitStops = () => {
fetchStops(map)
.then((stops) => {
.then(stops => {
setTransitStops(stops);
});
};
Expand All @@ -73,7 +73,7 @@ const TransitStops = ({ mapObject, classes }) => {
}
}, []); */

const getTransitIcon = (type) => {
const getTransitIcon = type => {
const { divIcon } = require('leaflet');
let icon;

Expand All @@ -93,10 +93,10 @@ const TransitStops = ({ mapObject, classes }) => {
case 7: // Bike stations
icon = <span aria-hidden className={`${classes.transitIconMap} ${classes.bikeIconColor} icon-icon-hsl-bike`} />;
break;
case -999: case 4: // Ferry stops
case 4: // Ferry stops
icon = <spanz aria-hidden className={`${classes.transitIconMap} ${classes.ferryIconColor} icon-icon-hsl-ferry`} />;
break;
default:
case -999:
icon = (
<span
aria-hidden
Expand All @@ -106,6 +106,9 @@ const TransitStops = ({ mapObject, classes }) => {
/>
);
break;
default:
icon = <span aria-hidden className={`${classes.transitIconMap} ${classes.busIconColor} icon-icon-hsl-bus`} />;
break;
}

return divIcon({
Expand All @@ -127,7 +130,7 @@ const TransitStops = ({ mapObject, classes }) => {
if (!showTransitStops()) return null;

return (
showTransitStops() ? transitStops.map((stop) => {
showTransitStops() ? transitStops.map(stop => {
const icon = getTransitIcon(stop.vehicleType);
return (
<Marker
Expand Down
13 changes: 6 additions & 7 deletions src/views/MapView/utils/transitFetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const digitransitApiHeaders = () => ({

/* eslint-disable global-require */
// Fetch list of stops
const fetchStops = async (map) => {
const fetchStops = async map => {
const L = require('leaflet');

const fetchBounds = map.getBounds();
Expand Down Expand Up @@ -63,25 +63,25 @@ const fetchStops = async (map) => {
bbox: `${fetchBox}`,
}),
])
.then((data) => {
.then(data => {
// Handle subwaystops and return list of all stops
const stops = data[0].data.stopsByBbox;
const subwayStations = stops.filter(stop => stop.vehicleType === 1);

// Remove subwaystations from stops list since they will be replaced with subway entrances
const filteredStops = stops.filter(stop => stop.vehicleType !== 1);

const entrances = data[1].results;
const entrances = data[1] ? data[1].results : [];

// Add subway entrances to the list of stops
entrances.forEach((entrance) => {
entrances.forEach(entrance => {
const closest = {
distance: null,
stop: null,
};
if (subwayStations.length) {
// Find the subwaystation closest to the entrance
subwayStations.forEach((stop) => {
subwayStations.forEach(stop => {
if (!stop.gtfsId) return;
const distance = Math.sqrt(
((stop.lat - entrance.location.coordinates[1]) ** 2)
Expand Down Expand Up @@ -116,7 +116,7 @@ const fetchStops = async (map) => {
};

// Fetch one stop data
const fetchStopData = async (stop) => {
const fetchStopData = async stop => {
const requestBody = id => (`{
stop(id: "${id}") {
name
Expand Down Expand Up @@ -165,7 +165,6 @@ const fetchStopData = async (stop) => {
return data;
};


const fetchBikeStations = async () => fetch(`${config.digitransitAPI.root}`, {
method: 'post',
headers: digitransitApiHeaders(),
Expand Down

0 comments on commit bab4100

Please sign in to comment.