chore(maplibre): update
This commit is contained in:
parent
b1c0b4de20
commit
95176b8a00
21 changed files with 5936 additions and 5826 deletions
|
@ -1,7 +1,12 @@
|
|||
import type { AnyLayer, Style, RasterLayer, RasterSource } from 'maplibre-gl';
|
||||
import type {
|
||||
LayerSpecification,
|
||||
RasterLayerSpecification,
|
||||
RasterSourceSpecification,
|
||||
StyleSpecification
|
||||
} from 'maplibre-gl';
|
||||
import invariant from 'tiny-invariant';
|
||||
|
||||
import cadastreLayers from './layers/cadastre';
|
||||
import cadastreLayers from './layers/cadastre.json';
|
||||
|
||||
function ignServiceURL(layer: string, style: string, format = 'image/png') {
|
||||
const url = `https://data.geopf.fr/wmts`;
|
||||
|
@ -163,7 +168,10 @@ function buildSources() {
|
|||
);
|
||||
}
|
||||
|
||||
function rasterSource(tiles: string[], attribution: string): RasterSource {
|
||||
function rasterSource(
|
||||
tiles: string[],
|
||||
attribution: string
|
||||
): RasterSourceSpecification {
|
||||
return {
|
||||
type: 'raster',
|
||||
tiles,
|
||||
|
@ -174,7 +182,10 @@ function rasterSource(tiles: string[], attribution: string): RasterSource {
|
|||
};
|
||||
}
|
||||
|
||||
function rasterLayer(source: string, opacity: number): RasterLayer {
|
||||
function rasterLayer(
|
||||
source: string,
|
||||
opacity: number
|
||||
): RasterLayerSpecification {
|
||||
return {
|
||||
id: source,
|
||||
source,
|
||||
|
@ -186,14 +197,14 @@ function rasterLayer(source: string, opacity: number): RasterLayer {
|
|||
export function buildOptionalLayers(
|
||||
ids: string[],
|
||||
opacity: Record<string, number>
|
||||
): AnyLayer[] {
|
||||
): LayerSpecification[] {
|
||||
return OPTIONAL_LAYERS.filter(({ id }) => ids.includes(id))
|
||||
.flatMap(({ layers, id }) =>
|
||||
layers.map(([, code]) => [code, opacity[id] / 100] as const)
|
||||
)
|
||||
.flatMap(([code, opacity]) =>
|
||||
code === 'CADASTRE'
|
||||
? cadastreLayers
|
||||
? (cadastreLayers as LayerSpecification[])
|
||||
: [rasterLayer(getLayerCode(code), opacity)]
|
||||
);
|
||||
}
|
||||
|
@ -210,9 +221,9 @@ function getLayerCode(code: string) {
|
|||
return code.toLowerCase().replace(/\./g, '-');
|
||||
}
|
||||
|
||||
export default {
|
||||
export const style: StyleSpecification = {
|
||||
version: 8,
|
||||
metadat: {
|
||||
metadata: {
|
||||
'mapbox:autocomposite': false,
|
||||
'mapbox:groups': {
|
||||
1444849242106.713: { collapsed: false, name: 'Places' },
|
||||
|
@ -257,5 +268,6 @@ export default {
|
|||
...buildSources()
|
||||
},
|
||||
sprite: 'https://openmaptiles.github.io/osm-bright-gl-style/sprite',
|
||||
glyphs: 'https://openmaptiles.geo.data.gouv.fr/fonts/{fontstack}/{range}.pbf'
|
||||
} as Style;
|
||||
glyphs: 'https://openmaptiles.geo.data.gouv.fr/fonts/{fontstack}/{range}.pbf',
|
||||
layers: []
|
||||
};
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
import type { Style } from 'maplibre-gl';
|
||||
import type { LayerSpecification, StyleSpecification } from 'maplibre-gl';
|
||||
|
||||
import baseStyle, { buildOptionalLayers, getLayerName, NBS } from './base';
|
||||
import orthoStyle from './layers/ortho';
|
||||
import vectorStyle from './layers/vector';
|
||||
import ignLayers from './layers/ign';
|
||||
import {
|
||||
style as baseStyle,
|
||||
buildOptionalLayers,
|
||||
getLayerName,
|
||||
NBS
|
||||
} from './base';
|
||||
import ignLayers from './layers/ign.json';
|
||||
import orthoLayers from './layers/ortho.json';
|
||||
import vectorLayers from './layers/vector.json';
|
||||
|
||||
export { getLayerName, NBS };
|
||||
|
||||
|
@ -21,20 +26,20 @@ export function getMapStyle(
|
|||
id: string,
|
||||
layers: string[],
|
||||
opacity: Record<string, number>
|
||||
): Style & { id: string } {
|
||||
): StyleSpecification & { id: string } {
|
||||
const style = { ...baseStyle, id };
|
||||
|
||||
switch (id) {
|
||||
case 'ortho':
|
||||
style.layers = orthoStyle;
|
||||
style.layers = orthoLayers as LayerSpecification[];
|
||||
style.name = 'Photographies aériennes';
|
||||
break;
|
||||
case 'vector':
|
||||
style.layers = vectorStyle;
|
||||
style.layers = vectorLayers as LayerSpecification[];
|
||||
style.name = 'Carte OSM';
|
||||
break;
|
||||
case 'ign':
|
||||
style.layers = ignLayers;
|
||||
style.layers = ignLayers as LayerSpecification[];
|
||||
style.name = 'Carte IGN';
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,106 @@
|
|||
[
|
||||
{
|
||||
"id": "batiments-line",
|
||||
"type": "line",
|
||||
"source": "cadastre",
|
||||
"source-layer": "batiments",
|
||||
"minzoom": 16,
|
||||
"maxzoom": 22,
|
||||
"layout": { "visibility": "visible" },
|
||||
"paint": {
|
||||
"line-opacity": 1,
|
||||
"line-color": "rgba(0, 0, 0, 1)",
|
||||
"line-width": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "batiments-fill",
|
||||
"type": "fill",
|
||||
"source": "cadastre",
|
||||
"source-layer": "batiments",
|
||||
"layout": { "visibility": "visible" },
|
||||
"paint": {
|
||||
"fill-color": "rgba(150, 150, 150, 1)",
|
||||
"fill-opacity": {
|
||||
"stops": [
|
||||
[16, 0],
|
||||
[17, 0.6]
|
||||
]
|
||||
},
|
||||
"fill-antialias": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "parcelles",
|
||||
"type": "line",
|
||||
"source": "cadastre",
|
||||
"source-layer": "parcelles",
|
||||
"minzoom": 15.5,
|
||||
"maxzoom": 24,
|
||||
"layout": {
|
||||
"visibility": "visible",
|
||||
"line-cap": "butt",
|
||||
"line-join": "miter",
|
||||
"line-miter-limit": 2
|
||||
},
|
||||
"paint": {
|
||||
"line-color": "rgba(255, 255, 255, 1)",
|
||||
"line-opacity": 0.8,
|
||||
"line-width": {
|
||||
"stops": [
|
||||
[16, 1.5],
|
||||
[17, 2]
|
||||
]
|
||||
},
|
||||
"line-offset": 0,
|
||||
"line-blur": 0,
|
||||
"line-translate": [0, 1],
|
||||
"line-dasharray": [1],
|
||||
"line-gap-width": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "parcelles-fill",
|
||||
"type": "fill",
|
||||
"source": "cadastre",
|
||||
"source-layer": "parcelles",
|
||||
"layout": {
|
||||
"visibility": "visible"
|
||||
},
|
||||
"paint": {
|
||||
"fill-color": "rgba(129, 123, 0, 1)",
|
||||
"fill-opacity": [
|
||||
"case",
|
||||
["boolean", ["feature-state", "hover"], false],
|
||||
0.7,
|
||||
0.1
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "parcelle-highlighted",
|
||||
"type": "fill",
|
||||
"source": "cadastre",
|
||||
"source-layer": "parcelles",
|
||||
"filter": ["in", "id", ""],
|
||||
"paint": {
|
||||
"fill-color": "rgba(1, 129, 0, 1)",
|
||||
"fill-opacity": 0.7
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "sections",
|
||||
"type": "line",
|
||||
"source": "cadastre",
|
||||
"source-layer": "sections",
|
||||
"minzoom": 12,
|
||||
"layout": { "visibility": "visible" },
|
||||
"paint": {
|
||||
"line-color": "rgba(0, 0, 0, 1)",
|
||||
"line-opacity": 0.7,
|
||||
"line-width": 2,
|
||||
"line-dasharray": [3, 3],
|
||||
"line-translate": [0, 0]
|
||||
}
|
||||
}
|
||||
]
|
|
@ -1,110 +0,0 @@
|
|||
import type { AnyLayer } from 'maplibre-gl';
|
||||
|
||||
const layers: AnyLayer[] = [
|
||||
{
|
||||
id: 'batiments-line',
|
||||
type: 'line',
|
||||
source: 'cadastre',
|
||||
'source-layer': 'batiments',
|
||||
minzoom: 16,
|
||||
maxzoom: 22,
|
||||
layout: { visibility: 'visible' },
|
||||
paint: {
|
||||
'line-opacity': 1,
|
||||
'line-color': 'rgba(0, 0, 0, 1)',
|
||||
'line-width': 1
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'batiments-fill',
|
||||
type: 'fill',
|
||||
source: 'cadastre',
|
||||
'source-layer': 'batiments',
|
||||
layout: { visibility: 'visible' },
|
||||
paint: {
|
||||
'fill-color': 'rgba(150, 150, 150, 1)',
|
||||
'fill-opacity': {
|
||||
stops: [
|
||||
[16, 0],
|
||||
[17, 0.6]
|
||||
]
|
||||
},
|
||||
'fill-antialias': true
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'parcelles',
|
||||
type: 'line',
|
||||
source: 'cadastre',
|
||||
'source-layer': 'parcelles',
|
||||
minzoom: 15.5,
|
||||
maxzoom: 24,
|
||||
layout: {
|
||||
visibility: 'visible',
|
||||
'line-cap': 'butt',
|
||||
'line-join': 'miter',
|
||||
'line-miter-limit': 2
|
||||
},
|
||||
paint: {
|
||||
'line-color': 'rgba(255, 255, 255, 1)',
|
||||
'line-opacity': 0.8,
|
||||
'line-width': {
|
||||
stops: [
|
||||
[16, 1.5],
|
||||
[17, 2]
|
||||
]
|
||||
},
|
||||
'line-offset': 0,
|
||||
'line-blur': 0,
|
||||
'line-translate': [0, 1],
|
||||
'line-dasharray': [1],
|
||||
'line-gap-width': 0
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'parcelles-fill',
|
||||
type: 'fill',
|
||||
source: 'cadastre',
|
||||
'source-layer': 'parcelles',
|
||||
layout: {
|
||||
visibility: 'visible'
|
||||
},
|
||||
paint: {
|
||||
'fill-color': 'rgba(129, 123, 0, 1)',
|
||||
'fill-opacity': [
|
||||
'case',
|
||||
['boolean', ['feature-state', 'hover'], false],
|
||||
0.7,
|
||||
0.1
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'parcelle-highlighted',
|
||||
type: 'fill',
|
||||
source: 'cadastre',
|
||||
'source-layer': 'parcelles',
|
||||
filter: ['in', 'id', ''],
|
||||
paint: {
|
||||
'fill-color': 'rgba(1, 129, 0, 1)',
|
||||
'fill-opacity': 0.7
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'sections',
|
||||
type: 'line',
|
||||
source: 'cadastre',
|
||||
'source-layer': 'sections',
|
||||
minzoom: 12,
|
||||
layout: { visibility: 'visible' },
|
||||
paint: {
|
||||
'line-color': 'rgba(0, 0, 0, 1)',
|
||||
'line-opacity': 0.7,
|
||||
'line-width': 2,
|
||||
'line-dasharray': [3, 3],
|
||||
'line-translate': [0, 0]
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
export default layers;
|
|
@ -0,0 +1,8 @@
|
|||
[
|
||||
{
|
||||
"id": "ign",
|
||||
"source": "plan-ign",
|
||||
"type": "raster",
|
||||
"paint": { "raster-resampling": "linear" }
|
||||
}
|
||||
]
|
|
@ -1,12 +0,0 @@
|
|||
import type { RasterLayer } from 'maplibre-gl';
|
||||
|
||||
const layers: RasterLayer[] = [
|
||||
{
|
||||
id: 'ign',
|
||||
source: 'plan-ign',
|
||||
type: 'raster',
|
||||
paint: { 'raster-resampling': 'linear' }
|
||||
}
|
||||
];
|
||||
|
||||
export default layers;
|
2647
app/javascript/components/shared/maplibre/styles/layers/ortho.json
Normal file
2647
app/javascript/components/shared/maplibre/styles/layers/ortho.json
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
2866
app/javascript/components/shared/maplibre/styles/layers/vector.json
Normal file
2866
app/javascript/components/shared/maplibre/styles/layers/vector.json
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue