@metastringfoundation/map-list 0.1.1 → 0.1.2
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/dist/components/Handler/MapComparisonControl.d.ts +7 -0
- package/dist/components/Handler/MapComparisonControl.d.ts.map +1 -0
- package/dist/components/Handler/MapComparisonControl.js +8 -0
- package/dist/components/core/button.js +1 -1
- package/dist/components/core/input.d.ts.map +1 -1
- package/dist/components/core/input.js +1 -1
- package/dist/components/dualMap/MapLayerCard.d.ts +8 -0
- package/dist/components/dualMap/MapLayerCard.d.ts.map +1 -0
- package/dist/components/dualMap/MapLayerCard.js +68 -0
- package/dist/components/dualMap/index.d.ts +2 -1
- package/dist/components/dualMap/index.d.ts.map +1 -1
- package/dist/components/dualMap/index.js +219 -56
- package/dist/components/map/compare-sidebar.d.ts +2 -0
- package/dist/components/map/compare-sidebar.d.ts.map +1 -0
- package/dist/components/map/compare-sidebar.js +34 -0
- package/dist/components/map/compare.d.ts +2 -0
- package/dist/components/map/compare.d.ts.map +1 -0
- package/dist/components/map/compare.js +42 -0
- package/dist/components/map/index.d.ts.map +1 -1
- package/dist/components/map/index.js +14 -1
- package/dist/components/map/layers/grid/index.d.ts.map +1 -1
- package/dist/components/map/layers/grid/index.js +11 -1
- package/dist/components/map/layers/index.d.ts.map +1 -1
- package/dist/components/map/layers/index.js +0 -1
- package/dist/components/map/layers/raster/index.d.ts.map +1 -1
- package/dist/components/map/layers/raster/index.js +5 -3
- package/dist/components/map/layers/vector/index.d.ts.map +1 -1
- package/dist/components/map/layers/vector/index.js +25 -2
- package/dist/components/map/search.d.ts +2 -0
- package/dist/components/map/search.d.ts.map +1 -0
- package/dist/components/map/search.js +122 -0
- package/dist/components/map-comparison/attribute-selector.d.ts +11 -0
- package/dist/components/map-comparison/attribute-selector.d.ts.map +1 -0
- package/dist/components/map-comparison/attribute-selector.js +10 -0
- package/dist/components/map-comparison/comparison-panel.d.ts +2 -0
- package/dist/components/map-comparison/comparison-panel.d.ts.map +1 -0
- package/dist/components/map-comparison/comparison-panel.js +45 -0
- package/dist/components/map-comparison/comparison-stats.d.ts +2 -0
- package/dist/components/map-comparison/comparison-stats.d.ts.map +1 -0
- package/dist/components/map-comparison/comparison-stats.js +35 -0
- package/dist/components/map-comparison/comparison-view.d.ts +2 -0
- package/dist/components/map-comparison/comparison-view.d.ts.map +1 -0
- package/dist/components/map-comparison/comparison-view.js +152 -0
- package/dist/components/map-comparison/comparison-wrapper.d.ts +8 -0
- package/dist/components/map-comparison/comparison-wrapper.d.ts.map +1 -0
- package/dist/components/map-comparison/comparison-wrapper.js +26 -0
- package/dist/components/map-comparison/index.d.ts +3 -0
- package/dist/components/map-comparison/index.d.ts.map +1 -0
- package/dist/components/map-comparison/index.js +165 -0
- package/dist/components/map-comparison/types.d.ts +30 -0
- package/dist/components/map-comparison/types.d.ts.map +1 -0
- package/dist/components/map-comparison/types.js +2 -0
- package/dist/components/map-comparison/use-map-comparison.d.ts +18 -0
- package/dist/components/map-comparison/use-map-comparison.d.ts.map +1 -0
- package/dist/components/map-comparison/use-map-comparison.js +139 -0
- package/dist/components/sidebar/common/attribute-compare-addon.d.ts +7 -0
- package/dist/components/sidebar/common/attribute-compare-addon.d.ts.map +1 -0
- package/dist/components/sidebar/common/attribute-compare-addon.js +36 -0
- package/dist/components/sidebar/common/layer-item-style.d.ts.map +1 -1
- package/dist/components/sidebar/common/layer-item-style.js +46 -1
- package/dist/components/sidebar/common/layer-item.d.ts.map +1 -1
- package/dist/components/sidebar/common/layer-item.js +1 -2
- package/dist/components/sidebar/common/opacity-handler-addon.d.ts +5 -2
- package/dist/components/sidebar/common/opacity-handler-addon.d.ts.map +1 -1
- package/dist/components/sidebar/common/opacity-handler-addon.js +101 -4
- package/dist/components/sidebar/common/style-legend.d.ts.map +1 -1
- package/dist/components/sidebar/common/style-legend.js +1 -2
- package/dist/components/sidebar/comparison/index.d.ts +4 -0
- package/dist/components/sidebar/comparison/index.d.ts.map +1 -0
- package/dist/components/sidebar/comparison/index.js +34 -0
- package/dist/components/sidebar/search/attribute-comparison.d.ts +10 -0
- package/dist/components/sidebar/search/attribute-comparison.d.ts.map +1 -0
- package/dist/components/sidebar/search/attribute-comparison.js +137 -0
- package/dist/components/sidebar/search/index.d.ts +2 -0
- package/dist/components/sidebar/search/index.d.ts.map +1 -0
- package/dist/components/sidebar/search/index.js +29 -0
- package/dist/components/sidebar/selected/index.d.ts.map +1 -1
- package/dist/components/sidebar/selected/index.js +4 -1
- package/dist/components/sidebar/tabs.js +2 -2
- package/dist/hooks/use-layers.d.ts +8 -0
- package/dist/hooks/use-layers.d.ts.map +1 -1
- package/dist/hooks/use-layers.js +101 -1
- package/dist/hooks/use-polygon-data.d.ts +34 -0
- package/dist/hooks/use-polygon-data.d.ts.map +1 -0
- package/dist/hooks/use-polygon-data.js +74 -0
- package/dist/index.css +659 -30
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -36
- package/dist/services/naksha.d.ts.map +1 -1
- package/dist/services/naksha.js +16 -158
- package/dist/services/polygon.d.ts +36 -0
- package/dist/services/polygon.d.ts.map +1 -0
- package/dist/services/polygon.js +67 -0
- package/dist/utils/naksha.d.ts.map +1 -1
- package/dist/utils/naksha.js +4 -2
- package/package.json +16 -15
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAQrD,QAAA,MAAM,YAAY,GAAI,OAAO,qBAAqB,4CAejD,CAAC;AAwBF,eAAe,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,54 +1,27 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use strict";
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
-
var ownKeys = function(o) {
|
|
21
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
-
var ar = [];
|
|
23
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
-
return ar;
|
|
25
|
-
};
|
|
26
|
-
return ownKeys(o);
|
|
27
|
-
};
|
|
28
|
-
return function (mod) {
|
|
29
|
-
if (mod && mod.__esModule) return mod;
|
|
30
|
-
var result = {};
|
|
31
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
-
__setModuleDefault(result, mod);
|
|
33
|
-
return result;
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
5
|
};
|
|
39
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
41
|
-
const react_1 =
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
42
9
|
const maplibre_1 = require("react-map-gl/maplibre");
|
|
43
10
|
const map_1 = __importDefault(require("./components/map"));
|
|
44
11
|
const constants_1 = require("./static/constants");
|
|
45
12
|
const use_layers_1 = require("./hooks/use-layers");
|
|
13
|
+
const use_layers_2 = __importDefault(require("./hooks/use-layers"));
|
|
46
14
|
const dualMap_1 = __importDefault(require("./components/dualMap"));
|
|
47
15
|
const LayerCompareControl_1 = __importDefault(require("./components/Handler/LayerCompareControl"));
|
|
48
16
|
// setup({ preflight: false });
|
|
49
17
|
const MapListIndex = (props) => {
|
|
50
|
-
const [compareLayer, setCompareLayer] = (0, react_1.useState)(false);
|
|
51
18
|
const mp = react_1.default.useMemo(() => ({ ...constants_1.defaultNakshaProps, ...props }), [props]);
|
|
52
|
-
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(maplibre_1.MapProvider, { children: (0, jsx_runtime_1.
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(maplibre_1.MapProvider, { children: (0, jsx_runtime_1.jsx)(use_layers_1.LayersProvider, { mp: mp, children: (0, jsx_runtime_1.jsx)(MapListContent, {}) }) }) }));
|
|
20
|
+
};
|
|
21
|
+
const MapListContent = () => {
|
|
22
|
+
const { layer } = (0, use_layers_2.default)();
|
|
23
|
+
const isCompareMode = layer?.isCompareMode ?? false;
|
|
24
|
+
const setCompareMode = layer?.setCompareMode ?? (() => { });
|
|
25
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(LayerCompareControl_1.default, { compare: isCompareMode, setCompare: setCompareMode }), (0, jsx_runtime_1.jsx)("div", { hidden: isCompareMode, children: (0, jsx_runtime_1.jsx)(map_1.default, {}) }), (0, jsx_runtime_1.jsx)("div", { hidden: !isCompareMode, children: (0, jsx_runtime_1.jsx)(dualMap_1.default, {}) })] }));
|
|
53
26
|
};
|
|
54
27
|
exports.default = MapListIndex;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"naksha.d.ts","sourceRoot":"","sources":["../../src/services/naksha.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"naksha.d.ts","sourceRoot":"","sources":["../../src/services/naksha.ts"],"names":[],"mappings":"AAiDA,eAAO,MAAM,oBAAoB,GAC/B,qBAAqB,MAAM,GAAG,IAAI,GAAG,SAAS,EAC9C,mBAAmB,MAAM,EACzB,WAAW,GAAG,EACd,iBAAiB,MAAM,EAAE,GAAG,IAAI,KAC/B,OAAO,CAAC,GAAG,EAAE,CAqBf,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,4BAA4B,GACvC,IAAI,MAAM,GAAG,MAAM,EACnB,UAAU,MAAM,KACf,OAAO,CAAC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAA;CAAE,CAY3D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,4BAA4B,GACvC,UAAU,MAAM,EAChB,WAAW,MAAM,EACjB,QAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAC1B,OAAO,CAAC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,GAAG,EAAE,CAAA;CAAE,CAuBxE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAClC,qBAAqB,MAAM,GAAG,IAAI,GAAG,SAAS,EAC9C,mBAAmB,MAAM,EACzB,SAAS,MAAM,GAAG,MAAM,EACxB,UAAU,OAAO,KAChB,OAAO,CAAC,OAAO,CAsBjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,GACxB,qBAAqB,MAAM,GAAG,IAAI,GAAG,SAAS,EAC9C,mBAAmB,MAAM,EACzB,SAAS,MAAM,GAAG,MAAM,KACvB,OAAO,CAAC,OAAO,CAejB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,GACnC,WAAW,MAAM,EACjB,WAAW,MAAM,EACjB,WAAW,MAAM,EACjB,UAAU,MAAM,KACf,OAAO,CAAC,GAAG,CAgBb,CAAC;AAEF;;;;GAIG;AAEH,eAAO,MAAM,gBAAgB,GAC3B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,EACtD,QAAQ;IACN,GAAG,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAClC,GAAG,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;CACnC,EACD,MAAM,MAAM,EACZ,iBAAY,EACZ,oBAAsB,KACrB,OAAO,CAAC;IACT,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC;IACb,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB,CA0DA,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,MAAM,EAChB,OAAO,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,WAAW,MAAM,EACjB,YAAY,MAAM,KACjB,OAAO,CAAC,IAAI,CAsBd,CAAC"}
|
package/dist/services/naksha.js
CHANGED
|
@@ -54,168 +54,17 @@ const parseResponse = async (res) => {
|
|
|
54
54
|
return res.text();
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
|
-
/* --------------------------
|
|
58
|
-
API functions (converted)
|
|
59
|
-
-------------------------- */
|
|
60
|
-
/**
|
|
61
|
-
* axGetGeoserverLayers
|
|
62
|
-
* Returns parsed layers (same behavior as before).
|
|
63
|
-
*/
|
|
64
|
-
// export const axGetGeoserverLayers = async (
|
|
65
|
-
// nakshaEndpointToken: string | null | undefined,
|
|
66
|
-
// nakshaApiEndpoint: string,
|
|
67
|
-
// geoserver: any,
|
|
68
|
-
// selectedLayers?: string[] | null
|
|
69
|
-
// ): Promise<any[]> => {
|
|
70
|
-
// try {
|
|
71
|
-
// const headers: Record<string, string> = {};
|
|
72
|
-
// if (nakshaEndpointToken) headers.Authorization = nakshaEndpointToken;
|
|
73
|
-
// const res = await fetch(`${nakshaApiEndpoint}/layer/all`, { headers });
|
|
74
|
-
// if (!res.ok) {
|
|
75
|
-
// // keep consistent with previous behavior which would throw and fall into catch
|
|
76
|
-
// throw new Error(`HTTP ${res.status} ${res.statusText}`);
|
|
77
|
-
// }
|
|
78
|
-
// const data = await parseResponse(res);
|
|
79
|
-
// const finalLayers = await parseGeoserverLayersXml(
|
|
80
|
-
// data,
|
|
81
|
-
// nakshaApiEndpoint,
|
|
82
|
-
// geoserver,
|
|
83
|
-
// selectedLayers
|
|
84
|
-
// );
|
|
85
|
-
// return finalLayers;
|
|
86
|
-
// } catch (e) {
|
|
87
|
-
// console.error(e);
|
|
88
|
-
// return [];
|
|
89
|
-
// }
|
|
90
|
-
// ---------------------------
|
|
91
|
-
// Dummy formatter (updated for new API shape)
|
|
92
|
-
// ---------------------------
|
|
93
|
-
function stableHashInt(s) {
|
|
94
|
-
let h = 2166136261 >>> 0;
|
|
95
|
-
for (let i = 0; i < s.length; i++) {
|
|
96
|
-
h ^= s.charCodeAt(i);
|
|
97
|
-
h = Math.imul(h, 16777619) >>> 0;
|
|
98
|
-
}
|
|
99
|
-
return h & 0x7fffffff;
|
|
100
|
-
}
|
|
101
|
-
function prettifyTitle(s) {
|
|
102
|
-
return (s || "")
|
|
103
|
-
.replace(/[:_]/g, " ")
|
|
104
|
-
.replace(/\b\w/g, (c) => c.toUpperCase())
|
|
105
|
-
.trim();
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Normalize the server response into an array of raw entries.
|
|
109
|
-
* Supports:
|
|
110
|
-
* - old shape: { layers: { layer: [...] } }
|
|
111
|
-
* - new single object shape (like the example you pasted)
|
|
112
|
-
* - plain array of entries
|
|
113
|
-
*/
|
|
114
|
-
function extractRawEntries(layersResponse) {
|
|
115
|
-
if (!layersResponse)
|
|
116
|
-
return [];
|
|
117
|
-
// old: { layers: { layer: [...] } }
|
|
118
|
-
if (layersResponse.layers && Array.isArray(layersResponse.layers.layer)) {
|
|
119
|
-
return layersResponse.layers.layer;
|
|
120
|
-
}
|
|
121
|
-
// if it's an array, use it
|
|
122
|
-
if (Array.isArray(layersResponse))
|
|
123
|
-
return layersResponse;
|
|
124
|
-
// new: single object with fields like name, nameOfDataset, geoserverName, id, etc.
|
|
125
|
-
if (typeof layersResponse === "object") {
|
|
126
|
-
// If the object itself looks like a layer
|
|
127
|
-
if (layersResponse.name || layersResponse.nameOfDataset || layersResponse.geoserverName || layersResponse.id) {
|
|
128
|
-
return [layersResponse];
|
|
129
|
-
}
|
|
130
|
-
// if it's a container whose values are layer-like objects
|
|
131
|
-
const maybeArray = Object.values(layersResponse).filter(
|
|
132
|
-
// @ts-ignore
|
|
133
|
-
(v) => v && typeof v === "object" && (v.name || v.nameOfDataset || v.geoserverName || v.id));
|
|
134
|
-
if (maybeArray.length)
|
|
135
|
-
return maybeArray;
|
|
136
|
-
}
|
|
137
|
-
return [];
|
|
138
|
-
}
|
|
139
|
-
function createDummyLayers(layersResponse, geoserver, selectedLayers) {
|
|
140
|
-
const rawEntries = extractRawEntries(layersResponse);
|
|
141
|
-
// filter if selectedLayers provided (match by name, nameOfDataset or id)
|
|
142
|
-
const filtered = selectedLayers && selectedLayers.length > 0
|
|
143
|
-
? rawEntries.filter((entry) => {
|
|
144
|
-
const rawName = entry.name || entry.nameOfDataset || entry.geoserverName;
|
|
145
|
-
return selectedLayers.includes(rawName) || selectedLayers.includes(entry.id);
|
|
146
|
-
})
|
|
147
|
-
: rawEntries;
|
|
148
|
-
return filtered.map((entry, idx) => {
|
|
149
|
-
// determine canonical rawName
|
|
150
|
-
const rawName = entry.name || entry.geoserverName || entry.nameOfDataset || `layer_${idx}`;
|
|
151
|
-
// workspace and layerName parsing from rawName (workspace:layer)
|
|
152
|
-
const [workspace = (geoserver?.workspace || "default"), layerName] = String(rawName).includes(":") ? String(rawName).split(":") : [geoserver?.workspace || "default", String(rawName)];
|
|
153
|
-
// prefer API id if present, else create stable hash
|
|
154
|
-
const id = entry.id;
|
|
155
|
-
// Dummy bbox (keeps UI layout stable)
|
|
156
|
-
const bbox = [
|
|
157
|
-
[75 + idx * 0.01, 23 + idx * 0.01],
|
|
158
|
-
[75.3 + idx * 0.01, 23.4 + idx * 0.01],
|
|
159
|
-
];
|
|
160
|
-
// choose thumbnail: prefer wms_link from API if available
|
|
161
|
-
const gsBase = (geoserver?.endpoint || "").replace(/\/$/, "");
|
|
162
|
-
const thumbnail = entry.wms_link
|
|
163
|
-
? entry.wms_link
|
|
164
|
-
: `${gsBase}/thumbnails/${workspace}/${layerName}?layers=${encodeURIComponent(layerName)}&bbox=${bbox
|
|
165
|
-
.flat()
|
|
166
|
-
.join(",")}&request=GetMap&service=WMS&version=1.1.0&format=image/gif`;
|
|
167
|
-
// const layerType = (entry.dataType || entry.layerType || "Vector").toUpperCase();
|
|
168
|
-
const layerType = ("vector").toUpperCase();
|
|
169
|
-
const titleCandidate = entry.nameOfDataset || layerName || entry.title || entry.geoserverName;
|
|
170
|
-
const title = prettifyTitle(String(titleCandidate || rawName));
|
|
171
|
-
return {
|
|
172
|
-
// UI fields (kept similar to your original shape)
|
|
173
|
-
layerType,
|
|
174
|
-
thumbnail,
|
|
175
|
-
author: entry.contactPerson || null,
|
|
176
|
-
bbox,
|
|
177
|
-
description: entry.purposeOfCreatingData || entry.description || `Layer ${title}`,
|
|
178
|
-
title,
|
|
179
|
-
pdfLink: entry.pdfLink || "",
|
|
180
|
-
pageId: null,
|
|
181
|
-
downloadAccess: entry.downloadAccess || "ALL",
|
|
182
|
-
url: entry.wms_link || entry.href || entry._originalHref || "",
|
|
183
|
-
tags: Array.isArray(entry.keywords) ? entry.keywords : (entry.tags || ["Dummy", "Test", layerName]),
|
|
184
|
-
license: entry.license || "BY-NC-ND",
|
|
185
|
-
createdDate: entry.createdOn ? new Date(entry.createdOn).getTime() : Date.now() - idx * 86400000,
|
|
186
|
-
uploaderUserId: entry.uploaderUserId || entry.contactEmail || "1",
|
|
187
|
-
isDownloadable: Boolean(entry.isDownloadable ?? true),
|
|
188
|
-
layerStatus: entry.layerStatus || "Active",
|
|
189
|
-
createdBy: entry.organization || entry.createdBy || "Unknown",
|
|
190
|
-
portalId: entry.portalId || "1",
|
|
191
|
-
name: entry.nameOfDataset || layerName,
|
|
192
|
-
attribution: workspace,
|
|
193
|
-
modifiedDate: entry.updatedOn || entry.modifiedDate || null,
|
|
194
|
-
modifiedBy: entry.modifiedBy || null,
|
|
195
|
-
// canonical ids + raw meta for debugging
|
|
196
|
-
id,
|
|
197
|
-
geoserverName: entry.geoserverName || rawName,
|
|
198
|
-
_originalHref: entry.href || entry._originalHref || null,
|
|
199
|
-
_rawName: rawName,
|
|
200
|
-
_rawEntry: entry,
|
|
201
|
-
};
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
// ---------------------------
|
|
205
|
-
// Inject INTO your real function
|
|
206
|
-
// ---------------------------
|
|
207
57
|
const axGetGeoserverLayers = async (nakshaEndpointToken, nakshaApiEndpoint, geoserver, selectedLayers) => {
|
|
208
58
|
try {
|
|
209
59
|
const headers = {};
|
|
210
60
|
if (nakshaEndpointToken)
|
|
211
61
|
headers.Authorization = nakshaEndpointToken;
|
|
212
|
-
const res = await fetch(`${nakshaApiEndpoint}/
|
|
62
|
+
const res = await fetch(`${nakshaApiEndpoint}/layers1`, { headers });
|
|
213
63
|
if (!res.ok)
|
|
214
64
|
throw new Error(`HTTP ${res.status} ${res.statusText}`);
|
|
215
|
-
|
|
216
|
-
const
|
|
217
|
-
const
|
|
218
|
-
const finalLayers = await (0, naksha_1.parseGeoserverLayersXml)(finalTransformedLayers, nakshaApiEndpoint, geoserver, selectedLayers);
|
|
65
|
+
const data = await res.json();
|
|
66
|
+
const finalLayersData = data.layers;
|
|
67
|
+
const finalLayers = await (0, naksha_1.parseGeoserverLayersXml)(finalLayersData, nakshaApiEndpoint, geoserver, selectedLayers);
|
|
219
68
|
return finalLayers;
|
|
220
69
|
}
|
|
221
70
|
catch (e) {
|
|
@@ -279,7 +128,9 @@ exports.axGexGetRasterInfoWithLonLat = axGexGetRasterInfoWithLonLat;
|
|
|
279
128
|
*/
|
|
280
129
|
const axToggleLayerPublishing = async (nakshaEndpointToken, nakshaApiEndpoint, layerId, isActive) => {
|
|
281
130
|
try {
|
|
282
|
-
const headers = {
|
|
131
|
+
const headers = {
|
|
132
|
+
"Content-Type": "application/json",
|
|
133
|
+
};
|
|
283
134
|
if (nakshaEndpointToken)
|
|
284
135
|
headers.Authorization = nakshaEndpointToken;
|
|
285
136
|
const res = await fetch(`${nakshaApiEndpoint}/layer/${isActive ? "active" : "pending"}/${layerId}`, {
|
|
@@ -408,13 +259,20 @@ exports.getGridLayerData = getGridLayerData;
|
|
|
408
259
|
*/
|
|
409
260
|
const axDownloadLayer = async (endpoint, token, layerName, layerTitle) => {
|
|
410
261
|
try {
|
|
411
|
-
const headers = {
|
|
262
|
+
const headers = {
|
|
263
|
+
"Content-Type": "application/json",
|
|
264
|
+
};
|
|
412
265
|
if (token)
|
|
413
266
|
headers.Authorization = token;
|
|
414
267
|
const res = await fetch(`${endpoint}/layer/download`, {
|
|
415
268
|
method: "POST",
|
|
416
269
|
headers,
|
|
417
|
-
body: JSON.stringify({
|
|
270
|
+
body: JSON.stringify({
|
|
271
|
+
layerName,
|
|
272
|
+
layerTitle,
|
|
273
|
+
attributeList: [],
|
|
274
|
+
filterArray: [],
|
|
275
|
+
}),
|
|
418
276
|
});
|
|
419
277
|
if (!res.ok)
|
|
420
278
|
throw new Error(`HTTP ${res.status}`);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Polygon data API – fetch data from backend by drawn polygon(s).
|
|
3
|
+
* Follows the same structure as services/naksha.ts (fetch, headers, parseResponse).
|
|
4
|
+
*/
|
|
5
|
+
type GeoJSONFeature = {
|
|
6
|
+
type: "Feature";
|
|
7
|
+
geometry: {
|
|
8
|
+
type: string;
|
|
9
|
+
coordinates: unknown;
|
|
10
|
+
};
|
|
11
|
+
properties?: Record<string, unknown>;
|
|
12
|
+
};
|
|
13
|
+
export type FetchDataByPolygonParams = {
|
|
14
|
+
endpoint: string;
|
|
15
|
+
/** Full URL override (e.g. from mp.polygonDataPath when it is a full URL) */
|
|
16
|
+
url?: string;
|
|
17
|
+
token?: string | null;
|
|
18
|
+
/** GeoJSON Feature[] from map-draw (polygons) */
|
|
19
|
+
features: GeoJSONFeature[];
|
|
20
|
+
/** Optional search term from the Search tab */
|
|
21
|
+
searchTerm?: string;
|
|
22
|
+
};
|
|
23
|
+
export type FetchDataByPolygonResult = {
|
|
24
|
+
success: true;
|
|
25
|
+
data: unknown;
|
|
26
|
+
} | {
|
|
27
|
+
success: false;
|
|
28
|
+
error: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* POST drawn polygon(s) to backend and return data within the polygon.
|
|
32
|
+
* Body: { geometry: GeoJSON Geometry or FeatureCollection, searchTerm?: string }
|
|
33
|
+
*/
|
|
34
|
+
export declare const axFetchDataByPolygon: ({ endpoint, url: urlOverride, token, features, searchTerm, }: FetchDataByPolygonParams) => Promise<FetchDataByPolygonResult>;
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=polygon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polygon.d.ts","sourceRoot":"","sources":["../../src/services/polygon.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,OAAO,CAAA;KAAE,CAAC;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC,CAAC;AAcF,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,6EAA6E;IAC7E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,iDAAiD;IACjD,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAChC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAChC;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtC;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAU,8DAMxC,wBAAwB,KAAG,OAAO,CAAC,wBAAwB,CA+C7D,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Polygon data API – fetch data from backend by drawn polygon(s).
|
|
4
|
+
* Follows the same structure as services/naksha.ts (fetch, headers, parseResponse).
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.axFetchDataByPolygon = void 0;
|
|
8
|
+
const parseResponse = async (res) => {
|
|
9
|
+
const ct = (res.headers.get("content-type") || "").toLowerCase();
|
|
10
|
+
if (ct.includes("application/json") || ct.includes("text/json")) {
|
|
11
|
+
return res.json();
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
return await res.json();
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return res.text();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* POST drawn polygon(s) to backend and return data within the polygon.
|
|
22
|
+
* Body: { geometry: GeoJSON Geometry or FeatureCollection, searchTerm?: string }
|
|
23
|
+
*/
|
|
24
|
+
const axFetchDataByPolygon = async ({ endpoint, url: urlOverride, token, features, searchTerm, }) => {
|
|
25
|
+
try {
|
|
26
|
+
const headers = {
|
|
27
|
+
"Content-Type": "application/json",
|
|
28
|
+
};
|
|
29
|
+
if (token)
|
|
30
|
+
headers.Authorization = token;
|
|
31
|
+
// Build body: use first polygon geometry, or FeatureCollection of all
|
|
32
|
+
const geometry = features.length === 0
|
|
33
|
+
? null
|
|
34
|
+
: features.length === 1
|
|
35
|
+
? features[0].geometry
|
|
36
|
+
: {
|
|
37
|
+
type: "GeometryCollection",
|
|
38
|
+
geometries: features.map((f) => f.geometry),
|
|
39
|
+
};
|
|
40
|
+
const body = { geometry };
|
|
41
|
+
if (searchTerm != null && searchTerm.trim() !== "") {
|
|
42
|
+
body.searchTerm = searchTerm.trim();
|
|
43
|
+
}
|
|
44
|
+
const url = urlOverride != null && urlOverride !== ""
|
|
45
|
+
? urlOverride
|
|
46
|
+
: endpoint.endsWith("/")
|
|
47
|
+
? `${endpoint}data/polygon`
|
|
48
|
+
: `${endpoint}/data/polygon`;
|
|
49
|
+
const res = await fetch(url, {
|
|
50
|
+
method: "POST",
|
|
51
|
+
headers,
|
|
52
|
+
body: JSON.stringify(body),
|
|
53
|
+
});
|
|
54
|
+
if (!res.ok) {
|
|
55
|
+
const text = await res.text().catch(() => "");
|
|
56
|
+
throw new Error(`HTTP ${res.status} ${res.statusText}${text ? `: ${text}` : ""}`);
|
|
57
|
+
}
|
|
58
|
+
const data = await parseResponse(res);
|
|
59
|
+
return { success: true, data };
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
63
|
+
console.error("axFetchDataByPolygon error:", e);
|
|
64
|
+
return { success: false, error: message };
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
exports.axFetchDataByPolygon = axFetchDataByPolygon;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"naksha.d.ts","sourceRoot":"","sources":["../../src/utils/naksha.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,GAClC,QAAQ,GAAG,EACX,mBAAmB,MAAM,EACzB,WAAW;IAAE,QAAQ,CAAC,EAAE,GAAG,CAAC;IAAC,SAAS,EAAE,GAAG,CAAA;CAAE,EAC7C,gBAAgB,GAAG,
|
|
1
|
+
{"version":3,"file":"naksha.d.ts","sourceRoot":"","sources":["../../src/utils/naksha.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,GAClC,QAAQ,GAAG,EACX,mBAAmB,MAAM,EACzB,WAAW;IAAE,QAAQ,CAAC,EAAE,GAAG,CAAC;IAAC,SAAS,EAAE,GAAG,CAAA;CAAE,EAC7C,gBAAgB,GAAG,mBAsDpB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GACxB,OAAO;IAAE,IAAI,EAAE,GAAG,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,EAChC,YAAY,MAAM,EAClB,mBAAmB,MAAM,EACzB,WAAW;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,iBAuGjC,CAAC"}
|
package/dist/utils/naksha.js
CHANGED
|
@@ -26,13 +26,14 @@ const parseGeoserverLayersXml = async (layers, nakshaApiEndpoint, geoserver, sel
|
|
|
26
26
|
: "vector";
|
|
27
27
|
const _l = {
|
|
28
28
|
...l,
|
|
29
|
-
id: l.
|
|
29
|
+
id: l.name,
|
|
30
30
|
thumbnail,
|
|
31
31
|
source: {
|
|
32
32
|
type: sourceType,
|
|
33
33
|
scheme: "tms",
|
|
34
34
|
tiles: [
|
|
35
35
|
`${geoserver.endpoint.replace(/\/$/, "")}/gwc/service/tms/1.0.0/${encodeURIComponent(`${geoserver.workspace}:${l.name}`)}@EPSG:3857@pbf/{z}/{x}/{y}.pbf`,
|
|
36
|
+
// `${geoserver.endpoint.replace(/\/$/, "")}/gwc/service/tms/1.0.0/${encodeURIComponent(`metastring:${l.name}`)}@EPSG:3857@pbf/{z}/{x}/{y}.pbf`,
|
|
36
37
|
],
|
|
37
38
|
},
|
|
38
39
|
data: { styles: [] },
|
|
@@ -78,8 +79,9 @@ const getLayerStyle = async (layer, styleIndex, nakshaApiEndpoint, geoserver) =>
|
|
|
78
79
|
: { styles: [] };
|
|
79
80
|
// 1) If styles list is empty, fetch style list and metadata
|
|
80
81
|
if (!Array.isArray(data.styles) || data.styles.length === 0) {
|
|
82
|
+
const layerIdWithWorkspace = `${geoserver.workspace}:${layer.id}`;
|
|
81
83
|
try {
|
|
82
|
-
const result = await (0, naksha_1.axGetGeoserverLayerStyleList)(
|
|
84
|
+
const result = await (0, naksha_1.axGetGeoserverLayerStyleList)(layerIdWithWorkspace, nakshaApiEndpoint);
|
|
83
85
|
if (result && result.success && result.data) {
|
|
84
86
|
const d = result.data;
|
|
85
87
|
data = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metastringfoundation/map-list",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"**/*.css"
|
|
6
6
|
],
|
|
@@ -17,24 +17,33 @@
|
|
|
17
17
|
"./styles.css": "./dist/index.css"
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build:styles": "tailwindcss -i ./src/styles.css -o ./dist/index.css",
|
|
22
|
+
"build:components": "tsc",
|
|
23
|
+
"check-types": "tsc --noEmit",
|
|
24
|
+
"dev:styles": "tailwindcss -i ./src/styles.css -o ./dist/index.css --watch",
|
|
25
|
+
"dev:components": "tsc --watch",
|
|
26
|
+
"lint": "eslint src --max-warnings 0"
|
|
27
|
+
},
|
|
20
28
|
"peerDependencies": {
|
|
21
29
|
"react": "^19"
|
|
22
30
|
},
|
|
23
31
|
"devDependencies": {
|
|
32
|
+
"@repo/eslint-config": "workspace:*",
|
|
33
|
+
"@repo/tailwind-config": "workspace:*",
|
|
34
|
+
"@repo/typescript-config": "workspace:*",
|
|
24
35
|
"@tailwindcss/cli": "^4.1.5",
|
|
25
36
|
"@types/react": "^19.1.0",
|
|
26
37
|
"eslint": "^9.39.1",
|
|
27
38
|
"tailwindcss": "^4.1.5",
|
|
28
|
-
"typescript": "5.9.2"
|
|
29
|
-
"@repo/eslint-config": "0.0.0",
|
|
30
|
-
"@repo/tailwind-config": "0.0.0",
|
|
31
|
-
"@repo/typescript-config": "0.0.0"
|
|
39
|
+
"typescript": "5.9.2"
|
|
32
40
|
},
|
|
33
41
|
"dependencies": {
|
|
34
42
|
"@dnd-kit/core": "^6.3.1",
|
|
35
43
|
"@dnd-kit/modifiers": "^9.0.0",
|
|
36
44
|
"@dnd-kit/sortable": "^10.0.0",
|
|
37
45
|
"@dnd-kit/utilities": "^3.2.2",
|
|
46
|
+
"@metastringfoundation/map-common": "workspace:*",
|
|
38
47
|
"@tanstack/react-virtual": "^3.13.12",
|
|
39
48
|
"boundingbox": "^1.4.0",
|
|
40
49
|
"colorbrewer": "^1.6.1",
|
|
@@ -44,14 +53,6 @@
|
|
|
44
53
|
"react-tiny-popover": "^8.1.6",
|
|
45
54
|
"react-virtualized-auto-sizer": "^1.0.26",
|
|
46
55
|
"react-web-share": "^2.0.2",
|
|
47
|
-
"@metastringfoundation/map-
|
|
48
|
-
},
|
|
49
|
-
"scripts": {
|
|
50
|
-
"build:styles": "tailwindcss -i ./src/styles.css -o ./dist/index.css",
|
|
51
|
-
"build:components": "tsc",
|
|
52
|
-
"check-types": "tsc --noEmit",
|
|
53
|
-
"dev:styles": "tailwindcss -i ./src/styles.css -o ./dist/index.css --watch",
|
|
54
|
-
"dev:components": "tsc --watch",
|
|
55
|
-
"lint": "eslint src --max-warnings 0"
|
|
56
|
+
"@metastringfoundation/map-draw": "workspace:*"
|
|
56
57
|
}
|
|
57
|
-
}
|
|
58
|
+
}
|