2020-07-29 15:27:08 +02:00
|
|
|
import baseStyle from './base-style';
|
|
|
|
import cadastre from './cadastre';
|
|
|
|
import orthoStyle from './ortho-style';
|
|
|
|
import vectorStyle from './vector-style';
|
|
|
|
|
2020-09-02 12:56:45 +02:00
|
|
|
function rasterStyle(source) {
|
|
|
|
return {
|
|
|
|
id: source,
|
|
|
|
source,
|
2020-07-29 15:27:08 +02:00
|
|
|
type: 'raster',
|
|
|
|
paint: { 'raster-resampling': 'linear' }
|
2020-09-02 12:56:45 +02:00
|
|
|
};
|
|
|
|
}
|
2020-06-09 17:23:24 +02:00
|
|
|
|
2020-09-02 12:56:45 +02:00
|
|
|
export function getMapStyle(style, hasCadastres, hasMNHN) {
|
2020-07-29 15:27:08 +02:00
|
|
|
const mapStyle = { ...baseStyle };
|
|
|
|
|
|
|
|
switch (style) {
|
|
|
|
case 'ortho':
|
|
|
|
mapStyle.layers = orthoStyle;
|
|
|
|
mapStyle.id = 'ortho';
|
|
|
|
mapStyle.name = 'Photographies aériennes';
|
|
|
|
break;
|
|
|
|
case 'vector':
|
|
|
|
mapStyle.layers = vectorStyle;
|
|
|
|
mapStyle.id = 'vector';
|
|
|
|
mapStyle.name = 'Carte OSM';
|
|
|
|
break;
|
|
|
|
case 'ign':
|
2020-09-02 12:56:45 +02:00
|
|
|
mapStyle.layers = [rasterStyle('plan-ign')];
|
2020-07-29 15:27:08 +02:00
|
|
|
mapStyle.id = 'ign';
|
|
|
|
mapStyle.name = 'Carte IGN';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-06-09 17:23:24 +02:00
|
|
|
if (hasCadastres) {
|
2020-07-29 15:27:08 +02:00
|
|
|
mapStyle.layers = mapStyle.layers.concat(cadastre);
|
|
|
|
mapStyle.id += '-cadastre';
|
2020-06-09 17:23:24 +02:00
|
|
|
}
|
2020-07-29 15:27:08 +02:00
|
|
|
|
2020-09-02 12:56:45 +02:00
|
|
|
if (hasMNHN) {
|
|
|
|
mapStyle.layers = mapStyle.layers.concat([
|
|
|
|
rasterStyle('protectedareas-gp'),
|
|
|
|
rasterStyle('protectedareas-pn'),
|
|
|
|
rasterStyle('protectedareas-pnr'),
|
|
|
|
rasterStyle('protectedareas-sic'),
|
|
|
|
rasterStyle('protectedareas-zps')
|
|
|
|
]);
|
|
|
|
mapStyle.id += '-mnhn';
|
|
|
|
}
|
|
|
|
|
2020-07-29 15:27:08 +02:00
|
|
|
return mapStyle;
|
2020-06-09 17:23:24 +02:00
|
|
|
}
|
2020-07-29 15:27:08 +02:00
|
|
|
|
|
|
|
export { SwitchMapStyle } from './SwitchMapStyle';
|