diff --git a/.gitignore b/.gitignore index 2357e41..97938ed 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ sources/*.3dm *.tgz .DS_Store .cache/ +public/tuiles/*.pmtiles +pmtiles.exe diff --git a/LICENCES.md b/LICENCES.md new file mode 100644 index 0000000..40c5cc9 --- /dev/null +++ b/LICENCES.md @@ -0,0 +1,16 @@ +# Licences des pièces tierces servies par le build + +Le code du dépôt est sous licence MIT (`LICENSE`) ; le contenu de `content/` sous CC BY-SA 4.0 (`content/LICENSE`). Ce fichier liste ce qui vient d'ailleurs et ce que chaque licence demande. + +## Prototype XL (`xl-proto.html`, lot ⑥a) + +| Pièce | Où | Version | Licence | Ce qu'elle demande | +|---|---|---|---|---| +| MapLibre GL JS | `node_modules/maplibre-gl`, groupée par Vite dans `dist/assets/xl-proto-*.js` et `maplibre-gl-worker-*.mjs` | 6.16.0 | BSD 3 clauses (`node_modules/maplibre-gl/LICENSE.txt`) | garder l'avis de copyright ; il reste dans l'en-tête `@license` des fichiers groupés | +| PMTiles (lecteur JS) | `node_modules/pmtiles`, groupé dans `dist/assets/xl-proto-*.js` | 4.5.0 | BSD 3 clauses (champ `license` du paquet ; le paquet npm ne contient pas de fichier LICENSE, le texte est dans le dépôt `protomaps/PMTiles`) | garder l'avis de copyright | +| fflate (décompression, dépendance de PMTiles) | groupé dans `dist/assets/xl-proto-*.js` | 0.8.3 | MIT | garder l'avis | +| Glyphes Noto Sans Regular, plages 0-255 et 256-511 | `public/xl/glyphs/NotoSansRegular/` | `protomaps/basemaps-assets`, commit `028c18f713baecad011301ff7a69acc39bcc2ae7` | SIL Open Font License 1.1 (`OFL.txt` du même dépôt ; Copyright 2022 The Noto Project Authors) | la police peut être servie et redistribuée ; ne pas la vendre seule ; garder la licence avec elle | +| Fond de carte (tuiles) | `public/tuiles/bigorre.pmtiles`, **hors git** (`pipeline/xl/README.md`) | build Protomaps du 06/11/2026 (basemap v4.15.2) | données © les contributeurs d'OpenStreetMap, ODbL 1.0 (« Produced Work ») ; schéma Protomaps sous BSD/ODbL | mention « © OpenStreetMap » lisible sur la carte avec un lien vers `openstreetmap.org/copyright` (fait dans le coin de la carte), et « Protomaps » | +| Outil `pmtiles` (go-pmtiles) | hors dépôt, `C:\Users\jules\dev\_outils\pmtiles\` ; jamais commité, jamais servi | 1.31.2 | BSD 3 clauses (`LICENSE` de l'archive publiée) | — (outil de fabrication, non redistribué) | + +Les épingles (`content/xl-epingles.md`) ne viennent pas d'OpenStreetMap : leurs positions sont les centres de communes de l'API Découpage administratif (`geo.api.gouv.fr`, Licence Ouverte 2.0). Elles restent hors ODbL. diff --git a/content/xl-epingles.md b/content/xl-epingles.md new file mode 100644 index 0000000..324a25c --- /dev/null +++ b/content/xl-epingles.md @@ -0,0 +1,29 @@ +--- +titre: Les épingles de la carte XL (prototype) +source: "Base de connaissances REinNOVER (vault, `REinNOVER/Base de connaissances/`, index du 03/11) ; centres de communes : geo.api.gouv.fr, relevés le 06/11/2026" +statut: prototype du lot ⑥a (06/11) ; toutes les positions sont provisoires, à relever par Jules +licence: CC BY-SA 4.0 +--- + +# Les épingles de la carte XL + +**D'où viennent les coordonnées.** Chaque épingle est posée au **centre de sa commune**, tel que le rend l'API Découpage administratif (`geo.api.gouv.fr/communes`, champ `centre`, Licence Ouverte 2.0), lu le 06/11/2026. Aucune position n'est extraite d'OpenStreetMap : ce fichier reste hors de la licence ODbL du fond de carte, en CC BY-SA comme le reste de `content/`. + +**Toutes les positions sont provisoires, à relever par Jules** : un centre de commune n'est pas l'adresse d'une structure. Deux épingles de la même commune se dessinent écartées l'une de l'autre ; la donnée, elle, reste au centre. + +## Mode d'emploi + +- Une ligne par épingle. `couche` : `existant` (ce qui est là, regardé et critiqué) ou `propose` (ce qu'on propose, ou le relais d'une proposition). L'attribution des couches est celle du prototype : à revoir par Jules. +- `base` : le titre exact de l'entrée de la base de connaissances ; `statut` : le sien, recopié tel quel (il s'affiche quand il appelle une réserve). +- `phrase` : une phrase tirée de l'entrée ; aucun chiffre hors d'une entrée « vérifié ». +- `ouvre` : un lien sortant (`https://…`, nouvel onglet), ou rien. +- Le build s'arrête sur une coordonnée hors du rectangle de la carte (longitude −0,40 à 0,55, latitude 42,65 à 43,55), une couche inconnue ou un identifiant en double, avec la ligne à corriger. + +## Épingles + +| id | lon | lat | couche | titre | base | statut | precision | phrase | ouvre | +|---|---|---|---|---|---|---|---|---|---| +| arbre-paysage-65 | 0.4006 | 43.2895 | propose | Arbre et Paysage 65, à la Maison de la Nature et de l'Environnement | Haies : Réseau Haies et Arbre et Paysage 65 | partiel | Puydarrieux | Le pôle Arbre et Paysage 65 conseille, fournit plants et paillage et suit les plantations de haies, particuliers compris : le premier relais à mettre sur la carte. | https://reseauhaies.fr | +| conservatoire-botanique | 0.1298 | 42.9686 | propose | Conservatoire botanique national des Pyrénées et de Midi-Pyrénées | Plants d'origine locale : Végétal local et le Conservatoire botanique des Pyrénées | à visiter | Bagnères-de-Bigorre | Siège au vallon de Salut : la part locale d'une haie, la palette végétale par biorégion, et un acteur public dans la ville de l'équipe ; son rôle actuel de correspondant Végétal local n'est pas vérifié. | | +| hopital-bagneres | 0.1298 | 42.9686 | existant | L'hôpital de Bagnères | Médecin, maison de santé, hôpital | à vérifier | Bagnères-de-Bigorre | La mobilisation pour l'hôpital de Bagnères rappelle que l'autonomie passe aussi par les services publics. | | +| zero-chomeur-pau | -0.3435 | 43.3219 | propose | Territoire zéro chômeur : des quartiers de Pau | Économie locale depuis le quartier : Territoires zéro chômeur, coopératives d'activité, régies | partiel | Pau | Des quartiers de Pau sont habilités « Territoire zéro chômeur de longue durée » (une seule source) : transformer les gestes du quartier en emplois. | https://tzcld.fr | diff --git a/package-lock.json b/package-lock.json index adbc633..252a5d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,8 @@ "dependencies": { "@fontsource/barlow": "^5.3.0", "@fontsource/barlow-condensed": "^5.3.0", + "maplibre-gl": "^6.16.0", + "pmtiles": "^4.5.0", "three": "^0.170.0", "zod": "^3.23.8" }, @@ -484,6 +486,92 @@ "url": "https://github.com/sponsors/ayuhito" } }, + "node_modules/@mapbox/jsonlint-lines-primitives": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@mapbox/jsonlint-lines-primitives/-/jsonlint-lines-primitives-2.0.3.tgz", + "integrity": "sha512-0SElaV0uMxEnxzBhhX9WTuPyUeMsAN/SS0i16tjuba4/mio63MG9khjC1a0JAiPGXAwvwm4UfHJURCN7nyudQg==", + "license": "MIT", + "engines": { + "node": ">= 22" + } + }, + "node_modules/@mapbox/point-geometry": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@mapbox/point-geometry/-/point-geometry-1.1.0.tgz", + "integrity": "sha512-YGcBz1cg4ATXDCM/71L9xveh4dynfGmcLDqufR+nQQy3fKwsAZsWd/x4621/6uJaeB9mwOHE6hPeDgXz9uViUQ==", + "license": "ISC" + }, + "node_modules/@mapbox/tiny-sdf": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@mapbox/tiny-sdf/-/tiny-sdf-2.3.0.tgz", + "integrity": "sha512-gBvcNDBBB66bgQYvnaJ6Jk+VCaMmVq5+IZR2kWPisT88Z8s0kBQt6hfVi8QgRW8Vpg0UWZzBA4ZSyzHHC+VeRA==", + "license": "BSD-2-Clause" + }, + "node_modules/@mapbox/unitbezier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@mapbox/unitbezier/-/unitbezier-1.0.0.tgz", + "integrity": "sha512-fqd515fjBmANKGGsQ286E2Wvj/XvDFpGzwJxq4CI6jMQue6Oy04uCKp+JWKF00xRTmk6cEu1jPJ9p3xqH8YWqQ==", + "license": "BSD-2-Clause" + }, + "node_modules/@mapbox/vector-tile": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@mapbox/vector-tile/-/vector-tile-3.0.0.tgz", + "integrity": "sha512-Qf10S1uIHMk20ri/IVBnpS+esUEkVaR5Hftmz88jTInrpmWgPGJfPe3LVjjlE77trLx8tH6qjTG7uWH9hIq/0Q==", + "license": "BSD-3-Clause", + "dependencies": { + "@mapbox/point-geometry": "~1.1.0", + "@types/geojson": "^7946.0.16", + "pbf": "^5.0.0" + } + }, + "node_modules/@maplibre/geojson-vt": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/@maplibre/geojson-vt/-/geojson-vt-6.3.0.tgz", + "integrity": "sha512-3Zw2jsU9pIJG3G2CQFbLjWj2MlAHodhD7cSY+15iywUuLmmkgzcKRnueVRZ4AcC/5wOtfhidcJAAzBpoBNs3Xg==", + "license": "ISC", + "dependencies": { + "kdbush": "^4.1.0" + } + }, + "node_modules/@maplibre/maplibre-gl-style-spec": { + "version": "26.5.1", + "resolved": "https://registry.npmjs.org/@maplibre/maplibre-gl-style-spec/-/maplibre-gl-style-spec-26.5.1.tgz", + "integrity": "sha512-9ufQ5LR+Ldn87SILPVyRNz4wVm/sBrM2ZRv9VfjLRKYKIGAcvC1VFw/DEkJLAHqfMV8m03zDz1DUNTIUj/GvdA==", + "license": "ISC", + "dependencies": { + "@mapbox/jsonlint-lines-primitives": "^2.0.3", + "@mapbox/unitbezier": "^1.0.0", + "json-stringify-pretty-compact": "^4.0.0", + "minimist": "^1.2.8", + "quickselect": "^3.0.0", + "tinyqueue": "^3.0.0" + }, + "bin": { + "gl-style-format": "dist/gl-style-format.mjs", + "gl-style-migrate": "dist/gl-style-migrate.mjs", + "gl-style-validate": "dist/gl-style-validate.mjs" + } + }, + "node_modules/@maplibre/mlt": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@maplibre/mlt/-/mlt-1.3.0.tgz", + "integrity": "sha512-7M2O7ABM80Oi8XPkfkrjKB8mOBIxGoVgkA52Mu4RMWoBvvMdagQ522+WxVYujZsMpqIr3BpzrTbXrm4k8lCzCQ==", + "license": "(MIT OR Apache-2.0)", + "dependencies": { + "@mapbox/point-geometry": "^1.1.0" + } + }, + "node_modules/@maplibre/vt-pbf": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/@maplibre/vt-pbf/-/vt-pbf-4.3.3.tgz", + "integrity": "sha512-dEe5XUd64RQbxNxy2OzIkJnwNDWjVmSXjCd0A7zLirm7QJ/WWbmtDFIkfsiM4yt1cplqzG6oSivRYeWx1SM1yg==", + "license": "MIT", + "dependencies": { + "@mapbox/point-geometry": "^1.1.0", + "@types/geojson": "^7946.0.16", + "pbf": "^5.1.2" + } + }, "node_modules/@napi-rs/lzma-linux-x64-gnu": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-x64-gnu/-/lzma-linux-x64-gnu-1.5.1.tgz", @@ -865,6 +953,12 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/geojson": { + "version": "7946.0.16", + "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.16.tgz", + "integrity": "sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==", + "license": "MIT" + }, "node_modules/@types/node": { "version": "22.20.4", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.4.tgz", @@ -911,6 +1005,21 @@ "dev": true, "license": "BSD-3-Clause" }, + "node_modules/bidi-js": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/bidi-js/-/bidi-js-1.1.0.tgz", + "integrity": "sha512-fX1Onk0tdVPC7obPWB5EbJ1z7NVhLq4m2xZLq2YXBkxzMXIGRpNMU88n0EPgWseKl12J7zXs7qrDxPK4sRs2fg==", + "license": "MIT", + "dependencies": { + "require-from-string": "^2.0.2" + } + }, + "node_modules/earcut": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/earcut/-/earcut-3.2.4.tgz", + "integrity": "sha512-FHc6yNpnTORB0tM5kmZ03iD2mDuNakDE2lvf4Hw1XkfxtEHIGVi01B/GqUSwx+NcC1WGjidAfpTXzeALtPtfpg==", + "license": "ISC" + }, "node_modules/esbuild": { "version": "0.25.12", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.12.tgz", @@ -975,7 +1084,6 @@ "version": "0.8.3", "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.3.tgz", "integrity": "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==", - "dev": true, "license": "MIT" }, "node_modules/fsevents": { @@ -993,6 +1101,57 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, + "node_modules/gl-matrix": { + "version": "3.4.4", + "resolved": "https://registry.npmjs.org/gl-matrix/-/gl-matrix-3.4.4.tgz", + "integrity": "sha512-latSnyDNt/8zYUB6VIJ6PCh2jBjJX6gnDsoCZ7LyW7GkqrD51EWwa9qCoGixj8YqBtETQK/xY7OmpTF8xz1DdQ==", + "license": "MIT" + }, + "node_modules/json-stringify-pretty-compact": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/json-stringify-pretty-compact/-/json-stringify-pretty-compact-4.0.0.tgz", + "integrity": "sha512-3CNZ2DnrpByG9Nqj6Xo8vqbjT4F6N+tb4Gb28ESAZjYZ5yqvmc56J+/kuIwkaAMOyblTQhUW7PxMkUb8Q36N3Q==", + "license": "MIT" + }, + "node_modules/kdbush": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/kdbush/-/kdbush-4.1.0.tgz", + "integrity": "sha512-e9vurzrXJQrFX6ckpHP3bvj5l+9CnYzkxDNnNQ1h2QTqdWsUAJgXiKdGNcOa1EY85dU8KbQ+z/FdQdB7P+9yfQ==", + "license": "ISC" + }, + "node_modules/maplibre-gl": { + "version": "6.16.0", + "resolved": "https://registry.npmjs.org/maplibre-gl/-/maplibre-gl-6.16.0.tgz", + "integrity": "sha512-gApO66EMtoDZuio680RUBvskR7ahFd/NNhLN4tBAs+Y7FeT4gQV8zVFgYVMRmFxQznOEzecW19w6xOd9XjZjiA==", + "license": "BSD-3-Clause", + "dependencies": { + "@mapbox/point-geometry": "^1.1.0", + "@mapbox/tiny-sdf": "^2.3.0", + "@mapbox/unitbezier": "^1.0.0", + "@mapbox/vector-tile": "^3.0.0", + "@maplibre/geojson-vt": "^6.3.0", + "@maplibre/maplibre-gl-style-spec": "^26.4.4", + "@maplibre/mlt": "^1.3.0", + "@maplibre/vt-pbf": "^4.3.3", + "@types/geojson": "^7946.0.16", + "bidi-js": "^1.1.0", + "earcut": "^3.2.4", + "gl-matrix": "^3.4.4", + "kdbush": "^4.1.0", + "murmurhash-js": "^1.0.0", + "pbf": "^5.1.2", + "potpack": "^2.1.0", + "quickselect": "^3.0.0", + "tinyqueue": "^3.0.0" + }, + "engines": { + "node": ">=16.14.0", + "npm": ">=8.1.0" + }, + "funding": { + "url": "https://github.com/maplibre/maplibre-gl-js?sponsor=1" + } + }, "node_modules/meshoptimizer": { "version": "0.18.1", "resolved": "https://registry.npmjs.org/meshoptimizer/-/meshoptimizer-0.18.1.tgz", @@ -1000,6 +1159,21 @@ "dev": true, "license": "MIT" }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/murmurhash-js": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/murmurhash-js/-/murmurhash-js-1.0.0.tgz", + "integrity": "sha512-TvmkNhkv8yct0SVBSy+o8wYzXjE4Zz3PCesbfs8HiCXXdcTuocApFv11UWlNFWKYsP2okqrhb7JNlSm9InBhIw==", + "license": "MIT" + }, "node_modules/nanoid": { "version": "3.3.19", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.19.tgz", @@ -1019,6 +1193,18 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, + "node_modules/pbf": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/pbf/-/pbf-5.1.2.tgz", + "integrity": "sha512-mnvGdvOrIvJOBGUEdGkrVXjN8E/VkIJCkf2eS1DH2yv82ORUlLttmDt0rWY38yYZmVwciZwBUvHM20qxBZf40w==", + "license": "BSD-3-Clause", + "dependencies": { + "resolve-protobuf-schema": "^2.1.0" + }, + "bin": { + "pbf": "bin/pbf" + } + }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -1039,6 +1225,15 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/pmtiles": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/pmtiles/-/pmtiles-4.5.0.tgz", + "integrity": "sha512-CBeD4SoUluFziGdy/8k7FOjQxQy486n+929W/tWophauvMICpkZ26vGBWhDt/6b1FZQWNaf4jFdT/5+q0Wii5w==", + "license": "BSD-3-Clause", + "dependencies": { + "fflate": "^0.8.2" + } + }, "node_modules/postcss": { "version": "8.5.28", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.28.tgz", @@ -1068,6 +1263,42 @@ "node": "^10 || ^12 || >=14" } }, + "node_modules/potpack": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/potpack/-/potpack-2.1.0.tgz", + "integrity": "sha512-pcaShQc1Shq0y+E7GqJqvZj8DTthWV1KeHGdi0Z6IAin2Oi3JnLCOfwnCo84qc+HAp52wT9nK9H7FAJp5a44GQ==", + "license": "ISC" + }, + "node_modules/protocol-buffers-schema": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/protocol-buffers-schema/-/protocol-buffers-schema-3.6.1.tgz", + "integrity": "sha512-VG2K63Igkiv9p76tk1lilczEK1cT+kCjKtkdhw1dQZV3k3IXJbd3o6Ho8b9zJZaHSnT2hKe4I+ObmX9w6m5SmQ==", + "license": "MIT" + }, + "node_modules/quickselect": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/quickselect/-/quickselect-3.0.0.tgz", + "integrity": "sha512-XdjUArbK4Bm5fLLvlm5KpTFOiOThgfWWI4axAZDWg4E/0mKdZyI9tNEfds27qCi1ze/vwTR16kvmmGhRra3c2g==", + "license": "ISC" + }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resolve-protobuf-schema": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/resolve-protobuf-schema/-/resolve-protobuf-schema-2.1.0.tgz", + "integrity": "sha512-kI5ffTiZWmJaS/huM8wZfEMer1eRd7oJQhDuxeCLe3t7N7mX3z94CN0xPxBQxFYQTSNz9T0i+v6inKqSdK8xrQ==", + "license": "MIT", + "dependencies": { + "protocol-buffers-schema": "^3.3.1" + } + }, "node_modules/rollup": { "version": "4.63.5", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.63.5.tgz", @@ -1147,6 +1378,12 @@ "url": "https://github.com/sponsors/SuperchupuDev" } }, + "node_modules/tinyqueue": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/tinyqueue/-/tinyqueue-3.0.0.tgz", + "integrity": "sha512-gRa9gwYU3ECmQYv3lslts5hxuIa90veaEcxDYuu3QGOIAEM2mOZkVHp48ANJuu1CURtRdHKUBY5Lm1tHV+sD4g==", + "license": "ISC" + }, "node_modules/typescript": { "version": "5.9.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", diff --git a/package.json b/package.json index 8eb8de9..7c9bf1c 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,8 @@ "dependencies": { "@fontsource/barlow": "^5.3.0", "@fontsource/barlow-condensed": "^5.3.0", + "maplibre-gl": "^6.16.0", + "pmtiles": "^4.5.0", "three": "^0.170.0", "zod": "^3.23.8" }, diff --git a/pipeline/xl/README.md b/pipeline/xl/README.md new file mode 100644 index 0000000..e8c1676 --- /dev/null +++ b/pipeline/xl/README.md @@ -0,0 +1,30 @@ +# pipeline/xl : le fond de carte de la Bigorre (prototype XL, lot ⑥a) + +Le fichier `public/tuiles/bigorre.pmtiles` **n'entre pas dans git** (`.gitignore`). Il se régénère ici, en une commande, et se pose à la main sur le serveur (transfert et `deploy.sh` : au pilotage). + +## La commande (exécutée le 06/11/2026) + +Outil : `pmtiles` 1.31.2 (`protomaps/go-pmtiles`, archive `go-pmtiles_1.31.2_Windows_x86_64.zip`, SHA-256 `a658baa4d7e55020aef6ca17bd9ff9faa1582671266b36f58c52db0ac8e785a1`, identique au `digest` publié sur la page de la version GitHub). Il vit **hors dépôt** : `C:\Users\jules\dev\_outils\pmtiles\pmtiles.exe`. + +``` +C:\Users\jules\dev\_outils\pmtiles\pmtiles.exe extract https://build.protomaps.com/20261106.pmtiles bigorre.pmtiles --bbox=-0.40,42.65,0.55,43.55 --maxzoom=14 +``` + +puis copier `bigorre.pmtiles` dans `public/tuiles/`. L'extraction lit le build mondial par requêtes de plage : 73 requêtes, ≈ 55 Mo transférés, une quinzaine de secondes (06/11). + +| | | +|---|---| +| Build source | `https://build.protomaps.com/20261106.pmtiles` (build quotidien Protomaps v4, publié le 06/11/2026 à 09:03 GMT ; basemap 4.15.2 ; données OSM au 06/11/2026 04:00 UTC) | +| Rectangle | `-0.40,42.65,0.55,43.55` (ouest, sud, est, nord : de Maubourguet à Gavarnie, de Lourdes à Lannemezan ; Pau entre au bord ouest) | +| Zooms | 0 à 14 (`ZOOM_MAX` dans `xl/style.ts`) | +| Taille | 52 084 419 octets (49,7 Mio) ; 3 577 tuiles, compressées gzip dans l'archive | +| SHA-256 du résultat | `89b23dd2bcb8e9baeb39386bddf3834dbd2cf3e2de18b218f7ace6d396cae914` | + +Tailles mesurées pour choisir le zoom maximal (même build, même rectangle) : zoom 12 : 17 446 488 octets · zoom 13 : 30 848 803 · **zoom 14 : 52 084 419** (le plus grand sous 60 Mo, retenu). + +## Ce qu'il faut savoir + +- **Un build quotidien ne reste pas en ligne indéfiniment** : l'adresse du jour se lit sur `docs.protomaps.com/basemaps/downloads` (« daily build channel », `maps.protomaps.com/builds`). Le SHA-256 changera à chaque régénération : le noter ici. +- Le fichier se sert **par requêtes de plage** (HTTP 206) ; Caddy `file_server` le fait. Ne pas le recompresser (les tuiles sont déjà en gzip dans l'archive). +- Licence : données © les contributeurs d'OpenStreetMap, ODbL (voir `LICENCES.md`). L'attribution est affichée dans le coin de la carte. +- Sans le fichier, `xl-proto.html` affiche un message lisible au lieu d'une carte vide. diff --git a/public/xl/glyphs/NotoSansRegular/0-255.pbf b/public/xl/glyphs/NotoSansRegular/0-255.pbf new file mode 100644 index 0000000..7f65901 Binary files /dev/null and b/public/xl/glyphs/NotoSansRegular/0-255.pbf differ diff --git a/public/xl/glyphs/NotoSansRegular/256-511.pbf b/public/xl/glyphs/NotoSansRegular/256-511.pbf new file mode 100644 index 0000000..f030288 Binary files /dev/null and b/public/xl/glyphs/NotoSansRegular/256-511.pbf differ diff --git a/public/xl/glyphs/OFL.txt b/public/xl/glyphs/OFL.txt new file mode 100644 index 0000000..0c037d1 --- /dev/null +++ b/public/xl/glyphs/OFL.txt @@ -0,0 +1,93 @@ +Copyright 2022 The Noto Project Authors (https://github.com/notofonts) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +https://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. \ No newline at end of file diff --git a/tests/xl-epingles.test.ts b/tests/xl-epingles.test.ts new file mode 100644 index 0000000..7c1b58d --- /dev/null +++ b/tests/xl-epingles.test.ts @@ -0,0 +1,64 @@ +import { test } from 'node:test'; +import assert from 'node:assert/strict'; +import { readFileSync } from 'node:fs'; +import { lireEpingles, filtrerParCouche, statutAffiche, decalages, ErreurEpingles, RECTANGLE } from '../xl/epingles.ts'; +import { construireStyle, ZOOM_MAX, VUE_DEPART } from '../xl/style.ts'; + +const md = readFileSync(new URL('../content/xl-epingles.md', import.meta.url), 'utf8'); +const ENTETE = '| id | lon | lat | couche | titre | base | statut | precision | phrase | ouvre |\n|---|---|---|---|---|---|---|---|---|---|\n'; +const ligne = (id: string, lon: string, lat: string, couche = 'existant') => `| ${id} | ${lon} | ${lat} | ${couche} | Titre | Entrée | partiel | Tarbes | Une phrase. | |\n`; + +test('la table du dépôt se lit : six à dix épingles au plus, toutes dans le rectangle', () => { + const e = lireEpingles(md); + assert.ok(e.length >= 1 && e.length <= 10, `${e.length} épingles`); + for (const p of e) { + assert.ok(p.lon >= RECTANGLE.ouest && p.lon <= RECTANGLE.est && p.lat >= RECTANGLE.sud && p.lat <= RECTANGLE.nord, p.id); + assert.ok(p.base.length > 0 && p.titre.length > 0, p.id); + } + assert.deepEqual(new Set(e.map((p) => p.couche)), new Set(['existant', 'propose'])); +}); + +test('une coordonnée hors du rectangle est refusée, avec la ligne', () => { + assert.throws(() => lireEpingles(ENTETE + ligne('a', '0.06', '43.23') + ligne('b', '1.44', '43.60')), (err: unknown) => err instanceof ErreurEpingles && err.ligne === 4 && /longitude/.test(err.message)); + assert.throws(() => lireEpingles(ENTETE + ligne('a', '0.06', '41.38')), /latitude/); +}); + +test('une couche inconnue est refusée', () => { + assert.throws(() => lireEpingles(ENTETE + ligne('a', '0.06', '43.23', 'futur')), /couche « futur » inconnue/); +}); + +test('un identifiant en double est refusé', () => { + assert.throws(() => lireEpingles(ENTETE + ligne('a', '0.06', '43.23') + ligne('a', '0.10', '43.20')), /en double/); +}); + +test('le filtre par couche garde les seules couches allumées', () => { + const e = lireEpingles(ENTETE + ligne('a', '0.06', '43.23') + ligne('b', '0.10', '43.20', 'propose') + ligne('c', '0.12', '43.10', 'propose')); + assert.deepEqual(filtrerParCouche(e, new Set(['propose'])).map((p) => p.id), ['b', 'c']); + assert.deepEqual(filtrerParCouche(e, new Set(['existant', 'propose'])).length, 3); + assert.deepEqual(filtrerParCouche(e, new Set()), []); +}); + +test('un lien sortant non https est refusé ; le statut de réserve s’affiche', () => { + assert.throws(() => lireEpingles(ENTETE + '| a | 0.06 | 43.23 | existant | T | E | partiel | Tarbes | P. | http://exemple.fr |\n'), /https/); + assert.equal(statutAffiche('à vérifier'), 'à vérifier'); + assert.equal(statutAffiche('vérifié'), null); +}); + +test('deux épingles au même centre de commune s’écartent à l’affichage, la donnée ne bouge pas', () => { + const e = lireEpingles(ENTETE + ligne('a', '0.1298', '42.9686') + ligne('b', '0.1298', '42.9686', 'propose') + ligne('c', '0.06', '43.23')); + const d = decalages(e); + assert.notDeepEqual(d.get('a'), d.get('b')); + assert.deepEqual(d.get('c'), [0, 0]); + assert.equal(e[0]!.lon, e[1]!.lon); +}); + +test('le style ne nomme aucun hôte : glyphes et tuiles viennent de la page', () => { + const s = construireStyle('http://127.0.0.1:4319/xl-proto.html'); + const texte = JSON.stringify(s); + const hotes = new Set([...texte.matchAll(/https?:\/\/([^/"\\]+)/g)].map((m) => m[1]).filter((h) => h !== '127.0.0.1:4319' && h !== 'www.openstreetmap.org' && h !== 'protomaps.com' && h !== 'github.com')); + assert.deepEqual([...hotes], []); + assert.equal('sprite' in s, false); + assert.match(String(s.glyphs), /^http:\/\/127\.0\.0\.1:4319\/xl\/glyphs\/\{fontstack\}\/\{range\}\.pbf$/); + assert.ok(ZOOM_MAX >= 12 && ZOOM_MAX <= 14); + assert.equal(VUE_DEPART.pitch, 45); +}); diff --git a/vite.config.ts b/vite.config.ts index b195e94..c5b5458 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,4 +1,4 @@ -import { defineConfig, type Plugin } from 'vite'; +import { defineConfig, build as construire, type Plugin } from 'vite'; import { execSync } from 'node:child_process'; import { readFileSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; @@ -51,6 +51,29 @@ function contenu(): Plugin { }; } +// Seconde entrée : le prototype XL (lot ⑥a, xl-proto.html, liée depuis aucune page). Bâtie dans une passe à part, +// après la démo : deux entrées HTML dans la même passe font sortir le polyfill modulepreload en morceau partagé, +// et l'entrée de la démo change (mesuré le 06/11 : 292,31 → 291,65 kB, une requête de plus). Ainsi, maplibre-gl +// et pmtiles n'entrent que dans dist/xl-proto.html et la démo reste identique à l'octet près. +function entreeXl(): Plugin { + return { + name: 'quartier-entree-xl', + apply: 'build', + async closeBundle() { + await construire({ + configFile: false, + root: ici('./'), + base: './', + publicDir: false, + logLevel: 'warn', + define: { __BUILD_HASH__: JSON.stringify(BUILD_HASH) }, + plugins: [{ name: 'quartier-xl-hash', transformIndexHtml: (html) => html.replace('__BUILD_HASH__', BUILD_HASH) }], + build: { target: 'es2022', sourcemap: false, emptyOutDir: false, assetsInlineLimit: 0, chunkSizeWarningLimit: 1200, rollupOptions: { input: { 'xl-proto': ici('./xl-proto.html') } } }, + }); + }, + }; +} + export default defineConfig({ // chemins relatifs : la même sortie sert sur quartier.trans-former.fr et en page autonome (lien privé de secours) base: './', @@ -69,6 +92,7 @@ export default defineConfig({ }, plugins: [ contenu(), + entreeXl(), { name: 'quartier-build-json', transformIndexHtml: (html) => html.replace('__BUILD_HASH__', BUILD_HASH), diff --git a/xl-proto.html b/xl-proto.html new file mode 100644 index 0000000..85e4ae0 --- /dev/null +++ b/xl-proto.html @@ -0,0 +1,31 @@ + + + + + + + + La Bigorre en carte : prototype XL (non publié) + + + +
+
+
+ + +
+

Chargement de la carte…

+ + Votre quartier en 2035 +
+ + + diff --git a/xl/epingles.ts b/xl/epingles.ts new file mode 100644 index 0000000..354c1e0 --- /dev/null +++ b/xl/epingles.ts @@ -0,0 +1,101 @@ +// Lecture de la table d'épingles XL (content/xl-epingles.md). Module pur : il reçoit le texte, +// il rend des objets, ou une erreur qui dit la ligne à corriger. Aucun import de la carte ici, +// pour que les tests le lisent sans navigateur. + +/** Le rectangle de la carte (brief D1) : ouest, sud, est, nord. */ +export const RECTANGLE = { ouest: -0.4, sud: 42.65, est: 0.55, nord: 43.55 } as const; + +export const COUCHES = ['existant', 'propose'] as const; +export type Couche = (typeof COUCHES)[number]; + +export interface Epingle { + id: string; + lon: number; + lat: number; + couche: Couche; + titre: string; + base: string; + statut: string; + precision: string; + phrase: string; + ouvre?: string; +} + +const COLONNES = ['id', 'lon', 'lat', 'couche', 'titre', 'base', 'statut', 'precision', 'phrase', 'ouvre'] as const; + +export class ErreurEpingles extends Error { + ligne: number; + constructor(ligne: number, message: string) { + super(`content/xl-epingles.md, ligne ${ligne} : ${message}`); + this.name = 'ErreurEpingles'; + this.ligne = ligne; + } +} + +const cellules = (l: string) => l.trim().replace(/^\|/, '').replace(/\|$/, '').split('|').map((c) => c.trim()); + +/** Lit la première table du fichier dont l'en-tête commence par `id | lon | lat`. */ +export function lireEpingles(md: string): Epingle[] { + const lignes = md.split(/\r?\n/); + const debut = lignes.findIndex((l) => /^\|\s*id\s*\|\s*lon\s*\|\s*lat\s*\|/.test(l)); + if (debut < 0) throw new ErreurEpingles(1, 'aucune table « id | lon | lat | … » trouvée'); + const entete = cellules(lignes[debut]!); + COLONNES.forEach((c, i) => { + if (entete[i] !== c) throw new ErreurEpingles(debut + 1, `colonne ${i + 1} attendue « ${c} », trouvée « ${entete[i] ?? ''} »`); + }); + const vues = new Set(); + const sortie: Epingle[] = []; + for (let i = debut + 2; i < lignes.length; i++) { + const brute = lignes[i]!; + if (!brute.trim().startsWith('|')) break; + const n = i + 1; + const c = cellules(brute); + if (c.length !== COLONNES.length) throw new ErreurEpingles(n, `${c.length} cellules au lieu de ${COLONNES.length}`); + const [id, lonT, latT, couche, titre, base, statut, precision, phrase, ouvre] = c as [string, string, string, string, string, string, string, string, string, string]; + if (!/^[a-z0-9-]+$/.test(id)) throw new ErreurEpingles(n, `identifiant « ${id} » : minuscules, chiffres et tirets seulement`); + if (vues.has(id)) throw new ErreurEpingles(n, `identifiant « ${id} » en double`); + vues.add(id); + const lon = Number(lonT.replace(',', '.')); + const lat = Number(latT.replace(',', '.')); + if (!Number.isFinite(lon) || lon < RECTANGLE.ouest || lon > RECTANGLE.est) throw new ErreurEpingles(n, `longitude « ${lonT} » hors du rectangle (${RECTANGLE.ouest} à ${RECTANGLE.est})`); + if (!Number.isFinite(lat) || lat < RECTANGLE.sud || lat > RECTANGLE.nord) throw new ErreurEpingles(n, `latitude « ${latT} » hors du rectangle (${RECTANGLE.sud} à ${RECTANGLE.nord})`); + if (!(COUCHES as readonly string[]).includes(couche)) throw new ErreurEpingles(n, `couche « ${couche} » inconnue (existant ou propose)`); + if (!titre) throw new ErreurEpingles(n, 'titre vide'); + if (!base) throw new ErreurEpingles(n, 'entrée de la base vide'); + if (ouvre && !/^https:\/\/[^\s]+$/.test(ouvre)) throw new ErreurEpingles(n, `lien « ${ouvre} » : une adresse https:// ou rien`); + sortie.push({ id, lon, lat, couche: couche as Couche, titre, base, statut, precision, phrase, ...(ouvre ? { ouvre } : {}) }); + } + if (!sortie.length) throw new ErreurEpingles(debut + 1, 'table vide'); + return sortie; +} + +/** Les épingles visibles quand seules les couches `actives` sont allumées. */ +export function filtrerParCouche(epingles: readonly Epingle[], actives: ReadonlySet): Epingle[] { + return epingles.filter((e) => actives.has(e.couche)); +} + +/** Statut affiché tel quel quand il appelle une réserve (brief §4). */ +export function statutAffiche(statut: string): string | null { + return /vérifier|partiel|visiter/i.test(statut) ? statut : null; +} + +/** + * Décalage d'affichage (en pixels) pour les épingles posées au même point : elles s'écartent + * en cercle autour du centre de la commune. La donnée ne bouge pas, seul le dessin s'écarte. + */ +export function decalages(epingles: readonly Epingle[], rayon = 24): Map { + const groupes = new Map(); + for (const e of epingles) { + const k = `${e.lon.toFixed(5)},${e.lat.toFixed(5)}`; + groupes.set(k, [...(groupes.get(k) ?? []), e]); + } + const sortie = new Map(); + for (const g of groupes.values()) { + g.forEach((e, i) => { + if (g.length === 1) return void sortie.set(e.id, [0, 0]); + const a = (2 * Math.PI * i) / g.length - Math.PI / 2; + sortie.set(e.id, [Math.round(Math.cos(a) * rayon), Math.round(Math.sin(a) * rayon)]); + }); + } + return sortie; +} diff --git a/xl/main.ts b/xl/main.ts new file mode 100644 index 0000000..9f6374e --- /dev/null +++ b/xl/main.ts @@ -0,0 +1,141 @@ +// Prototype XL (lot ⑥a) : la Bigorre en carte vectorielle, tout servi par le build. +// Bibliothèque groupée par Vite, worker copié dans dist/, glyphes dans public/xl/glyphs, +// tuiles dans public/tuiles/bigorre.pmtiles (hors git, pipeline/xl/README.md). Aucun tiers. +import '@fontsource/barlow/latin-400.css'; +import '@fontsource/barlow/latin-600.css'; +import 'maplibre-gl/dist/maplibre-gl.css'; +import './xl.css'; +import { Map as Carte, Marker, AttributionControl, NavigationControl, addProtocol, setWorkerUrl } from 'maplibre-gl'; +import urlWorker from 'maplibre-gl/dist/maplibre-gl-worker.mjs?url'; +import { Protocol } from 'pmtiles'; +import tableEpingles from '../content/xl-epingles.md?raw'; +import { lireEpingles, filtrerParCouche, statutAffiche, decalages, type Couche, type Epingle } from './epingles.ts'; +import { construireStyle, VUE_DEPART, BORNES, ZOOM_MIN, ZOOM_MAX, TUILES } from './style.ts'; + +const $ = (s: string) => document.querySelector(s) as T; +const etat = $('#etat'); +const dire = (t: string, erreur = false) => { + etat.textContent = t; + etat.hidden = !t; + etat.classList.toggle('erreur', erreur); +}; +const mouvementReduit = matchMedia('(prefers-reduced-motion: reduce)').matches; + +/** Le fichier de tuiles est-il là, et servi par plages ? (sinon : un message lisible, pas une carte vide) */ +async function tuilesPresentes(url: string): Promise { + try { + const r = await fetch(url, { headers: { Range: 'bytes=0-6' } }); + if (!r.ok) return false; + const debut = new TextDecoder().decode(new Uint8Array(await r.arrayBuffer()).slice(0, 7)); + return debut === 'PMTiles'; + } catch { + return false; + } +} + +async function demarrer() { + let epingles: Epingle[]; + try { + epingles = lireEpingles(tableEpingles); + } catch (e) { + dire(String((e as Error).message), true); + throw e; + } + const urlTuiles = new URL(TUILES, location.href).href; + if (!(await tuilesPresentes(urlTuiles))) { + dire('Le fond de carte n’est pas encore posé sur ce serveur (fichier tuiles/bigorre.pmtiles absent). Les épingles restent dans content/xl-epingles.md.', true); + document.body.classList.add('sans-tuiles'); + return; + } + + setWorkerUrl(urlWorker); + const protocole = new Protocol(); + addProtocol('pmtiles', protocole.tile); + + const carte = new Carte({ + container: 'carte', + style: construireStyle(location.href), + center: VUE_DEPART.centre, + zoom: VUE_DEPART.zoom, + pitch: VUE_DEPART.pitch, + bearing: VUE_DEPART.bearing, + minZoom: ZOOM_MIN, + maxZoom: ZOOM_MAX, + maxBounds: BORNES, + attributionControl: false, + fadeDuration: mouvementReduit ? 0 : 300, + cooperativeGestures: false, + }); + carte.addControl(new AttributionControl({ compact: false }), 'bottom-right'); + carte.addControl(new NavigationControl({ showZoom: false, visualizePitch: true }), 'top-right'); + (window as any).__xl = { carte, repos: false }; + + carte.once('load', () => dire('')); + carte.on('idle', () => ((window as any).__xl.repos = true)); + carte.on('error', (e) => console.warn('carte :', e.error?.message ?? e)); + + // Les épingles : des boutons HTML posés par des marqueurs (P6 : clavier, cibles ≥ 40 px). + const panneau = $('#panneau'); + const ecarts = decalages(epingles); + const marqueurs = new Map(); + for (const e of epingles) { + const b = document.createElement('button'); + b.type = 'button'; + b.className = `epingle c-${e.couche}`; + b.dataset.id = e.id; + b.setAttribute('aria-label', `${e.titre} (${e.couche === 'existant' ? 'l’existant' : 'ce qu’on propose'})`); + b.innerHTML = ''; + b.addEventListener('click', (ev) => { + ev.stopPropagation(); + ouvrir(e); + }); + const m = new Marker({ element: b, offset: ecarts.get(e.id) ?? [0, 0], pitchAlignment: 'viewport', rotationAlignment: 'viewport' }).setLngLat([e.lon, e.lat]).addTo(carte); + marqueurs.set(e.id, { m, e }); + } + + function ouvrir(e: Epingle) { + panneau.querySelector('.couche')!.textContent = e.couche === 'existant' ? 'L’existant' : 'Ce qu’on propose'; + panneau.querySelector('h2')!.textContent = e.titre; + panneau.querySelector('.phrase')!.textContent = e.phrase; + const s = statutAffiche(e.statut); + panneau.querySelector('.statut')!.textContent = `${s ? `Statut dans la base : ${s}. ` : ''}Position provisoire : centre de la commune (${e.precision}).`; + const lien = panneau.querySelector('.lien')!; + lien.replaceChildren(); + if (e.ouvre) { + const a = document.createElement('a'); + a.href = e.ouvre; + a.target = '_blank'; + a.rel = 'noopener'; + a.textContent = `${new URL(e.ouvre).hostname} (nouvel onglet)`; + lien.append(a); + } + panneau.hidden = false; + document.querySelectorAll('.epingle').forEach((x) => x.classList.toggle('active', (x as HTMLElement).dataset.id === e.id)); + const cible = { center: [e.lon, e.lat] as [number, number], offset: [0, -window.innerHeight * 0.12] as [number, number] }; + if (mouvementReduit) carte.jumpTo(cible); + else carte.easeTo({ ...cible, duration: 600 }); + (panneau.querySelector('.fermer') as HTMLButtonElement).focus({ preventScroll: true }); + } + const fermer = () => { + panneau.hidden = true; + document.querySelectorAll('.epingle.active').forEach((x) => x.classList.remove('active')); + }; + panneau.querySelector('.fermer')!.addEventListener('click', fermer); + document.addEventListener('keydown', (ev) => ev.key === 'Escape' && fermer()); + + // Les deux filtres (§4) : deux boutons à bascule, les deux allumés au départ. + const actives = new Set(['existant', 'propose']); + document.querySelectorAll('.filtre').forEach((b) => + b.addEventListener('click', () => { + const c = b.dataset.couche as Couche; + if (actives.has(c)) actives.delete(c); + else actives.add(c); + b.setAttribute('aria-pressed', String(actives.has(c))); + const visibles = new Set(filtrerParCouche(epingles, actives).map((e) => e.id)); + for (const [id, { m }] of marqueurs) m.getElement().hidden = !visibles.has(id); + if (!panneau.hidden && !visibles.has(String(document.querySelector('.epingle.active')?.dataset.id))) fermer(); + }), + ); +} + +demarrer().catch((e) => console.error(e)); diff --git a/xl/style.ts b/xl/style.ts new file mode 100644 index 0000000..ca99805 --- /dev/null +++ b/xl/style.ts @@ -0,0 +1,140 @@ +// Le style « papier et trait » de la carte XL (brief P3). Tout vient de la palette de la démo +// (maquette/style.css) ; aucune adresse d'un autre hôte : les glyphes et les tuiles sont résolus +// depuis l'adresse de la page, au moment de construire le style. +import type { StyleSpecification, LayerSpecification } from 'maplibre-gl'; + +// --- Constantes qui renversent les décisions (RECAP §2) --------------------------------------- + +/** Zoom maximal des tuiles extraites (D2 : plus grand zoom dont le fichier reste sous 60 Mo). */ +export const ZOOM_MAX = 14; +/** Zoom minimal de la vue (P4). */ +export const ZOOM_MIN = 8; +/** Vue de départ (P4) : Tarbes, inclinaison 45°, cap nord. `zoom` est le réglage qui pèse le plus sur le premier affichage. */ +export const VUE_DEPART = { centre: [0.0653, 43.2387] as [number, number], zoom: 10, pitch: 45, bearing: 0 }; +/** Bornes de la vue (P4) : le rectangle de D1. */ +export const BORNES: [[number, number], [number, number]] = [[-0.4, 42.65], [0.55, 43.55]]; +/** Fichier de tuiles, relatif à la page (D4). */ +export const TUILES = 'tuiles/bigorre.pmtiles'; +/** Police des étiquettes : un seul jeu de glyphes servi par le build (P1). */ +export const POLICE = 'NotoSansRegular'; +/** Routes visibles avant le zoom 11 : départementales et au-dessus (P3). */ +export const ROUTES_TOT = ['highway', 'major_road']; +/** Zoom d'apparition du bâti (P3). */ +export const ZOOM_BATI = 13; + +// Palette : recopiée de maquette/style.css (:root). Aucun hex nouveau. +export const PAL = { + papier: '#efeee2', // --papier + papier2: '#fffdf6', // --papier-2 + encre: '#102a3a', // --encre + encre2: '#3f5563', // --encre-2 + trait: '#ddd8c4', // --trait + eau: '#3a74a8', // --eau + eauFond: '#e1ebf5', // --eau-fond + vivant: '#8f7b22', // --vivant + auj: '#6b6458', // --auj +} as const; + +export const ATTRIBUTION = + 'Protomaps · © OpenStreetMap'; + +// ------------------------------------------------------------------------------------------------- + +const nom: any = ['coalesce', ['get', 'name:fr'], ['get', 'name']]; + +function couches(): LayerSpecification[] { + return [ + { id: 'fond', type: 'background', paint: { 'background-color': PAL.papier } }, + { + id: 'forets', + type: 'fill', + source: 'bigorre', + 'source-layer': 'landuse', + filter: ['in', ['get', 'kind'], ['literal', ['forest', 'wood']]], + paint: { 'fill-color': PAL.vivant, 'fill-opacity': 0.2, 'fill-antialias': false }, + }, + { + id: 'eau-surfaces', + type: 'fill', + source: 'bigorre', + 'source-layer': 'water', + filter: ['==', ['geometry-type'], 'Polygon'], + paint: { 'fill-color': PAL.eau, 'fill-opacity': 0.42 }, + }, + { + id: 'eau-cours', + type: 'line', + source: 'bigorre', + 'source-layer': 'water', + filter: ['all', ['==', ['geometry-type'], 'LineString'], ['any', ['in', ['get', 'kind'], ['literal', ['river', 'canal']]], ['>=', ['zoom'], 11]]], + paint: { 'line-color': PAL.eau, 'line-opacity': 0.75, 'line-width': ['interpolate', ['linear'], ['zoom'], 8, 0.5, 12, 1.2, 14, 2] }, + }, + { + id: 'bati', + type: 'fill', + source: 'bigorre', + 'source-layer': 'buildings', + minzoom: ZOOM_BATI, + paint: { 'fill-color': PAL.auj, 'fill-opacity': 0.28 }, + }, + { + id: 'limites-communes', + type: 'line', + source: 'bigorre', + 'source-layer': 'boundaries', + filter: ['all', ['==', ['get', 'kind'], 'locality'], ['==', ['to-string', ['get', 'kind_detail']], '8']], + paint: { 'line-color': PAL.encre2, 'line-opacity': 0.32, 'line-width': 0.7, 'line-dasharray': [2, 3] }, + }, + { + id: 'routes', + type: 'line', + source: 'bigorre', + 'source-layer': 'roads', + filter: [ + 'any', + ['in', ['get', 'kind'], ['literal', ROUTES_TOT]], + ['all', ['>=', ['zoom'], 11], ['==', ['get', 'kind'], 'minor_road']], + ], + layout: { 'line-cap': 'round', 'line-join': 'round' }, + paint: { + 'line-color': PAL.auj, + 'line-opacity': ['match', ['get', 'kind'], 'minor_road', 0.4, 0.7], + 'line-width': ['interpolate', ['linear'], ['zoom'], 8, ['match', ['get', 'kind'], 'highway', 0.9, 0.5], 12, ['match', ['get', 'kind'], 'highway', 1.6, 'minor_road', 0.5, 1], 14, ['match', ['get', 'kind'], 'highway', 2.4, 'minor_road', 1, 1.6]], + }, + }, + { + id: 'communes', + type: 'symbol', + source: 'bigorre', + 'source-layer': 'places', + filter: ['all', ['==', ['get', 'kind'], 'locality'], ['in', ['get', 'kind_detail'], ['literal', ['city', 'town', 'village']]], ['<=', ['coalesce', ['get', 'min_zoom'], 0], ['+', ['zoom'], 1]]], + layout: { + 'text-field': nom, + 'text-font': [POLICE], + 'text-size': ['interpolate', ['linear'], ['zoom'], 8, ['match', ['get', 'kind_detail'], 'city', 15, 'town', 12, 10.5], 13, ['match', ['get', 'kind_detail'], 'city', 19, 'town', 16, 14]], + 'symbol-sort-key': ['-', 0, ['coalesce', ['get', 'population_rank'], 0]], + 'text-padding': 4, + 'text-max-width': 8, + }, + paint: { 'text-color': PAL.encre2, 'text-halo-color': PAL.papier2, 'text-halo-width': 1.4 }, + }, + ]; +} + +/** Le style complet. `page` est l'adresse de la page (location.href) : tout se résout depuis elle. */ +export function construireStyle(page: string): StyleSpecification { + const base = new URL('./', page).href; + return { + version: 8, + name: 'Bigorre, papier et trait (prototype XL)', + glyphs: `${base}xl/glyphs/{fontstack}/{range}.pbf`, + sources: { + bigorre: { + type: 'vector', + url: `pmtiles://${base}${TUILES}`, + attribution: ATTRIBUTION, + }, + }, + layers: couches(), + }; +} diff --git a/xl/xl.css b/xl/xl.css new file mode 100644 index 0000000..6262ef6 --- /dev/null +++ b/xl/xl.css @@ -0,0 +1,48 @@ +/* Prototype XL : la page autour de la carte. Couleurs de maquette/style.css, recopiées. */ +:root { + --papier: #efeee2; --papier-2: #fffdf6; --encre: #102a3a; --encre-2: #3f5563; --trait: #ddd8c4; + --eau: #3a74a8; --vivant: #8f7b22; --vivant-encre: #62560f; --auj: #6b6458; --auj-encre: #4a443b; + --ombre: 0 10px 30px rgba(16, 42, 58, .14); +} +html, body { margin: 0; height: 100%; background: var(--papier); color: var(--encre); font-family: Barlow, system-ui, sans-serif; } +#xl { position: fixed; inset: 0; overflow: hidden; } +#carte { position: absolute; inset: 0; background: var(--papier); } +button { font: inherit; color: inherit; } + +.filtres { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 10px; display: flex; gap: 8px; z-index: 3; } +.filtre { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1.5px solid var(--encre-2); background: var(--papier-2); font-weight: 600; font-size: 15px; cursor: pointer; box-shadow: var(--ombre); } +.filtre[data-couche="existant"] { border-color: var(--auj-encre); } +.filtre[data-couche="propose"] { border-color: var(--vivant-encre); } +.filtre[aria-pressed="true"][data-couche="existant"] { background: var(--auj-encre); color: var(--papier-2); } +.filtre[aria-pressed="true"][data-couche="propose"] { background: var(--vivant-encre); color: var(--papier-2); } +.filtre:focus-visible, .epingle:focus-visible, .quartier:focus-visible, .fermer:focus-visible { outline: 3px solid var(--eau); outline-offset: 2px; } + +.etat { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); margin: 0; max-width: 300px; padding: 12px 16px; text-align: center; border-radius: 10px; background: var(--papier-2); color: var(--encre-2); box-shadow: var(--ombre); z-index: 2; font-size: 15px; } +.etat.erreur { color: var(--encre); border: 1.5px solid var(--auj-encre); } +.etat[hidden] { display: none; } + +/* Épingles : une cible de 40 px, un rond de 18 px dedans. */ +.epingle { width: 40px; height: 40px; padding: 0; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; } +.epingle[hidden] { display: none; } +.epingle > span { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--papier-2); box-shadow: 0 1px 4px rgba(16, 42, 58, .35); } +.epingle.c-existant > span { background: var(--auj-encre); } +.epingle.c-propose > span { background: var(--vivant-encre); } +.epingle.active > span { width: 24px; height: 24px; border-color: var(--encre); } + +.panneau { position: absolute; left: 8px; right: 8px; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 4; max-height: 40vh; overflow: auto; padding: 14px 44px 14px 16px; border-radius: 14px; background: var(--papier-2); box-shadow: var(--ombre); } +.panneau[hidden] { display: none; } +.panneau h2 { margin: 2px 0 6px; font-size: 18px; line-height: 1.2; } +.panneau p { margin: 0 0 6px; font-size: 15px; line-height: 1.35; } +.panneau .couche { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--encre-2); } +.panneau .statut { font-size: 13px; color: var(--encre-2); } +.panneau .lien a { color: var(--eau); font-weight: 600; } +.fermer { position: absolute; top: 4px; right: 4px; width: 40px; height: 40px; border: 0; background: transparent; font-size: 26px; line-height: 1; cursor: pointer; color: var(--encre-2); } + +.quartier { position: absolute; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 3; min-height: 44px; display: flex; align-items: center; padding: 0 20px; border-radius: 22px; background: var(--encre); color: var(--papier-2); font-weight: 600; font-size: 16px; text-decoration: none; box-shadow: var(--ombre); white-space: nowrap; } + +/* Attribution : lisible à 390 px, au-dessus du bouton du bas. */ +.maplibregl-ctrl-bottom-right { bottom: calc(60px + env(safe-area-inset-bottom)); } +.maplibregl-ctrl-attrib { background: rgba(255, 253, 246, .85) !important; font-size: 12px; } +.maplibregl-ctrl-attrib a { color: var(--encre-2); } +.maplibregl-ctrl-top-right { top: calc(56px + env(safe-area-inset-top)); } +body.sans-tuiles .filtres { opacity: .5; }