@angular-helpers/openlayers 0.4.0 → 0.5.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.
@@ -1,78 +1,8 @@
1
- import { Coordinate, Feature, OlFeature } from '@angular-helpers/openlayers/core';
2
1
  import * as i0 from '@angular/core';
2
+ import { Coordinate, EllipseConfig, Feature, SectorConfig, DonutConfig, OlFeature } from '@angular-helpers/openlayers/core';
3
+ import { Style } from 'ol/style';
4
+ import { Feature as Feature$1 } from 'ol';
3
5
 
4
- /**
5
- * Configuration for an ellipse polygon centered at `center`.
6
- * Coordinates are emitted in EPSG:4326 (lon/lat) using a local tangent-plane
7
- * approximation; accuracy degrades for radii > ~100 km or near the poles.
8
- */
9
- interface EllipseConfig {
10
- /** Ellipse center as `[lon, lat]` in EPSG:4326. */
11
- center: Coordinate;
12
- /** Semi-major axis in meters. Must be > 0. */
13
- semiMajor: number;
14
- /** Semi-minor axis in meters. Must be > 0. */
15
- semiMinor: number;
16
- /**
17
- * Rotation in radians, counter-clockwise from East. Default: 0
18
- * (semi-major axis points East).
19
- */
20
- rotation?: number;
21
- /**
22
- * Number of vertices used to approximate the ellipse. Default: 64.
23
- * Minimum: 8.
24
- */
25
- segments?: number;
26
- /** Custom feature properties to attach to the output feature. */
27
- properties?: Record<string, unknown>;
28
- }
29
- /**
30
- * Configuration for a circular sector (pie-slice) polygon.
31
- * Same projection caveats as `EllipseConfig`.
32
- */
33
- interface SectorConfig {
34
- /** Sector apex / center as `[lon, lat]` in EPSG:4326. */
35
- center: Coordinate;
36
- /** Sector radius in meters. Must be > 0. */
37
- radius: number;
38
- /** Start angle in radians (0 = East, CCW positive). */
39
- startAngle: number;
40
- /**
41
- * End angle in radians. Must satisfy `startAngle < endAngle <= startAngle + 2π`.
42
- */
43
- endAngle: number;
44
- /**
45
- * Number of vertices along the arc. Default: 32. Minimum: 4. The output
46
- * polygon has `segments + 3` vertices (apex + arc + apex closer).
47
- */
48
- segments?: number;
49
- /** Custom feature properties to attach to the output feature. */
50
- properties?: Record<string, unknown>;
51
- }
52
- /**
53
- * Configuration for a donut (annular ring) polygon — a disk with a
54
- * concentric circular hole. Useful for range rings, exclusion zones,
55
- * and similar GIS military primitives.
56
- *
57
- * The output `Feature<Polygon>` has TWO rings: an outer ring (CCW) and
58
- * an inner ring (CW per the GeoJSON right-hand rule), so renderers that
59
- * follow the spec fill only the band between the radii.
60
- */
61
- interface DonutConfig {
62
- /** Donut center as `[lon, lat]` in EPSG:4326. */
63
- center: Coordinate;
64
- /** Outer radius in meters. Must be > `innerRadius`. */
65
- outerRadius: number;
66
- /** Inner radius in meters. Must be > 0 and < `outerRadius`. */
67
- innerRadius: number;
68
- /**
69
- * Number of vertices per ring. Default: 64. Minimum: 8. Both rings use
70
- * the same segment count.
71
- */
72
- segments?: number;
73
- /** Custom feature properties to attach to the output feature. */
74
- properties?: Record<string, unknown>;
75
- }
76
6
  /**
77
7
  * Subset of `milsymbol`'s `SymbolOptions` exposed by this package.
78
8
  * `sidc` is the only required field; everything else is optional and
@@ -124,13 +54,20 @@ interface MilSymbolStyleResult {
124
54
  * Service exposing geometry helpers and MIL-STD-2525 symbology rendering.
125
55
  *
126
56
  * - `createEllipse`, `createSector`, `createDonut` are **pure math** and
127
- * have no runtime dependencies beyond the bundled types.
128
- * - `createMilSymbol` uses the milsymbol library via dynamic ESM import.
57
+ * delegate to {@link OlGeometryService} in core.
58
+ * - `createMilSymbol` uses the milsymbol library via Angular resource loading.
129
59
  */
