aviation-chart 0.3.26 → 2.0.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 CHANGED
@@ -1,170 +1 @@
1
- # Kunyu Aviation Chart SDK
2
-
3
- A high-performance aviation chart SDK providing complete aeronautical data visualization: FIR/UIR, controlled and restricted airspace, airways, navaids (VOR/NDB), airports and runways, AMM, and terrain — plus business features such as NOTAM, ADS-B, and weather radar. Built with a modular architecture supporting plugins, performance optimization, and unified error handling.
4
-
5
- ## ✨ Features
6
-
7
- - **Aviation data stack**: FIR, controlled/restricted airspace, airways, VOR/NDB, airport runways, AMM, terrain/contours — published per AIRAC period
8
- - **Theme switching**: in-place light/dark recoloring that never covers your overlay layers
9
- - **Business modules**: NOTAM, ADS-B, weather radar, raster layers
10
- - **Performance**: LOD (level-of-detail), lazy layer loading, massive-point clustering, low-zoom style simplification
11
- - **Plugin system**: unified plugin interface with a built-in measurement plugin
12
- - **Unified error handling**: centralized error management, fallback strategies, error statistics
13
-
14
- ## 🚀 Getting Started
15
-
16
- ### Option 1: CDN script (global `navMap`)
17
-
18
- ```html
19
- <!-- latest -->
20
- <script src="https://aips.siniswift.com/sdk/nav-sdk.min.js"></script>
21
- <!-- or pin a version -->
22
- <!-- <script src="https://aips.siniswift.com/sdk/nav-sdk@0.2.0.min.js"></script> -->
23
-
24
- <div id="map" style="width:100%;height:600px;"></div>
25
-
26
- <script>
27
- const sdk = new navMap.MapSDK({
28
- container: 'map',
29
- center: [116.3974, 39.9093],
30
- zoom: 4,
31
- theme: 'light', // 'light' | 'dark'
32
- period: '202606', // AIRAC period; auto-computed if omitted
33
- });
34
- </script>
35
- ```
36
-
37
- > The underlying map engine is bundled into `nav-sdk.min.js` — no extra script needed.
38
-
39
- ### Option 2: npm
40
-
41
- ```bash
42
- npm install aviation-chart
43
- ```
44
-
45
- ```javascript
46
- import { MapSDK, MeasurePlugin } from 'aviation-chart';
47
-
48
- const sdk = new MapSDK({
49
- container: 'map',
50
- center: [116.3974, 39.9093],
51
- zoom: 4,
52
- performance: { lodEnabled: true, clusteringEnabled: true, lazyLoadingEnabled: true },
53
- });
54
- ```
55
-
56
- ## 📚 API Overview
57
-
58
- ### Initialization options
59
-
60
- | Option | Description |
61
- |---|---|
62
- | `container` | Container id or element (required) |
63
- | `center` / `zoom` | Initial center and zoom |
64
- | `theme` | `'light'` / `'dark'` |
65
- | `period` | AIRAC period `YYYYMM` |
66
- | `apiUrl` | Chart data service URL, default `https://aips.siniswift.com` |
67
- | `layers` | Initial layer visibility, e.g. `{ airspace: true, controlled: false, terrain: false }` |
68
- | `performance` | `{ lodEnabled, clusteringEnabled, lazyLoadingEnabled }` |
69
- | `errorHandler` | Custom error handler function |
70
-
71
- ### Layer control
72
-
73
- Layer groups: `airspace` (FIR), `airline` (airways), `controlled`, `restricted`, `vor`, `ndb`, `airport`, `runway`, `adiz`, `waypointOffAirway`, `amm`, `terrain`, `contour`, `background`, `landLayer`, `boundary`.
74
-
75
- ```javascript
76
- // Two equivalent APIs
77
- sdk.setLayerVisible('airspace', true);
78
- sdk.addBuiltInLayer('controlled');
79
- sdk.toggleBuiltInLayer('airline');
80
- sdk.removeBuiltInLayer('restricted');
81
-
82
- // Theme and period
83
- sdk.setTheme('dark');
84
- sdk.setPeriod('202609');
85
-
86
- // LOD
87
- sdk.layerManager.setLODEnabled(true);
88
- ```
89
-
90
- ### Feature drawing (GeoJSON)
91
-
92
- ```javascript
93
- sdk.addPoint([lng, lat], properties, style);
94
- sdk.addLine(coordinates, properties, style);
95
- sdk.addPolygon(coordinates, properties, style);
96
-
97
- // Cluster massive point sets
98
- sdk.geoJSONManager.setClusteringEnabled(true);
99
- ```
100
-
101
- ### Business features
102
-
103
- ```javascript
104
- sdk.notam.open(true); // NOTAM
105
- sdk.adsb.open(); // ADS-B
106
- sdk.api.getRadarData(); // weather radar data
107
- ```
108
-
109
- ### Popup
110
-
111
- ```javascript
112
- const popup = new navMap.Popup()
113
- .setLngLat([lng, lat])
114
- .setHTML('<h3>Title</h3>')
115
- .addTo(sdk.map);
116
- ```
117
-
118
- ### Plugins
119
-
120
- ```javascript
121
- const measure = new navMap.MeasurePlugin();
122
- sdk.use(measure);
123
- measure.enable('distance'); // 'distance' | 'area'
124
- measure.disable();
125
-
126
- const plugin = sdk.getPlugin('measure');
127
- ```
128
-
129
- ### Underlying engine passthrough
130
-
131
- The SDK passes through the full underlying map-engine API — call methods directly on the instance, or access the raw instance via `sdk.map`:
132
-
133
- ```javascript
134
- sdk.flyTo({ center: [lng, lat], zoom: 8 });
135
- sdk.setPaintProperty('airline', 'line-color', '#0057c8');
136
- sdk.queryRenderedFeatures([x, y]);
137
-
138
- const map = sdk.map; // raw map instance
139
- ```
140
-
141
- ### Error & performance
142
-
143
- ```javascript
144
- const sdk = new navMap.MapSDK({
145
- container: 'map',
146
- errorHandler: (error) => console.error(error.code, error.details),
147
- });
148
-
149
- sdk.getErrorStats(); // error statistics
150
- sdk.getPerformanceStats(); // performance statistics
151
- ```
152
-
153
- ## 🔧 Writing a Plugin
154
-
155
- ```javascript
156
- export class MyPlugin {
157
- name = 'my-plugin';
158
- version = '1.0.0';
159
- install(sdk) { /* install logic */ }
160
- uninstall(sdk) { /* uninstall logic */ }
161
- }
162
-
163
- const plugin = new MyPlugin();
164
- sdk.use(plugin);
165
- sdk.pluginManager.hasPlugin('my-plugin');
166
- ```
167
-
168
- ## 📄 License
169
-
170
- MIT License
1
+ ## Kunyu
package/dist/nav-sdk.d.ts CHANGED
@@ -20,7 +20,7 @@ interface GlobalConfig {
20
20
  defaultZoom?: number;
21
21
  };
