Skip to content

Commit 6bf8fd1

Browse files
author
Joona Ojapalo
committed
Merge branch 'v2' into v3
2 parents cc53016 + 830da1f commit 6bf8fd1

File tree

9 files changed

+39
-15
lines changed

9 files changed

+39
-15
lines changed

app/component/map/Map.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,14 @@ export default class Map extends React.Component {
207207
if (this.props.mapBottomPadding) {
208208
boundsOptions.paddingBottomRight = [0, this.props.mapBottomPadding];
209209
}
210-
let mapUrl =
210+
const mapBaseUrl =
211211
(isDebugTiles && `${config.URL.OTP}inspector/tile/traversal/`) ||
212-
config.URL.MAP;
213-
if (mapUrl !== null && typeof mapUrl === 'object') {
214-
mapUrl = mapUrl[this.props.lang] || config.URL.MAP.default;
215-
}
212+
config.URL.MAP[this.props.lang] ||
213+
config.URL.MAP.default;
214+
const mapUrl = config.hasAPISubscriptionQueryParameter
215+
? `${mapBaseUrl}{z}/{x}/{y}{size}.png?${config.API_SUBSCRIPTION_QUERY_PARAMETER_NAME}=${config.API_SUBSCRIPTION_TOKEN}`
216+
: `${mapBaseUrl}{z}/{x}/{y}{size}.png`;
217+
216218
const leafletObjNew = leafletObjs.concat([
217219
<VectorTileLayerContainer
218220
key="vectorTileLayerContainer"
@@ -295,7 +297,7 @@ export default class Map extends React.Component {
295297
closePopupOnClick={false}
296298
>
297299
<TileLayer
298-
url={`${mapUrl}{z}/{x}/{y}{size}.png`}
300+
url={mapUrl}
299301
tileSize={config.map.tileSize || 256}
300302
zoomOffset={config.map.zoomOffset || 0}
301303
updateWhenIdle={false}

app/component/map/tile-layer/CityBikes.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import {
1919
BIKEAVL_UNKNOWN,
2020
} from '../../../util/citybikes';
2121

22+
import { fetchWithSubscription } from '../../../util/fetchUtils';
23+
2224
const timeOfLastFetch = {};
2325

2426
const query = graphql`
@@ -46,10 +48,11 @@ class CityBikes {
4648
}
4749

4850
fetchWithAction = actionFn =>
49-
fetch(
51+
fetchWithSubscription(
5052
`${this.config.URL.CITYBIKE_MAP}` +
5153
`${this.tile.coords.z + (this.tile.props.zoomOffset || 0)}/` +
5254
`${this.tile.coords.x}/${this.tile.coords.y}.pbf`,
55+
this.config,
5356
).then(res => {
5457
if (res.status !== 200) {
5558
return undefined;

app/component/map/tile-layer/ParkAndRide.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Protobuf from 'pbf';
88
import { drawParkAndRideIcon } from '../../../util/mapIconUtils';
99
import { Contour } from '../../../util/geo-utils';
1010
import { isBrowser } from '../../../util/browser';
11+
import { fetchWithSubscription } from '../../../util/fetchUtils';
1112

1213
import carParksQuery from './carParks';
1314
import carParkQuery from './carPark';
@@ -28,10 +29,11 @@ export default class ParkAndRide {
2829
static getName = () => 'parkAndRide';
2930

3031
getPromise() {
31-
return fetch(
32+
return fetchWithSubscription(
3233
`${this.config.URL.PARK_AND_RIDE_MAP}${
3334
this.tile.coords.z + (this.tile.props.zoomOffset || 0)
3435
}/${this.tile.coords.x}/${this.tile.coords.y}.pbf`,
36+
this.config,
3537
).then(res => {
3638
if (res.status !== 200) {
3739
return undefined;

app/component/map/tile-layer/ParkAndRideForBikes.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Protobuf from 'pbf';
55
import { drawParkAndRideForBikesIcon } from '../../../util/mapIconUtils';
66
import { Contour } from '../../../util/geo-utils';
77
import { isBrowser } from '../../../util/browser';
8+
import { fetchWithSubscription } from '../../../util/fetchUtils';
89

910
import bikeParkQuery from './bikePark';
1011

@@ -22,10 +23,11 @@ export default class ParkAndRideForBikes {
2223
static getName = () => 'parkAndRideForBikes';
2324

2425
getPromise() {
25-
return fetch(
26+
return fetchWithSubscription(
2627
`${this.config.URL.PARK_AND_RIDE_MAP}${
2728
this.tile.coords.z + (this.tile.props.zoomOffset || 0)
2829
}/${this.tile.coords.x}/${this.tile.coords.y}.pbf`,
30+
this.config,
2931
).then(res => {
3032
if (res.status !== 200) {
3133
return undefined;

app/component/map/tile-layer/Stops.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
import { ExtendedRouteTypes } from '../../../constants';
1111
import { isFeatureLayerEnabled } from '../../../util/mapLayerUtils';
1212
import { PREFIX_ITINERARY_SUMMARY, PREFIX_ROUTES } from '../../../util/path';
13+
import { fetchWithSubscription } from '../../../util/fetchUtils';
1314

1415
function isNull(val) {
1516
return val === 'null' || val === undefined || val === null;
@@ -100,10 +101,11 @@ class Stops {
100101
};
101102

102103
getPromise() {
103-
return fetch(
104+
return fetchWithSubscription(
104105
`${this.config.URL.STOP_MAP}${
105106
this.tile.coords.z + (this.tile.props.zoomOffset || 0)
106107
}/${this.tile.coords.x}/${this.tile.coords.y}.pbf`,
108+
this.config,
107109
).then(res => {
108110
if (res.status !== 200) {
109111
return undefined;

app/configurations/config.default.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ export default {
4242
default: `${MAP_URL}/map/${MAP_VERSION}/hsl-map/`,
4343
sv: `${MAP_URL}/map/${MAP_VERSION}/hsl-map-sv/`,
4444
},
45-
STOP_MAP: `${MAP_URL}/map/v1/finland-stop-map/`,
46-
CITYBIKE_MAP: `${MAP_URL}/map/v1/finland-citybike-map/`,
45+
STOP_MAP: `${MAP_URL}/map/${MAP_VERSION}/finland-stop-map/`,
46+
CITYBIKE_MAP: `${MAP_URL}/map/${MAP_VERSION}/finland-citybike-map/`,
47+
PARK_AND_RIDE_MAP: `${MAP_URL}/map/${MAP_VERSION}/hsl-parkandride-map/`,
48+
4749
FONT:
4850
'https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@400;700&family=Roboto:wght@400;700',
4951
PELIAS: `${process.env.GEOCODING_BASE_URL || GEOCODING_BASE_URL}/search`,

app/configurations/config.lappeenranta.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export default configMerger(walttiConfig, {
154154
sv: 'Cykelrutter',
155155
en: 'Bike routes',
156156
},
157-
url: 'https://ckan.saita.fi/geojson/pyorailyreitit_lpr.geojson',
157+
url: 'https://ckanlpr.meitademo.fi/geojson/pyorailyreitit_lpr.geojson',
158158
isOffByDefault: true,
159159
},
160160
{

app/configurations/config.matka.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ export default {
292292
parkingAreaSources: ['liipi'],
293293

294294
parkAndRide: {
295-
showParkAndRide: true,
295+
showParkAndRide: false,
296296
parkAndRideMinZoom: 13,
297297
pageContent: {
298298
default: HSLParkAndRideUtils,

app/util/fetchUtils.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,15 @@ export const retryFetch = (
5353
});
5454
};
5555

56-
export default retryFetch;
56+
/**
57+
* Uses fetch with subscription header with subscription header
58+
* if it is configured.
59+
*
60+
* @param {String} URL the url to fetch
61+
* @param {*} config The configuration for the software installation
62+
* @returns fetch's promise
63+
*/
64+
export const fetchWithSubscription = (URL, config) =>
65+
fetch(URL, {
66+
headers: addSubscriptionHeader({}, config),
67+
});

0 commit comments

Comments
 (0)