@metastringfoundation/map-list 0.1.0 → 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/LayerCompareControl.d.ts +7 -0
- package/dist/components/Handler/LayerCompareControl.d.ts.map +1 -0
- package/dist/components/Handler/LayerCompareControl.js +18 -0
- 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 +3 -0
- package/dist/components/dualMap/index.d.ts.map +1 -0
- package/dist/components/dualMap/index.js +277 -0
- 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 +17 -14
- package/dist/components/map/layers/raster/index.d.ts.map +1 -1
- package/dist/components/map/layers/raster/index.js +8 -8
- package/dist/components/map/layers/vector/index.d.ts.map +1 -1
- package/dist/components/map/layers/vector/index.js +25 -1
- 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/split-map/SplitMapComparision.d.ts +2 -0
- package/dist/components/map/split-map/SplitMapComparision.d.ts.map +1 -0
- package/dist/components/map/split-map/SplitMapComparision.js +78 -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-compare-addon.d.ts +4 -0
- package/dist/components/sidebar/common/layer-compare-addon.d.ts.map +1 -0
- package/dist/components/sidebar/common/layer-compare-addon.js +17 -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 -1
- 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/index.d.ts.map +1 -1
- 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 +7 -4
- package/dist/components/sidebar/tabs.js +2 -2
- package/dist/hooks/use-layers.d.ts +10 -0
- package/dist/hooks/use-layers.d.ts.map +1 -1
- package/dist/hooks/use-layers.js +115 -5
- 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 +708 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/services/naksha.d.ts.map +1 -1
- package/dist/services/naksha.js +22 -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 +15 -6
- 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
|
@@ -10,9 +10,18 @@ const maplibre_1 = require("react-map-gl/maplibre");
|
|
|
10
10
|
const map_1 = __importDefault(require("./components/map"));
|
|
11
11
|
const constants_1 = require("./static/constants");
|
|
12
12
|
const use_layers_1 = require("./hooks/use-layers");
|
|
13
|
+
const use_layers_2 = __importDefault(require("./hooks/use-layers"));
|
|
14
|
+
const dualMap_1 = __importDefault(require("./components/dualMap"));
|
|
15
|
+
const LayerCompareControl_1 = __importDefault(require("./components/Handler/LayerCompareControl"));
|
|
13
16
|
// setup({ preflight: false });
|
|
14
17
|
const MapListIndex = (props) => {
|
|
15
18
|
const mp = react_1.default.useMemo(() => ({ ...constants_1.defaultNakshaProps, ...props }), [props]);
|
|
16
|
-
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)(
|
|
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, {}) })] }));
|
|
17
26
|
};
|
|
18
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
|
@@ -7,6 +7,7 @@ exports.axDownloadLayer = exports.getGridLayerData = exports.axGetGeoserverLayer
|
|
|
7
7
|
// api.ts
|
|
8
8
|
const colorbrewer_1 = __importDefault(require("colorbrewer"));
|
|
9
9
|
const grid_1 = require("../utils/grid");
|
|
10
|
+
const naksha_1 = require("../utils/naksha");
|
|
10
11
|
/**
|
|
11
12
|
* Inline-typed alias for colorbrewer palettes to avoid TS errors.
|
|
12
13
|
* colorbrewer exports an object of shape: Record<schemeName, Record<count, string[]>>
|
|
@@ -53,166 +54,17 @@ const parseResponse = async (res) => {
|
|
|
53
54
|
return res.text();
|
|
54
55
|
}
|
|
55
56
|
};
|
|
56
|
-
/* --------------------------
|
|
57
|
-
API functions (converted)
|
|
58
|
-
-------------------------- */
|
|
59
|
-
/**
|
|
60
|
-
* axGetGeoserverLayers
|
|
61
|
-
* Returns parsed layers (same behavior as before).
|
|
62
|
-
*/
|
|
63
|
-
// export const axGetGeoserverLayers = async (
|
|
64
|
-
// nakshaEndpointToken: string | null | undefined,
|
|
65
|
-
// nakshaApiEndpoint: string,
|
|
66
|
-
// geoserver: any,
|
|
67
|
-
// selectedLayers?: string[] | null
|
|
68
|
-
// ): Promise<any[]> => {
|
|
69
|
-
// try {
|
|
70
|
-
// const headers: Record<string, string> = {};
|
|
71
|
-
// if (nakshaEndpointToken) headers.Authorization = nakshaEndpointToken;
|
|
72
|
-
// const res = await fetch(`${nakshaApiEndpoint}/layer/all`, { headers });
|
|
73
|
-
// if (!res.ok) {
|
|
74
|
-
// // keep consistent with previous behavior which would throw and fall into catch
|
|
75
|
-
// throw new Error(`HTTP ${res.status} ${res.statusText}`);
|
|
76
|
-
// }
|
|
77
|
-
// const data = await parseResponse(res);
|
|
78
|
-
// const finalLayers = await parseGeoserverLayersXml(
|
|
79
|
-
// data,
|
|
80
|
-
// nakshaApiEndpoint,
|
|
81
|
-
// geoserver,
|
|
82
|
-
// selectedLayers
|
|
83
|
-
// );
|
|
84
|
-
// return finalLayers;
|
|
85
|
-
// } catch (e) {
|
|
86
|
-
// console.error(e);
|
|
87
|
-
// return [];
|
|
88
|
-
// }
|
|
89
|
-
// ---------------------------
|
|
90
|
-
// Dummy formatter (updated for new API shape)
|
|
91
|
-
// ---------------------------
|
|
92
|
-
function stableHashInt(s) {
|
|
93
|
-
let h = 2166136261 >>> 0;
|
|
94
|
-
for (let i = 0; i < s.length; i++) {
|
|
95
|
-
h ^= s.charCodeAt(i);
|
|
96
|
-
h = Math.imul(h, 16777619) >>> 0;
|
|
97
|
-
}
|
|
98
|
-
return h & 0x7fffffff;
|
|
99
|
-
}
|
|
100
|
-
function prettifyTitle(s) {
|
|
101
|
-
return (s || "")
|
|
102
|
-
.replace(/[:_]/g, " ")
|
|
103
|
-
.replace(/\b\w/g, (c) => c.toUpperCase())
|
|
104
|
-
.trim();
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Normalize the server response into an array of raw entries.
|
|
108
|
-
* Supports:
|
|
109
|
-
* - old shape: { layers: { layer: [...] } }
|
|
110
|
-
* - new single object shape (like the example you pasted)
|
|
111
|
-
* - plain array of entries
|
|
112
|
-
*/
|
|
113
|
-
function extractRawEntries(layersResponse) {
|
|
114
|
-
if (!layersResponse)
|
|
115
|
-
return [];
|
|
116
|
-
// old: { layers: { layer: [...] } }
|
|
117
|
-
if (layersResponse.layers && Array.isArray(layersResponse.layers.layer)) {
|
|
118
|
-
return layersResponse.layers.layer;
|
|
119
|
-
}
|
|
120
|
-
// if it's an array, use it
|
|
121
|
-
if (Array.isArray(layersResponse))
|
|
122
|
-
return layersResponse;
|
|
123
|
-
// new: single object with fields like name, nameOfDataset, geoserverName, id, etc.
|
|
124
|
-
if (typeof layersResponse === "object") {
|
|
125
|
-
// If the object itself looks like a layer
|
|
126
|
-
if (layersResponse.name || layersResponse.nameOfDataset || layersResponse.geoserverName || layersResponse.id) {
|
|
127
|
-
return [layersResponse];
|
|
128
|
-
}
|
|
129
|
-
// if it's a container whose values are layer-like objects
|
|
130
|
-
const maybeArray = Object.values(layersResponse).filter(
|
|
131
|
-
// @ts-ignore
|
|
132
|
-
(v) => v && typeof v === "object" && (v.name || v.nameOfDataset || v.geoserverName || v.id));
|
|
133
|
-
if (maybeArray.length)
|
|
134
|
-
return maybeArray;
|
|
135
|
-
}
|
|
136
|
-
return [];
|
|
137
|
-
}
|
|
138
|
-
function createDummyLayers(layersResponse, geoserver, selectedLayers) {
|
|
139
|
-
const rawEntries = extractRawEntries(layersResponse);
|
|
140
|
-
// filter if selectedLayers provided (match by name, nameOfDataset or id)
|
|
141
|
-
const filtered = selectedLayers && selectedLayers.length > 0
|
|
142
|
-
? rawEntries.filter((entry) => {
|
|
143
|
-
const rawName = entry.name || entry.nameOfDataset || entry.geoserverName;
|
|
144
|
-
return selectedLayers.includes(rawName) || selectedLayers.includes(entry.id);
|
|
145
|
-
})
|
|
146
|
-
: rawEntries;
|
|
147
|
-
return filtered.map((entry, idx) => {
|
|
148
|
-
// determine canonical rawName
|
|
149
|
-
const rawName = entry.name || entry.geoserverName || entry.nameOfDataset || `layer_${idx}`;
|
|
150
|
-
// workspace and layerName parsing from rawName (workspace:layer)
|
|
151
|
-
const [workspace = (geoserver?.workspace || "default"), layerName] = String(rawName).includes(":") ? String(rawName).split(":") : [geoserver?.workspace || "default", String(rawName)];
|
|
152
|
-
// prefer API id if present, else create stable hash
|
|
153
|
-
const id = entry.id || stableHashInt(String(rawName));
|
|
154
|
-
// Dummy bbox (keeps UI layout stable)
|
|
155
|
-
const bbox = [
|
|
156
|
-
[75 + idx * 0.01, 23 + idx * 0.01],
|
|
157
|
-
[75.3 + idx * 0.01, 23.4 + idx * 0.01],
|
|
158
|
-
];
|
|
159
|
-
// choose thumbnail: prefer wms_link from API if available
|
|
160
|
-
const gsBase = (geoserver?.endpoint || "").replace(/\/$/, "");
|
|
161
|
-
const thumbnail = entry.wms_link
|
|
162
|
-
? entry.wms_link
|
|
163
|
-
: `${gsBase}/thumbnails/${workspace}/${layerName}?layers=${encodeURIComponent(layerName)}&bbox=${bbox
|
|
164
|
-
.flat()
|
|
165
|
-
.join(",")}&request=GetMap&service=WMS&version=1.1.0&format=image/gif`;
|
|
166
|
-
const layerType = (entry.dataType || entry.layerType || "Vector").toUpperCase();
|
|
167
|
-
const titleCandidate = entry.nameOfDataset || layerName || entry.title || entry.geoserverName;
|
|
168
|
-
const title = prettifyTitle(String(titleCandidate || rawName));
|
|
169
|
-
return {
|
|
170
|
-
// UI fields (kept similar to your original shape)
|
|
171
|
-
layerType,
|
|
172
|
-
thumbnail,
|
|
173
|
-
author: entry.contactPerson || null,
|
|
174
|
-
bbox,
|
|
175
|
-
description: entry.purposeOfCreatingData || entry.description || `Layer ${title}`,
|
|
176
|
-
title,
|
|
177
|
-
pdfLink: entry.pdfLink || "",
|
|
178
|
-
pageId: null,
|
|
179
|
-
downloadAccess: entry.downloadAccess || "ALL",
|
|
180
|
-
url: entry.wms_link || entry.href || entry._originalHref || "",
|
|
181
|
-
tags: Array.isArray(entry.keywords) ? entry.keywords : (entry.tags || ["Dummy", "Test", layerName]),
|
|
182
|
-
license: entry.license || "BY-NC-ND",
|
|
183
|
-
createdDate: entry.createdOn ? new Date(entry.createdOn).getTime() : Date.now() - idx * 86400000,
|
|
184
|
-
uploaderUserId: entry.uploaderUserId || entry.contactEmail || "1",
|
|
185
|
-
isDownloadable: Boolean(entry.isDownloadable ?? true),
|
|
186
|
-
layerStatus: entry.layerStatus || "Active",
|
|
187
|
-
createdBy: entry.organization || entry.createdBy || "Unknown",
|
|
188
|
-
portalId: entry.portalId || "1",
|
|
189
|
-
name: entry.nameOfDataset || layerName,
|
|
190
|
-
attribution: workspace,
|
|
191
|
-
modifiedDate: entry.updatedOn || entry.modifiedDate || null,
|
|
192
|
-
modifiedBy: entry.modifiedBy || null,
|
|
193
|
-
// canonical ids + raw meta for debugging
|
|
194
|
-
id,
|
|
195
|
-
geoserverName: entry.geoserverName || rawName,
|
|
196
|
-
_originalHref: entry.href || entry._originalHref || null,
|
|
197
|
-
_rawName: rawName,
|
|
198
|
-
_rawEntry: entry,
|
|
199
|
-
};
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
// ---------------------------
|
|
203
|
-
// Inject INTO your real function
|
|
204
|
-
// ---------------------------
|
|
205
57
|
const axGetGeoserverLayers = async (nakshaEndpointToken, nakshaApiEndpoint, geoserver, selectedLayers) => {
|
|
206
58
|
try {
|
|
207
59
|
const headers = {};
|
|
208
60
|
if (nakshaEndpointToken)
|
|
209
61
|
headers.Authorization = nakshaEndpointToken;
|
|
210
|
-
const res = await fetch(`${nakshaApiEndpoint}/
|
|
62
|
+
const res = await fetch(`${nakshaApiEndpoint}/layers1`, { headers });
|
|
211
63
|
if (!res.ok)
|
|
212
64
|
throw new Error(`HTTP ${res.status} ${res.statusText}`);
|
|
213
|
-
|
|
214
|
-
const
|
|
215
|
-
const finalLayers =
|
|
65
|
+
const data = await res.json();
|
|
66
|
+
const finalLayersData = data.layers;
|
|
67
|
+
const finalLayers = await (0, naksha_1.parseGeoserverLayersXml)(finalLayersData, nakshaApiEndpoint, geoserver, selectedLayers);
|
|
216
68
|
return finalLayers;
|
|
217
69
|
}
|
|
218
70
|
catch (e) {
|
|
@@ -227,7 +79,8 @@ exports.axGetGeoserverLayers = axGetGeoserverLayers;
|
|
|
227
79
|
*/
|
|
228
80
|
const axGetGeoserverLayerStyleList = async (id, endpoint) => {
|
|
229
81
|
try {
|
|
230
|
-
const res = await fetch(`${endpoint}/layer
|
|
82
|
+
const res = await fetch(`${endpoint}/styles/by-layer/${id}`);
|
|
83
|
+
// const res = await fetch(`${endpoint}/layer/onClick/${id}`);
|
|
231
84
|
if (!res.ok)
|
|
232
85
|
throw new Error(`HTTP ${res.status}`);
|
|
233
86
|
const data = await parseResponse(res);
|
|
@@ -275,7 +128,9 @@ exports.axGexGetRasterInfoWithLonLat = axGexGetRasterInfoWithLonLat;
|
|
|
275
128
|
*/
|
|
276
129
|
const axToggleLayerPublishing = async (nakshaEndpointToken, nakshaApiEndpoint, layerId, isActive) => {
|
|
277
130
|
try {
|
|
278
|
-
const headers = {
|
|
131
|
+
const headers = {
|
|
132
|
+
"Content-Type": "application/json",
|
|
133
|
+
};
|
|
279
134
|
if (nakshaEndpointToken)
|
|
280
135
|
headers.Authorization = nakshaEndpointToken;
|
|
281
136
|
const res = await fetch(`${nakshaApiEndpoint}/layer/${isActive ? "active" : "pending"}/${layerId}`, {
|
|
@@ -321,7 +176,9 @@ exports.axDeleteLayer = axDeleteLayer;
|
|
|
321
176
|
*/
|
|
322
177
|
const axGetGeoserverLayerStyle = async (layername, workspace, styleName, endpoint) => {
|
|
323
178
|
try {
|
|
324
|
-
const res = await fetch(
|
|
179
|
+
const res = await fetch(
|
|
180
|
+
// `${endpoint}/geoserver/workspaces/${workspace}/styles/${layername}_${styleName}.mbstyle`
|
|
181
|
+
`${endpoint}/styles/legend/${styleName}`);
|
|
325
182
|
if (!res.ok)
|
|
326
183
|
throw new Error(`HTTP ${res.status}`);
|
|
327
184
|
// .mbstyle may be JSON; attempt parse safely
|
|
@@ -402,13 +259,20 @@ exports.getGridLayerData = getGridLayerData;
|
|
|
402
259
|
*/
|
|
403
260
|
const axDownloadLayer = async (endpoint, token, layerName, layerTitle) => {
|
|
404
261
|
try {
|
|
405
|
-
const headers = {
|
|
262
|
+
const headers = {
|
|
263
|
+
"Content-Type": "application/json",
|
|
264
|
+
};
|
|
406
265
|
if (token)
|
|
407
266
|
headers.Authorization = token;
|
|
408
267
|
const res = await fetch(`${endpoint}/layer/download`, {
|
|
409
268
|
method: "POST",
|
|
410
269
|
headers,
|
|
411
|
-
body: JSON.stringify({
|
|
270
|
+
body: JSON.stringify({
|
|
271
|
+
layerName,
|
|
272
|
+
layerTitle,
|
|
273
|
+
attributeList: [],
|
|
274
|
+
filterArray: [],
|
|
275
|
+
}),
|
|
412
276
|
});
|
|
413
277
|
if (!res.ok)
|
|
414
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,
|
|
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
|
@@ -32,7 +32,8 @@ const parseGeoserverLayersXml = async (layers, nakshaApiEndpoint, geoserver, sel
|
|
|
32
32
|
type: sourceType,
|
|
33
33
|
scheme: "tms",
|
|
34
34
|
tiles: [
|
|
35
|
-
`${geoserver.endpoint.replace(/\/$/, "")}/gwc/service/tms/1.0.0/${encodeURIComponent(`${geoserver.workspace}:${l.name}`)}@EPSG
|
|
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: [] },
|
|
@@ -71,13 +72,16 @@ exports.parseGeoserverLayersXml = parseGeoserverLayersXml;
|
|
|
71
72
|
* @returns {Promise<any>} updated data object
|
|
72
73
|
*/
|
|
73
74
|
const getLayerStyle = async (layer, styleIndex, nakshaApiEndpoint, geoserver) => {
|
|
74
|
-
console.log("getLayerStyle", layer, styleIndex, nakshaApiEndpoint, geoserver)
|
|
75
|
+
// console.log("getLayerStyle", layer , styleIndex , nakshaApiEndpoint , geoserver)
|
|
75
76
|
// Start from existing data (defensive)
|
|
76
|
-
let data = layer.data && typeof layer.data === "object"
|
|
77
|
+
let data = layer.data && typeof layer.data === "object"
|
|
78
|
+
? { ...layer.data }
|
|
79
|
+
: { styles: [] };
|
|
77
80
|
// 1) If styles list is empty, fetch style list and metadata
|
|
78
81
|
if (!Array.isArray(data.styles) || data.styles.length === 0) {
|
|
82
|
+
const layerIdWithWorkspace = `${geoserver.workspace}:${layer.id}`;
|
|
79
83
|
try {
|
|
80
|
-
const result = await (0, naksha_1.axGetGeoserverLayerStyleList)(
|
|
84
|
+
const result = await (0, naksha_1.axGetGeoserverLayerStyleList)(layerIdWithWorkspace, nakshaApiEndpoint);
|
|
81
85
|
if (result && result.success && result.data) {
|
|
82
86
|
const d = result.data;
|
|
83
87
|
data = {
|
|
@@ -89,7 +93,10 @@ const getLayerStyle = async (layer, styleIndex, nakshaApiEndpoint, geoserver) =>
|
|
|
89
93
|
};
|
|
90
94
|
// build propertyMap safely
|
|
91
95
|
try {
|
|
92
|
-
data.propertyMap = Object.fromEntries((data.styles || []).map((o) => [
|
|
96
|
+
data.propertyMap = Object.fromEntries((data.styles || []).map((o) => [
|
|
97
|
+
o.styleName,
|
|
98
|
+
o.styleTitle,
|
|
99
|
+
]));
|
|
93
100
|
}
|
|
94
101
|
catch {
|
|
95
102
|
data.propertyMap = data.propertyMap ?? {};
|
|
@@ -117,7 +124,9 @@ const getLayerStyle = async (layer, styleIndex, nakshaApiEndpoint, geoserver) =>
|
|
|
117
124
|
}
|
|
118
125
|
if (needsColors || !styleExists) {
|
|
119
126
|
// determine styleName to fetch colors for; prefer newly-fetched styles metadata if present
|
|
120
|
-
const styleName = (data.styles &&
|
|
127
|
+
const styleName = (data.styles &&
|
|
128
|
+
data.styles[styleIndex] &&
|
|
129
|
+
data.styles[styleIndex].styleName) ||
|
|
121
130
|
null;
|
|
122
131
|
if (styleName) {
|
|
123
132
|
try {
|
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
|
+
}
|