aviation-chart 0.3.2 → 0.3.4
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/nav-sdk.d.ts +38 -1
- package/dist/nav-sdk.esm.js +101 -14
- package/package.json +1 -1
package/dist/nav-sdk.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { Geoman } from '@geoman-io/maplibre-geoman-free';
|
|
|
8
8
|
interface GlobalConfig {
|
|
9
9
|
apiKey?: string;
|
|
10
10
|
baseUrl?: string;
|
|
11
|
+
apiUrl?: string;
|
|
11
12
|
version?: string;
|
|
12
13
|
period?: string;
|
|
13
14
|
chartConfig?: {
|
|
@@ -799,6 +800,39 @@ declare class RasterManager {
|
|
|
799
800
|
removeRasterLayer(layerId: string, sourceId: string): void;
|
|
800
801
|
}
|
|
801
802
|
|
|
803
|
+
type FeatureType = "airport" | "waypoint" | "vor" | "ndb" | "airspace" | "restricted" | "controlled" | "airway";
|
|
804
|
+
interface SearchParams {
|
|
805
|
+
q: string;
|
|
806
|
+
type?: FeatureType;
|
|
807
|
+
period?: string;
|
|
808
|
+
limit?: number;
|
|
809
|
+
signal?: AbortSignal;
|
|
810
|
+
}
|
|
811
|
+
interface SearchResultItem {
|
|
812
|
+
type: FeatureType;
|
|
813
|
+
id: string;
|
|
814
|
+
code: string;
|
|
815
|
+
name?: string;
|
|
816
|
+
name_chn?: string;
|
|
817
|
+
}
|
|
818
|
+
interface GeometryParams {
|
|
819
|
+
type: FeatureType;
|
|
820
|
+
id: string;
|
|
821
|
+
period?: string;
|
|
822
|
+
signal?: AbortSignal;
|
|
823
|
+
}
|
|
824
|
+
interface GeometryFeature {
|
|
825
|
+
type: "Feature";
|
|
826
|
+
geometry: {
|
|
827
|
+
type: "Point" | "LineString" | "Polygon" | "MultiPolygon" | "MultiLineString" | "MultiPoint";
|
|
828
|
+
coordinates: any;
|
|
829
|
+
};
|
|
830
|
+
properties: Record<string, any>;
|
|
831
|
+
}
|
|
832
|
+
declare function searchFeatures(baseUrl: string, apiKey: string | undefined, params: SearchParams): Promise<SearchResultItem[]>;
|
|
833
|
+
declare function getFeatureGeometry(baseUrl: string, apiKey: string | undefined, params: GeometryParams): Promise<GeometryFeature>;
|
|
834
|
+
declare function getPeriods(baseUrl: string, apiKey?: string, signal?: AbortSignal): Promise<string[]>;
|
|
835
|
+
|
|
802
836
|
interface SelectFeatureOptions {
|
|
803
837
|
isHighlight: boolean;
|
|
804
838
|
highlightColor: string;
|
|
@@ -1005,6 +1039,9 @@ declare class MapSDK implements IMapSDK {
|
|
|
1005
1039
|
setPeriod(period: string): void;
|
|
1006
1040
|
getPeriod(): string | undefined;
|
|
1007
1041
|
generateCurrentPeriod(): Promise<string>;
|
|
1042
|
+
search(params: SearchParams): Promise<SearchResultItem[]>;
|
|
1043
|
+
getGeometry(params: GeometryParams): Promise<GeometryFeature>;
|
|
1044
|
+
getPeriods(signal?: AbortSignal): Promise<string[]>;
|
|
1008
1045
|
showGraticule(): void;
|
|
1009
1046
|
hideGraticule(): void;
|
|
1010
1047
|
toggleGraticule(): void;
|
|
@@ -3544,4 +3581,4 @@ declare function buildLayersDark(): ({
|
|
|
3544
3581
|
maxzoom?: never;
|
|
3545
3582
|
})[];
|
|
3546
3583
|
|
|
3547
|
-
export { API, MapSDK as AviationChart, BuiltInLayer, CHART_THEMES, Circle, CircleOptions, ClusteringConfig, DEFAULT_LAYER_VISIBILITY, DrawPlugin, EnhancedMarker, EnhancedPolygon, ErrorHandler, ErrorManager, EventListener, GROUP_ALIASES, GeoJSONCollection, GeoJSONFeature, GeoJSONManager, GlobalConfigManager, HookCallback, HookContext, HookRegistry, IGeoJSONManager, ILayerManager, IMapSDK, IPlugin, LAYER_GROUPS, LAYER_LABELS, LODConfig, LayerConfig, LayerManager, LineType, MapEvent, MapSDK, MapSDKOptions, MarkerOptions, MeasurePlugin, NOTAM, PerformanceManager, PluginManager, PolygonOptions, Polyline, PolylineOptions, SDKError, StrokeLineType, StyleConfig, TYPEMAP, Text, TextOptions, WindFrame, WindManager, WindOptions, MapSDK as default, globalConfig };
|
|
3584
|
+
export { API, MapSDK as AviationChart, BuiltInLayer, CHART_THEMES, Circle, CircleOptions, ClusteringConfig, DEFAULT_LAYER_VISIBILITY, DrawPlugin, EnhancedMarker, EnhancedPolygon, ErrorHandler, ErrorManager, EventListener, FeatureType, GROUP_ALIASES, GeoJSONCollection, GeoJSONFeature, GeoJSONManager, GeometryFeature, GeometryParams, GlobalConfigManager, HookCallback, HookContext, HookRegistry, IGeoJSONManager, ILayerManager, IMapSDK, IPlugin, LAYER_GROUPS, LAYER_LABELS, LODConfig, LayerConfig, LayerManager, LineType, MapEvent, MapSDK, MapSDKOptions, MarkerOptions, MeasurePlugin, NOTAM, PerformanceManager, PluginManager, PolygonOptions, Polyline, PolylineOptions, SDKError, SearchParams, SearchResultItem, StrokeLineType, StyleConfig, TYPEMAP, Text, TextOptions, WindFrame, WindManager, WindOptions, MapSDK as default, getFeatureGeometry, getPeriods, globalConfig, searchFeatures };
|
package/dist/nav-sdk.esm.js
CHANGED
|
@@ -3259,12 +3259,6 @@ class ClickManager {
|
|
|
3259
3259
|
}
|
|
3260
3260
|
}
|
|
3261
3261
|
|
|
3262
|
-
let _api = null;
|
|
3263
|
-
function getApi() {
|
|
3264
|
-
if (!_api)
|
|
3265
|
-
_api = new API();
|
|
3266
|
-
return _api;
|
|
3267
|
-
}
|
|
3268
3262
|
class GlobalConfigManager {
|
|
3269
3263
|
constructor() {
|
|
3270
3264
|
this.config = {};
|
|
@@ -3463,11 +3457,20 @@ class GlobalConfigManager {
|
|
|
3463
3457
|
return this.config.period;
|
|
3464
3458
|
}
|
|
3465
3459
|
async generateCurrentPeriod() {
|
|
3466
|
-
const
|
|
3467
|
-
const
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3460
|
+
const base = (this.config.apiUrl || "https://aips.siniswift.com").replace(/\/$/, "");
|
|
3461
|
+
const headers = this.config.apiKey
|
|
3462
|
+
? { "X-Api-Key": this.config.apiKey }
|
|
3463
|
+
: {};
|
|
3464
|
+
const response = await fetch(`${base}/api/periods`, { headers });
|
|
3465
|
+
if (!response.ok) {
|
|
3466
|
+
throw new Error(`获取期数失败(${response.status})`);
|
|
3467
|
+
}
|
|
3468
|
+
const { periods } = (await response.json());
|
|
3469
|
+
const current = periods?.[0];
|
|
3470
|
+
if (!current) {
|
|
3471
|
+
throw new Error("后端未返回任何期数");
|
|
3472
|
+
}
|
|
3473
|
+
return current;
|
|
3471
3474
|
}
|
|
3472
3475
|
setMapReinitCallback(callback) {
|
|
3473
3476
|
this.mapReinitCallback = callback;
|
|
@@ -4278,6 +4281,69 @@ class GraticuleManager {
|
|
|
4278
4281
|
}
|
|
4279
4282
|
}
|
|
4280
4283
|
|
|
4284
|
+
function authHeaders(apiKey) {
|
|
4285
|
+
return apiKey ? { "X-Api-Key": apiKey } : {};
|
|
4286
|
+
}
|
|
4287
|
+
async function toJSON(res) {
|
|
4288
|
+
if (!res.ok) {
|
|
4289
|
+
let detail = "";
|
|
4290
|
+
try {
|
|
4291
|
+
detail = await res.text();
|
|
4292
|
+
}
|
|
4293
|
+
catch {
|
|
4294
|
+
}
|
|
4295
|
+
const msg = res.status === 403
|
|
4296
|
+
? "搜索接口鉴权失败(403):请检查初始化传入的 apiKey 是否正确"
|
|
4297
|
+
: `请求失败(${res.status})${detail ? ": " + detail.trim() : ""}`;
|
|
4298
|
+
throw new Error(msg);
|
|
4299
|
+
}
|
|
4300
|
+
return res.json();
|
|
4301
|
+
}
|
|
4302
|
+
async function searchFeatures(baseUrl, apiKey, params) {
|
|
4303
|
+
const { q, type, period, limit, signal } = params;
|
|
4304
|
+
if (!q || !q.trim()) {
|
|
4305
|
+
throw new Error("search: q 参数必填");
|
|
4306
|
+
}
|
|
4307
|
+
const qs = new URLSearchParams({ q: q.trim() });
|
|
4308
|
+
if (type)
|
|
4309
|
+
qs.set("type", type);
|
|
4310
|
+
if (period)
|
|
4311
|
+
qs.set("period", period);
|
|
4312
|
+
if (limit != null)
|
|
4313
|
+
qs.set("limit", String(limit));
|
|
4314
|
+
const res = await fetch(`${baseUrl}/api/search?${qs.toString()}`, {
|
|
4315
|
+
method: "GET",
|
|
4316
|
+
headers: authHeaders(apiKey),
|
|
4317
|
+
...(signal ? { signal } : {}),
|
|
4318
|
+
});
|
|
4319
|
+
const data = await toJSON(res);
|
|
4320
|
+
return data.results ?? [];
|
|
4321
|
+
}
|
|
4322
|
+
async function getFeatureGeometry(baseUrl, apiKey, params) {
|
|
4323
|
+
const { type, id, period, signal } = params;
|
|
4324
|
+
if (!type || !id) {
|
|
4325
|
+
throw new Error("getGeometry: type 和 id 参数必填");
|
|
4326
|
+
}
|
|
4327
|
+
const qs = new URLSearchParams({ type, id });
|
|
4328
|
+
if (period)
|
|
4329
|
+
qs.set("period", period);
|
|
4330
|
+
const res = await fetch(`${baseUrl}/api/geometry?${qs.toString()}`, {
|
|
4331
|
+
method: "GET",
|
|
4332
|
+
headers: authHeaders(apiKey),
|
|
4333
|
+
...(signal ? { signal } : {}),
|
|
4334
|
+
});
|
|
4335
|
+
return toJSON(res);
|
|
4336
|
+
}
|
|
4337
|
+
async function getPeriods(baseUrl, apiKey, signal) {
|
|
4338
|
+
const res = await fetch(`${baseUrl}/api/periods`, {
|
|
4339
|
+
method: "GET",
|
|
4340
|
+
headers: authHeaders(apiKey),
|
|
4341
|
+
...(signal ? { signal } : {}),
|
|
4342
|
+
});
|
|
4343
|
+
const data = await toJSON(res);
|
|
4344
|
+
return data.periods ?? [];
|
|
4345
|
+
}
|
|
4346
|
+
|
|
4281
4347
|
function identity(x) {
|
|
4282
4348
|
return x;
|
|
4283
4349
|
}
|
|
@@ -5433,7 +5499,7 @@ function buildLayersLight() {
|
|
|
5433
5499
|
'source-layer': 'vor',
|
|
5434
5500
|
minzoom: 8,
|
|
5435
5501
|
layout: {
|
|
5436
|
-
"icon-image": "vor_dial",
|
|
5502
|
+
"icon-image": "vor:vor_dial",
|
|
5437
5503
|
"icon-size": ["interpolate", ["linear"], ["zoom"], 8, 0.072, 10, 0.072, 11, 0.126, 12, 0.180, 13, 0.234, 14, 0.288, 15, 0.342, 16, 0.396, 17, 0.450, 22, 0.450],
|
|
5438
5504
|
"icon-rotate": ["to-number", ["get", "VAL_MAG_VAR"], 0],
|
|
5439
5505
|
"icon-rotation-alignment": "map",
|
|
@@ -5927,7 +5993,7 @@ function buildLayersDark() {
|
|
|
5927
5993
|
},
|
|
5928
5994
|
{
|
|
5929
5995
|
id: 'vor_icon_dial', type: 'symbol', source: sourceId, 'source-layer': 'vor',
|
|
5930
|
-
layout: { "icon-image": "vor_dial", "icon-size": ["interpolate", ["linear"], ["zoom"], 5, 0.072, 10, 0.072, 11, 0.126, 12, 0.180, 13, 0.234, 14, 0.288, 15, 0.342, 16, 0.396, 17, 0.450, 22, 0.450], "icon-rotate": ["to-number", ["get", "VAL_MAG_VAR"], 0], "icon-rotation-alignment": "map", "symbol-z-order": "viewport-y", "text-letter-spacing": 0.05, "text-optional": true, "icon-allow-overlap": true, "visibility": "none" },
|
|
5996
|
+
layout: { "icon-image": "vor:vor_dial", "icon-size": ["interpolate", ["linear"], ["zoom"], 5, 0.072, 10, 0.072, 11, 0.126, 12, 0.180, 13, 0.234, 14, 0.288, 15, 0.342, 16, 0.396, 17, 0.450, 22, 0.450], "icon-rotate": ["to-number", ["get", "VAL_MAG_VAR"], 0], "icon-rotation-alignment": "map", "symbol-z-order": "viewport-y", "text-letter-spacing": 0.05, "text-optional": true, "icon-allow-overlap": true, "visibility": "none" },
|
|
5931
5997
|
paint: { "icon-color": "#38bdf8" }
|
|
5932
5998
|
},
|
|
5933
5999
|
{
|
|
@@ -6554,6 +6620,26 @@ class MapSDK {
|
|
|
6554
6620
|
async generateCurrentPeriod() {
|
|
6555
6621
|
return await this.globalConfig.generateCurrentPeriod();
|
|
6556
6622
|
}
|
|
6623
|
+
search(params) {
|
|
6624
|
+
const apiKey = this.globalConfig.getConfig().apiKey;
|
|
6625
|
+
const period = params.period ?? this.getPeriod();
|
|
6626
|
+
return searchFeatures(this._chartApiUrl, apiKey, {
|
|
6627
|
+
...params,
|
|
6628
|
+
...(period ? { period } : {}),
|
|
6629
|
+
});
|
|
6630
|
+
}
|
|
6631
|
+
getGeometry(params) {
|
|
6632
|
+
const apiKey = this.globalConfig.getConfig().apiKey;
|
|
6633
|
+
const period = params.period ?? this.getPeriod();
|
|
6634
|
+
return getFeatureGeometry(this._chartApiUrl, apiKey, {
|
|
6635
|
+
...params,
|
|
6636
|
+
...(period ? { period } : {}),
|
|
6637
|
+
});
|
|
6638
|
+
}
|
|
6639
|
+
getPeriods(signal) {
|
|
6640
|
+
const apiKey = this.globalConfig.getConfig().apiKey;
|
|
6641
|
+
return getPeriods(this._chartApiUrl, apiKey, signal);
|
|
6642
|
+
}
|
|
6557
6643
|
showGraticule() {
|
|
6558
6644
|
this.graticule?.show();
|
|
6559
6645
|
}
|
|
@@ -6635,6 +6721,7 @@ class MapSDK {
|
|
|
6635
6721
|
config.apiKey = options.apiKey;
|
|
6636
6722
|
if (options.baseUrl)
|
|
6637
6723
|
config.baseUrl = options.baseUrl;
|
|
6724
|
+
config.apiUrl = this._chartApiUrl;
|
|
6638
6725
|
if (options.period)
|
|
6639
6726
|
config.period = options.period;
|
|
6640
6727
|
globalConfig.setConfig(config);
|
|
@@ -28287,4 +28374,4 @@ var LngLat = _mlGlExports.LngLat;
|
|
|
28287
28374
|
var LngLatBounds = _mlGlExports.LngLatBounds;
|
|
28288
28375
|
var Marker = _mlGlExports.Marker;
|
|
28289
28376
|
var Popup = _mlGlExports.Popup;
|
|
28290
|
-
export { API, MapSDK as AviationChart, CHART_THEMES, Circle, DEFAULT_LAYER_VISIBILITY, DrawPlugin, EnhancedMarker, EnhancedPolygon, ErrorManager, GROUP_ALIASES, GeoJSONManager, LAYER_GROUPS, LAYER_LABELS, LayerManager, LngLat, LngLatBounds, _mlGl as MapEngine, MapSDK, Marker, MeasurePlugin, NOTAM, PerformanceManager, PluginManager, Polyline, Popup, TYPEMAP, Text$1 as Text, WindManager, MapSDK as default, globalConfig };
|
|
28377
|
+
export { API, MapSDK as AviationChart, CHART_THEMES, Circle, DEFAULT_LAYER_VISIBILITY, DrawPlugin, EnhancedMarker, EnhancedPolygon, ErrorManager, GROUP_ALIASES, GeoJSONManager, LAYER_GROUPS, LAYER_LABELS, LayerManager, LngLat, LngLatBounds, _mlGl as MapEngine, MapSDK, Marker, MeasurePlugin, NOTAM, PerformanceManager, PluginManager, Polyline, Popup, TYPEMAP, Text$1 as Text, WindManager, MapSDK as default, getFeatureGeometry, getPeriods, globalConfig, searchFeatures };
|