Skip to content

Commit

Permalink
fix ign url with geoplatform
Browse files Browse the repository at this point in the history
  • Loading branch information
lhapaipai committed Nov 10, 2024
1 parent 3fb3ee6 commit d952baf
Show file tree
Hide file tree
Showing 7 changed files with 508 additions and 61 deletions.
46 changes: 0 additions & 46 deletions Makefile

This file was deleted.

11 changes: 4 additions & 7 deletions apps/front/src/features/map/mapSlice.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import { RootState } from "~/store";
import { france, marignier } from "~/features/map/util";
import { debug } from "~/config/constants";
import { marignier } from "~/features/map/util";
import { BaseLayerId, OptionalLayerId } from "./layers";
import { parseHashString } from "~/store/hash";

Expand All @@ -25,12 +24,10 @@ const hashInfos = parseHashString(window.location.hash);
const initialState: MapState = hashInfos?.map
? hashInfos.map
: {
baseLayer: "ign-plan_ign-standard-modern",
baseLayer: "ign-raster-default_scan",
viewState: {
center: debug
? [marignier.lng, marignier.lat]
: [france.lng, france.lat],
zoom: debug ? marignier.zoom : france.zoom,
center: [marignier.lng, marignier.lat],
zoom: marignier.zoom,
pitch: 0,
bearing: 0,
},
Expand Down
2 changes: 1 addition & 1 deletion apps/front/src/features/map/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export async function prepareStyle(
export const marignier = {
lng: 6.498,
lat: 46.089,
zoom: 14,
zoom: 12,
};
export const france =
document.documentElement.clientWidth > 768
Expand Down
14 changes: 10 additions & 4 deletions apps/pentatrion-geo/api/ign/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { urlBuilder } from "./urlBuilder";

export const dataGeoserviceUrl = "https://data.geopf.fr";
export const legacyWMTSEndpoint = "https://wxs.ign.fr/{TOKEN}/geoportail/wmts";
export const geoplatformeWMTSEndpoint = "https://data.geopf.fr/private/wmts";
export const geoplatformeWMTSPrivateEndpoint =
"https://data.geopf.fr/private/wmts";
export const geoplatformeWMTSEndpoint = "https://data.geopf.fr/wmts";

/**
* maxZoom: 20
Expand All @@ -22,21 +24,25 @@ export const getIgnCadastreURL = () => {
* maxZoom: 18
*/
export const getIgnDefaultScanURL = (ignToken: string) => {
return new urlBuilder("GEOGRAPHICALGRIDSYSTEMS.MAPS").setToken(ignToken).getUrl();
return new urlBuilder("GEOGRAPHICALGRIDSYSTEMS.MAPS")
.setToken(ignToken)
.getUrl();
};

/**
* maxZoom 16
*/
export const getIgnScan25URL = (ignToken: string) => {
return new urlBuilder("GEOGRAPHICALGRIDSYSTEMS.MAPS.SCAN25TOUR").setToken(ignToken).getUrl();
return new urlBuilder("GEOGRAPHICALGRIDSYSTEMS.MAPS.SCAN25TOUR")
.setToken(ignToken)
.getUrl();
};

/**
* maxZoom: 19
*/
export const getIgnOrthophotoURL = () => {
return new urlBuilder("ORTHOIMAGERY.ORTHOPHOTOS", false).getUrl();
return new urlBuilder("ORTHOIMAGERY.ORTHOPHOTOS").getUrl();
};

export const getIgnExpressURL = () => {
Expand Down
15 changes: 12 additions & 3 deletions apps/pentatrion-geo/api/ign/urlBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { geoplatformeWMTSEndpoint, legacyWMTSEndpoint } from "./url";
import {
geoplatformeWMTSEndpoint,
geoplatformeWMTSPrivateEndpoint,
legacyWMTSEndpoint,
} from "./url";

export type ignSearchParams = {
SERVICE: "WMTS";
Expand Down Expand Up @@ -35,7 +39,10 @@ export class urlBuilder {
this.isGeoplateforme = isGeoplateforme;
}

public set<K extends keyof ignSearchParams>(key: K, value: ignSearchParams[K]) {
public set<K extends keyof ignSearchParams>(
key: K,
value: ignSearchParams[K],
) {
this.params[key] = value;
return this;
}
Expand Down Expand Up @@ -65,7 +72,9 @@ export class urlBuilder {
public getUrl() {
return (
(this.isGeoplateforme
? geoplatformeWMTSEndpoint
? this.token === null
? geoplatformeWMTSEndpoint
: geoplatformeWMTSPrivateEndpoint
: legacyWMTSEndpoint.replace("{TOKEN}", this.getToken())) +
"?" +
// we can't use new URLSearchParams(this.params).toString() because
Expand Down
239 changes: 239 additions & 0 deletions extra/assets/public/styles/ign/ADMIN_EXPRESS/adminexpress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
{
"version": 8,
"name": "ADMIN_EXPRESS",
"glyphs": "https://data.geopf.fr/annexes/ressources/vectorTiles/fonts/{fontstack}/{range}.pbf",
"sources": {
"adminexpress": {
"type": "vector",
"tiles": ["https://data.geopf.fr/tms/1.0.0/ADMIN_EXPRESS/{z}/{x}/{y}.pbf"]
}
},
"transition": { "duration": 300, "delay": 0 },
"layers": [
{
"id": "chef_lieu",
"type": "circle",
"source": "adminexpress",
"source-layer": "chflieu_commune",
"paint": {
"circle-color": "#273d9d",
"circle-stroke-color": "rgba(0, 0, 0, 1)",
"circle-radius": 5,
"circle-stroke-width": 1
}
},
{
"id": "commune_limites",
"type": "line",
"source": "adminexpress",
"source-layer": "commune",
"minzoom": 12,
"paint": { "line-color": "#e49b67", "line-width": 2 }
},
{
"id": "arrondissement_limites",
"type": "line",
"source": "adminexpress",
"source-layer": "arrondissement",
"paint": {
"line-color": "#000000",
"line-width": 0.5
}
},
{
"id": "canton_limites",
"type": "line",
"source": "adminexpress",
"source-layer": "canton",
"paint": {
"line-color": {
"stops": [
[11, "#b81414"],
[12, "#d65c5c"]
]
},
"line-width": {
"stops": [
[11, 2],
[12, 6]
]
},
"line-opacity": {
"stops": [
[11, 1],
[12, 0.4]
]
}
}
},
{
"id": "epci_limites",
"type": "line",
"source": "adminexpress",
"source-layer": "epci",
"paint": {
"line-color": {
"stops": [
[9, "#b814b8"],
[14, "#c270c2"]
]
},
"line-width": {
"stops": [
[9, 1],
[14, 10]
]
},
"line-opacity": {
"stops": [
[9, 1],
[14, 0.4]
]
}
}
},
{
"id": "departement",
"type": "line",
"source": "adminexpress",
"source-layer": "departement",
"paint": {
"line-color": "#000000",
"line-width": 1
}
},
{
"id": "region",
"type": "line",
"source": "adminexpress",
"source-layer": "region",
"paint": {
"line-color": "#000000",
"line-width": 2
}
},
{
"id": "capitale_label",
"type": "symbol",
"source": "adminexpress",
"source-layer": "commune",
"minzoom": 6,
"maxzoom": 11,
"filter": ["all", ["==", "statut", "Capitale d'état"]],
"layout": {
"text-field": "{nom}",
"text-allow-overlap": false,
"text-offset": [0, -2],
"icon-text-fit": "none",
"text-size": 13,
"text-font": ["Source Sans Pro Bold"]
},
"paint": {
"text-color": "#273d9d",
"text-halo-color": "#ffffff",
"text-halo-width": 2
}
},
{
"id": "prefecture_label",
"type": "symbol",
"source": "adminexpress",
"source-layer": "commune",
"minzoom": 6,
"maxzoom": 11,
"filter": ["all", ["==", "statut", "Préfecture"]],
"layout": {
"text-field": "{nom}",
"text-allow-overlap": false,
"text-offset": [0, -2],
"icon-text-fit": "none",
"text-size": 13,
"text-font": ["Source Sans Pro Bold"]
},
"paint": {
"text-color": "#273d9d",
"text-halo-color": "#ffffff",
"text-halo-width": 2
}
},
{
"id": "chef_lieu_label",
"type": "symbol",
"source": "adminexpress",
"source-layer": "chflieu_commune",
"minzoom": 14,
"layout": {
"text-field": "{nom}",
"text-allow-overlap": false,
"text-offset": [0, -2],
"icon-text-fit": "none",
"text-size": 12,
"text-font": ["Source Sans Pro Bold"]
},
"paint": {
"text-color": "#273d9d",
"text-halo-color": "#ffffff",
"text-halo-width": 2
}
},
{
"id": "commune_label",
"type": "symbol",
"source": "adminexpress",
"source-layer": "commune",
"minzoom": 13,
"layout": {
"text-field": "{nom}",
"text-size": 12,
"text-font": ["Source Sans Pro Bold"]
},
"paint": { "text-halo-color": "#ffffff", "text-halo-width": 2 }
},
{
"id": "epci_labels",
"type": "symbol",
"source": "adminexpress",
"source-layer": "epci",
"layout": {
"text-size": 13,
"text-font": ["Source Sans Pro Bold"],
"text-field": "{nom}"
},
"paint": {
"text-color": "#b814b8",
"text-halo-color": "#ffffff",
"text-halo-width": 2
}
},
{
"id": "departement_label",
"type": "symbol",
"source": "adminexpress",
"source-layer": "departement",
"maxzoom": 11,
"layout": {
"text-field": "{nom}",
"icon-size": 1,
"text-size": 12,
"text-font": ["Source Sans Pro Bold"]
},
"paint": {
"text-halo-color": "rgba(255, 255, 255, 1)",
"text-halo-width": 2
}
},
{
"id": "region_label",
"type": "symbol",
"source": "adminexpress",
"source-layer": "region",
"maxzoom": 12,
"layout": {
"text-field": "{nom}",
"text-size": 14,
"text-font": ["Source Sans Pro Bold"]
},
"paint": { "text-halo-color": "rgba(255, 255, 255, 1)" }
}
]
}
Loading

0 comments on commit d952baf

Please sign in to comment.