@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-polygon-data.d.ts","sourceRoot":"","sources":["../../src/hooks/use-polygon-data.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAKhF,8CAA8C;AAC9C,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,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;AAEF,UAAU,uBAAuB;IAC/B,mDAAmD;IACnD,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,6FAA6F;IAC7F,gBAAgB,EAAE,CAAC,UAAU,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,+CAA+C;IAC/C,WAAW,EAAE,OAAO,CAAC;IACrB,+CAA+C;IAC/C,OAAO,EAAE,OAAO,CAAC;IACjB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,0DAA0D;IAC1D,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAID,MAAM,WAAW,oBAAoB;IACnC,sDAAsD;IACtD,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,wBAAgB,eAAe,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,oBAAoB,2CAkEzE;AAED,wBAAgB,cAAc,IAAI,uBAAuB,CAMxD"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.PolygonProvider = PolygonProvider;
|
|
8
|
+
exports.usePolygonData = usePolygonData;
|
|
9
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
10
|
+
const react_1 = require("react");
|
|
11
|
+
const polygon_1 = require("../services/polygon");
|
|
12
|
+
const use_layers_1 = __importDefault(require("./use-layers"));
|
|
13
|
+
const PolygonDataContext = (0, react_1.createContext)(null);
|
|
14
|
+
function PolygonProvider({ shapes, children }) {
|
|
15
|
+
const { mp } = (0, use_layers_1.default)();
|
|
16
|
+
const [polygonData, setPolygonData] = (0, react_1.useState)(null);
|
|
17
|
+
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
18
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
19
|
+
const fetchPolygonData = (0, react_1.useCallback)(async (searchTerm) => {
|
|
20
|
+
const endpoint = mp?.nakshaApiEndpoint;
|
|
21
|
+
const hasFullUrl = mp?.polygonDataPath != null && mp.polygonDataPath.startsWith("http");
|
|
22
|
+
if (!endpoint && !hasFullUrl) {
|
|
23
|
+
setError("API endpoint not configured (set nakshaApiEndpoint or polygonDataPath)");
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (!shapes?.length) {
|
|
27
|
+
setError("Draw at least one polygon on the map first");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const url = mp?.polygonDataPath != null && mp.polygonDataPath !== ""
|
|
31
|
+
? mp.polygonDataPath.startsWith("http")
|
|
32
|
+
? mp.polygonDataPath
|
|
33
|
+
: `${(endpoint ?? "").replace(/\/$/, "")}${mp.polygonDataPath.startsWith("/") ? "" : "/"}${mp.polygonDataPath}`
|
|
34
|
+
: undefined;
|
|
35
|
+
setError(null);
|
|
36
|
+
setLoading(true);
|
|
37
|
+
try {
|
|
38
|
+
const result = await (0, polygon_1.axFetchDataByPolygon)({
|
|
39
|
+
endpoint: endpoint ?? "",
|
|
40
|
+
url,
|
|
41
|
+
token: mp?.nakshaEndpointToken ?? undefined,
|
|
42
|
+
features: shapes,
|
|
43
|
+
searchTerm,
|
|
44
|
+
});
|
|
45
|
+
if (result.success) {
|
|
46
|
+
setPolygonData(result.data);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
setError(result.error);
|
|
50
|
+
setPolygonData(null);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
setLoading(false);
|
|
55
|
+
}
|
|
56
|
+
}, [mp?.nakshaApiEndpoint, mp?.nakshaEndpointToken, shapes]);
|
|
57
|
+
const clearError = (0, react_1.useCallback)(() => setError(null), []);
|
|
58
|
+
const value = {
|
|
59
|
+
shapes: shapes ?? [],
|
|
60
|
+
fetchPolygonData,
|
|
61
|
+
polygonData,
|
|
62
|
+
loading,
|
|
63
|
+
error,
|
|
64
|
+
clearError,
|
|
65
|
+
};
|
|
66
|
+
return ((0, jsx_runtime_1.jsx)(PolygonDataContext.Provider, { value: value, children: children }));
|
|
67
|
+
}
|
|
68
|
+
function usePolygonData() {
|
|
69
|
+
const ctx = (0, react_1.useContext)(PolygonDataContext);
|
|
70
|
+
if (!ctx) {
|
|
71
|
+
throw new Error("usePolygonData must be used within PolygonProvider");
|
|
72
|
+
}
|
|
73
|
+
return ctx;
|
|
74
|
+
}
|