130
60
  declare class OlMilitaryService {
131
61
  private idCounter;
132
- private mlLoader;
133
- private msModule;
62
+ private geometryService;
63
+ /**
64
+ * Resource managing the lazy-loading of the milsymbol library.
65
+ * Angular resource provides native signals for value, loading state, and errors.
66
+ */
67
+ private readonly msResource;
68
+ /** Signal indicating if the milsymbol library is currently being loaded. */
69
+ readonly isLoading: i0.Signal<boolean>;
70
+ constructor();
134
71
  /**
135
72
  * Build a `Feature<Polygon>` approximating an ellipse centered at
136
73
  * `config.center`. See {@link EllipseConfig} for parameter semantics.
@@ -142,46 +79,99 @@ declare class OlMilitaryService {
142
79
  */
143
80
  createSector(config: SectorConfig): Feature;
144
81
  /**
145
- * Build a `Feature<Polygon>` for a donut (annular ring). The output has
146
- * two rings: an outer ring wound counter-clockwise and an inner ring
147
- * wound clockwise so the GeoJSON right-hand rule renders the hole.
82
+ * Build a `Feature<Polygon>` for a donut (annular ring).
148
83
  */
149
84
  createDonut(config: DonutConfig): Feature;
150
85
  /**
151
- * Pre-load the optional `milsymbol` peer dependency so subsequent calls
152
- * to `createMilSymbol` / `createMilSymbolSync` resolve immediately.
153
- * Idempotent multiple calls share the same promise.
86
+ * Pre-load the optional `milsymbol` peer dependency.
87
+ * Since resource() starts loading immediately, this simply returns a promise
88
+ * that resolves when the resource is ready.
154
89
  */
155
90
  preloadMilsymbol(): Promise<void>;
156
91
  /**
157
92
  * Build a MIL-STD-2525 symbol feature asynchronously.
158
- * Lazy-loads `milsymbol` on the first call.
93
+ * Waits for the milsymbol resource to resolve.
159
94
  */
160
95
  createMilSymbol(config: MilSymbolConfig): Promise<Feature>;
161
96
  /**
162
97
  * Build a MIL-STD-2525 symbol feature synchronously.
163
- * Throws if `milsymbol` has not been preloaded via `preloadMilsymbol()`
164
- * or a previous `createMilSymbol()` call.
98
+ * Throws if `milsymbol` resource is not ready.
165
99
  */
166
100
  createMilSymbolSync(config: MilSymbolConfig): Feature;
167
- /**
168
- * Project an `(dx, dy)` meter offset from `center` to lon/lat using a
169
- * local tangent-plane (equirectangular) approximation. Acceptable for
170
- * the radii typical in military symbology (<100 km from center).
171
- */
172
- private offsetMetersToLonLat;
173
101
  private nextId;
174
102
  private buildSymbolFeature;
175
103
  private symbolToStyleResult;
176
104
  private encodeBase64Utf8;
105
+ /**
106
+ * Generates a canvas and anchor for a MIL-STD-2525 symbol.
107
+ * Requires milsymbol to be loaded (synchronous).
108
+ */
109
+ createUnitStyle(sidc: string, selected?: boolean, size?: number): {
110
+ image: {
111
+ img: HTMLCanvasElement;
112
+ size: [number, number];
113
+ anchor: [number, number];
114
+ };
115
+ zIndex: number;
116
+ } | null;
177
117
  private assertSidc;
178
118
  private assertBrowser;
179
119
  static ɵfac: i0.ɵɵFactoryDeclaration<OlMilitaryService, never>;
180
120
  static ɵprov: i0.ɵɵInjectableDeclaration<OlMilitaryService>;
181
121
  }
182
122
 
123
+ /**
124
+ * Service providing styles and geometry generators for military tactical graphics
125
+ * such as battle fronts, axes of attack, and boundaries.
126
+ *
127
+ * NOTE: For point symbols (units), it delegates to {@link OlMilitaryService}
128
+ * for lazy-loading `milsymbol`.
129
+ */
130
+ declare class OlTacticalGraphicsService {
131
+ private idCounter;
132
+ private militaryService;
133
+ /**
134
+ * Creates a LineString feature representing a battle front.
135
+ */
136
+ createFrontLine(coordinates: Coordinate[], direction?: 'friendly' | 'hostile'): Feature;
137
+ /**
138
+ * Creates a LineString feature representing an attack arrow.
139
+ */
140
+ createAttackArrow(coordinates: Coordinate[], direction?: 'friendly' | 'hostile'): Feature;
141
+ /**
142
+ * Creates a Polygon feature representing a control zone.
143
+ */
144
+ createControlZone(coordinates: Coordinate[][], direction?: 'friendly' | 'hostile'): Feature;
145
+ /**
146
+ * Creates a Point feature representing a military unit.
147
+ * @param sidc - Symbol Identification Code (MIL-STD-2525 / APP-6)
148
+ */
149
+ createUnit(coordinate: Coordinate, sidc: string, name: string): Feature;
150
+ private nextId;
151
+ /**
152
+ * Style for Troop Units using milsymbol.
153
+ * NOTE: Requires milsymbol to be pre-loaded via OlMilitaryService.
154
+ */
155
+ createUnitStyle(sidc: string, selected?: boolean): Style | null;
156
+ /**
157
+ * Style for Battle Fronts (Complex LineString with teeth).
158
+ */
159
+ createFrontLineStyle(color: string, direction?: 'friendly' | 'hostile'): (feature: Feature$1, resolution: number) => Style[];
160
+ /**
161
+ * Style for Troop Movements (Arrows).
162
+ */
163
+ createAttackArrowStyle(color: string): (feature: Feature$1) => Style[];
164
+ /**
165
+ * Style for Control Zones (Polygons).
166
+ */
167
+ createZoneStyle(color: string, opacity?: number): Style;
168
+ private hexToRgba;
169
+ static ɵfac: i0.ɵɵFactoryDeclaration<OlTacticalGraphicsService, never>;
170
+ static ɵprov: i0.ɵɵInjectableDeclaration<OlTacticalGraphicsService>;
171
+ }
172
+
183
173
  declare function withMilitary(): OlFeature<'military'>;
184
174
  declare function provideMilitary(): OlFeature<'military'>;
185
175
 
186
- export { OlMilitaryService, provideMilitary, withMilitary };
187
- export type { DonutConfig, EllipseConfig, MilSymbolConfig, MilSymbolStyleResult, SectorConfig };
176
+ export { OlMilitaryService, OlTacticalGraphicsService, provideMilitary, withMilitary };
177
+ export type { MilSymbolConfig, MilSymbolStyleResult };