ofs-object 0.1.4 → 0.1.6

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
@@ -302,6 +302,10 @@ initMap();
302
302
  </script>
303
303
  ```
304
304
 
305
+ > `mount()` ตกแต่งหน้าตาของ console อย่างเดียว **ไม่จัดตำแหน่งให้** — วาง element `console-mount` ตาม layout
306
+ > ของหน้าเอง หรือใส่ class `ofs-console-floating` ให้ลอยชิดล่างของ parent ที่ `position: relative`
307
+ > (ก่อน 0.1.6 ไลบรารีบังคับ `position: absolute; left: 80px; right: 420px` ซึ่งเป็นขนาดของ playground)
308
+
305
309
  ---
306
310
 
307
311
  ### React
package/dist/index.d.ts CHANGED
@@ -364,6 +364,19 @@ export declare abstract class BaseGLAdapter implements IMapAdapter {
364
364
  */
365
365
  protected listen(event: string, handler: (e: any) => void): void;
366
366
  protected setupMapEventListeners(): void;
367
+ /** undefined = not worked out yet for the current style */
368
+ private styleFontCache;
369
+ /**
370
+ * Font for text when the basemap names none - a satellite or OSM raster basemap has no labels to
371
+ * read one from. It must exist on the style's glyph server. null leaves the engine default
372
+ * ("Open Sans Regular"), which many glyph servers do not have.
373
+ */
374
+ private fallbackFont;
375
+ /** Set before `init()` / `attach()` to apply everywhere; set later, labels already drawn are redone */
376
+ setFallbackFont(font: string[] | null): void;
377
+ /** The basemap's own label font; else the fallback font; else null */
378
+ getStyleFont(): string[] | null;
379
+ private readStyleFont;
367
380
  getRawMap<T = any>(): T;
368
381
  /**
369
382
  * Take every source and layer this adapter added off a map it does not own, so the host is
@@ -406,27 +419,18 @@ export declare function bulgePoints(p1: Position, p2: Position, bulge: number, m
406
419
  export declare function bulgeThroughPoint(start: Coordinate, through: Coordinate, end: Coordinate, projection?: PlanarProjection): number;
407
420
 
408
421
  export declare class CADOperations {
409
- /**
410
- * Split a Polygon using a LineString.
411
- * Creates a hairline buffer "blade" to perform difference, then flattens into pieces.
412
- */
413
- /**
414
- * Extend a ray from startPt through endPt until safely outside the polygon's bounding box.
415
- * Uses Cartesian unit vector in coordinate space to avoid spherical bearing drift.
416
- */
417
- private static extendRayOutside;
418
- /**
419
- * Prepare cutting line: ensures head and tail pierce outside the polygon if they stop inside.
420
- * The cutting line is ALWAYS kept as a single continuous LineString (never decomposed into separate rays).
421
- */
422
- private static prepareCuttingLine;
423
422
  /**
424
423
  * Split a single Polygon by a single LineString using planar graph noded polygonization.
425
424
  */
426
425
  private static splitSinglePolygonByLine;
427
426
  /**
428
- * Split a Polygon using a LineString.
429
- * Ensures cutting lines pierce completely through boundaries without leaving unsevered edges or dead-end slits.
427
+ * Split a Polygon using a LineString. Returns null when the line does not cut it.
428
+ *
429
+ * The line has to cross the polygon from one side to the other, as in QGIS. An end that stops
430
+ * inside used to be carried on in a straight line - 1.5 times the polygon's diagonal, worked out in
431
+ * degrees - so a line that only poked in still cut, along a path nobody drew. Now it does not cut.
432
+ * An end on the boundary is fine, snapped or computed onto an edge: that is a crossing, and the
433
+ * noding below finds it without any extension.
430
434
  */
431
435
  static splitPolygonByLine(polygon: Feature<Polygon | MultiPolygon>, cuttingLine: Feature<LineString>): Feature<Polygon>[] | null;
432
436
  /**
@@ -599,6 +603,8 @@ export declare interface CategoricalFieldStats {
599
603
  export declare interface CategoricalThemeOptions {
600
604
  reverse?: boolean;
601
605
  baseSymbol?: SymbolStyleInput;
606
+ /** Keep categories that no feature has any more when reclassifying (see ThematicDefinition) */
607
+ keepEmptyCategories?: boolean;
602
608
  }
603
609
 
604
610
  /**
@@ -1248,8 +1254,11 @@ export declare interface DrawGuideSettings {
1248
1254
  angles: boolean;
1249
1255
  /** How far off the segment the dimension line sits, in screen pixels */
1250
1256
  dimensionOffsetPixels: number;
1251
- /** Glyph names for the labels; the map style must provide them */
1252
- font: string[];
1257
+ /**
1258
+ * Glyph font stack for the labels; the map style's glyph server must have it. null (the default)
1259
+ * uses the font the basemap's own labels use - see `IMapAdapter.getStyleFont`.
1260
+ */
1261
+ font: string[] | null;
1253
1262
  }
1254
1263
 
1255
1264
  /** Minimal 2D context surface used by the drawing helpers (so they can be tested without a DOM) */
@@ -1780,6 +1789,14 @@ export declare interface IMapAdapter {
1780
1789
  setDoubleClickZoom(enabled: boolean): void;
1781
1790
  /** Raw map engine access */
1782
1791
  getRawMap<T = any>(): T;
1792
+ /**
1793
+ * The glyph font stack the basemap's own labels use, so text added on top is drawn in a font its
1794
+ * glyph server has; when the style names none (a raster basemap), the fallback font; else null.
1795
+ * Optional: an adapter without it gets the engine default font.
1796
+ */
1797
+ getStyleFont?(): string[] | null;
1798
+ /** Font to use when the basemap names none; it must exist on the style's glyph server */
1799
+ setFallbackFont?(font: string[] | null): void;
1783
1800
  /** Cleanup */
1784
1801
  destroy(): void;
1785
1802
  }
@@ -2900,7 +2917,7 @@ export declare class OFSDataSource extends TypedEventEmitter<OFSDataSourceEvents
2900
2917
  setLayerGroupVisibility(groupId: string, visible: boolean): void;
2901
2918
  /** Move a layer into a group (null = top level) */
2902
2919
  moveLayerToGroup(layerId: string, groupId: string | null): void;
2903
- /** True when the layer is inside the group, directly or through sub-groups */
2920
+ /** True when the layer (of either kind) is inside the group, directly or through sub-groups */
2904
2921
  isLayerInGroup(layerId: string, groupId: string): boolean;
2905
2922
  /** A layer of either kind is drawn when it and all of its parent groups are visible */
2906
2923
  isLayerRendered(layerId: string): boolean;
@@ -2975,6 +2992,8 @@ export declare class OFSDataSource extends TypedEventEmitter<OFSDataSourceEvents
2975
2992
  * Create buffer around feature and add as new feature or replace
2976
2993
  */
2977
2994
  buffer(layerId: string, featureId: string | number, distance: number, units?: turf.Units, targetLayerId?: string): Feature<Polygon | MultiPolygon>;
2995
+ /** The polygon layer that buffers of a line or point layer go into, created on first use */
2996
+ private bufferLayerFor;
2978
2997
  /**
2979
2998
  * Calculate polygon area in square meters or hectares
2980
2999
  */
@@ -3508,7 +3527,6 @@ export declare class OFSDrawTools extends TypedEventEmitter<DrawEvents> {
3508
3527
  result: Feature<Geometry>;
3509
3528
  };
3510
3529
  private replaceLineWithPieces;
3511
- private safeRawMap;
3512
3530
  /** Segments of all visible features except `exclude` (used as cutting edges / boundaries) */
3513
3531
  private boundarySegments;
3514
3532
  /**
@@ -3590,6 +3608,8 @@ export declare class OFSDrawTools extends TypedEventEmitter<DrawEvents> {
3590
3608
  * in any mode), then the active drawing mode, and nothing at all when no tool is running.
3591
3609
  */
3592
3610
  private applyCursor;
3611
+ /** The font the guide labels are drawn in: the one set, else the basemap's, else the engine default */
3612
+ private guideFont;
3593
3613
  /** Current guide settings (a copy: change them through `setGuides`) */
3594
3614
  getGuides(): DrawGuideSettings;
3595
3615
  /**
@@ -3948,8 +3968,14 @@ export declare class OFSLegendTools extends TypedEventEmitter<LegendEvents> {
3948
3968
  * Notify subscribers of a state change
3949
3969
  */
3950
3970
  notifyUpdate(): void;
3971
+ /** A legend row of either kind: a feature layer or a tile layer */
3972
+ private findRow;
3951
3973
  toggleLayerVisibility(layerId: string): void;
3952
3974
  setLayerOpacity(layerId: string, opacity: number): void;
3975
+ /**
3976
+ * Make a layer the one new features go into. A tile layer cannot hold features, so choosing one -
3977
+ * clicking a basemap row in the legend, say - is ignored rather than an error.
3978
+ */
3953
3979
  setActiveLayer(layerId: string): void;
3954
3980
  toggleLayerPinned(layerId: string): void;
3955
3981
  /** Move a layer one place up among its siblings in the legend tree (above a sibling group as a whole) */
@@ -4105,6 +4131,12 @@ export declare interface OFSObjectConfig {
4105
4131
  * with `consoleWidget.submit(text)` and render the `console:line` / `console:prompt` events.
4106
4132
  */
4107
4133
  console?: IOFSConsole;
4134
+ /**
4135
+ * Font for labels and drawing guides when the basemap has no labels to take one from - satellite
4136
+ * imagery, OSM raster tiles. It must exist on the style's glyph server, e.g. `['Noto Sans Regular']`
4137
+ * for OpenFreeMap. A basemap that has labels still wins: its font is known to exist.
4138
+ */
4139
+ fallbackFont?: string[];
4108
4140
  }
4109
4141
 
4110
4142
  export declare interface OFSProjectFile {
@@ -4172,6 +4204,8 @@ export declare class OFSSymbologyPanel {
4172
4204
  private options;
4173
4205
  /** Renderer settings chosen in the form but not yet applied with "Classify" */
4174
4206
  private draft;
4207
+ /** Last real color of each color control, so switching "no color" off restores it */
4208
+ private colorMemory;
4175
4209
  constructor(legendTools: OFSLegendTools, options?: SymbologyPanelOptions);
4176
4210
  mount(target: HTMLElement | string): void;
4177
4211
  unmount(): void;
@@ -4183,6 +4217,9 @@ export declare class OFSSymbologyPanel {
4183
4217
  private render;
4184
4218
  /** Labels tab: field or expression, size, colour, halo and zoom range */
4185
4219
  private renderLabels;
4220
+ private colorKey;
4221
+ /** Color picker plus a "no color" (transparent) toggle */
4222
+ private colorControl;
4186
4223
  private renderClassification;
4187
4224
  private renderClassTable;
4188
4225
  private dashSelect;
@@ -4190,6 +4227,8 @@ export declare class OFSSymbologyPanel {
4190
4227
  private classify;
4191
4228
  private handleClick;
4192
4229
  private handleChange;
4230
+ /** Apply a form control's value (or an override, e.g. "no color") to the layer */
4231
+ private apply;
4193
4232
  }
4194
4233
 
4195
4234
  export declare class OFSThematicEngine extends TypedEventEmitter<ThematicEvents> {
@@ -4235,6 +4274,13 @@ export declare class OFSThematicEngine extends TypedEventEmitter<ThematicEvents>
4235
4274
  exportThemes(): ThematicDefinition[];
4236
4275
  /** Restore themes saved with exportThemes */
4237
4276
  importThemes(themes: ThematicDefinition[]): void;
4277
+ /**
4278
+ * Settings that belong to the layer rather than to the way it is classified, carried over when the
4279
+ * renderer changes. In QGIS labels are a tab of their own and switching Single / Categorized /
4280
+ * Graduated never touches them; here switching used to drop them, along with the selection
4281
+ * highlight colour.
4282
+ */
4283
+ private carriedLayerSettings;
4238
4284
  private carriedSymbol;
4239
4285
  /**
4240
4286
  * Create a simple uniform color theme
@@ -4257,6 +4303,11 @@ export declare class OFSThematicEngine extends TypedEventEmitter<ThematicEvents>
4257
4303
  * symbol overrides are kept where the same category value / class position still exists.
4258
4304
  */
4259
4305
  reclassify(layer: OFSLayerData): ThematicDefinition | undefined;
4306
+ /**
4307
+ * The first colour of `palette` that is clearly different from every colour in `inUse`; when the
4308
+ * palette has none left, the colour furthest from them all.
4309
+ */
4310
+ private unusedClassColor;
4260
4311
  private createCategoricalThemeData;
4261
4312
  /**
4262
4313
  * Merge changes into the base symbol (creates a simple theme when the layer has none)
@@ -5424,6 +5475,12 @@ export declare interface ThematicDefinition {
5424
5475
  enableSelectionHighlight?: boolean;
5425
5476
  /** Labels drawn for this layer */
5426
5477
  label?: LabelSettings;
5478
+ /**
5479
+ * Categorised: keep categories no feature has when the theme is reclassified, instead of dropping
5480
+ * them. For a fixed colour table - crop types, land-use codes - that should read the same whether or
5481
+ * not this season's data has every value yet.
5482
+ */
5483
+ keepEmptyCategories?: boolean;
5427
5484
  }
5428
5485
 
5429
5486
  export declare interface ThematicEngineOptions {