22
22
  styleConfig?: {
23
- theme?: "light" | "dark";
23
+ theme?: string;
24
24
  language?: "zh-CN" | "en-US";
25
25
  };
26
26
  periodConfig?: {
@@ -424,7 +424,7 @@ interface IMapSDK {
424
424
  setMapStyle(style: string | StyleSpecification, options?: {
425
425
  diff?: boolean;
426
426
  }): Promise<void>;
427
- setTheme(theme: "light" | "dark"): void;
427
+ setTheme(theme: string): void;
428
428
  addPoint(coordinates: [number, number], properties?: Record<string, any>, style?: StyleConfig): string;
429
429
  addLine(coordinates: [number, number][], properties?: Record<string, any>, style?: StyleConfig): string;
430
430
  addPolygon(coordinates: [number, number][][], properties?: Record<string, any>, style?: StyleConfig): string;
@@ -541,7 +541,7 @@ interface MapSDKOptions {
541
541
  enableAIP?: boolean;
542
542
  enableNOTAM?: boolean;
543
543
  enableADSB?: boolean;
544
- theme?: 'light' | 'dark';
544
+ theme?: string;
545
545
  language?: 'zh-CN' | 'en-US';
546
546
  switchDay?: number;
547
547
  graticule?: {
@@ -1005,7 +1005,8 @@ declare class MapSDK implements IMapSDK {
1005
1005
  setMapStyle(style: string | StyleSpecification, options?: {
1006
1006
  diff?: boolean;
1007
1007
  }): Promise<void>;
1008
- setTheme(theme: "light" | "dark"): void;
1008
+ setTheme(theme: string): void;
1009
+ private _resolveThemeId;
1009
1010
  private _themeLayerDefs;
1010
1011
  private _applyThemedProps;
1011
1012
  restoreLandLayer(): void;
@@ -1262,6 +1263,22 @@ declare namespace CHART_THEMES {
1262
1263
  let background_1: string;
1263
1264
  export { background_1 as background };
1264
1265
  }
1266
+ namespace dusk {
1267
+ let id_2: string;
1268
+ export { id_2 as id };
1269
+ let label_2: string;
1270
+ export { label_2 as label };
1271
+ let background_2: string;
1272
+ export { background_2 as background };
1273
+ }
1274
+ namespace foreflight {
1275
+ let id_3: string;
1276
+ export { id_3 as id };
1277
+ let label_3: string;
1278
+ export { label_3 as label };
1279
+ let background_3: string;
1280
+ export { background_3 as background };
1281
+ }
1265
1282
  }
1266
1283
  declare namespace LAYER_GROUPS {
1267
1284
  export let adiz: string[];
@@ -7600,6 +7600,11 @@ async function fetchGzJson(url, headers = {}) {
7600
7600
  //
7601
7601
  // 加主题 = 在 THEME_TOKENS 增加一张 token 表;不再复制整份 build 函数,
7602
7602
  // 彻底消除 light/dark 漂移(历史上 dark 航线消失、6,6 插值等 bug 均源于此)。
7603
+ //
7604
+ // 本次新增两套主题:
7605
+ // dusk 暮光模式 —— 晨昏蒙影时段过渡用,中等亮度,避免日/夜切换的瞳孔冲击
7606
+ // redNight 红光夜视模式 —— 驾驶舱标准红光照明,全色系统一为红色,
7607
+ // 靠明度而非色相区分要素,保护夜间暗适应(视杆细胞)
7603
7608
 
7604
7609
  /**
7605
7610
  * 主题 token 表。每个 key 是一个"随主题变化"的值,值可以是颜色字符串、
@@ -7676,6 +7681,81 @@ const THEME_TOKENS = {
7676
7681
  alHalo: {},
7677
7682
  ndbHalo: { 'text-halo-color': '#0f172a', 'text-halo-width': 1 },
7678
7683
  },
7684
+ // ── 新增:暮光模式(晨昏蒙影 / 日夜切换过渡)───────────────────────────
7685
+ // 设计目标:亮度介于 light 与 dark 之间,避免瞳孔在两个极端间来回收放;
7686
+ // 色相仍按 light 的语义分组(橙=限制区/绿=管制区),但饱和度、对比度降低。
7687
+ dusk: {
7688
+ background: '#1B2838',
7689
+ land: '#22303F',
7690
+ halo: '#16212c',
7691
+ boundaryPattern: 'normal:national-border-dark', // 复用 dark 的深色底图案
7692
+ adizLine: '#c77dff',
7693
+ adizLabel: '#e0aaff',
7694
+ airspaceStroke: '#7fb3d5',
7695
+ restrictedFill: '#e67e22',
7696
+ restrictedStrokeLine: '#e59866',
7697
+ restrictedStroke: '#e59866',
7698
+ controlledStroke: '#52c9a3',
7699
+ controlledFill: '#52c9a3',
7700
+ segment: '#8fa8c7',
7701
+ segmentRemark: '#f4c542',
7702
+ airport: '#7fd1ae',
7703
+ airportText: '#dce9f0',
7704
+ runway: '#7c8ea3',
7705
+ vorDial: '#5dade2',
7706
+ vorNormal: '#5dade2',
7707
+ vor: '#85a9e0',
7708
+ ndbIcon: 'ndb-inway',
7709
+ ndb: '#7ec8e3',
7710
+ waypoint: '#a9c6d8',
7711
+ alBase: '#1B2838', alDist: '#b8c9d9', alRnp: '#f4c542',
7712
+ sideHalo: { 'text-halo-color': '#1B2838', 'text-halo-width': 1 },
7713
+ centerHalo: { 'text-halo-color': '#1B2838', 'text-halo-width': 1.5 },
7714
+ restrictedHalo: { 'text-halo-color': '#1B2838', 'text-halo-width': 1 },
7715
+ controlledHalo: { 'text-halo-color': '#1B2838', 'text-halo-width': 1.5 },
7716
+ radialHalo: { 'text-halo-color': '#1B2838', 'text-halo-width': 1 },
7717
+ runwayHalo: { 'text-halo-color': '#1B2838', 'text-halo-width': 1 },
7718
+ alHalo: { 'text-halo-color': '#1B2838', 'text-halo-width': 0.5 },
7719
+ ndbHalo: { 'text-halo-color': '#1B2838', 'text-halo-width': 1 },
7720
+ },
7721
+ // ── 新增:ForeFlight 风格(致敬,非像素级复刻,官方未公开具体色值)──────
7722
+ // 设计目标:暖米黄底图 + 扁平化(去地形纹理)+ 传统航图色彩语义
7723
+ // (蓝=管制空域,洋红=非管制机场,棕=NDB,橙=限制区)+ 现代无衬线字体,
7724
+ // 整体比三色 VFR 纸图更"干净",符合 ForeFlight 网页版/Light 主题的视觉语言。
7725
+ foreflight: {
7726
+ background: '#F2EFE6',
7727
+ land: '#F7F5EC',
7728
+ halo: '#F2EFE6',
7729
+ boundaryPattern: 'normal:national-border',
7730
+ adizLine: '#8e44ad',
7731
+ adizLabel: '#8e44ad',
7732
+ airspaceStroke: '#2E5C8A',
7733
+ restrictedFill: '#E8A33D',
7734
+ restrictedStrokeLine: '#C0392B',
7735
+ restrictedStroke: '#C0392B',
7736
+ controlledStroke: '#2E5C8A',
7737
+ controlledFill: '#2E5C8A',
7738
+ segment: '#34495E',
7739
+ segmentRemark: '#D68910',
7740
+ airport: '#B03060',
7741
+ airportText: '#1B2631',
7742
+ runway: '#4A4A4A',
7743
+ vorDial: '#2E5C8A',
7744
+ vorNormal: '#2E5C8A',
7745
+ vor: '#154360',
7746
+ ndbIcon: 'v2:ndb-normal',
7747
+ ndb: '#8B5A2B',
7748
+ waypoint: '#2C3E50',
7749
+ alBase: '#F2EFE6', alDist: '#5D6D7E', alRnp: '#D68910',
7750
+ sideHalo: { 'text-halo-color': '#F2EFE6', 'text-halo-width': 1 },
7751
+ centerHalo: { 'text-halo-color': '#F2EFE6', 'text-halo-width': 1.5 },
7752
+ restrictedHalo: { 'text-halo-color': '#F2EFE6', 'text-halo-width': 1 },
7753
+ controlledHalo: { 'text-halo-color': '#F2EFE6', 'text-halo-width': 1.5 },
7754
+ radialHalo: { 'text-halo-color': '#F2EFE6', 'text-halo-width': 1 },
7755
+ runwayHalo: { 'text-halo-color': '#F2EFE6', 'text-halo-width': 1 },
7756
+ alHalo: { 'text-halo-color': '#F2EFE6', 'text-halo-width': 0.5 },
7757
+ ndbHalo: { 'text-halo-color': '#F2EFE6', 'text-halo-width': 1 },
7758
+ },
7679
7759
  };
7680
7760
 
7681
7761
  function buildLayers(themeId = 'light') {
@@ -7988,6 +8068,8 @@ function buildLayers(themeId = 'light') {
7988
8068
  const CHART_THEMES = {
7989
8069
  light: { id: 'light', label: '日间', background: '#EAF2F8' },
7990
8070
  dark: { id: 'dark', label: '夜间', background: '#000000' },
8071
+ dusk: { id: 'dusk', label: '暮光', background: '#1B2838' },
8072
+ foreflight: { id: 'foreflight', label: 'ForeFlight 风格', background: '#F2EFE6' },
7991
8073
  };
7992
8074
 
7993
8075
  // ── Layer groups & labels (theme-independent) ────────────────────────────────
@@ -8098,7 +8180,7 @@ class MapSDK {
8098
8180
  this._baseUrl = options.staticUrl || "https://aips.siniswift.com";
8099
8181
  this._chartApiUrl = (options.apiUrl || DEFAULT_CHART_API_URL).replace(/\/$/, "");
8100
8182
  this._apiVersion = options.apiVersion || undefined;
8101
- const themeId = options.theme === "dark" ? "dark" : "light";
8183
+ const themeId = this._resolveThemeId(options.theme);
8102
8184
  const themeConfig = CHART_THEMES[themeId] ?? CHART_THEMES.light;
8103
8185
  const style = options.style ??
8104
8186
  getAviationBaseStyle({
@@ -8254,7 +8336,7 @@ class MapSDK {
8254
8336
  if (!this.map.getSource("navdata")) {
8255
8337
  this.map.addSource("navdata", getNavdataSource(this._chartApiUrl, period, this._apiVersion));
8256
8338
  }
8257
- const themeId = this.initialOptions.theme === "dark" ? "dark" : "light";
8339
+ const themeId = this._resolveThemeId(this.initialOptions.theme);
8258
8340
  for (const layer of buildLayers(themeId)) {
8259
8341
  if (this.map.getLayer(layer.id))
8260
8342
  continue;
@@ -8395,8 +8477,8 @@ class MapSDK {
8395
8477
  });
8396
8478
  }
8397
8479
  setTheme(theme) {
8398
- const prevTheme = globalConfig.getConfig().styleConfig?.theme ||
8399
- "light";
8480
+ theme = this._resolveThemeId(theme);
8481
+ const prevTheme = this._resolveThemeId(globalConfig.getConfig().styleConfig?.theme);
8400
8482
  if (prevTheme === theme)
8401
8483
  return;
8402
8484
  globalConfig.updateConfigItem("styleConfig", {
@@ -8412,6 +8494,9 @@ class MapSDK {
8412
8494
  this._applyThemedProps(id, prevDefs[id], nextDefs[id]);
8413
8495
  }
8414
8496
  }
8497
+ _resolveThemeId(theme) {
8498
+ return theme && CHART_THEMES[theme] ? theme : "light";
8499
+ }
8415
8500
  _themeLayerDefs(theme) {
8416
8501
  const themeConfig = CHART_THEMES[theme] ?? CHART_THEMES.light;
8417
8502
  const defs = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aviation-chart",
3
- "version": "0.3.26",
3
+ "version": "2.0.1",
4
4
  "description": "KunYu aviation map SDK",
5
5
  "main": "dist/nav-sdk.esm.js",
6
6
  "module": "dist/nav-sdk.esm.js",