@metastringfoundation/map-list 0.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/dist/card.d.ts +7 -0
- package/dist/card.d.ts.map +1 -0
- package/dist/card.js +7 -0
- package/dist/components/core/button.d.ts +7 -0
- package/dist/components/core/button.d.ts.map +1 -0
- package/dist/components/core/button.js +21 -0
- package/dist/components/core/highlighter.d.ts +5 -0
- package/dist/components/core/highlighter.d.ts.map +1 -0
- package/dist/components/core/highlighter.js +15 -0
- package/dist/components/core/icons.d.ts +17 -0
- package/dist/components/core/icons.d.ts.map +1 -0
- package/dist/components/core/icons.js +60 -0
- package/dist/components/core/iconts.d.ts +2 -0
- package/dist/components/core/iconts.d.ts.map +1 -0
- package/dist/components/core/iconts.js +2 -0
- package/dist/components/core/index.d.ts +5 -0
- package/dist/components/core/index.d.ts.map +1 -0
- package/dist/components/core/index.js +20 -0
- package/dist/components/core/input.d.ts +14 -0
- package/dist/components/core/input.d.ts.map +1 -0
- package/dist/components/core/input.js +18 -0
- package/dist/components/core/popup.d.ts +5 -0
- package/dist/components/core/popup.d.ts.map +1 -0
- package/dist/components/core/popup.js +11 -0
- package/dist/components/core/tabs.d.ts +46 -0
- package/dist/components/core/tabs.d.ts.map +1 -0
- package/dist/components/core/tabs.js +147 -0
- package/dist/components/infobar/content.d.ts +4 -0
- package/dist/components/infobar/content.d.ts.map +1 -0
- package/dist/components/infobar/content.js +22 -0
- package/dist/components/infobar/index.d.ts +2 -0
- package/dist/components/infobar/index.d.ts.map +1 -0
- package/dist/components/infobar/index.js +17 -0
- package/dist/components/infobar/infobar-panel.d.ts +4 -0
- package/dist/components/infobar/infobar-panel.d.ts.map +1 -0
- package/dist/components/infobar/infobar-panel.js +52 -0
- package/dist/components/map/index.d.ts +2 -0
- package/dist/components/map/index.d.ts.map +1 -0
- package/dist/components/map/index.js +66 -0
- package/dist/components/map/layers/grid/index.d.ts +6 -0
- package/dist/components/map/layers/grid/index.d.ts.map +1 -0
- package/dist/components/map/layers/grid/index.js +31 -0
- package/dist/components/map/layers/highlight/index.d.ts +2 -0
- package/dist/components/map/layers/highlight/index.d.ts.map +1 -0
- package/dist/components/map/layers/highlight/index.js +7 -0
- package/dist/components/map/layers/index.d.ts +6 -0
- package/dist/components/map/layers/index.d.ts.map +1 -0
- package/dist/components/map/layers/index.js +27 -0
- package/dist/components/map/layers/raster/index.d.ts +6 -0
- package/dist/components/map/layers/raster/index.d.ts.map +1 -0
- package/dist/components/map/layers/raster/index.js +19 -0
- package/dist/components/map/layers/vector/index.d.ts +5 -0
- package/dist/components/map/layers/vector/index.d.ts.map +1 -0
- package/dist/components/map/layers/vector/index.js +29 -0
- package/dist/components/map/marker-list/index.d.ts +3 -0
- package/dist/components/map/marker-list/index.d.ts.map +1 -0
- package/dist/components/map/marker-list/index.js +16 -0
- package/dist/components/map/markers-list/index.d.ts +3 -0
- package/dist/components/map/markers-list/index.d.ts.map +1 -0
- package/dist/components/map/markers-list/index.js +16 -0
- package/dist/components/map/popup/index.d.ts +4 -0
- package/dist/components/map/popup/index.d.ts.map +1 -0
- package/dist/components/map/popup/index.js +17 -0
- package/dist/components/sidebar/common/grid-legend.d.ts +4 -0
- package/dist/components/sidebar/common/grid-legend.d.ts.map +1 -0
- package/dist/components/sidebar/common/grid-legend.js +22 -0
- package/dist/components/sidebar/common/info-popover.d.ts +10 -0
- package/dist/components/sidebar/common/info-popover.d.ts.map +1 -0
- package/dist/components/sidebar/common/info-popover.js +32 -0
- package/dist/components/sidebar/common/layer-item-style.d.ts +4 -0
- package/dist/components/sidebar/common/layer-item-style.d.ts.map +1 -0
- package/dist/components/sidebar/common/layer-item-style.js +21 -0
- package/dist/components/sidebar/common/layer-item.d.ts +11 -0
- package/dist/components/sidebar/common/layer-item.d.ts.map +1 -0
- package/dist/components/sidebar/common/layer-item.js +59 -0
- package/dist/components/sidebar/common/moreless.d.ts +4 -0
- package/dist/components/sidebar/common/moreless.d.ts.map +1 -0
- package/dist/components/sidebar/common/moreless.js +10 -0
- package/dist/components/sidebar/common/opacity-handler-addon.d.ts +3 -0
- package/dist/components/sidebar/common/opacity-handler-addon.d.ts.map +1 -0
- package/dist/components/sidebar/common/opacity-handler-addon.js +9 -0
- package/dist/components/sidebar/common/style-legend.d.ts +4 -0
- package/dist/components/sidebar/common/style-legend.d.ts.map +1 -0
- package/dist/components/sidebar/common/style-legend.js +23 -0
- package/dist/components/sidebar/common.d.ts +2 -0
- package/dist/components/sidebar/common.d.ts.map +1 -0
- package/dist/components/sidebar/common.js +2 -0
- package/dist/components/sidebar/index.d.ts +2 -0
- package/dist/components/sidebar/index.d.ts.map +1 -0
- package/dist/components/sidebar/index.js +38 -0
- package/dist/components/sidebar/layers/index.d.ts +2 -0
- package/dist/components/sidebar/layers/index.d.ts.map +1 -0
- package/dist/components/sidebar/layers/index.js +12 -0
- package/dist/components/sidebar/layers/layer-list.d.ts +2 -0
- package/dist/components/sidebar/layers/layer-list.d.ts.map +1 -0
- package/dist/components/sidebar/layers/layer-list.js +64 -0
- package/dist/components/sidebar/layers/search.d.ts +2 -0
- package/dist/components/sidebar/layers/search.d.ts.map +1 -0
- package/dist/components/sidebar/layers/search.js +16 -0
- package/dist/components/sidebar/layers.d.ts +2 -0
- package/dist/components/sidebar/layers.d.ts.map +1 -0
- package/dist/components/sidebar/layers.js +2 -0
- package/dist/components/sidebar/selected/extended.d.ts +3 -0
- package/dist/components/sidebar/selected/extended.d.ts.map +1 -0
- package/dist/components/sidebar/selected/extended.js +7 -0
- package/dist/components/sidebar/selected/index.d.ts +2 -0
- package/dist/components/sidebar/selected/index.d.ts.map +1 -0
- package/dist/components/sidebar/selected/index.js +20 -0
- package/dist/components/sidebar/selected/selected-item-list.d.ts +10 -0
- package/dist/components/sidebar/selected/selected-item-list.d.ts.map +1 -0
- package/dist/components/sidebar/selected/selected-item-list.js +36 -0
- package/dist/components/sidebar/settings/index.d.ts +2 -0
- package/dist/components/sidebar/settings/index.d.ts.map +1 -0
- package/dist/components/sidebar/settings/index.js +16 -0
- package/dist/components/sidebar/settings/layer-selection.d.ts +6 -0
- package/dist/components/sidebar/settings/layer-selection.d.ts.map +1 -0
- package/dist/components/sidebar/settings/layer-selection.js +17 -0
- package/dist/components/sidebar/tabs.d.ts +4 -0
- package/dist/components/sidebar/tabs.d.ts.map +1 -0
- package/dist/components/sidebar/tabs.js +15 -0
- package/dist/gradient.d.ts +6 -0
- package/dist/gradient.d.ts.map +1 -0
- package/dist/gradient.js +9 -0
- package/dist/hooks/use-layers.d.ts +55 -0
- package/dist/hooks/use-layers.d.ts.map +1 -0
- package/dist/hooks/use-layers.js +298 -0
- package/dist/index.css +1129 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/interfaces/index.d.ts +103 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +2 -0
- package/dist/services/naksha.d.ts +62 -0
- package/dist/services/naksha.d.ts.map +1 -0
- package/dist/services/naksha.js +420 -0
- package/dist/static/constant.d.ts +16 -0
- package/dist/static/constant.d.ts.map +1 -0
- package/dist/static/constant.js +34 -0
- package/dist/static/constants.d.ts +16 -0
- package/dist/static/constants.d.ts.map +1 -0
- package/dist/static/constants.js +34 -0
- package/dist/test.d.ts +2 -0
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +9 -0
- package/dist/turborepo-logo.d.ts +2 -0
- package/dist/turborepo-logo.d.ts.map +1 -0
- package/dist/turborepo-logo.js +8 -0
- package/dist/utils/array-move.d.ts +3 -0
- package/dist/utils/array-move.d.ts.map +1 -0
- package/dist/utils/array-move.js +19 -0
- package/dist/utils/grid.d.ts +22 -0
- package/dist/utils/grid.d.ts.map +1 -0
- package/dist/utils/grid.js +116 -0
- package/dist/utils/naksha.d.ts +32 -0
- package/dist/utils/naksha.d.ts.map +1 -0
- package/dist/utils/naksha.js +141 -0
- package/package.json +57 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAKrD,QAAA,MAAM,YAAY,GAAI,OAAO,qBAAqB,4CAejD,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const maplibre_1 = require("react-map-gl/maplibre");
|
|
10
|
+
const map_1 = __importDefault(require("./components/map"));
|
|
11
|
+
const constants_1 = require("./static/constants");
|
|
12
|
+
const use_layers_1 = require("./hooks/use-layers");
|
|
13
|
+
// setup({ preflight: false });
|
|
14
|
+
const MapListIndex = (props) => {
|
|
15
|
+
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)(map_1.default, {}) }) }) }));
|
|
17
|
+
};
|
|
18
|
+
exports.default = MapListIndex;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { ViewState } from "react-map-gl/maplibre";
|
|
2
|
+
import { MapStyles } from "@metastringfoundation/map-common";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
type LayerType = "grid" | "vector" | "raster";
|
|
5
|
+
export interface ExtendedMarkerProps {
|
|
6
|
+
latitude: number;
|
|
7
|
+
longitude: number;
|
|
8
|
+
colorHex: string;
|
|
9
|
+
}
|
|
10
|
+
export interface NakshaMapboxListProps {
|
|
11
|
+
defaultViewState?: Partial<ViewState>;
|
|
12
|
+
loadToC?: boolean;
|
|
13
|
+
showToC?: boolean;
|
|
14
|
+
managePublishing?: boolean;
|
|
15
|
+
nakshaEndpointToken?: string;
|
|
16
|
+
mapboxAccessToken?: string;
|
|
17
|
+
nakshaApiEndpoint?: string;
|
|
18
|
+
bearerToken?: string;
|
|
19
|
+
geoserver?: {
|
|
20
|
+
endpoint: string;
|
|
21
|
+
store: string;
|
|
22
|
+
workspace: string;
|
|
23
|
+
onClick?: any;
|
|
24
|
+
};
|
|
25
|
+
selectedLayers?: string[];
|
|
26
|
+
onSelectedLayersChange?: (layers: string[]) => void;
|
|
27
|
+
mapStyle?: MapStyles;
|
|
28
|
+
layers?: GeoserverLayer[];
|
|
29
|
+
onLayerDownload?: (layer: GeoserverLayer) => void;
|
|
30
|
+
canLayerShare?: boolean;
|
|
31
|
+
lang?: string;
|
|
32
|
+
markers?: ExtendedMarkerProps[];
|
|
33
|
+
children?: ReactNode;
|
|
34
|
+
}
|
|
35
|
+
interface VectorStyleMeta {
|
|
36
|
+
styleName?: any;
|
|
37
|
+
styleTitle?: any;
|
|
38
|
+
colors?: any;
|
|
39
|
+
}
|
|
40
|
+
export interface IUseDisclosure {
|
|
41
|
+
isOpen: boolean;
|
|
42
|
+
onOpen: () => void;
|
|
43
|
+
onClose: () => void;
|
|
44
|
+
onToggle: () => void;
|
|
45
|
+
}
|
|
46
|
+
export interface GeoserverLayer {
|
|
47
|
+
id: string;
|
|
48
|
+
index?: number;
|
|
49
|
+
title: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
thumbnail?: string;
|
|
52
|
+
attribution?: string;
|
|
53
|
+
license?: string;
|
|
54
|
+
tags?: string[];
|
|
55
|
+
createdBy?: string;
|
|
56
|
+
layerStatus?: string;
|
|
57
|
+
author?: {
|
|
58
|
+
name: string;
|
|
59
|
+
};
|
|
60
|
+
url?: string;
|
|
61
|
+
createdDate?: string;
|
|
62
|
+
isDownloadable?: boolean;
|
|
63
|
+
bbox?: any[];
|
|
64
|
+
isAdded?: boolean;
|
|
65
|
+
ats?: any;
|
|
66
|
+
source: {
|
|
67
|
+
type: LayerType;
|
|
68
|
+
scheme?: any;
|
|
69
|
+
tiles?: any;
|
|
70
|
+
endpoint?: any;
|
|
71
|
+
fetcher?: any;
|
|
72
|
+
};
|
|
73
|
+
onClick?: (args: {
|
|
74
|
+
bbox?: any;
|
|
75
|
+
feature?: any;
|
|
76
|
+
layerId?: string;
|
|
77
|
+
}) => ReactNode;
|
|
78
|
+
onHover?: (args: {
|
|
79
|
+
bbox?: any;
|
|
80
|
+
feature?: any;
|
|
81
|
+
layerId?: string;
|
|
82
|
+
}) => ReactNode;
|
|
83
|
+
data?: {
|
|
84
|
+
styles?: VectorStyleMeta[];
|
|
85
|
+
styleIndex?: any;
|
|
86
|
+
propertyMap?: any;
|
|
87
|
+
titleColumn?: any;
|
|
88
|
+
summaryColumn?: any;
|
|
89
|
+
[key: string]: any;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export interface LegendInfo {
|
|
93
|
+
squareSize: number;
|
|
94
|
+
stops: [number, string][];
|
|
95
|
+
}
|
|
96
|
+
export interface Layer {
|
|
97
|
+
gridLegends: Record<string, LegendInfo | undefined>;
|
|
98
|
+
}
|
|
99
|
+
export interface Item {
|
|
100
|
+
id: string;
|
|
101
|
+
}
|
|
102
|
+
export {};
|
|
103
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.tsx"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export declare const axGetGeoserverLayers: (nakshaEndpointToken: string | null | undefined, nakshaApiEndpoint: string, geoserver: any, selectedLayers?: string[] | null) => Promise<any[]>;
|
|
2
|
+
/**
|
|
3
|
+
* axGetGeoserverLayerStyleList
|
|
4
|
+
* Returns { success: true, data } or { success: false }.
|
|
5
|
+
*/
|
|
6
|
+
export declare const axGetGeoserverLayerStyleList: (id: string | number, endpoint: string) => Promise<{
|
|
7
|
+
success: true;
|
|
8
|
+
data: any;
|
|
9
|
+
} | {
|
|
10
|
+
success: false;
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* axGexGetRasterInfoWithLonLat
|
|
14
|
+
* Builds GetFeatureInfo query and returns { success, data }.
|
|
15
|
+
*/
|
|
16
|
+
export declare const axGexGetRasterInfoWithLonLat: (endpoint: string, workspace: string, params: Record<string, any>) => Promise<{
|
|
17
|
+
success: true;
|
|
18
|
+
data: any;
|
|
19
|
+
} | {
|
|
20
|
+
success: false;
|
|
21
|
+
data: any[];
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* axToggleLayerPublishing
|
|
25
|
+
* PUT to toggle active/pending
|
|
26
|
+
*/
|
|
27
|
+
export declare const axToggleLayerPublishing: (nakshaEndpointToken: string | null | undefined, nakshaApiEndpoint: string, layerId: string | number, isActive: boolean) => Promise<boolean>;
|
|
28
|
+
/**
|
|
29
|
+
* axDeleteLayer
|
|
30
|
+
*/
|
|
31
|
+
export declare const axDeleteLayer: (nakshaEndpointToken: string | null | undefined, nakshaApiEndpoint: string, layerId: string | number) => Promise<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* axGetGeoserverLayerStyle
|
|
34
|
+
* Fetches the .mbstyle and returns the first layer or {}.
|
|
35
|
+
*/
|
|
36
|
+
export declare const axGetGeoserverLayerStyle: (layername: string, workspace: string, styleName: string, endpoint: string) => Promise<any>;
|
|
37
|
+
/**
|
|
38
|
+
* getGridLayerData
|
|
39
|
+
* - Uses the provided fetcher(params) (keeps pluggable design)
|
|
40
|
+
* - Builds palette safely (no undefined) and returns stops & paint same as original.
|
|
41
|
+
*/
|
|
42
|
+
export declare const getGridLayerData: (fetcher: (params: Record<string, any>) => Promise<any>, bounds: {
|
|
43
|
+
_ne: {
|
|
44
|
+
lat: number;
|
|
45
|
+
lng: number;
|
|
46
|
+
};
|
|
47
|
+
_sw: {
|
|
48
|
+
lat: number;
|
|
49
|
+
lng: number;
|
|
50
|
+
};
|
|
51
|
+
}, zoom: number, binCount?: number, colorScheme?: string) => Promise<{
|
|
52
|
+
success: boolean;
|
|
53
|
+
geojson: any;
|
|
54
|
+
paint: any;
|
|
55
|
+
stops: [any, string][];
|
|
56
|
+
squareSize: number;
|
|
57
|
+
}>;
|
|
58
|
+
/**
|
|
59
|
+
* axDownloadLayer
|
|
60
|
+
*/
|
|
61
|
+
export declare const axDownloadLayer: (endpoint: string, token: string | null | undefined, layerName: string, layerTitle: string) => Promise<void>;
|
|
62
|
+
//# sourceMappingURL=naksha.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naksha.d.ts","sourceRoot":"","sources":["../../src/services/naksha.ts"],"names":[],"mappings":"AAkOA,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,CAiBf,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,CAU3D,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,CAoBjB,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,CAcb,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;IAAE,GAAG,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAAC,GAAG,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,EAChF,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,CAed,CAAC"}
|
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.axDownloadLayer = exports.getGridLayerData = exports.axGetGeoserverLayerStyle = exports.axDeleteLayer = exports.axToggleLayerPublishing = exports.axGexGetRasterInfoWithLonLat = exports.axGetGeoserverLayerStyleList = exports.axGetGeoserverLayers = void 0;
|
|
7
|
+
// api.ts
|
|
8
|
+
const colorbrewer_1 = __importDefault(require("colorbrewer"));
|
|
9
|
+
const grid_1 = require("../utils/grid");
|
|
10
|
+
/**
|
|
11
|
+
* Inline-typed alias for colorbrewer palettes to avoid TS errors.
|
|
12
|
+
* colorbrewer exports an object of shape: Record<schemeName, Record<count, string[]>>
|
|
13
|
+
*/
|
|
14
|
+
const cbTyped = colorbrewer_1.default;
|
|
15
|
+
/**
|
|
16
|
+
* Utility: build query string from params (inline, simple)
|
|
17
|
+
* - Skips undefined/null
|
|
18
|
+
* - Arrays -> repeated keys
|
|
19
|
+
* - Objects -> JSON.stringify
|
|
20
|
+
*/
|
|
21
|
+
const buildQs = (params) => {
|
|
22
|
+
if (!params)
|
|
23
|
+
return "";
|
|
24
|
+
const usp = new URLSearchParams();
|
|
25
|
+
Object.entries(params).forEach(([k, v]) => {
|
|
26
|
+
if (v === undefined || v === null)
|
|
27
|
+
return;
|
|
28
|
+
if (Array.isArray(v)) {
|
|
29
|
+
v.forEach((item) => usp.append(k, String(item)));
|
|
30
|
+
}
|
|
31
|
+
else if (typeof v === "object") {
|
|
32
|
+
usp.append(k, JSON.stringify(v));
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
usp.append(k, String(v));
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
const s = usp.toString();
|
|
39
|
+
return s ? `?${s}` : "";
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Safe JSON/text parsing: prefer JSON if content-type says so; otherwise try JSON then fallback to text.
|
|
43
|
+
*/
|
|
44
|
+
const parseResponse = async (res) => {
|
|
45
|
+
const ct = (res.headers.get("content-type") || "").toLowerCase();
|
|
46
|
+
if (ct.includes("application/json") || ct.includes("text/json")) {
|
|
47
|
+
return res.json();
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
return await res.json();
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return res.text();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
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
|
+
const axGetGeoserverLayers = async (nakshaEndpointToken, nakshaApiEndpoint, geoserver, selectedLayers) => {
|
|
206
|
+
try {
|
|
207
|
+
const headers = {};
|
|
208
|
+
if (nakshaEndpointToken)
|
|
209
|
+
headers.Authorization = nakshaEndpointToken;
|
|
210
|
+
const res = await fetch(`${nakshaApiEndpoint}/layers`, { headers });
|
|
211
|
+
if (!res.ok)
|
|
212
|
+
throw new Error(`HTTP ${res.status} ${res.statusText}`);
|
|
213
|
+
// parseResponse may be your existing helper — if not, use res.json()
|
|
214
|
+
const data = typeof parseResponse === "function" ? await parseResponse(res) : await res.json().catch(() => null);
|
|
215
|
+
const finalLayers = createDummyLayers(data, geoserver, selectedLayers);
|
|
216
|
+
return finalLayers;
|
|
217
|
+
}
|
|
218
|
+
catch (e) {
|
|
219
|
+
console.error("axGetGeoserverLayers error:", e);
|
|
220
|
+
return [];
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
exports.axGetGeoserverLayers = axGetGeoserverLayers;
|
|
224
|
+
/**
|
|
225
|
+
* axGetGeoserverLayerStyleList
|
|
226
|
+
* Returns { success: true, data } or { success: false }.
|
|
227
|
+
*/
|
|
228
|
+
const axGetGeoserverLayerStyleList = async (id, endpoint) => {
|
|
229
|
+
try {
|
|
230
|
+
const res = await fetch(`${endpoint}/layer/onClick/${id}`);
|
|
231
|
+
if (!res.ok)
|
|
232
|
+
throw new Error(`HTTP ${res.status}`);
|
|
233
|
+
const data = await parseResponse(res);
|
|
234
|
+
return { success: true, data };
|
|
235
|
+
}
|
|
236
|
+
catch (e) {
|
|
237
|
+
console.error(e);
|
|
238
|
+
return { success: false };
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
exports.axGetGeoserverLayerStyleList = axGetGeoserverLayerStyleList;
|
|
242
|
+
/**
|
|
243
|
+
* axGexGetRasterInfoWithLonLat
|
|
244
|
+
* Builds GetFeatureInfo query and returns { success, data }.
|
|
245
|
+
*/
|
|
246
|
+
const axGexGetRasterInfoWithLonLat = async (endpoint, workspace, params) => {
|
|
247
|
+
const RasterInfoParams = {
|
|
248
|
+
service: "WMS",
|
|
249
|
+
version: "1.1.1",
|
|
250
|
+
request: "GetFeatureInfo",
|
|
251
|
+
info_format: "application/json",
|
|
252
|
+
width: 100,
|
|
253
|
+
height: 100,
|
|
254
|
+
x: 50,
|
|
255
|
+
y: 50,
|
|
256
|
+
srs: "EPSG:4326",
|
|
257
|
+
};
|
|
258
|
+
try {
|
|
259
|
+
const qs = buildQs({ ...params, ...RasterInfoParams });
|
|
260
|
+
const res = await fetch(`${endpoint}/${workspace}/wms${qs}`);
|
|
261
|
+
if (!res.ok)
|
|
262
|
+
throw new Error(`HTTP ${res.status}`);
|
|
263
|
+
const data = await parseResponse(res);
|
|
264
|
+
return { success: true, data };
|
|
265
|
+
}
|
|
266
|
+
catch (e) {
|
|
267
|
+
console.error(e);
|
|
268
|
+
return { success: false, data: [] };
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
exports.axGexGetRasterInfoWithLonLat = axGexGetRasterInfoWithLonLat;
|
|
272
|
+
/**
|
|
273
|
+
* axToggleLayerPublishing
|
|
274
|
+
* PUT to toggle active/pending
|
|
275
|
+
*/
|
|
276
|
+
const axToggleLayerPublishing = async (nakshaEndpointToken, nakshaApiEndpoint, layerId, isActive) => {
|
|
277
|
+
try {
|
|
278
|
+
const headers = { "Content-Type": "application/json" };
|
|
279
|
+
if (nakshaEndpointToken)
|
|
280
|
+
headers.Authorization = nakshaEndpointToken;
|
|
281
|
+
const res = await fetch(`${nakshaApiEndpoint}/layer/${isActive ? "active" : "pending"}/${layerId}`, {
|
|
282
|
+
method: "PUT",
|
|
283
|
+
headers,
|
|
284
|
+
body: JSON.stringify({}),
|
|
285
|
+
});
|
|
286
|
+
if (!res.ok)
|
|
287
|
+
throw new Error(`HTTP ${res.status}`);
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
catch (e) {
|
|
291
|
+
console.error(e);
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
exports.axToggleLayerPublishing = axToggleLayerPublishing;
|
|
296
|
+
/**
|
|
297
|
+
* axDeleteLayer
|
|
298
|
+
*/
|
|
299
|
+
const axDeleteLayer = async (nakshaEndpointToken, nakshaApiEndpoint, layerId) => {
|
|
300
|
+
try {
|
|
301
|
+
const headers = {};
|
|
302
|
+
if (nakshaEndpointToken)
|
|
303
|
+
headers.Authorization = nakshaEndpointToken;
|
|
304
|
+
const res = await fetch(`${nakshaApiEndpoint}/layer/${layerId}`, {
|
|
305
|
+
method: "DELETE",
|
|
306
|
+
headers,
|
|
307
|
+
});
|
|
308
|
+
if (!res.ok)
|
|
309
|
+
throw new Error(`HTTP ${res.status}`);
|
|
310
|
+
return true;
|
|
311
|
+
}
|
|
312
|
+
catch (e) {
|
|
313
|
+
console.error(e);
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
exports.axDeleteLayer = axDeleteLayer;
|
|
318
|
+
/**
|
|
319
|
+
* axGetGeoserverLayerStyle
|
|
320
|
+
* Fetches the .mbstyle and returns the first layer or {}.
|
|
321
|
+
*/
|
|
322
|
+
const axGetGeoserverLayerStyle = async (layername, workspace, styleName, endpoint) => {
|
|
323
|
+
try {
|
|
324
|
+
const res = await fetch(`${endpoint}/geoserver/workspaces/${workspace}/styles/${layername}_${styleName}.mbstyle`);
|
|
325
|
+
if (!res.ok)
|
|
326
|
+
throw new Error(`HTTP ${res.status}`);
|
|
327
|
+
// .mbstyle may be JSON; attempt parse safely
|
|
328
|
+
const data = await parseResponse(res).catch(() => ({}));
|
|
329
|
+
return data?.layers?.[0] ?? {};
|
|
330
|
+
}
|
|
331
|
+
catch (e) {
|
|
332
|
+
console.error(e);
|
|
333
|
+
return {};
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
exports.axGetGeoserverLayerStyle = axGetGeoserverLayerStyle;
|
|
337
|
+
/**
|
|
338
|
+
* getGridLayerData
|
|
339
|
+
* - Uses the provided fetcher(params) (keeps pluggable design)
|
|
340
|
+
* - Builds palette safely (no undefined) and returns stops & paint same as original.
|
|
341
|
+
*/
|
|
342
|
+
const getGridLayerData = async (fetcher, bounds, zoom, binCount = 6, colorScheme = "YlOrRd") => {
|
|
343
|
+
try {
|
|
344
|
+
const [geoAggegationPrecision, level, squareSize] = (0, grid_1.getZoomConfig)(zoom);
|
|
345
|
+
const { _ne, _sw } = bounds;
|
|
346
|
+
const params = {
|
|
347
|
+
top: _ne.lat,
|
|
348
|
+
left: _sw.lng,
|
|
349
|
+
bottom: _sw.lat,
|
|
350
|
+
right: _ne.lng,
|
|
351
|
+
geoAggegationPrecision,
|
|
352
|
+
};
|
|
353
|
+
const data = await fetcher(params);
|
|
354
|
+
// @ts-ignore
|
|
355
|
+
const geojson = (0, grid_1.geohashToJSON)(data, level);
|
|
356
|
+
const bins = (0, grid_1.getDataBins)(data, binCount);
|
|
357
|
+
// Palette selection safely (guarantee palette is string[])
|
|
358
|
+
const rawPalette = cbTyped[colorScheme];
|
|
359
|
+
const paletteForCount = rawPalette?.[binCount];
|
|
360
|
+
let palette = [];
|
|
361
|
+
if (Array.isArray(paletteForCount) && paletteForCount.length > 0) {
|
|
362
|
+
// normalize to binCount
|
|
363
|
+
palette = paletteForCount.slice(0, binCount);
|
|
364
|
+
const lastDefined = palette[palette.length - 1] ?? "#000000";
|
|
365
|
+
while (palette.length < binCount)
|
|
366
|
+
palette.push(lastDefined);
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
const fallback = ["#ffffb2", "#fecc5c", "#fd8d3c", "#f03b20", "#bd0026"];
|
|
370
|
+
palette = fallback.slice(0, binCount);
|
|
371
|
+
const lastFallback = fallback[fallback.length - 1];
|
|
372
|
+
// @ts-ignore
|
|
373
|
+
while (palette.length < binCount)
|
|
374
|
+
palette.push(lastFallback);
|
|
375
|
+
}
|
|
376
|
+
const lastColor = palette[palette.length - 1];
|
|
377
|
+
// @ts-ignore
|
|
378
|
+
const stops = bins.map((bin, index) => {
|
|
379
|
+
const color = palette[index] ?? lastColor;
|
|
380
|
+
return [bin, color];
|
|
381
|
+
});
|
|
382
|
+
const paint = {
|
|
383
|
+
"fill-color": {
|
|
384
|
+
property: "count",
|
|
385
|
+
default: "yellow",
|
|
386
|
+
stops,
|
|
387
|
+
},
|
|
388
|
+
"fill-outline-color": "rgba(0,0,0,0.2)",
|
|
389
|
+
"fill-opacity": 0.7,
|
|
390
|
+
};
|
|
391
|
+
// @ts-ignore
|
|
392
|
+
return { success: true, geojson, paint, stops, squareSize };
|
|
393
|
+
}
|
|
394
|
+
catch (e) {
|
|
395
|
+
console.error(e);
|
|
396
|
+
return { success: false, geojson: {}, paint: {}, stops: [], squareSize: 0 };
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
exports.getGridLayerData = getGridLayerData;
|
|
400
|
+
/**
|
|
401
|
+
* axDownloadLayer
|
|
402
|
+
*/
|
|
403
|
+
const axDownloadLayer = async (endpoint, token, layerName, layerTitle) => {
|
|
404
|
+
try {
|
|
405
|
+
const headers = { "Content-Type": "application/json" };
|
|
406
|
+
if (token)
|
|
407
|
+
headers.Authorization = token;
|
|
408
|
+
const res = await fetch(`${endpoint}/layer/download`, {
|
|
409
|
+
method: "POST",
|
|
410
|
+
headers,
|
|
411
|
+
body: JSON.stringify({ layerName, layerTitle, attributeList: [], filterArray: [] }),
|
|
412
|
+
});
|
|
413
|
+
if (!res.ok)
|
|
414
|
+
throw new Error(`HTTP ${res.status}`);
|
|
415
|
+
}
|
|
416
|
+
catch (e) {
|
|
417
|
+
console.error(e);
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
exports.axDownloadLayer = axDownloadLayer;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NakshaMapboxListProps } from "../interfaces";
|
|
2
|
+
import { CSSProperties } from "react";
|
|
3
|
+
export declare const defaultNakshaProps: NakshaMapboxListProps;
|
|
4
|
+
export declare const FALLBACK_THUMB = "data:image/svg+xml,%3Csvg fill='none' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 72'%3E%3Cpath fill='%23fff' d='M0 0h72v72H0z'/%3E%3Cpath d='M35.981 48.293l-13.853-10.77-3.045 2.368L36 53.048l16.917-13.157-3.064-2.387-13.872 10.789zM36 43.519l13.834-10.77 3.083-2.388L36 17.204 19.083 30.36l3.064 2.387L36 43.518z' fill='%23A0AEC0'/%3E%3C/svg%3E";
|
|
5
|
+
export declare const overflowStyle: CSSProperties;
|
|
6
|
+
export declare const overflowStyle2: CSSProperties;
|
|
7
|
+
export declare const PROPERTY_ID = "ogc_fid";
|
|
8
|
+
export declare const LAYER_STATUS: {
|
|
9
|
+
ACTIVE: string;
|
|
10
|
+
PENDING: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const SELECTION_STYLE: {
|
|
13
|
+
TOP: string;
|
|
14
|
+
ALL: string;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=constant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../src/static/constant.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,eAAO,MAAM,kBAAkB,EAAE,qBAUhC,CAAC;AAEF,eAAO,MAAM,cAAc,sWAC0U,CAAC;AAEtW,eAAO,MAAM,aAAa,EAAE,aAM3B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,aAG5B,CAAC;AAEF,eAAO,MAAM,WAAW,YAAY,CAAC;AAErC,eAAO,MAAM,YAAY;;;CAGxB,CAAC;AAEF,eAAO,MAAM,eAAe;;;CAG3B,CAAC"}
|