Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change map tiles server and use pmtiles instead of mbtiles #10487

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
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
16 changes: 16 additions & 0 deletions front/package-lock.json

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

1 change: 1 addition & 0 deletions front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"maplibre-gl": "^4.0.0",
"openapi-typescript-codegen": "^0.29.0",
"party-js": "^2.2.0",
"pmtiles": "^4.2.1",
"prop-types": "^15.8.1",
"rc-slider": "^11.1.8",
"react": "^18.2.0",
Expand Down
5 changes: 5 additions & 0 deletions front/src/applications/editor/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { useContext, useMemo, useState, type PropsWithChildren } from 'react';

import type { TFunction } from 'i18next';
import { isEmpty, isEqual, isNil } from 'lodash';
import maplibregl from 'maplibre-gl';
import { Protocol } from 'pmtiles';
import { withTranslation } from 'react-i18next';
import ReactMapGL, { AttributionControl, ScaleControl, type MapRef } from 'react-map-gl/maplibre';
import { useSelector } from 'react-redux';
Expand Down Expand Up @@ -50,6 +52,9 @@ interface MapState {
isHovering: boolean;
}

const protocol = new Protocol();
maplibregl.addProtocol('pmtiles', protocol.tile);

const MapUnplugged = ({
mapRef,
toolState,
Expand Down
9 changes: 2 additions & 7 deletions front/src/common/Map/Layers/Background.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function Background(props: BackgroundProps) {
const { colors, layerOrder } = props;

const backgroundParams: LayerProps = {
id: 'osm/background',
id: 'background',
type: 'background',
layout: {
visibility: 'visible',
Expand All @@ -23,12 +23,7 @@ function Background(props: BackgroundProps) {
};

return (
<Source
id="platform"
type="vector"
url="https://osm.osrd.fr/data/v3.json"
source-layer="transportation"
>
<Source id="background" type="vector">
<OrderedLayer {...backgroundParams} layerOrder={layerOrder} />
</Source>
);
Expand Down
3 changes: 2 additions & 1 deletion front/src/common/Map/Layers/Hillshade.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Source, type LayerProps } from 'react-map-gl/maplibre';
import { useSelector } from 'react-redux';

import { TERRAIN_URL } from 'common/Map/const';
import OrderedLayer from 'common/Map/Layers/OrderedLayer';
import { getTerrain3DExaggeration } from 'reducers/map/selectors';

Expand Down Expand Up @@ -29,7 +30,7 @@ const Hillshade = ({ mapStyle, layerOrder }: HillshadeProps) => {
id="hillshade"
type="raster-dem"
encoding="terrarium"
url="https://osm.osrd.fr/data/terrain.json"
url={TERRAIN_URL}
tileSize={256}
maxzoom={12}
>
Expand Down
7 changes: 6 additions & 1 deletion front/src/common/Map/Layers/OSM.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ function OSM({ mapStyle, layerOrder, mapIsLoaded }: OSMProps) {

if (reload) return null;
return (
<Source id="osm" type="vector" url={OSM_URL}>
<Source
id="osm"
type="vector"
url={OSM_URL}
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
>
{genOSMLayers(mapStyle, toggledLayers, layerOrder)}
</Source>
);
Expand Down
4 changes: 3 additions & 1 deletion front/src/common/Map/Layers/Terrain.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Source } from 'react-map-gl/maplibre';

import { TERRAIN_URL } from 'common/Map/const';

export default function Terrain() {
return (
<Source
id="terrain"
type="raster-dem"
encoding="terrarium"
url="https://osm.osrd.fr/data/terrain.json"
url={TERRAIN_URL}
tileSize={256}
maxzoom={12}
/>
Expand Down
4 changes: 3 additions & 1 deletion front/src/common/Map/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import config from 'config/config';
export const MAP_URL = `${config.proxy_editoast}/layers`;
export const SPRITES_URL = `${config.proxy_editoast}/sprites`;
export const FONTS_URL = `${config.proxy_editoast}/fonts`;
export const OSM_URL = 'https://osm.osrd.fr/data/v3.json';
export const OSM_URL = 'pmtiles://https://osm.nbg1.your-objectstorage.com/planet.pmtiles';
export const TERRAIN_URL =
'pmtiles://https://osm.nbg1.your-objectstorage.com/terrain-europe.pmtiles';

export const MAP_MODES = {
display: 'display',
Expand Down
Loading