tds-map-methods 0.0.0-stage → 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/README.md +20 -2
- package/index.cjs +286 -0
- package/index.js +26560 -0
- package/package.json +30 -4
- package/types/components/map/methods/arrowLayer.d.ts +25 -0
- package/types/components/map/methods/common.d.ts +1 -0
- package/types/components/map/methods/createIsoline.d.ts +76 -0
- package/types/components/map/methods/createMic.d.ts +28 -0
- package/types/components/map/methods/fcstLayer.d.ts +81 -0
- package/types/components/map/methods/fcstLayer2.d.ts +30 -0
- package/types/components/map/methods/girdLayer.d.ts +62 -0
- package/types/components/map/methods/index.d.ts +16 -0
- package/types/components/map/methods/isolineLayer.d.ts +18 -0
- package/types/components/map/methods/layer.d.ts +39 -0
- package/types/components/map/methods/micLayer.d.ts +28 -0
- package/types/components/map/methods/typhoonLayer.d.ts +54 -0
- package/types/components/map/methods/utils.d.ts +95 -0
- package/types/components/map/methods/webgpuRaster.d.ts +13 -0
- package/types/components/map/methods/windLayer.d.ts +23 -0
- package/types/components/map/methods/windShaft.d.ts +43 -0
- package/types/components/map/methods/wmsLayer.d.ts +36 -0
- package/types/request/typhoon.d.ts +50 -0
- package/types/serivce/api/tds.d.ts +16 -0
- package/types/serivce/request/index.d.ts +2 -0
- package/types/typings/layer.d.ts +222 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import ImageCanvasSource from "ol/source/ImageCanvas";
|
|
2
|
+
import type { WindVectorData } from "./windLayer";
|
|
3
|
+
type WindShaftResolvedConfig = {
|
|
4
|
+
pixelStep: number;
|
|
5
|
+
fontSize: number;
|
|
6
|
+
color: string;
|
|
7
|
+
minWindSpeed: number;
|
|
8
|
+
speedLevelStep: number;
|
|
9
|
+
maxLevel: number;
|
|
10
|
+
spriteCellSize: number;
|
|
11
|
+
baseFontSize: number;
|
|
12
|
+
iconYOffsetRatio: number;
|
|
13
|
+
firstRowMaxLevel: number;
|
|
14
|
+
firstRowStartX: number;
|
|
15
|
+
firstRowY: number;
|
|
16
|
+
secondRowOffsetX: number;
|
|
17
|
+
secondRowY: number;
|
|
18
|
+
};
|
|
19
|
+
export declare class WindShaft {
|
|
20
|
+
map: Layer.Map;
|
|
21
|
+
options: any;
|
|
22
|
+
contourCache: Map<string, WindVectorData>;
|
|
23
|
+
iconImagePromise: Promise<HTMLImageElement> | null;
|
|
24
|
+
externalWindDataProvider?: () => Promise<WindVectorData | null>;
|
|
25
|
+
constructor(map: Layer.Map, options: any, externalWindDataProvider?: () => Promise<WindVectorData | null>);
|
|
26
|
+
getClassName(): string;
|
|
27
|
+
normalizeUrls(url: unknown): string[];
|
|
28
|
+
getComponentScope(): [number, number];
|
|
29
|
+
getCacheKey(): string;
|
|
30
|
+
getRuntimeConfig(): Layer.Config["config"] & Record<string, any>;
|
|
31
|
+
getVisibleWindSpeedScope(): [number, number];
|
|
32
|
+
getWindShaftConfig(): WindShaftResolvedConfig;
|
|
33
|
+
getIconImage(): Promise<HTMLImageElement>;
|
|
34
|
+
getOrLoadWindData(): Promise<WindVectorData | null>;
|
|
35
|
+
createWindShaftSource(data: WindVectorData, iconImage: CanvasImageSource): ImageCanvasSource;
|
|
36
|
+
getSourceFromCache(): Promise<ImageCanvasSource>;
|
|
37
|
+
getSourceFromParams(): Promise<ImageCanvasSource>;
|
|
38
|
+
add(): Promise<void>;
|
|
39
|
+
delete(): void;
|
|
40
|
+
toggleVisible(visible: boolean): void;
|
|
41
|
+
updateParams(newOptions: Layer.Config): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { TileWMS } from "ol/source";
|
|
2
|
+
type WmsLayerConfig = Record<string, string | number | boolean | string[] | undefined>;
|
|
3
|
+
type WmsColorOptions = {
|
|
4
|
+
styles?: string;
|
|
5
|
+
colorScaleRange?: string | [number, number];
|
|
6
|
+
numColorBands?: string | number;
|
|
7
|
+
aboveMaxColor?: string;
|
|
8
|
+
belowMinColor?: string;
|
|
9
|
+
bgColor?: string;
|
|
10
|
+
logScale?: boolean | string;
|
|
11
|
+
};
|
|
12
|
+
export declare class WmsLayer {
|
|
13
|
+
map: Layer.Map;
|
|
14
|
+
options: Layer.Config;
|
|
15
|
+
constructor(map: Layer.Map, options: Layer.Config);
|
|
16
|
+
getClassName(): string;
|
|
17
|
+
getConfig(): Layer.Config["config"] & {
|
|
18
|
+
opacity?: number;
|
|
19
|
+
layerConfig?: WmsLayerConfig;
|
|
20
|
+
};
|
|
21
|
+
normalizeParamValue(value: unknown): string | undefined;
|
|
22
|
+
buildWmsParams(): Record<string, string>;
|
|
23
|
+
splitUrlAndParams(rawUrl: string): {
|
|
24
|
+
baseUrl: string;
|
|
25
|
+
urlParams: Record<string, string>;
|
|
26
|
+
};
|
|
27
|
+
getTintColorRGB(): [number, number, number] | null;
|
|
28
|
+
tintBlobToDataUrl(blob: Blob, tintRGB: [number, number, number]): Promise<string>;
|
|
29
|
+
createSource(): TileWMS;
|
|
30
|
+
add(): void;
|
|
31
|
+
delete(): void;
|
|
32
|
+
toggleVisible(visible: boolean): void;
|
|
33
|
+
updateParams(newOptions: Layer.Config): void;
|
|
34
|
+
updateColor(colorOptions: WmsColorOptions): void;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
export interface TyphoonListItem {
|
|
5
|
+
num_inati: string;
|
|
6
|
+
num_nati: string;
|
|
7
|
+
name_en: string;
|
|
8
|
+
name_cn: string;
|
|
9
|
+
data_id?: string;
|
|
10
|
+
init_grade?: string | null;
|
|
11
|
+
first_seen_file?: string;
|
|
12
|
+
first_seen_ts?: string;
|
|
13
|
+
latest_ts?: string;
|
|
14
|
+
obs_points?: number;
|
|
15
|
+
fcst_sources?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface TyphoonPoint {
|
|
18
|
+
datetime: string;
|
|
19
|
+
file_ts: string;
|
|
20
|
+
validtime: number;
|
|
21
|
+
lat: number;
|
|
22
|
+
lon: number;
|
|
23
|
+
prs_hpa: number | null;
|
|
24
|
+
wind_max_ms: number | null;
|
|
25
|
+
wind_gust_ms: number | null;
|
|
26
|
+
grade: string | null;
|
|
27
|
+
move_dir_deg: number | null;
|
|
28
|
+
move_speed_ms: number | null;
|
|
29
|
+
radius_7: (number | null)[];
|
|
30
|
+
radius_10: (number | null)[];
|
|
31
|
+
radius_12: (number | null)[];
|
|
32
|
+
}
|
|
33
|
+
export interface TyphoonForecast {
|
|
34
|
+
file_ts?: string;
|
|
35
|
+
points?: TyphoonPoint[];
|
|
36
|
+
}
|
|
37
|
+
export interface TyphoonDetail {
|
|
38
|
+
typhoon_num: string;
|
|
39
|
+
name_cn: string;
|
|
40
|
+
name_en: string;
|
|
41
|
+
updated?: string;
|
|
42
|
+
obs?: Record<string, TyphoonPoint[] | TyphoonForecast>;
|
|
43
|
+
fcst?: Record<string, TyphoonPoint[] | TyphoonForecast>;
|
|
44
|
+
}
|
|
45
|
+
export interface TyphoonRequestOptions {
|
|
46
|
+
dataPath?: string;
|
|
47
|
+
authorization?: string;
|
|
48
|
+
}
|
|
49
|
+
export declare function getTyphoonList(options?: TyphoonRequestOptions): Promise<TyphoonListItem[]>;
|
|
50
|
+
export declare function getTyphoonDetail(typhoonNum: string, options?: TyphoonRequestOptions): Promise<TyphoonDetail>;
|
|
@@ -0,0 +1,16 @@
|
|
|
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>;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
declare namespace Layer {
|
|
2
|
+
type Map = import("ol").Map;
|
|
3
|
+
type Dayjs = import("dayjs").Dayjs;
|
|
4
|
+
|
|
5
|
+
/** 图层类型:只显示图例,网格,渐变,等高线,可见性,箭头,micaps,uv风,风杆 */
|
|
6
|
+
type LegendType =
|
|
7
|
+
| "legend"
|
|
8
|
+
| "grid"
|
|
9
|
+
| "gradual"
|
|
10
|
+
| "isoline"
|
|
11
|
+
| "contour"
|
|
12
|
+
| "visible"
|
|
13
|
+
| "arrow"
|
|
14
|
+
| "micaps"
|
|
15
|
+
| "wms"
|
|
16
|
+
| "uv"
|
|
17
|
+
| "windShaft"
|
|
18
|
+
| "typhoon";
|
|
19
|
+
/** 图层模式:离散、渐变、网格 */
|
|
20
|
+
type LayerMode = "discrete" | "gradient" | "grid";
|
|
21
|
+
type Legend = {
|
|
22
|
+
name: string;
|
|
23
|
+
scope?: number[];
|
|
24
|
+
color: string;
|
|
25
|
+
}[];
|
|
26
|
+
|
|
27
|
+
interface Config {
|
|
28
|
+
/** 图层id,唯一标识 */
|
|
29
|
+
readonly id: string;
|
|
30
|
+
/** 图层标题 */
|
|
31
|
+
readonly title: string;
|
|
32
|
+
/** 图层标签 */
|
|
33
|
+
label: string;
|
|
34
|
+
/** 图层类型 */
|
|
35
|
+
type: LegendType | LegendType[];
|
|
36
|
+
/** 图层数据文件路径 */
|
|
37
|
+
filePath: string;
|
|
38
|
+
/** 主数据目录不可用时使用的备用目录 */
|
|
39
|
+
fallbackFilePath?: string;
|
|
40
|
+
/** 图层数据url地址 */
|
|
41
|
+
url?: string;
|
|
42
|
+
/** 图层是否显示,默认true */
|
|
43
|
+
show?: boolean;
|
|
44
|
+
/** 菜单图标名称 */
|
|
45
|
+
icon?: string;
|
|
46
|
+
/** 目录接口返回的节点类型 */
|
|
47
|
+
fileListType?: "file" | "menu";
|
|
48
|
+
/** 数据单位 */
|
|
49
|
+
unit?: string;
|
|
50
|
+
/** 菜单项请求头 Authorization,优先于环境变量 */
|
|
51
|
+
authorization?: string;
|
|
52
|
+
/** 备用目录对应的 Authorization */
|
|
53
|
+
fallbackAuthorization?: string;
|
|
54
|
+
/** 数据时间 */
|
|
55
|
+
time?: string | Dayjs;
|
|
56
|
+
config: {
|
|
57
|
+
/** 是否缓存图层数据,默认false,---!!该参数准备作废!!--- */
|
|
58
|
+
cache?: boolean;
|
|
59
|
+
/** 图片边界取值bbox */
|
|
60
|
+
extent: [number, number, number, number];
|
|
61
|
+
/** 图层zIndex,默认0,数值越大越靠上 */
|
|
62
|
+
zIndex?: number;
|
|
63
|
+
/** 图层透明度,取值范围 0-1 */
|
|
64
|
+
opacity?: number;
|
|
65
|
+
/** 等值线线宽 */
|
|
66
|
+
lineWidth?: number;
|
|
67
|
+
/** 等值线线宽,优先于 lineWidth */
|
|
68
|
+
isolineLineWidth?: number;
|
|
69
|
+
/** 是否启用等值线平滑,默认 true */
|
|
70
|
+
isolineSmooth?: boolean;
|
|
71
|
+
/** 等值线平滑度,0 表示关闭,1-3 表示逐级增强,默认 1 */
|
|
72
|
+
isolineSmoothness?: number;
|
|
73
|
+
/** 色斑图是否使用与等值线相同的数值场和平滑边界,默认 false */
|
|
74
|
+
alignWithIsoline?: boolean;
|
|
75
|
+
/** 等值线颜色;true 表示跟随图例 */
|
|
76
|
+
isolineColor?: string | boolean;
|
|
77
|
+
/** 等值面边界颜色 */
|
|
78
|
+
isolineBorderColor?: string;
|
|
79
|
+
/** 是否绘制分级等值面 */
|
|
80
|
+
isolineFill?: boolean;
|
|
81
|
+
/** 是否沿等值线显示数值 */
|
|
82
|
+
showIsolineValue?: boolean;
|
|
83
|
+
/** showIsolineValue 的兼容配置名 */
|
|
84
|
+
showIsolineLabel?: boolean;
|
|
85
|
+
/** MICAPS 是否显示文本 */
|
|
86
|
+
showText?: boolean;
|
|
87
|
+
/** MICAPS 是否填色 */
|
|
88
|
+
showFillcolor?: boolean;
|
|
89
|
+
/** MICAPS 是否显示等值线 */
|
|
90
|
+
showIsoline?: boolean;
|
|
91
|
+
/** MICAPS 是否显示符号点 */
|
|
92
|
+
showPointMarkers?: boolean;
|
|
93
|
+
/** 图例色带范围 */
|
|
94
|
+
legend: Legend;
|
|
95
|
+
/** 图例色带类型 visible:不显示色带 legend: 显示色块文字 grid:显示网格色带 gradual:显示渐变色带 */
|
|
96
|
+
legendType: "visible" | "legend" | "grid" | "gradual";
|
|
97
|
+
/** 图例色带范围(图例下标),只有在legendType为visible时有效,空数组表示不限制范围 */
|
|
98
|
+
legendScope?: [] | [number, number];
|
|
99
|
+
/** 数据值域;不设置时,从 TDS 自动获取最大/最小值 */
|
|
100
|
+
scope?: [number, number];
|
|
101
|
+
/**
|
|
102
|
+
* 对栅格值进行二次计算后再参与绘制与查询。
|
|
103
|
+
* 返回 null/undefined/NaN 时,该像素按无效值处理。
|
|
104
|
+
* 也支持字符串符号引用,例如 #sym:valueTransform。
|
|
105
|
+
*/
|
|
106
|
+
valueTransform?:
|
|
107
|
+
| ((
|
|
108
|
+
value: number,
|
|
109
|
+
context: {
|
|
110
|
+
x: number;
|
|
111
|
+
y: number;
|
|
112
|
+
width: number;
|
|
113
|
+
height: number;
|
|
114
|
+
source: "raw" | "smooth";
|
|
115
|
+
},
|
|
116
|
+
) => number | null | undefined)
|
|
117
|
+
| string;
|
|
118
|
+
/**
|
|
119
|
+
* valueTransform 结果是否参与范围过滤,默认 true。
|
|
120
|
+
* false 时仅用于显示值,不改变过滤判定。
|
|
121
|
+
*/
|
|
122
|
+
valueTransformAffectsScope?: boolean;
|
|
123
|
+
/** 掩膜边缘平滑开关,默认false */
|
|
124
|
+
smooth?: boolean;
|
|
125
|
+
/** Chaikin 平滑迭代次数,默认2,建议1-3,取值范围1-5 */
|
|
126
|
+
smoothIterations?: number;
|
|
127
|
+
mode: LayerMode;
|
|
128
|
+
/** tds图层配置项 */
|
|
129
|
+
layerConfig?: Record<string, any>;
|
|
130
|
+
/** grid图层配置项 */
|
|
131
|
+
gridConfig?: {
|
|
132
|
+
/** 网格文本像素间距,默认40,单位px */
|
|
133
|
+
pixelStep: number | string;
|
|
134
|
+
/** 网格文本字体大小,默认14,单位px */
|
|
135
|
+
fontSize: number | string;
|
|
136
|
+
/** 网格文本小数位数,默认1 */
|
|
137
|
+
decimals: number | string;
|
|
138
|
+
/** 网格文本颜色,默认#000 */
|
|
139
|
+
fontColor: string;
|
|
140
|
+
/** 网格文本描边颜色,默认#fff */
|
|
141
|
+
strokeColor: string;
|
|
142
|
+
/** 网格文本描边宽度,默认2,单位px */
|
|
143
|
+
strokeWidth: number | string;
|
|
144
|
+
/** 网格文本字体,默认Arial, sans-serif */
|
|
145
|
+
fontFamily: string;
|
|
146
|
+
/** 是否开启文本描边,默认true */
|
|
147
|
+
useDevicePixelRatio: boolean;
|
|
148
|
+
};
|
|
149
|
+
/** wind图层配置项 */
|
|
150
|
+
windConfig?: Record<string, any>;
|
|
151
|
+
/** windShaft图层配置项 */
|
|
152
|
+
windShaftConfig?: {
|
|
153
|
+
/** 风杆采样像素步长,默认20,单位px */
|
|
154
|
+
pixelStep?: number | string;
|
|
155
|
+
/** 风杆尺寸,默认18,单位px */
|
|
156
|
+
fontSize?: number | string;
|
|
157
|
+
/** 风杆叠加颜色,默认rgb(255,255,255) */
|
|
158
|
+
color?: string;
|
|
159
|
+
/** 过滤最小风速,默认0.01 */
|
|
160
|
+
minWindSpeed?: number | string;
|
|
161
|
+
/** 风速分级步长,默认2 */
|
|
162
|
+
speedLevelStep?: number | string;
|
|
163
|
+
/** 风速级别上限,默认30 */
|
|
164
|
+
maxLevel?: number | string;
|
|
165
|
+
/** 雪碧图单格尺寸,默认32 */
|
|
166
|
+
spriteCellSize?: number | string;
|
|
167
|
+
/** 图标缩放基准字号,默认32 */
|
|
168
|
+
baseFontSize?: number | string;
|
|
169
|
+
/** 图标Y轴偏移比例,默认0.7 */
|
|
170
|
+
iconYOffsetRatio?: number | string;
|
|
171
|
+
/** 雪碧图第一行最大等级,默认3 */
|
|
172
|
+
firstRowMaxLevel?: number | string;
|
|
173
|
+
/** 雪碧图第一行起始X,默认28 */
|
|
174
|
+
firstRowStartX?: number | string;
|
|
175
|
+
/** 雪碧图第一行Y,默认4 */
|
|
176
|
+
firstRowY?: number | string;
|
|
177
|
+
/** 雪碧图第二行X偏移,默认4 */
|
|
178
|
+
secondRowOffsetX?: number | string;
|
|
179
|
+
/** 雪碧图第二行Y,默认5 */
|
|
180
|
+
secondRowY?: number | string;
|
|
181
|
+
};
|
|
182
|
+
/** 台风路径图层配置 */
|
|
183
|
+
typhoonConfig?: {
|
|
184
|
+
/** TDS fileServer 下的台风 JSON 目录 */
|
|
185
|
+
dataPath?: string;
|
|
186
|
+
/** 只加载指定台风编号;不传则加载列表内全部台风 */
|
|
187
|
+
typhoonNums?: string[];
|
|
188
|
+
/** 优先显示的实况/预报来源 */
|
|
189
|
+
sourcePriority?: string[];
|
|
190
|
+
/** 是否显示预报路径 */
|
|
191
|
+
showForecast?: boolean;
|
|
192
|
+
/** 加载后是否自动缩放到路径范围 */
|
|
193
|
+
fitToExtent?: boolean;
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
interface TimeInfoResult {
|
|
199
|
+
/** 单时次or多时次 */
|
|
200
|
+
type: TimeOrderType;
|
|
201
|
+
/** 数据经纬度四角范围 */
|
|
202
|
+
latLonBox: LatLonBox;
|
|
203
|
+
/** 时间序列数量 */
|
|
204
|
+
npts?: string;
|
|
205
|
+
/** 数据时间间隔 */
|
|
206
|
+
increment?: string;
|
|
207
|
+
/** 请求连接 */
|
|
208
|
+
url: string;
|
|
209
|
+
/** 时间单位(hour | hours | minute) */
|
|
210
|
+
units: string;
|
|
211
|
+
/** 时间序列 */
|
|
212
|
+
timeOrder: TimeOrder[];
|
|
213
|
+
/** 起始时间 */
|
|
214
|
+
startTime: Date;
|
|
215
|
+
/** 结束时间 */
|
|
216
|
+
endTime: Date;
|
|
217
|
+
/** 高度层信息 */
|
|
218
|
+
level?: string[];
|
|
219
|
+
heightAboveGround?: string;
|
|
220
|
+
[key: string]: any;
|
|
221
|
+
}
|
|
222
|
+
}
|