tds-map-methods 0.1.0 → 0.1.1
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/README.md +16 -6
- package/index.cjs +18 -24
- package/index.js +7605 -25720
- package/package.json +1 -1
- package/types/components/map/methods/arrowLayer.d.ts +2 -2
- package/types/components/map/methods/config.d.ts +32 -0
- package/types/components/map/methods/createIsoline.d.ts +2 -2
- package/types/components/map/methods/createMic.d.ts +3 -3
- package/types/components/map/methods/fcstLayer.d.ts +4 -4
- package/types/components/map/methods/fcstLayer2.d.ts +2 -2
- package/types/components/map/methods/girdLayer.d.ts +2 -2
- package/types/components/map/methods/index.d.ts +6 -1
- package/types/components/map/methods/isolineLayer.d.ts +1 -1
- package/types/components/map/methods/layer.d.ts +3 -1
- package/types/components/map/methods/layerRequest.d.ts +7 -0
- package/types/components/map/methods/request.d.ts +21 -0
- package/types/components/map/methods/tdsRequest.d.ts +49 -0
- package/types/components/map/methods/typhoonLayer.d.ts +7 -4
- package/types/{request/typhoon.d.ts → components/map/methods/typhoonRequest.d.ts} +2 -3
- package/types/components/map/methods/utils.d.ts +4 -2
- package/types/components/map/methods/windShaft.d.ts +1 -1
- package/types/components/map/methods/wmsLayer.d.ts +1 -1
- package/types/typings/layer.d.ts +4 -0
- package/types/serivce/api/tds.d.ts +0 -16
- package/types/serivce/request/index.d.ts +0 -2
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import ImageCanvasSource from "ol/source/ImageCanvas";
|
|
2
|
-
import ImageLayer from "ol/layer/Image";
|
|
1
|
+
import ImageCanvasSource from "ol/source/ImageCanvas.js";
|
|
2
|
+
import ImageLayer from "ol/layer/Image.js";
|
|
3
3
|
type ExtentLike = [number, number, number, number];
|
|
4
4
|
export declare class ArrowLayer {
|
|
5
5
|
map: Layer.Map;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface MapMethodsConfig {
|
|
2
|
+
/** Prefix used for WMS requests, for example "/server". */
|
|
3
|
+
serviceBaseUrl?: string;
|
|
4
|
+
/** Default Authorization header used for TDS requests. */
|
|
5
|
+
serviceAuthorization?: string;
|
|
6
|
+
/** Prefix used for NCSS dataset.xml requests, for example "/ncss/grid". */
|
|
7
|
+
ncssBaseUrl?: string;
|
|
8
|
+
/** Request timeout in milliseconds. */
|
|
9
|
+
requestTimeout?: number;
|
|
10
|
+
/** Maximum width/height used when requesting source images. */
|
|
11
|
+
imageSize?: number;
|
|
12
|
+
/** Prefix used for typhoon JSON requests. Falls back to serviceBaseUrl. */
|
|
13
|
+
typhoonServiceBaseUrl?: string;
|
|
14
|
+
/** Default typhoon data directory. */
|
|
15
|
+
typhoonDataPath?: string;
|
|
16
|
+
/** Default Authorization header for typhoon requests. */
|
|
17
|
+
typhoonAuthorization?: string;
|
|
18
|
+
}
|
|
19
|
+
export type ResolvedMapMethodsConfig = {
|
|
20
|
+
serviceBaseUrl: string;
|
|
21
|
+
serviceAuthorization: string;
|
|
22
|
+
ncssBaseUrl: string;
|
|
23
|
+
requestTimeout: number;
|
|
24
|
+
imageSize: number;
|
|
25
|
+
typhoonServiceBaseUrl: string;
|
|
26
|
+
typhoonDataPath: string;
|
|
27
|
+
typhoonAuthorization: string;
|
|
28
|
+
};
|
|
29
|
+
/** Configure values that must be supplied by the consuming application. */
|
|
30
|
+
export declare function configureMapMethods(config: MapMethodsConfig): void;
|
|
31
|
+
export declare function getMapMethodsConfig(): Readonly<ResolvedMapMethodsConfig>;
|
|
32
|
+
export declare function resetMapMethodsConfig(): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type Map from "ol/Map";
|
|
2
|
-
import VectorLayer from "ol/layer/Vector";
|
|
3
|
-
import VectorSource from "ol/source/Vector";
|
|
1
|
+
import type Map from "ol/Map.js";
|
|
2
|
+
import VectorLayer from "ol/layer/Vector.js";
|
|
3
|
+
import VectorSource from "ol/source/Vector.js";
|
|
4
4
|
type LegendItem = {
|
|
5
5
|
name?: string;
|
|
6
6
|
scope?: number[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import ImageCanvasSource from "ol/source/ImageCanvas";
|
|
2
|
-
import ImageLayer from "ol/layer/Image";
|
|
1
|
+
import ImageCanvasSource from "ol/source/ImageCanvas.js";
|
|
2
|
+
import ImageLayer from "ol/layer/Image.js";
|
|
3
3
|
type ExtentLike = [number, number, number, number];
|
|
4
4
|
type ScopeLike = [number, number] | [] | undefined;
|
|
5
5
|
type ValueTransformContext = {
|
|
@@ -69,9 +69,9 @@ export declare class FcstLayer {
|
|
|
69
69
|
createVisibleMaskContourPath(rawArr2D: (number | undefined)[][], width: number, height: number, scope?: ScopeLike, smooth?: boolean, runtimeOptions?: any): Path2D;
|
|
70
70
|
createIsolineContourPath(valueArr2D: (number | undefined)[][], width: number, height: number, scope?: ScopeLike, runtimeOptions?: any): Path2D;
|
|
71
71
|
createIsolineContourFills(valueArr2D: (number | undefined)[][], width: number, height: number, thresholds: number[], colorsRGBA: [number, number, number, number][], scope?: ScopeLike, runtimeOptions?: any): ContourFill[];
|
|
72
|
-
createScopeMaskCanvas(valueArr2D: (number | undefined)[][], width: number, height: number, scope?: ScopeLike): HTMLCanvasElement;
|
|
72
|
+
createScopeMaskCanvas(valueArr2D: (number | undefined)[][], width: number, height: number, scope?: ScopeLike, maxExclusive?: boolean): HTMLCanvasElement;
|
|
73
73
|
createLegendEdgeColorCanvas(valueArr2D: (number | undefined)[][], width: number, height: number, firstThreshold: number, lastThreshold: number, firstColor: [number, number, number, number], lastColor: [number, number, number, number]): HTMLCanvasElement;
|
|
74
|
-
createFcstCanvasSource(rasterCanvas: HTMLCanvasElement, dataExtent: ExtentLike, colorMode?: Layer.LayerMode, rawArr2D?: (number | undefined)[][], scope?: ScopeLike, runtimeOptions?: any, contourFills?: ContourFill[], contourValues?: (number | undefined)[][], selectedEdgeCanvas?: HTMLCanvasElement | null): ImageCanvasSource;
|
|
74
|
+
createFcstCanvasSource(rasterCanvas: HTMLCanvasElement, dataExtent: ExtentLike, colorMode?: Layer.LayerMode, rawArr2D?: (number | undefined)[][], scope?: ScopeLike, runtimeOptions?: any, contourFills?: ContourFill[], contourValues?: (number | undefined)[][], selectedEdgeCanvas?: HTMLCanvasElement | null, maxExclusive?: boolean): ImageCanvasSource;
|
|
75
75
|
/** 预加载图层 */
|
|
76
76
|
preload(url: string): Promise<void>;
|
|
77
77
|
delete(): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import ImageCanvasSource from "ol/source/ImageCanvas";
|
|
2
|
-
import ImageLayer from "ol/layer/Image";
|
|
1
|
+
import ImageCanvasSource from "ol/source/ImageCanvas.js";
|
|
2
|
+
import ImageLayer from "ol/layer/Image.js";
|
|
3
3
|
type ExtentLike = [number, number, number, number];
|
|
4
4
|
type ScopeLike = [number, number] | [] | undefined;
|
|
5
5
|
type ContourRing = number[][];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import ImageCanvasSource from "ol/source/ImageCanvas";
|
|
2
|
-
import ImageLayer from "ol/layer/Image";
|
|
1
|
+
import ImageCanvasSource from "ol/source/ImageCanvas.js";
|
|
2
|
+
import ImageLayer from "ol/layer/Image.js";
|
|
3
3
|
type ExtentLike = [number, number, number, number];
|
|
4
4
|
type GridValueTransformContext = {
|
|
5
5
|
x: number;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
/// <reference path="
|
|
1
|
+
/// <reference path="../../../typings/layer.d.ts" />
|
|
2
2
|
export * from "./common";
|
|
3
|
+
export * from "./config";
|
|
4
|
+
export * from "./request";
|
|
5
|
+
export * from "./tdsRequest";
|
|
6
|
+
export * from "./layerRequest";
|
|
3
7
|
export * from "./layer";
|
|
4
8
|
export * from "./utils";
|
|
5
9
|
export * from "./fcstLayer";
|
|
@@ -14,3 +18,4 @@ export * from "./windLayer";
|
|
|
14
18
|
export * from "./windShaft";
|
|
15
19
|
export * from "./wmsLayer";
|
|
16
20
|
export * from "./typhoonLayer";
|
|
21
|
+
export * from "./typhoonRequest";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Map } from "ol";
|
|
2
|
+
import { type MapMethodsConfig } from "./config";
|
|
2
3
|
type WmsLayerColorOptions = {
|
|
3
4
|
styles?: string;
|
|
4
5
|
colorScaleRange?: string | [number, number];
|
|
@@ -8,10 +9,11 @@ type WmsLayerColorOptions = {
|
|
|
8
9
|
bgColor?: string;
|
|
9
10
|
logScale?: boolean | string;
|
|
10
11
|
};
|
|
11
|
-
type MapInitConfig = {
|
|
12
|
+
export type MapInitConfig = {
|
|
12
13
|
center?: [number, number];
|
|
13
14
|
zoom?: number;
|
|
14
15
|
layers?: any[];
|
|
16
|
+
mapMethodsConfig?: MapMethodsConfig;
|
|
15
17
|
};
|
|
16
18
|
export declare function initMap(target: string | HTMLElement, config?: MapInitConfig): Promise<Map>;
|
|
17
19
|
/**
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface LayerResolveRequestOptions {
|
|
2
|
+
serviceBaseUrl?: string;
|
|
3
|
+
ncssBaseUrl?: string;
|
|
4
|
+
authorization?: string;
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
}
|
|
7
|
+
export declare function resolveLayerLoadOptions(menu: Layer.Config, options?: LayerResolveRequestOptions): Promise<Layer.Config | null>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type TdsResponseType = "json" | "text" | "blob" | "arrayBuffer" | "arraybuffer" | "response";
|
|
2
|
+
export interface TdsRequestOptions {
|
|
3
|
+
baseUrl?: string;
|
|
4
|
+
authorization?: string;
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
timeout?: number;
|
|
7
|
+
headers?: HeadersInit;
|
|
8
|
+
credentials?: RequestCredentials;
|
|
9
|
+
}
|
|
10
|
+
export interface TdsGetOptions extends TdsRequestOptions {
|
|
11
|
+
responseType?: TdsResponseType;
|
|
12
|
+
}
|
|
13
|
+
export declare function createTdsRequestUrl(url: string, baseUrl?: string): string;
|
|
14
|
+
export declare function fetchTdsResponse(url: string, options?: TdsRequestOptions): Promise<Response>;
|
|
15
|
+
export declare function fetchTdsGet<T = unknown>(url: string, params?: Record<string, unknown>, authorization?: string, options?: TdsGetOptions): Promise<T>;
|
|
16
|
+
export declare function fetchXmlData(url: string, authorization?: string, options?: TdsRequestOptions): Promise<string>;
|
|
17
|
+
export declare function fetchXMLFromUrl(url: string, authorization?: string, options?: TdsRequestOptions): Promise<string>;
|
|
18
|
+
export declare function fetchTxtOrJson(url: string, params?: Record<string, unknown>, authorization?: string, options?: TdsRequestOptions): Promise<string>;
|
|
19
|
+
export declare function fetchExcel(url: string, authorization?: string, options?: TdsRequestOptions): Promise<ArrayBuffer>;
|
|
20
|
+
export declare function fetchImageBase64(url: string, paramsOrAuthorization?: Record<string, unknown> | string, authorization?: string, options?: TdsRequestOptions): Promise<string>;
|
|
21
|
+
export declare function fetchTdsImageBase64(url: string, params?: Record<string, unknown>): Promise<string>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export interface VariableMinMaxResult {
|
|
2
|
+
min: number;
|
|
3
|
+
max: number;
|
|
4
|
+
}
|
|
5
|
+
export interface TdsCatalogItem {
|
|
6
|
+
label: string;
|
|
7
|
+
key: string;
|
|
8
|
+
url: string;
|
|
9
|
+
type: "menu" | "file";
|
|
10
|
+
isLeaf: boolean;
|
|
11
|
+
fileType?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface TdsDatasetRequestOptions {
|
|
14
|
+
filePath: string;
|
|
15
|
+
url?: string;
|
|
16
|
+
authorization?: string;
|
|
17
|
+
serviceBaseUrl?: string;
|
|
18
|
+
ncssBaseUrl?: string;
|
|
19
|
+
signal?: AbortSignal;
|
|
20
|
+
}
|
|
21
|
+
export declare function parseXML(xml: string, target?: string): any;
|
|
22
|
+
export declare function getNCXmlData(xml: string): {
|
|
23
|
+
latLonBox: any;
|
|
24
|
+
timeSpan: any;
|
|
25
|
+
axis: any;
|
|
26
|
+
grid: any;
|
|
27
|
+
};
|
|
28
|
+
export declare function getNodeData(options: {
|
|
29
|
+
xmlJson: any[];
|
|
30
|
+
type: "menu" | "file";
|
|
31
|
+
}): TdsCatalogItem[];
|
|
32
|
+
export declare function getVariableMinMax(filePath: string, variable: string, latLonBox: {
|
|
33
|
+
north: number;
|
|
34
|
+
south: number;
|
|
35
|
+
east: number;
|
|
36
|
+
west: number;
|
|
37
|
+
}, time?: string, authorization?: string, serviceBaseUrl?: string, signal?: AbortSignal): Promise<VariableMinMaxResult>;
|
|
38
|
+
export declare function getMenuList(url: string, authorization?: string, options?: Pick<TdsDatasetRequestOptions, "serviceBaseUrl" | "signal">): Promise<{
|
|
39
|
+
type: "" | "menu" | "file";
|
|
40
|
+
data: TdsCatalogItem[];
|
|
41
|
+
}>;
|
|
42
|
+
export declare function getXmlData(options: TdsDatasetRequestOptions): Promise<{
|
|
43
|
+
type: "file";
|
|
44
|
+
latLonBox: any;
|
|
45
|
+
timeList: string[];
|
|
46
|
+
fileList: TdsCatalogItem[];
|
|
47
|
+
url: string;
|
|
48
|
+
authorization: string;
|
|
49
|
+
}>;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { FeatureLike } from "ol/Feature";
|
|
2
|
-
import VectorSource from "ol/source/Vector";
|
|
3
|
-
import { Style } from "ol/style";
|
|
4
|
-
import { type TyphoonDetail, type TyphoonListItem, type TyphoonPoint } from "
|
|
1
|
+
import type { FeatureLike } from "ol/Feature.js";
|
|
2
|
+
import VectorSource from "ol/source/Vector.js";
|
|
3
|
+
import { Style } from "ol/style.js";
|
|
4
|
+
import { type TyphoonDetail, type TyphoonListItem, type TyphoonPoint } from "./typhoonRequest";
|
|
5
5
|
type TrackKind = "obs" | "fcst";
|
|
6
6
|
type TyphoonLayerOptions = Layer.Config & {
|
|
7
7
|
config: Layer.Config["config"] & {
|
|
8
8
|
typhoonConfig?: {
|
|
9
|
+
serviceBaseUrl?: string;
|
|
9
10
|
dataPath?: string;
|
|
10
11
|
typhoonNums?: string[];
|
|
11
12
|
sourcePriority?: string[];
|
|
@@ -22,12 +23,14 @@ export declare class TyphoonLayer {
|
|
|
22
23
|
constructor(map: Layer.Map, options: TyphoonLayerOptions);
|
|
23
24
|
getClassName(): string;
|
|
24
25
|
getConfig(): {
|
|
26
|
+
serviceBaseUrl?: string;
|
|
25
27
|
dataPath?: string;
|
|
26
28
|
typhoonNums?: string[];
|
|
27
29
|
sourcePriority?: string[];
|
|
28
30
|
showForecast?: boolean;
|
|
29
31
|
fitToExtent?: boolean;
|
|
30
32
|
} & {
|
|
33
|
+
serviceBaseUrl?: string;
|
|
31
34
|
dataPath?: string;
|
|
32
35
|
typhoonNums?: string[];
|
|
33
36
|
sourcePriority?: string[];
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
export declare const TYPHOON_SERVICE_BASE_URL: any;
|
|
2
|
-
export declare const TYPHOON_AUTHORIZATION: any;
|
|
3
|
-
export declare const TYPHOON_DATA_PATH: any;
|
|
4
1
|
export interface TyphoonListItem {
|
|
5
2
|
num_inati: string;
|
|
6
3
|
num_nati: string;
|
|
@@ -43,8 +40,10 @@ export interface TyphoonDetail {
|
|
|
43
40
|
fcst?: Record<string, TyphoonPoint[] | TyphoonForecast>;
|
|
44
41
|
}
|
|
45
42
|
export interface TyphoonRequestOptions {
|
|
43
|
+
serviceBaseUrl?: string;
|
|
46
44
|
dataPath?: string;
|
|
47
45
|
authorization?: string;
|
|
46
|
+
signal?: AbortSignal;
|
|
48
47
|
}
|
|
49
48
|
export declare function getTyphoonList(options?: TyphoonRequestOptions): Promise<TyphoonListItem[]>;
|
|
50
49
|
export declare function getTyphoonDetail(typhoonNum: string, options?: TyphoonRequestOptions): Promise<TyphoonDetail>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Dayjs } from "dayjs";
|
|
1
|
+
import { type Dayjs } from "dayjs";
|
|
2
|
+
import { type MapMethodsConfig } from "./config";
|
|
2
3
|
export declare function resolveSymFunction<T extends (...args: any[]) => any>(candidate: unknown): T | undefined;
|
|
3
4
|
/** bbox经纬度转3857 */
|
|
4
5
|
export declare function bboxFromLonlatTo3857(bbox: [number, number, number, number]): [number, number, number, number];
|
|
@@ -49,6 +50,7 @@ export declare function bilinearInterpolate(arr: Float32Array, x: number, y: num
|
|
|
49
50
|
*/
|
|
50
51
|
export declare function getGrayDataFromImage(src: string, scope: [number, number], scopeBoundaries?: [boolean, boolean], authorization?: string, options?: {
|
|
51
52
|
detectNoDataByBorderColor?: boolean;
|
|
53
|
+
signal?: AbortSignal;
|
|
52
54
|
}): Promise<{
|
|
53
55
|
grayArr: (number | undefined)[];
|
|
54
56
|
width: number;
|
|
@@ -85,7 +87,7 @@ export declare function getWidthAndHeight(extent: [number, number, number, numbe
|
|
|
85
87
|
width: number;
|
|
86
88
|
height: number;
|
|
87
89
|
};
|
|
88
|
-
export declare function getUrlFromTime(el: any, time: string | Dayjs): string | string[];
|
|
90
|
+
export declare function getUrlFromTime(el: any, time: string | Dayjs, requestConfig?: Pick<MapMethodsConfig, "serviceBaseUrl" | "imageSize">): string | string[];
|
|
89
91
|
/**
|
|
90
92
|
* 把单个数值映射为 rgba 数组(0..255)
|
|
91
93
|
* thresholds: 排序后的阈值数组
|
package/types/typings/layer.d.ts
CHANGED
|
@@ -39,6 +39,8 @@ declare namespace Layer {
|
|
|
39
39
|
fallbackFilePath?: string;
|
|
40
40
|
/** 图层数据url地址 */
|
|
41
41
|
url?: string;
|
|
42
|
+
/** WMS service prefix. Overrides the global package configuration. */
|
|
43
|
+
serviceBaseUrl?: string;
|
|
42
44
|
/** 图层是否显示,默认true */
|
|
43
45
|
show?: boolean;
|
|
44
46
|
/** 菜单图标名称 */
|
|
@@ -181,6 +183,8 @@ declare namespace Layer {
|
|
|
181
183
|
};
|
|
182
184
|
/** 台风路径图层配置 */
|
|
183
185
|
typhoonConfig?: {
|
|
186
|
+
/** Typhoon JSON service prefix. */
|
|
187
|
+
serviceBaseUrl?: string;
|
|
184
188
|
/** TDS fileServer 下的台风 JSON 目录 */
|
|
185
189
|
dataPath?: string;
|
|
186
190
|
/** 只加载指定台风编号;不传则加载列表内全部台风 */
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { ResponseType } from "axios";
|
|
2
|
-
export declare function fetchXmlData(url: string, auth?: string): Promise<any>;
|
|
3
|
-
export declare function fetchXMLFromUrl(url: string, auth?: string): Promise<any>;
|
|
4
|
-
export declare function fetchExcel(url: string, auth?: string): Promise<any>;
|
|
5
|
-
export declare function fetchTxtOrJson(url: string, params?: any, auth?: string): Promise<any>;
|
|
6
|
-
export declare function fetchTdsGet(url: string, params?: any, auth?: string, options?: {
|
|
7
|
-
responseType?: ResponseType;
|
|
8
|
-
}): Promise<any>;
|
|
9
|
-
/**
|
|
10
|
-
* 通过已有代理请求图片并返回 base64(DataURL)
|
|
11
|
-
*/
|
|
12
|
-
export declare function fetchTdsImageBase64(url: string, params?: any): Promise<string>;
|
|
13
|
-
/**
|
|
14
|
-
* 统一获取图片 base64
|
|
15
|
-
*/
|
|
16
|
-
export declare function fetchImageBase64(url: string, paramsOrAuth?: any, auth?: string): Promise<string>;
|