mapicgc-gl-js 1.0.8 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +141 -1
- package/dist-mcp/index.js +37167 -0
- package/mcp/content/CHANGELOG.md +15 -0
- package/mcp/content/README.md +294 -0
- package/mcp/content/config-snapshot.json +12 -0
- package/mcp/content/docu_Map.md +2111 -0
- package/mcp/content/examples/basemap-switcher.md +63 -0
- package/mcp/content/examples/canviar-estil.md +52 -0
- package/mcp/content/examples/capa-fgb.md +51 -0
- package/mcp/content/examples/capa-geojson.md +65 -0
- package/mcp/content/examples/capa-imatge-icgc.md +54 -0
- package/mcp/content/examples/capa-vectorial-icgc.md +57 -0
- package/mcp/content/examples/cerca-territorial.md +69 -0
- package/mcp/content/examples/comparador-mapes.md +58 -0
- package/mcp/content/examples/consulta-elements.md +67 -0
- package/mcp/content/examples/controls-mapa.md +65 -0
- package/mcp/content/examples/estil-relleu.md +75 -0
- package/mcp/content/examples/exportar-mapa.md +52 -0
- package/mcp/content/examples/geocodificador.md +46 -0
- package/mcp/content/examples/llistat-capes.md +61 -0
- package/mcp/content/examples/logo.md +49 -0
- package/mcp/content/examples/mapa-basic.md +60 -0
- package/mcp/content/examples/marcadors.md +60 -0
- package/mcp/content/examples/terreny-3d.md +53 -0
- package/nodeDeploy.js +7 -0
- package/package.json +15 -3
- package/test/exemples/addApiTerritorialICGC.html +2 -2
- package/test/vitest/MapFunctions.test.js +13 -11
- package/.editorconfig +0 -6
- package/.eslintrc +0 -26
- package/.github/workflows/npm-publish.yml +0 -34
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Exportar el mapa a imatge/PDF
|
|
2
|
+
|
|
3
|
+
mapicgc-gl-js no té una API de "mapa estàtic" pròpia (sense navegador), però
|
|
4
|
+
inclou `addExportControl`, un embolcall de `@watergis/maplibre-gl-export` que
|
|
5
|
+
permet a l'usuari exportar la vista actual del mapa a PNG/JPEG/PDF directament
|
|
6
|
+
des del navegador.
|
|
7
|
+
|
|
8
|
+
```html
|
|
9
|
+
<!DOCTYPE html>
|
|
10
|
+
<html>
|
|
11
|
+
<head>
|
|
12
|
+
<meta charset="utf-8" />
|
|
13
|
+
<link href="https://eines.icgc.cat/recursos//mapicgc-gl-js/mapicgc-gl.css" rel="stylesheet" />
|
|
14
|
+
<style>
|
|
15
|
+
body { margin: 0; padding: 0; }
|
|
16
|
+
#map { position: absolute; top: 0; bottom: 0; width: 100%; height: 100%; }
|
|
17
|
+
</style>
|
|
18
|
+
</head>
|
|
19
|
+
<body>
|
|
20
|
+
<div id="map"></div>
|
|
21
|
+
<script src="https://eines.icgc.cat/recursos//mapicgc-gl-js/mapicgc-gl.js"></script>
|
|
22
|
+
<script>
|
|
23
|
+
async function initMap() {
|
|
24
|
+
const data = await mapicgcgl.Config.getConfigICGC();
|
|
25
|
+
const map = new mapicgcgl.Map({
|
|
26
|
+
container: "map",
|
|
27
|
+
style: data.Styles.TOPO,
|
|
28
|
+
center: [2.1464, 41.306],
|
|
29
|
+
zoom: 7.4,
|
|
30
|
+
maxZoom: 19,
|
|
31
|
+
hash: true,
|
|
32
|
+
pitch: 0,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
map.on("load", () => {
|
|
36
|
+
map.addExportControl();
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
initMap();
|
|
40
|
+
</script>
|
|
41
|
+
</body>
|
|
42
|
+
</html>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Si necessites generar una imatge de mapa des del servidor (sense navegador),
|
|
46
|
+
hauràs de fer servir directament els serveis WMS de l'ICGC (`GetMap`) com els
|
|
47
|
+
que es troben a `data.Layers.WMS` o `data.Layers.Orto`, construint tu mateix la
|
|
48
|
+
URL amb els paràmetres `bbox`, `width`, `height`, etc.
|
|
49
|
+
|
|
50
|
+
Amb NPM: `import { Map, Config } from "mapicgc-gl-js";` i treu el prefix `mapicgcgl.`.
|
|
51
|
+
|
|
52
|
+
Font: test/exemples/addControl.html i src/map/Map.js (`addExportControl`).
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Geocodificador ICGC
|
|
2
|
+
|
|
3
|
+
`addGeocoderICGC(options, position)` afegeix un control de cerca d'adreces basat
|
|
4
|
+
en l'API Pelias de l'ICGC (`geocoder.peliasUrl1`/`peliasUrl2` de la configuració).
|
|
5
|
+
|
|
6
|
+
```html
|
|
7
|
+
<!DOCTYPE html>
|
|
8
|
+
<html>
|
|
9
|
+
<head>
|
|
10
|
+
<meta charset="utf-8" />
|
|
11
|
+
<link href="https://eines.icgc.cat/recursos//mapicgc-gl-js/mapicgc-gl.css" rel="stylesheet" />
|
|
12
|
+
<style>
|
|
13
|
+
body { margin: 0; padding: 0; }
|
|
14
|
+
#map { position: absolute; top: 0; bottom: 0; width: 100%; height: 100%; }
|
|
15
|
+
</style>
|
|
16
|
+
</head>
|
|
17
|
+
<body>
|
|
18
|
+
<div id="map"></div>
|
|
19
|
+
<script src="https://eines.icgc.cat/recursos//mapicgc-gl-js/mapicgc-gl.js"></script>
|
|
20
|
+
<script>
|
|
21
|
+
async function initMap() {
|
|
22
|
+
const data = await mapicgcgl.Config.getConfigICGC();
|
|
23
|
+
const map = new mapicgcgl.Map({
|
|
24
|
+
container: "map",
|
|
25
|
+
style: data.Styles.TOPO,
|
|
26
|
+
center: [1.8436, 41.5923],
|
|
27
|
+
zoom: 11,
|
|
28
|
+
maxZoom: 19,
|
|
29
|
+
hash: true,
|
|
30
|
+
pitch: 0,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
map.on("load", () => {
|
|
34
|
+
// 'options' es passa directament al control maplibre-gl-geocoder subjacent.
|
|
35
|
+
map.addGeocoderICGC({ zoom: 10 }, "top-right");
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
initMap();
|
|
39
|
+
</script>
|
|
40
|
+
</body>
|
|
41
|
+
</html>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Amb NPM: `import { Map, Config } from "mapicgc-gl-js";` i treu el prefix `mapicgcgl.`.
|
|
45
|
+
|
|
46
|
+
Font: test/exemples/addGeocoderICGC.html i Map.js (`addGeocoderICGC`).
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Llistat de capes amb casella de selecció (`addLayerTree`)
|
|
2
|
+
|
|
3
|
+
`addLayerTree(options)` crea un petit panell HTML amb una casella per capa,
|
|
4
|
+
agrupant els punts d'una col·lecció GeoJSON per la seva propietat `icon`.
|
|
5
|
+
|
|
6
|
+
```html
|
|
7
|
+
<!DOCTYPE html>
|
|
8
|
+
<html>
|
|
9
|
+
<head>
|
|
10
|
+
<meta charset="utf-8" />
|
|
11
|
+
<link href="https://eines.icgc.cat/recursos//mapicgc-gl-js/mapicgc-gl.css" rel="stylesheet" />
|
|
12
|
+
<style>
|
|
13
|
+
body { margin: 0; padding: 0; }
|
|
14
|
+
#map { position: absolute; top: 0; bottom: 0; width: 100%; height: 100%; }
|
|
15
|
+
</style>
|
|
16
|
+
</head>
|
|
17
|
+
<body>
|
|
18
|
+
<div id="map"></div>
|
|
19
|
+
<script src="https://eines.icgc.cat/recursos//mapicgc-gl-js/mapicgc-gl.js"></script>
|
|
20
|
+
<script>
|
|
21
|
+
async function initMap() {
|
|
22
|
+
const data = await mapicgcgl.Config.getConfigICGC();
|
|
23
|
+
const map = new mapicgcgl.Map({
|
|
24
|
+
container: "map",
|
|
25
|
+
style: data.Styles.TOPO,
|
|
26
|
+
center: [2.1464, 41.306],
|
|
27
|
+
zoom: 6.4,
|
|
28
|
+
maxZoom: 19,
|
|
29
|
+
hash: true,
|
|
30
|
+
pitch: 0,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const options = {
|
|
34
|
+
id: "testLayer",
|
|
35
|
+
type: "geojson",
|
|
36
|
+
features: {
|
|
37
|
+
type: "FeatureCollection",
|
|
38
|
+
features: [
|
|
39
|
+
{ type: "Feature", properties: { icon: "Rubí" }, geometry: { type: "Point", coordinates: [2.0119, 41.489] } },
|
|
40
|
+
{ type: "Feature", properties: { icon: "Moià" }, geometry: { type: "Point", coordinates: [2.119, 41.87] } },
|
|
41
|
+
{ type: "Feature", properties: { icon: "Berga" }, geometry: { type: "Point", coordinates: [1.83, 42.163] } },
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
map.on("load", () => {
|
|
47
|
+
map.addLayerTree(options);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
initMap();
|
|
51
|
+
</script>
|
|
52
|
+
</body>
|
|
53
|
+
</html>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Nota: `addLayerTree` crea el seu `<nav id="filter-group">` dins del contenidor
|
|
57
|
+
amb id `map`, així que cal que el DOM tingui un element `#map`.
|
|
58
|
+
|
|
59
|
+
Amb NPM: `import { Map, Config } from "mapicgc-gl-js";` i treu el prefix `mapicgcgl.`.
|
|
60
|
+
|
|
61
|
+
Font: test/exemples/addLayerTree.html i Map.js (`addLayerTree`).
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Afegir un logo al mapa
|
|
2
|
+
|
|
3
|
+
`addLogo(options)` afegeix una imatge enllaçada (logo) superposada al mapa.
|
|
4
|
+
|
|
5
|
+
```html
|
|
6
|
+
<!DOCTYPE html>
|
|
7
|
+
<html>
|
|
8
|
+
<head>
|
|
9
|
+
<meta charset="utf-8" />
|
|
10
|
+
<link href="https://eines.icgc.cat/recursos//mapicgc-gl-js/mapicgc-gl.css" rel="stylesheet" />
|
|
11
|
+
<style>
|
|
12
|
+
body { margin: 0; padding: 0; }
|
|
13
|
+
#map { position: absolute; top: 0; bottom: 0; width: 100%; height: 100%; }
|
|
14
|
+
</style>
|
|
15
|
+
</head>
|
|
16
|
+
<body>
|
|
17
|
+
<div id="map"></div>
|
|
18
|
+
<script src="https://eines.icgc.cat/recursos//mapicgc-gl-js/mapicgc-gl.js"></script>
|
|
19
|
+
<script>
|
|
20
|
+
async function initMap() {
|
|
21
|
+
const data = await mapicgcgl.Config.getConfigICGC();
|
|
22
|
+
const map = new mapicgcgl.Map({
|
|
23
|
+
container: "map",
|
|
24
|
+
style: data.Styles.TOPO,
|
|
25
|
+
center: [2.1464, 41.306],
|
|
26
|
+
zoom: 7.4,
|
|
27
|
+
maxZoom: 19,
|
|
28
|
+
hash: true,
|
|
29
|
+
pitch: 0,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
map.on("load", () => {
|
|
33
|
+
map.addLogo({
|
|
34
|
+
id: "icgcColorLogo",
|
|
35
|
+
url: "https://eines.icgc.cat/recursos/logos/icgc_logo_color.png",
|
|
36
|
+
href: "https://www.icgc.cat",
|
|
37
|
+
height: "80px",
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
initMap();
|
|
42
|
+
</script>
|
|
43
|
+
</body>
|
|
44
|
+
</html>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Amb NPM: `import { Map, Config } from "mapicgc-gl-js";` i treu el prefix `mapicgcgl.`.
|
|
48
|
+
|
|
49
|
+
Font: test/exemples/addLogo.html i Map.js (`addLogo`).
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Mapa bàsic amb mapicgc-gl-js
|
|
2
|
+
|
|
3
|
+
Exemple mínim per crear un mapa centrat a Catalunya amb un estil base de l'ICGC.
|
|
4
|
+
Cal carregar primer la configuració amb `Config.getConfigICGC()` per obtenir les
|
|
5
|
+
URLs d'estil reals (`data.Styles.<CLAU>`).
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<!DOCTYPE html>
|
|
9
|
+
<html>
|
|
10
|
+
<head>
|
|
11
|
+
<meta charset="utf-8" />
|
|
12
|
+
<link href="https://eines.icgc.cat/recursos//mapicgc-gl-js/mapicgc-gl.css" rel="stylesheet" />
|
|
13
|
+
<style>
|
|
14
|
+
body { margin: 0; padding: 0; }
|
|
15
|
+
#map { position: absolute; top: 0; bottom: 0; width: 100%; height: 100%; }
|
|
16
|
+
</style>
|
|
17
|
+
</head>
|
|
18
|
+
<body>
|
|
19
|
+
<div id="map"></div>
|
|
20
|
+
<script src="https://eines.icgc.cat/recursos//mapicgc-gl-js/mapicgc-gl.js"></script>
|
|
21
|
+
<script>
|
|
22
|
+
async function initMap() {
|
|
23
|
+
const data = await mapicgcgl.Config.getConfigICGC();
|
|
24
|
+
const map = new mapicgcgl.Map({
|
|
25
|
+
container: "map",
|
|
26
|
+
style: data.Styles.TOPO, // TOPO, ORTO, ORTO3D, ADMIN, DARK, LIGHT, GEOLOGY, ORTOHYBRID
|
|
27
|
+
center: [2.1464, 41.306],
|
|
28
|
+
zoom: 7.4,
|
|
29
|
+
maxZoom: 19,
|
|
30
|
+
hash: true,
|
|
31
|
+
pitch: 0,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
initMap();
|
|
35
|
+
</script>
|
|
36
|
+
</body>
|
|
37
|
+
</html>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Equivalent amb NPM i mòduls ES:
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
import { Map, Config } from "mapicgc-gl-js";
|
|
44
|
+
|
|
45
|
+
async function initMap() {
|
|
46
|
+
const data = await Config.getConfigICGC();
|
|
47
|
+
const map = new Map({
|
|
48
|
+
container: "map",
|
|
49
|
+
style: data.Styles.LIGHT,
|
|
50
|
+
center: [1.808, 41.618],
|
|
51
|
+
zoom: 10,
|
|
52
|
+
maxZoom: 19,
|
|
53
|
+
hash: true,
|
|
54
|
+
pitch: 0,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
initMap();
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Font: README.md i test/exemples/addMapStyle.html del repositori mapicgc-gl-js.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Marcadors i popups
|
|
2
|
+
|
|
3
|
+
`addMarker(options)` afegeix un `maplibregl.Marker` amb un popup opcional.
|
|
4
|
+
`addPopup(coord, text, popupStyle)` afegeix un popup independent amb un títol i,
|
|
5
|
+
opcionalment, una imatge.
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<!DOCTYPE html>
|
|
9
|
+
<html>
|
|
10
|
+
<head>
|
|
11
|
+
<meta charset="utf-8" />
|
|
12
|
+
<link href="https://eines.icgc.cat/recursos//mapicgc-gl-js/mapicgc-gl.css" rel="stylesheet" />
|
|
13
|
+
<style>
|
|
14
|
+
body { margin: 0; padding: 0; }
|
|
15
|
+
#map { position: absolute; top: 0; bottom: 0; width: 100%; height: 100%; }
|
|
16
|
+
</style>
|
|
17
|
+
</head>
|
|
18
|
+
<body>
|
|
19
|
+
<div id="map"></div>
|
|
20
|
+
<script src="https://eines.icgc.cat/recursos//mapicgc-gl-js/mapicgc-gl.js"></script>
|
|
21
|
+
<script>
|
|
22
|
+
async function initMap() {
|
|
23
|
+
const data = await mapicgcgl.Config.getConfigICGC();
|
|
24
|
+
const map = new mapicgcgl.Map({
|
|
25
|
+
container: "map",
|
|
26
|
+
style: data.Styles.TOPO,
|
|
27
|
+
center: [2.1464, 41.306],
|
|
28
|
+
zoom: 7.4,
|
|
29
|
+
maxZoom: 19,
|
|
30
|
+
hash: true,
|
|
31
|
+
pitch: 0,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const optionsMarker = {
|
|
35
|
+
coord: [2.119, 41.87],
|
|
36
|
+
text: "<h3>Hola Test</h3>",
|
|
37
|
+
textOffset: 25,
|
|
38
|
+
options: { color: "#D08288" },
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
map.on("load", () => {
|
|
42
|
+
map.addMarker(optionsMarker);
|
|
43
|
+
|
|
44
|
+
// Popup independent amb títol i imatge opcional.
|
|
45
|
+
map.addPopup(
|
|
46
|
+
[1.8436, 41.5923],
|
|
47
|
+
"Informació addicional sobre aquest punt.",
|
|
48
|
+
{ title: "Informació:", image: "https://eines.icgc.cat/recursos/logos/icgc_logo_color.png" }
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
initMap();
|
|
53
|
+
</script>
|
|
54
|
+
</body>
|
|
55
|
+
</html>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Amb NPM: `import { Map, Config } from "mapicgc-gl-js";` i treu el prefix `mapicgcgl.`.
|
|
59
|
+
|
|
60
|
+
Font: test/exemples/addMarker.html i Map.js (`addMarker`, `addPopup`).
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Terreny 3D (hillshade)
|
|
2
|
+
|
|
3
|
+
`addTerrainICGC(url, controlPosition)` carrega un terreny "raster-dem" i afegeix
|
|
4
|
+
(opcionalment) un botó per activar/desactivar la inclinació 3D. Les claus vàlides
|
|
5
|
+
per `url` són `data.Terrains.ICGC5M` (5m, només Catalunya) i `data.Terrains.WORLD30M`
|
|
6
|
+
(cobertura mundial, Mapterhorn).
|
|
7
|
+
|
|
8
|
+
```html
|
|
9
|
+
<!DOCTYPE html>
|
|
10
|
+
<html>
|
|
11
|
+
<head>
|
|
12
|
+
<meta charset="utf-8" />
|
|
13
|
+
<link href="https://eines.icgc.cat/recursos//mapicgc-gl-js/mapicgc-gl.css" rel="stylesheet" />
|
|
14
|
+
<style>
|
|
15
|
+
body { margin: 0; padding: 0; }
|
|
16
|
+
#map { position: absolute; top: 0; bottom: 0; width: 100%; height: 100%; background: linear-gradient(to bottom, #82addb 0%, #ebb2b1 100%); }
|
|
17
|
+
</style>
|
|
18
|
+
</head>
|
|
19
|
+
<body>
|
|
20
|
+
<div id="map"></div>
|
|
21
|
+
<script src="https://eines.icgc.cat/recursos//mapicgc-gl-js/mapicgc-gl.js"></script>
|
|
22
|
+
<script>
|
|
23
|
+
async function initMap() {
|
|
24
|
+
const data = await mapicgcgl.Config.getConfigICGC();
|
|
25
|
+
const map = new mapicgcgl.Map({
|
|
26
|
+
container: "map",
|
|
27
|
+
style: data.Styles.ORTO,
|
|
28
|
+
center: [0.959, 42.201],
|
|
29
|
+
zoom: 13,
|
|
30
|
+
maxZoom: 19,
|
|
31
|
+
hash: true,
|
|
32
|
+
pitch: 80,
|
|
33
|
+
bearing: 40,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const controlPosition = "bottom-right"; // posa null per no mostrar el botó
|
|
37
|
+
|
|
38
|
+
map.on("load", () => {
|
|
39
|
+
map.addTerrainICGC(data.Terrains.WORLD30M, controlPosition);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
initMap();
|
|
43
|
+
</script>
|
|
44
|
+
</body>
|
|
45
|
+
</html>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Per al terreny d'alta resolució (5 m) de Catalunya, fes servir
|
|
49
|
+
`data.Terrains.ICGC5M` en lloc de `WORLD30M`.
|
|
50
|
+
|
|
51
|
+
Amb NPM: `import { Map, Config } from "mapicgc-gl-js";` i treu el prefix `mapicgcgl.`.
|
|
52
|
+
|
|
53
|
+
Font: test/exemples/addICGCTerrain.html i Map.js (`addTerrainICGC`).
|
package/nodeDeploy.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
const SftpClient = require("ssh2-sftp-client");
|
|
2
2
|
const dotenv = require("dotenv");
|
|
3
3
|
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
4
5
|
|
|
5
6
|
dotenv.config();
|
|
6
7
|
|
|
7
8
|
const inFilePath = `${process.env.FTP_LOCA_PATH}${process.env.FILE_JS_UMD}`;
|
|
8
9
|
const renamedFilePath = `${process.env.FTP_LOCA_PATH}${process.env.FILE_JS}`;
|
|
10
|
+
// Fitxers com el worker de maplibre-gl es generen com a chunk separat i cal pujar-los també.
|
|
11
|
+
const assetsLocalPath = path.join(process.env.FTP_LOCA_PATH, 'assets');
|
|
12
|
+
const assetsRemotePath = `${process.env.FTP_REMOTE_PATH}assets/`;
|
|
9
13
|
|
|
10
14
|
function rename(){
|
|
11
15
|
fs.copyFile(inFilePath, renamedFilePath, (err) => {
|
|
@@ -45,6 +49,9 @@ async function deploy(hostFTP) {
|
|
|
45
49
|
overwrite: true,
|
|
46
50
|
}
|
|
47
51
|
);
|
|
52
|
+
if (fs.existsSync(assetsLocalPath)) {
|
|
53
|
+
await sftp.uploadDir(assetsLocalPath, assetsRemotePath);
|
|
54
|
+
}
|
|
48
55
|
console.log("Deploy OK");
|
|
49
56
|
} catch (err) {
|
|
50
57
|
console.error(`Deploy Error: ${err.message}`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mapicgc-gl-js",
|
|
3
3
|
"homepage": "https://openicgc.github.io/mapicgc-doc/",
|
|
4
|
-
"version": "1.0
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"description": "mapicgc-gl-js library",
|
|
6
6
|
"author": "Institut Cartogràfic i Geològic de Catalunya",
|
|
7
7
|
"license": "BSD-3-Clause",
|
|
@@ -33,6 +33,9 @@
|
|
|
33
33
|
"require": "./dist/mapicgc-gl.mjs"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
|
+
"bin": {
|
|
37
|
+
"mapicgc-mcp": "dist-mcp/index.js"
|
|
38
|
+
},
|
|
36
39
|
"overrides": {
|
|
37
40
|
"maplibre-gl": "^6.10.0"
|
|
38
41
|
},
|
|
@@ -44,14 +47,21 @@
|
|
|
44
47
|
"publish": "npm publish --access public --tag latest",
|
|
45
48
|
"setConfig": "node nodeSetConfig.js",
|
|
46
49
|
"publishBeta": "npm publish --tag beta --access public",
|
|
47
|
-
"test": "vitest"
|
|
50
|
+
"test": "vitest",
|
|
51
|
+
"build:content": "node mcp/scripts/sync.js",
|
|
52
|
+
"build:mcp": "node mcp/scripts/build-mcp.mjs",
|
|
53
|
+
"test:mcp": "vitest run mcp/test",
|
|
54
|
+
"prepublishOnly": "npm run build:content && npm run build:mcp && npm run build"
|
|
48
55
|
},
|
|
49
56
|
"devDependencies": {
|
|
50
57
|
"@babel/core": "^7.29.7",
|
|
51
58
|
"@babel/preset-env": "^7.29.2",
|
|
59
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
52
60
|
"@rollup/plugin-babel": "^7.1.0",
|
|
61
|
+
"@types/node": "^22.10.0",
|
|
53
62
|
"axios": "^1.20.0",
|
|
54
63
|
"dotenv": "^17.4.2",
|
|
64
|
+
"esbuild": "^0.28.2",
|
|
55
65
|
"jest": "30.5.1",
|
|
56
66
|
"jsdoc": "^4.0.5",
|
|
57
67
|
"jsdom": "^30.1.0",
|
|
@@ -60,10 +70,12 @@
|
|
|
60
70
|
"path": "^0.12.7",
|
|
61
71
|
"rollup-plugin-polyfill": "^4.2.0",
|
|
62
72
|
"ssh2-sftp-client": "^12.1.1",
|
|
73
|
+
"typescript": "^5.5.4",
|
|
63
74
|
"vite": "^8.3.0",
|
|
64
75
|
"vite-plugin-node-polyfills": "^0.2.0",
|
|
65
76
|
"vitest": "^5.0.1",
|
|
66
|
-
"xml2js": "^0.6.2"
|
|
77
|
+
"xml2js": "^0.6.2",
|
|
78
|
+
"zod": "^4.6.7"
|
|
67
79
|
},
|
|
68
80
|
"dependencies": {
|
|
69
81
|
"@deck.gl/core": "^9.4.0",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
IconButton: true,
|
|
61
61
|
|
|
62
62
|
// Icona del botó: text, SVG inline, URL d'imatge o objecte { src, alt }.
|
|
63
|
-
icon: mapPinIconSvg,
|
|
64
|
-
|
|
63
|
+
// icon: mapPinIconSvg,
|
|
64
|
+
icon: mapPinIconImage,
|
|
65
65
|
|
|
66
66
|
// Posició lliure dins del contenidor del mapa.
|
|
67
67
|
// (Si ho treus, usarà la posició MapLibre de l'argument "top-right").
|
|
@@ -38,6 +38,7 @@ const mockMapInstance = {
|
|
|
38
38
|
getSource: vi.fn(),
|
|
39
39
|
getSprite: vi.fn(() => []),
|
|
40
40
|
getStyle: vi.fn(() => ({ name: 'ICGC mapa base gris', id: 'icgc_mapa_base_gris' })),
|
|
41
|
+
getTerrain: vi.fn(() => null),
|
|
41
42
|
getZoom: vi.fn(() => 7.5),
|
|
42
43
|
hasControl: vi.fn(() => true),
|
|
43
44
|
hasImage: vi.fn(() => false),
|
|
@@ -104,18 +105,19 @@ vi.mock('maplibre-gl', () => {
|
|
|
104
105
|
this.setHTML = vi.fn().mockReturnValue(this);
|
|
105
106
|
this.addTo = vi.fn().mockReturnValue(this);
|
|
106
107
|
});
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
FullscreenControl: vi.fn(function (opts) { this._options = opts; this.type = 'FullscreenControl'; }),
|
|
117
|
-
},
|
|
108
|
+
const exports = {
|
|
109
|
+
Map: MapCtor,
|
|
110
|
+
Marker: MarkerCtor,
|
|
111
|
+
Popup: PopupCtor,
|
|
112
|
+
AttributionControl: vi.fn(function (opts) { this._options = opts; this.type = 'AttributionControl'; }),
|
|
113
|
+
NavigationControl: vi.fn(function (opts) { this._options = opts; this.type = 'NavigationControl'; }),
|
|
114
|
+
ScaleControl: vi.fn(function (opts) { this._options = opts; this.type = 'ScaleControl'; }),
|
|
115
|
+
GeolocateControl: vi.fn(function (opts) { this._options = opts; this.type = 'GeolocateControl'; }),
|
|
116
|
+
FullscreenControl: vi.fn(function (opts) { this._options = opts; this.type = 'FullscreenControl'; }),
|
|
118
117
|
};
|
|
118
|
+
// Exposed both as named exports (for `import * as maplibregl`, used by src/map/Map.js)
|
|
119
|
+
// and under `default` (for `import maplibregl from`, used by this test file).
|
|
120
|
+
return { ...exports, default: exports };
|
|
119
121
|
});
|
|
120
122
|
|
|
121
123
|
// ─── Mock other dependencies ─────────────────────────────────────────
|
package/.editorconfig
DELETED
package/.eslintrc
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": [
|
|
3
|
-
"@geostarters"
|
|
4
|
-
],
|
|
5
|
-
"parserOptions": {
|
|
6
|
-
"sourceType": "module"
|
|
7
|
-
},
|
|
8
|
-
"overrides": [
|
|
9
|
-
{
|
|
10
|
-
"files": [
|
|
11
|
-
"**/*.test.js"
|
|
12
|
-
],
|
|
13
|
-
"env": {
|
|
14
|
-
"jest": true
|
|
15
|
-
},
|
|
16
|
-
"plugins": ["jest"],
|
|
17
|
-
"rules": {
|
|
18
|
-
"jest/no-disabled-tests": "warn",
|
|
19
|
-
"jest/no-focused-tests": "error",
|
|
20
|
-
"jest/no-identical-title": "error",
|
|
21
|
-
"jest/prefer-to-have-length": "warn",
|
|
22
|
-
"jest/valid-expect": "error"
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
-
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
|
3
|
-
|
|
4
|
-
name: Node.js Package
|
|
5
|
-
|
|
6
|
-
on:
|
|
7
|
-
release:
|
|
8
|
-
types: [created]
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
build:
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
steps:
|
|
14
|
-
- uses: actions/checkout@v3
|
|
15
|
-
- uses: actions/setup-node@v3
|
|
16
|
-
with:
|
|
17
|
-
node-version: 20
|
|
18
|
-
- run: npm ci
|
|
19
|
-
- run: npm test
|
|
20
|
-
|
|
21
|
-
publish-npm:
|
|
22
|
-
needs: build
|
|
23
|
-
runs-on: ubuntu-latest
|
|
24
|
-
steps:
|
|
25
|
-
- uses: actions/checkout@v3
|
|
26
|
-
- uses: actions/setup-node@v3
|
|
27
|
-
with:
|
|
28
|
-
node-version: 20
|
|
29
|
-
registry-url: https://npm.pkg.github.com/
|
|
30
|
-
scope: '@unitatgeostart'
|
|
31
|
-
- run: npm ci
|
|
32
|
-
- run: npm publish
|
|
33
|
-
env:
|
|
34
|
-
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|