@chrtco/sdk 0.5.0 → 0.7.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/CHANGELOG.md +12 -0
- package/dist/atlas/browser.cjs +3245 -0
- package/dist/atlas/browser.cjs.map +1 -0
- package/dist/atlas/browser.d.cts +33 -0
- package/dist/atlas/browser.d.ts +33 -0
- package/dist/atlas/browser.js +3215 -0
- package/dist/atlas/browser.js.map +1 -0
- package/dist/index.cjs +9347 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +825 -5
- package/dist/index.d.ts +825 -5
- package/dist/index.js +9273 -2
- package/dist/index.js.map +1 -1
- package/dist/s52-colors-CdVzqt2K.d.cts +17 -0
- package/dist/s52-colors-CdVzqt2K.d.ts +17 -0
- package/package.json +18 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { F as FileSystemAdapter } from './fs-adapter-D5iwdb1Q.cjs';
|
|
2
|
+
import { C as ColorTableName } from './s52-colors-CdVzqt2K.cjs';
|
|
3
|
+
export { S as S52_COLORS, a as S52_DAY, b as S52_DUSK, c as S52_NIGHT, g as getColorTable, r as resolveColor } from './s52-colors-CdVzqt2K.cjs';
|
|
4
|
+
import maplibregl from 'maplibre-gl';
|
|
5
|
+
import { ExpressionSpecification } from '@maplibre/maplibre-gl-style-spec';
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* Pure helper: take an online MapLibre style and rewrite the named region's
|
|
@@ -14,10 +18,10 @@ import { F as FileSystemAdapter } from './fs-adapter-D5iwdb1Q.cjs';
|
|
|
14
18
|
* MapLibre clients (iOS/Android/desktop) that don't have the JS atlas
|
|
15
19
|
* available.
|
|
16
20
|
*
|
|
17
|
-
* 2. Generate the online style themselves (e.g. via
|
|
18
|
-
* `
|
|
19
|
-
* locally — recommended for JS/web SDK
|
|
20
|
-
* atlas at runtime.
|
|
21
|
+
* 2. Generate the online style themselves (e.g. via this SDK's
|
|
22
|
+
* `generateStyle()` export from `@chrtco/sdk`) and call
|
|
23
|
+
* `buildOfflineStyle()` locally — recommended for JS/web SDK
|
|
24
|
+
* consumers who already use the atlas at runtime.
|
|
21
25
|
*
|
|
22
26
|
* Both paths produce equivalent output.
|
|
23
27
|
*/
|
|
@@ -632,6 +636,822 @@ declare class OfflineError extends Error {
|
|
|
632
636
|
constructor(code: OfflineErrorCode, message: string, status?: number, detail?: Record<string, unknown>);
|
|
633
637
|
}
|
|
634
638
|
|
|
639
|
+
/** S-52 display categories – controls default visibility */
|
|
640
|
+
type DisplayCategory = "BASE" | "STANDARD" | "OTHER" | "MARINERS" | "META";
|
|
641
|
+
/** Mapbox GL layer type we'll use for this entry */
|
|
642
|
+
type GeomType = "fill" | "line" | "circle" | "symbol";
|
|
643
|
+
/** Nautical groupings (loosely follows Chart No. 1 sections) */
|
|
644
|
+
type NauticalCategory = "Depths" | "Land" | "Navigation Aids" | "Hazards" | "Regulated Areas" | "Infrastructure" | "Meta";
|
|
645
|
+
/** Paint properties – a subset we actually use */
|
|
646
|
+
interface AtlasStyle {
|
|
647
|
+
type: GeomType;
|
|
648
|
+
paint: Record<string, unknown>;
|
|
649
|
+
layout?: Record<string, unknown>;
|
|
650
|
+
/** Nautical symbol ID for symbol-type layers */
|
|
651
|
+
iconImage?: string;
|
|
652
|
+
}
|
|
653
|
+
/** One row in the S-52 lookup table */
|
|
654
|
+
interface LookupEntry {
|
|
655
|
+
/** S-57 object class acronym */
|
|
656
|
+
objectClass: string;
|
|
657
|
+
/** Human-readable name */
|
|
658
|
+
name: string;
|
|
659
|
+
/** Chart No. 1 section */
|
|
660
|
+
category: NauticalCategory;
|
|
661
|
+
/** S-52 display category */
|
|
662
|
+
displayCategory: DisplayCategory;
|
|
663
|
+
/** Default style using S-52 color tokens (resolved later) */
|
|
664
|
+
style: AtlasStyle;
|
|
665
|
+
/** Whether conditional symbology may override the style */
|
|
666
|
+
hasConditional?: boolean;
|
|
667
|
+
/** Attributes that affect styling */
|
|
668
|
+
conditionalAttributes?: string[];
|
|
669
|
+
/** INT1 / Chart No. 1 reference (e.g. "Q130.1") */
|
|
670
|
+
int1Ref?: string;
|
|
671
|
+
/** S-52 viewing group number */
|
|
672
|
+
viewingGroup?: number;
|
|
673
|
+
/** Minimum compilation scale for display (SCAMIN) */
|
|
674
|
+
scamin?: number;
|
|
675
|
+
/**
|
|
676
|
+
* Mark this class as deliberately invisible (label-only or metadata-only)
|
|
677
|
+
* so the layer-coverage audit doesn't flag its geometry-type gaps as bugs.
|
|
678
|
+
*
|
|
679
|
+
* Examples:
|
|
680
|
+
* - SOUNDG: rendered as depth numbers via labels.ts, not as visible dots
|
|
681
|
+
* - LNDRGN: region NAME labels only, no shape
|
|
682
|
+
* - M_NPUB / M_NSYS / M_QUAL / M_SREL / DSID: S-57 metadata classes;
|
|
683
|
+
* present for click-query attributes, never drawn
|
|
684
|
+
*
|
|
685
|
+
* Without this flag, `scripts/audit-layer-coverage.ts` reports the
|
|
686
|
+
* thousands of features in these classes as "gaps" every week even
|
|
687
|
+
* though the invisibility is intentional.
|
|
688
|
+
*/
|
|
689
|
+
auditIgnore?: boolean;
|
|
690
|
+
}
|
|
691
|
+
/** Resolved style ready for Mapbox GL (tokens → hex) */
|
|
692
|
+
interface ResolvedStyle {
|
|
693
|
+
type: GeomType;
|
|
694
|
+
paint: Record<string, unknown>;
|
|
695
|
+
layout?: Record<string, unknown>;
|
|
696
|
+
minzoom?: number;
|
|
697
|
+
maxzoom?: number;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* S-52 lookup table covering all S-57 object classes found in NOAA ENCs.
|
|
702
|
+
* Colours reference S-52 tokens (resolved at render time).
|
|
703
|
+
* INT1 references per NOAA Chart No. 1 (Ed 13).
|
|
704
|
+
*/
|
|
705
|
+
declare const S52_LOOKUP: Record<string, LookupEntry>;
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* S-52 draw order: layers listed bottom → top.
|
|
709
|
+
* Layers not in this list are inserted before point features.
|
|
710
|
+
*/
|
|
711
|
+
declare const S52_DRAW_ORDER: string[];
|
|
712
|
+
/** Get numeric draw priority for a layer (lower = drawn first / below) */
|
|
713
|
+
declare function getDrawPriority(layerName: string): number;
|
|
714
|
+
|
|
715
|
+
/** S-52 display modes */
|
|
716
|
+
type DisplayMode = "BASE" | "STANDARD" | "ALL";
|
|
717
|
+
/** Check if a layer's display category is visible in the given mode */
|
|
718
|
+
declare function isVisibleInMode(displayCategory: DisplayCategory, mode: DisplayMode): boolean;
|
|
719
|
+
/**
|
|
720
|
+
* Convert S-52 SCAMIN (scale minimum) to Mapbox GL minzoom.
|
|
721
|
+
*/
|
|
722
|
+
declare function scaminToMinZoom(scamin?: number): number | undefined;
|
|
723
|
+
declare function getCollisionSettings(viewingGroup?: number): {
|
|
724
|
+
iconAllowOverlap: boolean;
|
|
725
|
+
iconOptional: boolean;
|
|
726
|
+
symbolSortKey?: number;
|
|
727
|
+
};
|
|
728
|
+
/**
|
|
729
|
+
* Get the resolved Mapbox GL style for a given S-57 layer.
|
|
730
|
+
*/
|
|
731
|
+
declare function resolveStyle(layerName: string, geomKind?: GeomType, ct?: ColorTableName): ResolvedStyle;
|
|
732
|
+
declare function getLookupEntry(layerName: string): LookupEntry;
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* S-52 Conditional Symbology Procedures.
|
|
736
|
+
* Each function takes feature properties and returns paint overrides (hex colours).
|
|
737
|
+
* All expression builders accept an optional colorTable parameter.
|
|
738
|
+
*/
|
|
739
|
+
declare function depareColor(props: Record<string, unknown>, ct?: ColorTableName): string;
|
|
740
|
+
declare function depareFillExpression(ct?: ColorTableName): unknown[];
|
|
741
|
+
declare function lightColor(props: Record<string, unknown>, ct?: ColorTableName): string;
|
|
742
|
+
declare function lightFillExpression(ct?: ColorTableName): unknown[];
|
|
743
|
+
declare function lateralColor(props: Record<string, unknown>, ct?: ColorTableName): string;
|
|
744
|
+
declare function lateralFillExpression(ct?: ColorTableName): unknown[];
|
|
745
|
+
declare function hazardColor(props: Record<string, unknown>, ct?: ColorTableName): string;
|
|
746
|
+
declare function hazardFillExpression(ct?: ColorTableName): unknown[];
|
|
747
|
+
declare function daymarkColor(props: Record<string, unknown>, ct?: ColorTableName): string;
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* Label configurations for S-57 layers.
|
|
751
|
+
* Defines which layers get text labels and how to extract label text.
|
|
752
|
+
*/
|
|
753
|
+
|
|
754
|
+
interface LabelLayerConfig {
|
|
755
|
+
/** Mapbox source layer type */
|
|
756
|
+
type: "symbol";
|
|
757
|
+
/** Text field expression or string */
|
|
758
|
+
textField: ExpressionSpecification | string;
|
|
759
|
+
/** Text size in pixels */
|
|
760
|
+
textSize: number | ExpressionSpecification;
|
|
761
|
+
/** Text color (hex) or data-driven expression */
|
|
762
|
+
textColor: string | ExpressionSpecification;
|
|
763
|
+
/** Halo color for contrast */
|
|
764
|
+
textHaloColor: string;
|
|
765
|
+
/** Halo width — pixels or zoom-interpolation expression */
|
|
766
|
+
textHaloWidth: number | ExpressionSpecification;
|
|
767
|
+
/** Text offset [x, y] in ems */
|
|
768
|
+
textOffset: [number, number];
|
|
769
|
+
/** Font stack */
|
|
770
|
+
textFont?: string[];
|
|
771
|
+
/** Additional layout properties */
|
|
772
|
+
layout?: Record<string, unknown>;
|
|
773
|
+
/** Minimum zoom level for this label */
|
|
774
|
+
minzoom?: number;
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Optional palette-and-data-driven options for label config.
|
|
778
|
+
*
|
|
779
|
+
* Currently used by SOUNDG to pick palette-aware text/halo colors and to
|
|
780
|
+
* drive the S-52 safety-contour two-shade rule. Other classes ignore
|
|
781
|
+
* these options.
|
|
782
|
+
*/
|
|
783
|
+
interface LabelConfigOptions {
|
|
784
|
+
/** S-52 colour table — drives palette-aware text and halo colors. */
|
|
785
|
+
colorTable?: ColorTableName;
|
|
786
|
+
/**
|
|
787
|
+
* Safety contour depth in metres. Soundings shoaler than this render in
|
|
788
|
+
* `SNDG2` (high-contrast); deeper soundings render in `SNDG1` (muted).
|
|
789
|
+
* S-52 §SOUNDG02 conditional symbology.
|
|
790
|
+
*/
|
|
791
|
+
safetyContour?: number;
|
|
792
|
+
/**
|
|
793
|
+
* When false, all soundings render in `SNDG2` (single-shade). Default
|
|
794
|
+
* true — emit the safety-contour case expression.
|
|
795
|
+
*/
|
|
796
|
+
twoShadeSoundings?: boolean;
|
|
797
|
+
/**
|
|
798
|
+
* When "semibold", SOUNDG labels use Open Sans Semibold for crisper
|
|
799
|
+
* numerals at small sizes. Default "semibold".
|
|
800
|
+
*/
|
|
801
|
+
soundingFontWeight?: "regular" | "semibold";
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* Two-tier label rendering strategy for the band-priority style.
|
|
805
|
+
*
|
|
806
|
+
* `feature-band-gated` — emit one variant per source band, each gated to
|
|
807
|
+
* its band's zoom window (the existing `makeBandVariants` behaviour). Right
|
|
808
|
+
* for dense feature labels where seeing the same buoy designation or
|
|
809
|
+
* sounding twice across overlapping bands is visual noise.
|
|
810
|
+
*
|
|
811
|
+
* `orientation-cross-band` — emit a SINGLE label layer with no band
|
|
812
|
+
* filter. The per-class `minzoom` is honoured. Right for orientation
|
|
813
|
+
* "where am I" labels (sea-area names, land regions, cities) — these
|
|
814
|
+
* must persist as the user zooms in, even if the broader-scope cell
|
|
815
|
+
* carrying the OBJNAM is from a coarser band than the one rendering
|
|
816
|
+
* features at the current zoom. Collision arbitration via
|
|
817
|
+
* `ORIENTATION_BAND_SORT_KEY` gives the broader-scope (lower-band) copy
|
|
818
|
+
* priority where the same OBJNAM exists in multiple bands.
|
|
819
|
+
*/
|
|
820
|
+
type LabelBehavior = "feature-band-gated" | "orientation-cross-band";
|
|
821
|
+
declare const LABEL_BEHAVIOR: Record<string, LabelBehavior>;
|
|
822
|
+
/** Returns the rendering strategy for an S-57 class. Unknown classes default to band-gated. */
|
|
823
|
+
declare function getLabelBehavior(layerName: string): LabelBehavior;
|
|
824
|
+
/** Get label config for a given S-57 layer, or null if no labels */
|
|
825
|
+
declare function getLabelConfig(layerName: string, opts?: LabelConfigOptions): LabelLayerConfig | null;
|
|
826
|
+
/**
|
|
827
|
+
* Build a Mapbox symbol layer spec from a label config.
|
|
828
|
+
*/
|
|
829
|
+
declare function buildLabelLayer(layerId: string, sourceId: string, config: LabelLayerConfig, visible: boolean, overrides?: {
|
|
830
|
+
textScale?: number;
|
|
831
|
+
minzoom?: number | null;
|
|
832
|
+
allowOverlap?: boolean;
|
|
833
|
+
}): maplibregl.LayerSpecification;
|
|
834
|
+
/**
|
|
835
|
+
* Pre-process SOUNDG GeoJSON to extract Z coordinates as `depth` properties.
|
|
836
|
+
* Soundings are MultiPoint with Z values in geometry.coordinates[][2].
|
|
837
|
+
* This explodes MultiPoints into individual Points with a `depth` property.
|
|
838
|
+
*/
|
|
839
|
+
declare function preprocessSoundings(fc: GeoJSON.FeatureCollection): GeoJSON.FeatureCollection;
|
|
840
|
+
/**
|
|
841
|
+
* Pre-process LIGHTS GeoJSON to derive compact light characteristic labels.
|
|
842
|
+
* Adds `_lightLabel` property (e.g., "Fl R 4s").
|
|
843
|
+
*/
|
|
844
|
+
declare function preprocessLights(fc: GeoJSON.FeatureCollection): GeoJSON.FeatureCollection;
|
|
845
|
+
/** List of layers that have labels */
|
|
846
|
+
declare const LABELED_LAYERS: Set<string>;
|
|
847
|
+
/**
|
|
848
|
+
* Pre-process buoy/beacon GeoJSON to derive concise mariner-style labels.
|
|
849
|
+
* Adds `_navAidLabel` property (e.g., 'R "8"', 'G "5"').
|
|
850
|
+
*/
|
|
851
|
+
declare function preprocessNavAids(fc: GeoJSON.FeatureCollection): GeoJSON.FeatureCollection;
|
|
852
|
+
/** Check if a layer name needs nav aid preprocessing */
|
|
853
|
+
declare function isNavAidLayer(layerName: string): boolean;
|
|
854
|
+
/**
|
|
855
|
+
* Pre-process water body polygon GeoJSON into centroid points for label placement.
|
|
856
|
+
* Computes a simple average-coordinate centroid for each polygon feature that has OBJNAM.
|
|
857
|
+
*/
|
|
858
|
+
declare function preprocessWaterBodies(fc: GeoJSON.FeatureCollection): GeoJSON.FeatureCollection;
|
|
859
|
+
|
|
860
|
+
/**
|
|
861
|
+
* Spatial grid-based feature decimation for performance at low zoom levels.
|
|
862
|
+
* Thins dense GeoJSON feature sets by keeping only one representative
|
|
863
|
+
* feature per grid cell per layer.
|
|
864
|
+
*/
|
|
865
|
+
interface DecimationOptions {
|
|
866
|
+
/** Grid resolution (cells per axis). Default 80. */
|
|
867
|
+
gridSize?: number;
|
|
868
|
+
/** Zoom level below which decimation kicks in. Default 12. */
|
|
869
|
+
zoomThreshold?: number;
|
|
870
|
+
}
|
|
871
|
+
/**
|
|
872
|
+
* Zoom-adaptive grid resolution for decimation.
|
|
873
|
+
*/
|
|
874
|
+
declare function getGridSizeForZoom(zoom: number): number;
|
|
875
|
+
/**
|
|
876
|
+
* Decimate a GeoJSON FeatureCollection using spatial grid thinning.
|
|
877
|
+
* Only runs when zoom < zoomThreshold. Returns the original FC otherwise.
|
|
878
|
+
*
|
|
879
|
+
* @param fc - Input FeatureCollection
|
|
880
|
+
* @param layerName - S-57 layer name (affects priority logic)
|
|
881
|
+
* @param currentZoom - Current map zoom level
|
|
882
|
+
* @param bounds - Current viewport bounds
|
|
883
|
+
* @param opts - Decimation options
|
|
884
|
+
*/
|
|
885
|
+
declare function decimateFeatures(fc: GeoJSON.FeatureCollection, layerName: string, currentZoom: number, bounds: {
|
|
886
|
+
west: number;
|
|
887
|
+
south: number;
|
|
888
|
+
east: number;
|
|
889
|
+
north: number;
|
|
890
|
+
}, opts?: DecimationOptions): GeoJSON.FeatureCollection;
|
|
891
|
+
/**
|
|
892
|
+
* Get the max number of cells to load based on zoom level.
|
|
893
|
+
*/
|
|
894
|
+
declare function getMaxCellsForZoom(zoom: number): number;
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* IHO S-52 / NOAA Chart No. 1 / INT1 nautical symbol SVGs.
|
|
898
|
+
*
|
|
899
|
+
* Complete symbology suite following:
|
|
900
|
+
* - IHO S-52 Presentation Library (Ed 4.0)
|
|
901
|
+
* - IALA Maritime Buoyage System R1001 (Region B for US waters)
|
|
902
|
+
* - NOAA Chart No. 1 (Ed 13) / INT1
|
|
903
|
+
*
|
|
904
|
+
* Buoy shape terminology (US / Chart No. 1):
|
|
905
|
+
* - CAN (Q20): Flat-top cylindrical buoy — Port mark in IALA-B (red)
|
|
906
|
+
* - NUN (Q21): Conical/pointed-top buoy — Starboard mark in IALA-B (green)
|
|
907
|
+
* - PILLAR: Tall narrow buoy — used for cardinal, isolated danger, etc.
|
|
908
|
+
* - SPAR: Tall thin pole buoy
|
|
909
|
+
* - SPHERICAL: Round buoy — safe water marks
|
|
910
|
+
* - BARREL: Barrel/tun shaped buoy
|
|
911
|
+
* - SUPER: Large navigation buoy / LANBY
|
|
912
|
+
*
|
|
913
|
+
* Cardinal mark topmark orientations (IALA):
|
|
914
|
+
* - North: both cones point UP ▲▲
|
|
915
|
+
* - South: both cones point DOWN ▼▼
|
|
916
|
+
* - East: cones base-to-base (diamond) ◆
|
|
917
|
+
* - West: cones point-to-point (hourglass) ⊗
|
|
918
|
+
*
|
|
919
|
+
* Each symbol is a compact SVG at 32×32 for Mapbox GL `map.addImage()`.
|
|
920
|
+
*/
|
|
921
|
+
/** Color used in the SVG with its S-52 token name, hex, and usage */
|
|
922
|
+
interface SymbolColor {
|
|
923
|
+
token: string;
|
|
924
|
+
hex: string;
|
|
925
|
+
usage: string;
|
|
926
|
+
}
|
|
927
|
+
/** Line style used in the SVG */
|
|
928
|
+
interface SymbolLineStyle {
|
|
929
|
+
element: string;
|
|
930
|
+
width: number;
|
|
931
|
+
pattern?: string;
|
|
932
|
+
color: string;
|
|
933
|
+
}
|
|
934
|
+
/** Fill element used in the SVG */
|
|
935
|
+
interface SymbolFillElement {
|
|
936
|
+
element: string;
|
|
937
|
+
color: string;
|
|
938
|
+
opacity?: number;
|
|
939
|
+
}
|
|
940
|
+
interface NauticalSymbol {
|
|
941
|
+
id: string;
|
|
942
|
+
label: string;
|
|
943
|
+
/** INT1 / Chart No. 1 reference */
|
|
944
|
+
int1Ref: string;
|
|
945
|
+
/** Chart No. 1 section letter */
|
|
946
|
+
section: string;
|
|
947
|
+
getSvg: () => string;
|
|
948
|
+
/** Generate SVG with theme-specific colors (for bridge icons etc.) */
|
|
949
|
+
getThemedSvg?: (chblk: string, movable: string) => string;
|
|
950
|
+
/** What this symbol represents on a chart */
|
|
951
|
+
description?: string;
|
|
952
|
+
/** S-52 Presentation Library symbol name */
|
|
953
|
+
s52PlRef?: string;
|
|
954
|
+
/** Grouping key for family clustering */
|
|
955
|
+
group?: string;
|
|
956
|
+
/** IDs of related variant symbols */
|
|
957
|
+
variants?: string[];
|
|
958
|
+
/** S-57 attribute that selects this variant */
|
|
959
|
+
attributeKey?: string;
|
|
960
|
+
/** Value of that attribute for this variant */
|
|
961
|
+
attributeValue?: number;
|
|
962
|
+
/** Example label strings seen on charts */
|
|
963
|
+
labelExamples?: string[];
|
|
964
|
+
/** What the color represents */
|
|
965
|
+
colorMeaning?: string;
|
|
966
|
+
/** Colors used in the SVG */
|
|
967
|
+
colors?: SymbolColor[];
|
|
968
|
+
/** Line/stroke styles used in the SVG */
|
|
969
|
+
lineStyles?: SymbolLineStyle[];
|
|
970
|
+
/** Fill regions in the SVG */
|
|
971
|
+
fillElements?: SymbolFillElement[];
|
|
972
|
+
/** Expanded navigational usage context (2-4 sentences) */
|
|
973
|
+
usageContext?: string;
|
|
974
|
+
/** Render size for documentation */
|
|
975
|
+
renderSize?: string;
|
|
976
|
+
}
|
|
977
|
+
/** A logical grouping of related symbols */
|
|
978
|
+
interface SymbolGroup {
|
|
979
|
+
id: string;
|
|
980
|
+
label: string;
|
|
981
|
+
section: string;
|
|
982
|
+
description: string;
|
|
983
|
+
symbolIds: string[];
|
|
984
|
+
}
|
|
985
|
+
/** Chart No. 1 section metadata */
|
|
986
|
+
interface ChartSection {
|
|
987
|
+
id: string;
|
|
988
|
+
label: string;
|
|
989
|
+
description: string;
|
|
990
|
+
}
|
|
991
|
+
declare const NAUTICAL_SYMBOLS: NauticalSymbol[];
|
|
992
|
+
/** S-57 object class → default symbol ID mapping.
|
|
993
|
+
* Values are S-52 PL symbol names (matching SVG filenames in s52/point/).
|
|
994
|
+
* Conditional expressions in getIconExpression() override these for classes
|
|
995
|
+
* with attribute-dependent variants.
|
|
996
|
+
*/
|
|
997
|
+
declare const SYMBOL_MAP: Record<string, string>;
|
|
998
|
+
/** Get the Mapbox icon-image expression for data-driven symbol selection.
|
|
999
|
+
* Returns S-52 PL symbol names that correspond to SVG files in s52/point/.
|
|
1000
|
+
*/
|
|
1001
|
+
declare function getIconExpression(layerName: string): string | unknown[];
|
|
1002
|
+
/**
|
|
1003
|
+
* Browser-only image loaders (`loadSymbolImages`, `loadThemedBridgeImages`)
|
|
1004
|
+
* live in `./symbols-browser.ts` (sub-export `@chrtco/sdk/atlas/browser`) —
|
|
1005
|
+
* they require a DOM (use `new Image()` + `map.addImage()`).
|
|
1006
|
+
*/
|
|
1007
|
+
/** Get inline SVG string for a symbol by ID (for the Atlas legend) */
|
|
1008
|
+
declare function getSymbolSvgString(symbolId: string): string | null;
|
|
1009
|
+
declare const CHART_SECTIONS: ChartSection[];
|
|
1010
|
+
declare const SYMBOL_GROUPS: SymbolGroup[];
|
|
1011
|
+
/** Generate a single SVG sprite sheet containing all symbols as <symbol> elements */
|
|
1012
|
+
declare function generateSpriteSheet(): string;
|
|
1013
|
+
/** Generate a JSON manifest mapping symbol IDs to metadata */
|
|
1014
|
+
declare function generateSpriteManifest(): Record<string, {
|
|
1015
|
+
label: string;
|
|
1016
|
+
int1Ref: string;
|
|
1017
|
+
section: string;
|
|
1018
|
+
group?: string;
|
|
1019
|
+
s52PlRef?: string;
|
|
1020
|
+
description?: string;
|
|
1021
|
+
attributeKey?: string;
|
|
1022
|
+
attributeValue?: number;
|
|
1023
|
+
}>;
|
|
1024
|
+
|
|
1025
|
+
/**
|
|
1026
|
+
* IHO S-101 ENC Product Specification — Feature Catalogue
|
|
1027
|
+
*
|
|
1028
|
+
* S-101 replaces S-57 as the data model for Electronic Navigational Charts.
|
|
1029
|
+
* This catalogue maps S-101 feature classes to:
|
|
1030
|
+
* - S-57 equivalents (where they exist)
|
|
1031
|
+
* - Chart No. 1 sections (same organizational structure)
|
|
1032
|
+
* - Portrayal catalogue references (S-100 Portrayal Model)
|
|
1033
|
+
*
|
|
1034
|
+
* Key S-101 changes from S-57:
|
|
1035
|
+
* - CamelCase feature class names (DepthArea vs DEPARE)
|
|
1036
|
+
* - Complex/structured attributes (nested objects vs flat)
|
|
1037
|
+
* - New feature types for AIS, quality, under-keel clearance
|
|
1038
|
+
* - Removed/merged features for simplification
|
|
1039
|
+
*
|
|
1040
|
+
* Reference: IHO S-101 Product Specification (Ed 1.1.0)
|
|
1041
|
+
* IHO S-100 Universal Hydrographic Data Model
|
|
1042
|
+
*/
|
|
1043
|
+
interface S101Feature {
|
|
1044
|
+
/** S-101 camelCase feature class name */
|
|
1045
|
+
featureClass: string;
|
|
1046
|
+
/** Human-readable name */
|
|
1047
|
+
name: string;
|
|
1048
|
+
/** S-57 6-char equivalent acronym, if any */
|
|
1049
|
+
s57Equivalent?: string;
|
|
1050
|
+
/** Chart No. 1 section letter */
|
|
1051
|
+
section: string;
|
|
1052
|
+
/** Group key for clustering */
|
|
1053
|
+
group: string;
|
|
1054
|
+
/** Feature category */
|
|
1055
|
+
category: "geo" | "meta" | "info";
|
|
1056
|
+
/** Description of the feature */
|
|
1057
|
+
description: string;
|
|
1058
|
+
/** S-100 Portrayal Catalogue reference */
|
|
1059
|
+
portrayalRef?: string;
|
|
1060
|
+
/** True if this feature has no S-57 equivalent */
|
|
1061
|
+
isNewInS101: boolean;
|
|
1062
|
+
/** Key attributes specific to this feature */
|
|
1063
|
+
attributes?: string[];
|
|
1064
|
+
}
|
|
1065
|
+
declare const S101_FEATURES: S101Feature[];
|
|
1066
|
+
declare const S101_CHART_SECTIONS: {
|
|
1067
|
+
id: string;
|
|
1068
|
+
label: string;
|
|
1069
|
+
description: string;
|
|
1070
|
+
}[];
|
|
1071
|
+
declare const S101_SYMBOL_GROUPS: {
|
|
1072
|
+
id: string;
|
|
1073
|
+
label: string;
|
|
1074
|
+
section: string;
|
|
1075
|
+
description: string;
|
|
1076
|
+
}[];
|
|
1077
|
+
|
|
1078
|
+
/**
|
|
1079
|
+
* S-101 Portrayal Catalogue — New Symbol SVGs
|
|
1080
|
+
*
|
|
1081
|
+
* These symbols represent features introduced in S-101 that have no
|
|
1082
|
+
* direct S-57/S-52 equivalent. The existing S-52 symbols are reused
|
|
1083
|
+
* where S-101 retains visual continuity with the S-57 portrayal.
|
|
1084
|
+
*
|
|
1085
|
+
* Reference: IHO S-101 Portrayal Catalogue (Ed 1.1.0)
|
|
1086
|
+
*/
|
|
1087
|
+
|
|
1088
|
+
declare const S101_NEW_SYMBOLS: NauticalSymbol[];
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* S-52 SVG Loader — pure (DOM-free) string operations over the inlined S-52
|
|
1092
|
+
* SVG catalogue in `s52-svgs-generated.ts`. SVG files use S-52 color token
|
|
1093
|
+
* names (e.g., CHBLK, LITRD) as fill/stroke values; `applyColorTheme` swaps
|
|
1094
|
+
* those tokens for hex from the active palette.
|
|
1095
|
+
*
|
|
1096
|
+
* Browser-only image loaders live in `./s52-svg-loader-browser.ts` (sub-export
|
|
1097
|
+
* `@chrtco/sdk/atlas/browser`) — they use `new Image()` and require a DOM.
|
|
1098
|
+
*/
|
|
1099
|
+
|
|
1100
|
+
/**
|
|
1101
|
+
* Get raw SVG string for an S-52 symbol by name (e.g., "BOYCAN01").
|
|
1102
|
+
* Returns null if the symbol is not found.
|
|
1103
|
+
*/
|
|
1104
|
+
declare function getS52SvgString(symbolName: string): string | null;
|
|
1105
|
+
/**
|
|
1106
|
+
* Get an S-52 SVG string with color tokens resolved to hex values
|
|
1107
|
+
* from the specified color table.
|
|
1108
|
+
*/
|
|
1109
|
+
declare function getThemedS52Svg(symbolName: string, colorTable?: ColorTableName): string | null;
|
|
1110
|
+
/**
|
|
1111
|
+
* Replace S-52 color token names in an SVG string with hex colors
|
|
1112
|
+
* from the active color table.
|
|
1113
|
+
*
|
|
1114
|
+
* Matches tokens in fill="TOKEN" and stroke="TOKEN" attribute values.
|
|
1115
|
+
*/
|
|
1116
|
+
declare function applyColorTheme(svgString: string, colorTable?: ColorTableName): string;
|
|
1117
|
+
/** Get a list of all available S-52 point symbol names. */
|
|
1118
|
+
declare function getAvailablePointSymbols(): string[];
|
|
1119
|
+
/** Get a list of all available S-52 pattern names. */
|
|
1120
|
+
declare function getAvailablePatterns(): string[];
|
|
1121
|
+
/** Get a list of all available S-52 line symbol names. */
|
|
1122
|
+
declare function getAvailableLineSymbols(): string[];
|
|
1123
|
+
/** Stats for debugging */
|
|
1124
|
+
declare function getS52SymbolStats(): {
|
|
1125
|
+
pointCount: number;
|
|
1126
|
+
patternCount: number;
|
|
1127
|
+
lineCount: number;
|
|
1128
|
+
totalCount: number;
|
|
1129
|
+
};
|
|
1130
|
+
|
|
1131
|
+
/**
|
|
1132
|
+
* Zoom range of CHRT tile builds — kept in lockstep with the baremetal
|
|
1133
|
+
* tippecanoe invocation (tools/chrt-baremetal/server/src/tilebuild/per-layer-zoom.ts).
|
|
1134
|
+
*
|
|
1135
|
+
* Per-S-57-class minzoom/maxzoom narrowing is handled inside the MVT at
|
|
1136
|
+
* tile-build time via per-feature `tippecanoe.minzoom/maxzoom`; these two
|
|
1137
|
+
* constants are the outer envelope the MapLibre source declares, so the
|
|
1138
|
+
* client doesn't request tiles outside what the pmtiles can actually serve.
|
|
1139
|
+
*/
|
|
1140
|
+
declare const BUILD_MINZOOM = 3;
|
|
1141
|
+
declare const BUILD_MAXZOOM = 14;
|
|
1142
|
+
|
|
1143
|
+
/**
|
|
1144
|
+
* Post-consolidation (2026-04): one consolidated PMTiles per region, all
|
|
1145
|
+
* S-57 classes as distinct MVT layers inside. The MapLibre style emits one
|
|
1146
|
+
* vector source (id = region) and N paint layers that reference it via
|
|
1147
|
+
* `source-layer` = S-57 class name.
|
|
1148
|
+
*
|
|
1149
|
+
* `buildSources()` returns either the legacy Mapbox MTS shape (preserved for
|
|
1150
|
+
* demos / external style export — see generateStyle comments) or the PMTiles
|
|
1151
|
+
* shape pointing at a single tile URL per region.
|
|
1152
|
+
*/
|
|
1153
|
+
/** Vector source emitted for the legacy Mapbox MTS path. */
|
|
1154
|
+
interface MapboxVectorSource {
|
|
1155
|
+
type: "vector";
|
|
1156
|
+
url: string;
|
|
1157
|
+
}
|
|
1158
|
+
/**
|
|
1159
|
+
* Vector source emitted for the tiles.chrt.co PMTiles path. Uses an explicit
|
|
1160
|
+
* `tiles` array (not a TileJSON `url`) because the tile-worker serves raw MVT
|
|
1161
|
+
* bytes without a TileJSON descriptor.
|
|
1162
|
+
*/
|
|
1163
|
+
interface PmtilesVectorSource {
|
|
1164
|
+
type: "vector";
|
|
1165
|
+
tiles: string[];
|
|
1166
|
+
minzoom: number;
|
|
1167
|
+
maxzoom: number;
|
|
1168
|
+
}
|
|
1169
|
+
type VectorSourceSpec = MapboxVectorSource | PmtilesVectorSource;
|
|
1170
|
+
type SourceMode = "mapbox" | "pmtiles";
|
|
1171
|
+
/**
|
|
1172
|
+
* Default tile-worker origin for PMTiles mode. Callers should pass
|
|
1173
|
+
* `tileBaseUrl` explicitly via `BuildSourcesOptions` to override (e.g. the
|
|
1174
|
+
* React app reads `import.meta.env.VITE_TILE_WORKER_BASE`; the offline-worker
|
|
1175
|
+
* reads `env.TILE_BASE_URL`). This constant is the prod fallback only.
|
|
1176
|
+
*/
|
|
1177
|
+
declare const DEFAULT_TILE_BASE_URL = "https://tiles.chrt.co";
|
|
1178
|
+
/** Canonical source id used in `generateStyle()` — matches the region name
|
|
1179
|
+
* of the one consolidated PMTiles served by the tile-worker for this region. */
|
|
1180
|
+
declare const DEFAULT_REGION = "NOAA_ENC";
|
|
1181
|
+
interface BuildSourcesOptions {
|
|
1182
|
+
/** Which tile path to emit. Default: "pmtiles" (the supported path post-Mapbox). */
|
|
1183
|
+
mode?: SourceMode;
|
|
1184
|
+
/** Chart region. Default: "NOAA_ENC". */
|
|
1185
|
+
region?: string;
|
|
1186
|
+
/**
|
|
1187
|
+
* Reserved for future cache-busting on KV-pointer flips. Currently unused;
|
|
1188
|
+
* build pinning rides in the JWT, not the URL.
|
|
1189
|
+
*/
|
|
1190
|
+
buildTag?: string;
|
|
1191
|
+
/** Override tile-worker origin (e.g. staging). Default: DEFAULT_TILE_BASE_URL. */
|
|
1192
|
+
tileBaseUrl?: string;
|
|
1193
|
+
}
|
|
1194
|
+
/**
|
|
1195
|
+
* Build the "sources" block for a CHRT style.
|
|
1196
|
+
*
|
|
1197
|
+
* - `mode: "mapbox"`: one mapbox:// url (kept for external style export only).
|
|
1198
|
+
* - `mode: "pmtiles"` (default): one vector tile endpoint for the region,
|
|
1199
|
+
* routed by the Worker to the one consolidated PMTiles:
|
|
1200
|
+
* `${tileBaseUrl}/v1/tiles/{region}/{z}/{x}/{y}.mvt`
|
|
1201
|
+
*/
|
|
1202
|
+
declare function buildSources(opts?: BuildSourcesOptions): Record<string, VectorSourceSpec>;
|
|
1203
|
+
|
|
1204
|
+
/**
|
|
1205
|
+
* Builds Mapbox GL Style layer specs from S-52 lookup entries.
|
|
1206
|
+
* Wraps the existing atlas resolveStyle() and adds source/source-layer/filter.
|
|
1207
|
+
*/
|
|
1208
|
+
|
|
1209
|
+
interface StyleLayer {
|
|
1210
|
+
id: string;
|
|
1211
|
+
type: string;
|
|
1212
|
+
source: string;
|
|
1213
|
+
"source-layer": string;
|
|
1214
|
+
filter?: unknown[];
|
|
1215
|
+
paint: Record<string, unknown>;
|
|
1216
|
+
layout?: Record<string, unknown>;
|
|
1217
|
+
minzoom?: number;
|
|
1218
|
+
maxzoom?: number;
|
|
1219
|
+
metadata?: Record<string, unknown>;
|
|
1220
|
+
}
|
|
1221
|
+
/**
|
|
1222
|
+
* Build all Mapbox GL layers for a given S-57 object class.
|
|
1223
|
+
* Returns multiple layers (fill, outline, symbol, label, etc.).
|
|
1224
|
+
*
|
|
1225
|
+
* Post-consolidation: all S-57 classes live as MVT layers inside one
|
|
1226
|
+
* consolidated PMTiles per region; `source` is always the region name.
|
|
1227
|
+
*/
|
|
1228
|
+
declare function buildLayersForClass(objectClass: string, ct: ColorTableName, sourceId?: string): StyleLayer[];
|
|
1229
|
+
/**
|
|
1230
|
+
* Get the full ordered list of object classes for style generation.
|
|
1231
|
+
* Uses S52_DRAW_ORDER as base, then adds any missing classes from the
|
|
1232
|
+
* S-52 lookup table so a newly-ingested class automatically gets styled
|
|
1233
|
+
* without touching this file.
|
|
1234
|
+
*/
|
|
1235
|
+
declare function getOrderedClasses(): string[];
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* Strict scale-band priority for continuous-mode rendering.
|
|
1239
|
+
*
|
|
1240
|
+
* Each ENC feature in the served PMTiles carries `_cell_id` (added at
|
|
1241
|
+
* baremetal NDJSON export time). NOAA's cell-id format encodes the source
|
|
1242
|
+
* scale band as the third character: `US5MA85M` is band 5 (Harbor).
|
|
1243
|
+
*
|
|
1244
|
+
* MapLibre layer filters can't read `["zoom"]`, so to enforce "only one
|
|
1245
|
+
* band renders at any given zoom" we emit one layer copy per band, each
|
|
1246
|
+
* with a static band filter and per-band `minzoom`/`maxzoom`. The ranges
|
|
1247
|
+
* below are non-overlapping (`minzoom` inclusive, `maxzoom` exclusive),
|
|
1248
|
+
* so exactly one band is visible at any continuous zoom.
|
|
1249
|
+
*
|
|
1250
|
+
* Long-term cleanup: baremetal should emit a normalized `_band: 1..6`
|
|
1251
|
+
* integer in NDJSON so this works for non-NOAA chart sources too. The
|
|
1252
|
+
* `["slice", _cell_id, 2, 3]` extraction here is NOAA-specific.
|
|
1253
|
+
*/
|
|
1254
|
+
/**
|
|
1255
|
+
* UI-facing scale-band names (matches the app's `ScaleBand` type in
|
|
1256
|
+
* `src/lib/map/constants.ts`). Defined locally so the SDK doesn't have
|
|
1257
|
+
* to depend on app code.
|
|
1258
|
+
*/
|
|
1259
|
+
type ScaleBand = "Overview" | "General" | "Coastal" | "Approach" | "Harbor";
|
|
1260
|
+
/** S-57 source bands. NOAA cell ids use these as the third character. */
|
|
1261
|
+
type BandCode = "1" | "2" | "3" | "4" | "5" | "6";
|
|
1262
|
+
interface BandPriorityRange {
|
|
1263
|
+
/** MapLibre `minzoom` (inclusive). */
|
|
1264
|
+
minzoom: number;
|
|
1265
|
+
/** MapLibre `maxzoom` (exclusive). `undefined` means no upper cap. */
|
|
1266
|
+
maxzoom?: number;
|
|
1267
|
+
}
|
|
1268
|
+
/**
|
|
1269
|
+
* Per-band minzoom thresholds for continuous mode. Bands cascade as
|
|
1270
|
+
* fallbacks for one another — every band whose `minzoom` is satisfied
|
|
1271
|
+
* may render. The deeper-numbered band's features render preferentially
|
|
1272
|
+
* (drawn last in the z-stack, so its opaque fills cover lower bands),
|
|
1273
|
+
* and lower bands fill in where the higher band has no coverage.
|
|
1274
|
+
*
|
|
1275
|
+
* Cross-band visual overlap (doubled coastlines, blended fills) is
|
|
1276
|
+
* suppressed by the `_dominated_by_min` per-feature tag added at NDJSON
|
|
1277
|
+
* export time (see `tools/chrt-baremetal/server/src/tilebuild/dominanceIndex.ts`):
|
|
1278
|
+
* every feature whose centroid sits inside a higher-band cell's M_COVR
|
|
1279
|
+
* coverage polygon is tagged with the LOWEST band code (2..6) that
|
|
1280
|
+
* dominates it, and `makeBandVariants()` in the style generator emits
|
|
1281
|
+
* per-(featureBand, dominatorBand) layer variants gated by `maxzoom =
|
|
1282
|
+
* BAND_PRIORITY_RANGES[D].minzoom`. The dominated feature renders until
|
|
1283
|
+
* exactly the zoom where its dominator becomes eligible — solving the
|
|
1284
|
+
* low-zoom "black silhouettes" bug where a band-3 LNDARE dominated by
|
|
1285
|
+
* a band-5 cell was dropped at z7 even though band 5 wasn't yet rendering
|
|
1286
|
+
* at z7. At any pixel, exactly ONE band's data renders — the
|
|
1287
|
+
* most-detailed band whose minzoom has been reached and whose cells
|
|
1288
|
+
* actually cover that pixel.
|
|
1289
|
+
*
|
|
1290
|
+
* Bands 5 and 6 both start at z11; band 6 (Berthing) is drawn AFTER
|
|
1291
|
+
* band 5 (Harbor) so where Berthing exists it visually wins, and
|
|
1292
|
+
* Harbor shows through everywhere else.
|
|
1293
|
+
*/
|
|
1294
|
+
declare const BAND_PRIORITY_RANGES: Record<BandCode, BandPriorityRange>;
|
|
1295
|
+
/**
|
|
1296
|
+
* Order in which band layers are emitted (and thus drawn — earlier = lower
|
|
1297
|
+
* in the z-stack). Band 6 last so Berthing draws on top of Harbor.
|
|
1298
|
+
*/
|
|
1299
|
+
declare const BAND_DRAW_ORDER: BandCode[];
|
|
1300
|
+
/**
|
|
1301
|
+
* UI scale-band names → cell-id band codes that should render in chart mode
|
|
1302
|
+
* for that selection. The UI doesn't expose Berthing separately, so picking
|
|
1303
|
+
* Harbor includes both `5` and `6` cells.
|
|
1304
|
+
*
|
|
1305
|
+
* `CHART_BAND_CODES` is the *requested* band set (what the user picked);
|
|
1306
|
+
* `CHART_CASCADE_CODES` below adds the coarser bands that fall back where
|
|
1307
|
+
* the requested band has no cells.
|
|
1308
|
+
*/
|
|
1309
|
+
declare const CHART_BAND_CODES: Record<ScaleBand, readonly BandCode[]>;
|
|
1310
|
+
/**
|
|
1311
|
+
* UI scale-band names → ordered cascade of cell-id band codes for chart-mode
|
|
1312
|
+
* rendering with graceful coverage fallback. Bands are listed coarsest-first
|
|
1313
|
+
* so the style generator can use array order as draw order: lower bands draw
|
|
1314
|
+
* earlier in the z-stack, the requested band draws last on top.
|
|
1315
|
+
*
|
|
1316
|
+
* The chart-mode implementation emits one filtered layer per cascade band per
|
|
1317
|
+
* S-57 class. Where the requested band's cells provide data, its opaque fills
|
|
1318
|
+
* cover the lower bands underneath; where the requested band has no cells
|
|
1319
|
+
* (e.g. Chart→Harbor over Massachusetts Bay offshore), the next-coarser band
|
|
1320
|
+
* shows through. Different cells in the same viewport may end up rendering at
|
|
1321
|
+
* different effective bands.
|
|
1322
|
+
*
|
|
1323
|
+
* The per-feature `_dominated_by_min` tag baked at baremetal NDJSON-export
|
|
1324
|
+
* time (see `tools/chrt-baremetal/server/src/tilebuild/dominanceIndex.ts`)
|
|
1325
|
+
* suppresses lower-band features inside higher-band cell coverage so cell
|
|
1326
|
+
* boundaries don't render with doubled coastlines or contours.
|
|
1327
|
+
*
|
|
1328
|
+
* Lock scope: when chart-Harbor's viewport-lock greyout is active, the
|
|
1329
|
+
* `["within"]` bbox filter is applied ONLY to the requested band's variants
|
|
1330
|
+
* — cascade fallback bands render across the full viewport. The greyout
|
|
1331
|
+
* overlay still cues the lock boundary visually; the user picks Harbor and
|
|
1332
|
+
* gets Harbor inside the lock plus dimmed Approach/Coastal context outside.
|
|
1333
|
+
*
|
|
1334
|
+
* See `.chrt/ux/chart-mode-band-fallback-2026-05-05.md` for the design
|
|
1335
|
+
* rationale and the geographies (Boston Harbor, Massachusetts Bay offshore)
|
|
1336
|
+
* that motivated this.
|
|
1337
|
+
*/
|
|
1338
|
+
declare const CHART_CASCADE_CODES: Record<ScaleBand, readonly BandCode[]>;
|
|
1339
|
+
/**
|
|
1340
|
+
* Build a MapLibre filter expression that matches features in the given
|
|
1341
|
+
* band code(s) by extracting the band character from `_cell_id`.
|
|
1342
|
+
*/
|
|
1343
|
+
declare function bandFilterExpression(codes: BandCode | readonly BandCode[]): unknown[];
|
|
1344
|
+
/**
|
|
1345
|
+
* Combine a base filter (may be undefined) with a band filter via `["all"]`.
|
|
1346
|
+
* If the base filter is itself an `["all", ...]`, flatten so we don't end
|
|
1347
|
+
* up with `["all", ["all", ...], ...]` (which is legal but ugly).
|
|
1348
|
+
*/
|
|
1349
|
+
declare function combineWithBandFilter(baseFilter: unknown[] | undefined, bandFilter: unknown[]): unknown[];
|
|
1350
|
+
/**
|
|
1351
|
+
* Geographic bounding box used for chart-mode viewport locking.
|
|
1352
|
+
* Coordinates in WGS84 lng/lat. `sw` is south-west corner, `ne` is north-east.
|
|
1353
|
+
*/
|
|
1354
|
+
interface BBox {
|
|
1355
|
+
sw: [number, number];
|
|
1356
|
+
ne: [number, number];
|
|
1357
|
+
}
|
|
1358
|
+
/**
|
|
1359
|
+
* Build a MapLibre `["within"]` filter expression that matches features
|
|
1360
|
+
* inside the given bbox. Used by chart mode to spatially limit which
|
|
1361
|
+
* features render — when locked to a Harbor area, only features inside
|
|
1362
|
+
* the locked bbox draw, even though the tile pyramid covers more.
|
|
1363
|
+
*
|
|
1364
|
+
* The polygon is closed (first and last vertex repeated) per the GeoJSON
|
|
1365
|
+
* spec; without that, MapLibre throws on style validation.
|
|
1366
|
+
*/
|
|
1367
|
+
declare function withinBboxFilter(bbox: BBox): unknown[];
|
|
1368
|
+
/**
|
|
1369
|
+
* Build a GeoJSON Polygon for the world MINUS a given bbox — i.e. an
|
|
1370
|
+
* outer ring covering the whole world with a single hole punched at
|
|
1371
|
+
* the bbox. Used by the frontend as the source for a translucent grey
|
|
1372
|
+
* overlay so the user sees clearly where the chart is "locked."
|
|
1373
|
+
*
|
|
1374
|
+
* Outer ring uses the standard antimeridian-safe world extent
|
|
1375
|
+
* (lng [-180, 180], lat [-85, 85] — Web Mercator's safe range).
|
|
1376
|
+
*/
|
|
1377
|
+
declare function worldMinusBboxPolygon(bbox: BBox): GeoJSON.Polygon;
|
|
1378
|
+
|
|
1379
|
+
/**
|
|
1380
|
+
* Generates a complete Mapbox GL Style Specification v8 JSON
|
|
1381
|
+
* from the S-52 atlas definitions.
|
|
1382
|
+
*/
|
|
1383
|
+
|
|
1384
|
+
interface MapboxStyle {
|
|
1385
|
+
version: 8;
|
|
1386
|
+
name: string;
|
|
1387
|
+
metadata: Record<string, unknown>;
|
|
1388
|
+
sources: Record<string, unknown>;
|
|
1389
|
+
sprite?: string;
|
|
1390
|
+
glyphs: string;
|
|
1391
|
+
layers: StyleLayer[];
|
|
1392
|
+
}
|
|
1393
|
+
interface StyleGeneratorOptions extends BuildSourcesOptions {
|
|
1394
|
+
/**
|
|
1395
|
+
* When set, emit a "paper chart" style centered on the selected scale
|
|
1396
|
+
* band, with graceful coverage fallback: the requested band's layers
|
|
1397
|
+
* draw on top where its cells have data; coarser bands (driven by
|
|
1398
|
+
* `CHART_CASCADE_CODES`) fill gaps where the requested band has no
|
|
1399
|
+
* cells. Per-feature SCAMIN minzooms are preserved on every cascade
|
|
1400
|
+
* variant; `maxzoom` is dropped so the user can zoom in indefinitely.
|
|
1401
|
+
*
|
|
1402
|
+
* When omitted (default), continuous mode emits one layer copy per
|
|
1403
|
+
* source band with strict per-band zoom windows so exactly one band
|
|
1404
|
+
* renders at any given continuous zoom.
|
|
1405
|
+
*
|
|
1406
|
+
* `lockedBounds` (optional) restricts chart-mode rendering to a
|
|
1407
|
+
* specific bbox via a `["within"]` filter — applied ONLY to the
|
|
1408
|
+
* requested band's variants. Cascade fallback bands render across the
|
|
1409
|
+
* full viewport so a chart-Harbor user panning offshore still sees
|
|
1410
|
+
* Approach/Coastal data. The frontend pairs this with a translucent
|
|
1411
|
+
* grey overlay outside the bbox so the lock boundary is still visible
|
|
1412
|
+
* to the user (the fallback data is dimmed by the overlay but not
|
|
1413
|
+
* filtered out).
|
|
1414
|
+
*/
|
|
1415
|
+
chartMode?: {
|
|
1416
|
+
band: ScaleBand;
|
|
1417
|
+
lockedBounds?: BBox;
|
|
1418
|
+
};
|
|
1419
|
+
/**
|
|
1420
|
+
* Display unit for depth labels (SOUNDG soundings, DEPCNT contour
|
|
1421
|
+
* values). Source data is always meters (S-57 / VALSOU / VALDCO);
|
|
1422
|
+
* "feet" wraps the text-field expression with a unit conversion +
|
|
1423
|
+
* round so the rendered numbers match. Default "meters".
|
|
1424
|
+
*/
|
|
1425
|
+
depthUnits?: "meters" | "feet";
|
|
1426
|
+
/**
|
|
1427
|
+
* S-52 §SOUNDG02 — soundings shoaler than this depth (metres) render in
|
|
1428
|
+
* the high-contrast color; deeper soundings render in the muted color.
|
|
1429
|
+
* Default 10 m.
|
|
1430
|
+
*/
|
|
1431
|
+
safetyContour?: number;
|
|
1432
|
+
/**
|
|
1433
|
+
* When false, all soundings render in a single shade. Default true.
|
|
1434
|
+
*/
|
|
1435
|
+
twoShadeSoundings?: boolean;
|
|
1436
|
+
/**
|
|
1437
|
+
* Font weight for SOUNDG labels. Default "semibold" — crisper numerals
|
|
1438
|
+
* at small sizes on screen.
|
|
1439
|
+
*/
|
|
1440
|
+
soundingFontWeight?: "regular" | "semibold";
|
|
1441
|
+
}
|
|
1442
|
+
declare function generateStyle(palette?: ColorTableName, opts?: StyleGeneratorOptions): MapboxStyle;
|
|
1443
|
+
declare function generateStyleJSON(palette?: ColorTableName, opts?: StyleGeneratorOptions): string;
|
|
1444
|
+
/** Get summary stats about the generated style */
|
|
1445
|
+
declare function getStyleStats(style: MapboxStyle): {
|
|
1446
|
+
totalLayers: number;
|
|
1447
|
+
fillLayers: number;
|
|
1448
|
+
lineLayers: number;
|
|
1449
|
+
symbolLayers: number;
|
|
1450
|
+
circleLayers: number;
|
|
1451
|
+
sources: number;
|
|
1452
|
+
objectClasses: Set<string>;
|
|
1453
|
+
};
|
|
1454
|
+
|
|
635
1455
|
declare class Chrt {
|
|
636
1456
|
/** Tile endpoints — styleUrl, tileUrl, groups */
|
|
637
1457
|
readonly tiles: TilesEndpoint;
|
|
@@ -690,4 +1510,4 @@ declare class Chrt {
|
|
|
690
1510
|
transformRequest(): (url: string) => TransformRequest | undefined;
|
|
691
1511
|
}
|
|
692
1512
|
|
|
693
|
-
export { type BuildOfflineStyleOptions, type CellDeletedEvent, type CellDetail, type CellEventData, type CellNewEvent, type CellUpdatedData, type CellUpdatedEvent, type CellsOptions, type CellsResponse, Chrt, type ChrtConfig, ChrtError, type CoverageOptions, type CoverageResponse, type CoverageSource, type FeatureCollection, type FeaturesOptions, FileSystemAdapter, type GeoJsonFeature, type GeoJsonGeometry, type MapLibreStyle, type OfflineBundleResponse, type OfflineDownloadOptions, type OfflineDownloadProgress, type OfflineDownloadResult, OfflineError, type OfflineErrorCode, type OfflineFetchStyleOptions, type OfflineHeartbeatOptions, type OfflineRegionSummary, type OfflineRemoveOptions, OfflineStyleError, type OfflineStylePlatform, type OfflineStyleResponse, type QueryOptions, type RouteFeatureQueryOptions, type RouteFeatureQueryResponse, type RouteQueryOptions, type RouteQueryResponse, type TileGroup, type TileGroupsResponse, type TransformRequest, type WebhookEvent, type WebhookEventType, type WebhookPayload, buildOfflineStyle, paginate, parseWebhook };
|
|
1513
|
+
export { type AtlasStyle, BAND_DRAW_ORDER, BAND_PRIORITY_RANGES, type BBox, BUILD_MAXZOOM, BUILD_MINZOOM, type BandCode, type BandPriorityRange, type BuildOfflineStyleOptions, type BuildSourcesOptions, CHART_BAND_CODES, CHART_CASCADE_CODES, CHART_SECTIONS, type CellDeletedEvent, type CellDetail, type CellEventData, type CellNewEvent, type CellUpdatedData, type CellUpdatedEvent, type CellsOptions, type CellsResponse, type ChartSection, Chrt, type ChrtConfig, ChrtError, ColorTableName, type CoverageOptions, type CoverageResponse, type CoverageSource, DEFAULT_REGION, DEFAULT_TILE_BASE_URL, type DisplayCategory, type DisplayMode, type FeatureCollection, type FeaturesOptions, FileSystemAdapter, type GeoJsonFeature, type GeoJsonGeometry, type GeomType, LABELED_LAYERS, LABEL_BEHAVIOR, type LabelBehavior, type LabelConfigOptions, type LabelLayerConfig, type LookupEntry, type MapLibreStyle, type MapboxStyle, type MapboxVectorSource, NAUTICAL_SYMBOLS, type NauticalCategory, type NauticalSymbol, type OfflineBundleResponse, type OfflineDownloadOptions, type OfflineDownloadProgress, type OfflineDownloadResult, OfflineError, type OfflineErrorCode, type OfflineFetchStyleOptions, type OfflineHeartbeatOptions, type OfflineRegionSummary, type OfflineRemoveOptions, OfflineStyleError, type OfflineStylePlatform, type OfflineStyleResponse, type PmtilesVectorSource, type QueryOptions, type ResolvedStyle, type RouteFeatureQueryOptions, type RouteFeatureQueryResponse, type RouteQueryOptions, type RouteQueryResponse, type S101Feature, S101_CHART_SECTIONS, S101_FEATURES, S101_NEW_SYMBOLS, S101_SYMBOL_GROUPS, S52_DRAW_ORDER, S52_LOOKUP, SYMBOL_GROUPS, SYMBOL_MAP, type ScaleBand, type SourceMode, type StyleGeneratorOptions, type StyleLayer, type SymbolGroup, type TileGroup, type TileGroupsResponse, type TransformRequest, type VectorSourceSpec, type WebhookEvent, type WebhookEventType, type WebhookPayload, applyColorTheme, bandFilterExpression, buildLabelLayer, buildLayersForClass, buildOfflineStyle, buildSources, combineWithBandFilter, daymarkColor, decimateFeatures, depareColor, depareFillExpression, generateSpriteManifest, generateSpriteSheet, generateStyle, generateStyleJSON, getAvailableLineSymbols, getAvailablePatterns, getAvailablePointSymbols, getCollisionSettings, getDrawPriority, getGridSizeForZoom, getIconExpression, getLabelBehavior, getLabelConfig, getLookupEntry, getMaxCellsForZoom, getOrderedClasses, getS52SvgString, getS52SymbolStats, getStyleStats, getSymbolSvgString, getThemedS52Svg, hazardColor, hazardFillExpression, isNavAidLayer, isVisibleInMode, lateralColor, lateralFillExpression, lightColor, lightFillExpression, paginate, parseWebhook, preprocessLights, preprocessNavAids, preprocessSoundings, preprocessWaterBodies, resolveStyle, scaminToMinZoom, withinBboxFilter, worldMinusBboxPolygon };
|