@accelint/map-toolkit 2.0.0 → 3.0.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 +50 -0
- package/README.md +8 -1
- package/catalog-info.yaml +9 -6
- package/dist/deckgl/base-map/index.d.ts +2 -2
- package/dist/deckgl/base-map/provider.d.ts +2 -2
- package/dist/deckgl/extensions/coffin-corner/coffin-corner-extension.d.ts +144 -0
- package/dist/deckgl/extensions/coffin-corner/coffin-corner-extension.js +535 -0
- package/dist/deckgl/extensions/coffin-corner/coffin-corner-extension.js.map +1 -0
- package/dist/deckgl/extensions/coffin-corner/index.d.ts +17 -0
- package/dist/deckgl/extensions/coffin-corner/index.js +19 -0
- package/dist/deckgl/extensions/coffin-corner/store.d.ts +96 -0
- package/dist/deckgl/extensions/coffin-corner/store.js +173 -0
- package/dist/deckgl/extensions/coffin-corner/store.js.map +1 -0
- package/dist/deckgl/extensions/coffin-corner/types.d.ts +76 -0
- package/dist/deckgl/extensions/coffin-corner/types.js +27 -0
- package/dist/deckgl/extensions/coffin-corner/types.js.map +1 -0
- package/dist/deckgl/extensions/coffin-corner/use-coffin-corner.d.ts +81 -0
- package/dist/deckgl/extensions/coffin-corner/use-coffin-corner.js +75 -0
- package/dist/deckgl/extensions/coffin-corner/use-coffin-corner.js.map +1 -0
- package/dist/deckgl/extensions/index.d.ts +15 -0
- package/dist/deckgl/extensions/index.js +16 -0
- package/dist/deckgl/index.d.ts +6 -1
- package/dist/deckgl/index.js +5 -1
- package/dist/deckgl/shapes/display-shape-layer/constants.js +6 -15
- package/dist/deckgl/shapes/display-shape-layer/constants.js.map +1 -1
- package/dist/deckgl/shapes/display-shape-layer/index.d.ts +31 -15
- package/dist/deckgl/shapes/display-shape-layer/index.js +97 -78
- package/dist/deckgl/shapes/display-shape-layer/index.js.map +1 -1
- package/dist/deckgl/shapes/display-shape-layer/types.d.ts +8 -0
- package/dist/deckgl/shapes/display-shape-layer/utils/icon-config.js +3 -48
- package/dist/deckgl/shapes/display-shape-layer/utils/icon-config.js.map +1 -1
- package/dist/deckgl/shapes/display-shape-layer/utils/radius-label.js +53 -0
- package/dist/deckgl/shapes/display-shape-layer/utils/radius-label.js.map +1 -0
- package/dist/deckgl/shapes/draw-shape-layer/index.d.ts +7 -3
- package/dist/deckgl/shapes/draw-shape-layer/index.js +7 -3
- package/dist/deckgl/shapes/draw-shape-layer/index.js.map +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-circle-mode-with-tooltip.js +4 -2
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-circle-mode-with-tooltip.js.map +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-ellipse-mode-with-tooltip.js +3 -2
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-ellipse-mode-with-tooltip.js.map +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-line-string-mode-with-tooltip.js +5 -2
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-line-string-mode-with-tooltip.js.map +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-polygon-mode-with-tooltip.js +5 -2
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-polygon-mode-with-tooltip.js.map +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-rectangle-mode-with-tooltip.js +7 -2
- package/dist/deckgl/shapes/draw-shape-layer/modes/draw-rectangle-mode-with-tooltip.js.map +1 -1
- package/dist/deckgl/shapes/draw-shape-layer/types.d.ts +2 -2
- package/dist/deckgl/shapes/edit-shape-layer/index.d.ts +7 -4
- package/dist/deckgl/shapes/edit-shape-layer/index.js +22 -8
- package/dist/deckgl/shapes/edit-shape-layer/index.js.map +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/modes/bounding-transform-mode.js +3 -2
- package/dist/deckgl/shapes/edit-shape-layer/modes/bounding-transform-mode.js.map +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/modes/circle-transform-mode.js +4 -2
- package/dist/deckgl/shapes/edit-shape-layer/modes/circle-transform-mode.js.map +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/store.js +15 -4
- package/dist/deckgl/shapes/edit-shape-layer/store.js.map +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/types.d.ts +4 -2
- package/dist/deckgl/shapes/edit-shape-layer/use-edit-shape.d.ts +1 -1
- package/dist/deckgl/shapes/edit-shape-layer/use-edit-shape.js +7 -3
- package/dist/deckgl/shapes/edit-shape-layer/use-edit-shape.js.map +1 -1
- package/dist/deckgl/shapes/index.d.ts +3 -2
- package/dist/deckgl/shapes/index.js +2 -1
- package/dist/deckgl/shapes/shared/constants.js +1 -1
- package/dist/deckgl/shapes/shared/types.d.ts +11 -4
- package/dist/deckgl/shapes/shared/types.js.map +1 -1
- package/dist/deckgl/shapes/shared/utils/duplicate-shape.d.ts +56 -0
- package/dist/deckgl/shapes/shared/utils/duplicate-shape.js +131 -0
- package/dist/deckgl/shapes/shared/utils/duplicate-shape.js.map +1 -0
- package/dist/deckgl/shapes/shared/utils/geometry-measurements.js.map +1 -1
- package/dist/deckgl/shapes/shared/utils/layer-config.js +10 -7
- package/dist/deckgl/shapes/shared/utils/layer-config.js.map +1 -1
- package/dist/deckgl/symbol-layer/fiber.d.ts +3 -1
- package/dist/deckgl/symbol-layer/fiber.js.map +1 -1
- package/dist/shared/units.d.ts +15 -56
- package/dist/shared/units.js +1 -52
- package/dist/shared/units.js.map +1 -1
- package/dist/viewport/index.d.ts +2 -3
- package/dist/viewport/index.js +1 -2
- package/dist/viewport/types.d.ts +8 -4
- package/dist/viewport/utils.d.ts +3 -3
- package/dist/viewport/utils.js +16 -8
- package/dist/viewport/utils.js.map +1 -1
- package/dist/viewport/viewport-size.d.ts +4 -3
- package/dist/viewport/viewport-size.js +2 -2
- package/dist/viewport/viewport-size.js.map +1 -1
- package/package.json +13 -6
- package/dist/deckgl/shapes/display-shape-layer/utils/interaction.js +0 -50
- package/dist/deckgl/shapes/display-shape-layer/utils/interaction.js.map +0 -1
|
@@ -11,12 +11,14 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
import { DEFAULT_DISTANCE_UNITS
|
|
14
|
+
import { DEFAULT_DISTANCE_UNITS } from "../../../../shared/units.js";
|
|
15
15
|
import { DEFAULT_EDIT_HANDLE_COLOR, EDITABLE_LAYER_SUBLAYER_PROPS } from "../constants.js";
|
|
16
|
+
import { DISTANCE_UNIT_BY_SYMBOL } from "@accelint/constants/units";
|
|
16
17
|
|
|
17
18
|
//#region src/deckgl/shapes/shared/utils/layer-config.ts
|
|
18
|
-
let
|
|
19
|
+
let cachedSymbol;
|
|
19
20
|
let cachedProps;
|
|
21
|
+
let hasCache = false;
|
|
20
22
|
/**
|
|
21
23
|
* Returns default props for EditableGeoJsonLayer configuration.
|
|
22
24
|
*
|
|
@@ -25,7 +27,7 @@ let cachedProps;
|
|
|
25
27
|
* - Mode configuration with distance units
|
|
26
28
|
* - Sublayer props for tooltips and handles
|
|
27
29
|
*
|
|
28
|
-
* @param
|
|
30
|
+
* @param unitSymbol - Optional unit symbol (e.g., 'km', 'mi'). Defaults to DEFAULT_DISTANCE_UNITS.
|
|
29
31
|
* @returns Default props to spread onto EditableGeoJsonLayer.
|
|
30
32
|
*
|
|
31
33
|
* @example
|
|
@@ -36,13 +38,14 @@ let cachedProps;
|
|
|
36
38
|
* />
|
|
37
39
|
* ```
|
|
38
40
|
*/
|
|
39
|
-
function getDefaultEditableLayerProps(
|
|
40
|
-
if (
|
|
41
|
-
|
|
41
|
+
function getDefaultEditableLayerProps(unitSymbol) {
|
|
42
|
+
if (hasCache && cachedSymbol === unitSymbol && cachedProps) return cachedProps;
|
|
43
|
+
hasCache = true;
|
|
44
|
+
cachedSymbol = unitSymbol;
|
|
42
45
|
cachedProps = {
|
|
43
46
|
getEditHandlePointColor: DEFAULT_EDIT_HANDLE_COLOR,
|
|
44
47
|
getEditHandlePointOutlineColor: DEFAULT_EDIT_HANDLE_COLOR,
|
|
45
|
-
modeConfig: { distanceUnits:
|
|
48
|
+
modeConfig: { distanceUnits: unitSymbol ? DISTANCE_UNIT_BY_SYMBOL[unitSymbol] ?? DEFAULT_DISTANCE_UNITS : DEFAULT_DISTANCE_UNITS },
|
|
46
49
|
_subLayerProps: EDITABLE_LAYER_SUBLAYER_PROPS
|
|
47
50
|
};
|
|
48
51
|
return cachedProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layer-config.js","names":["
|
|
1
|
+
{"version":3,"file":"layer-config.js","names":["cachedSymbol: DistanceUnitSymbol | undefined","cachedProps: EditableLayerDefaultProps | undefined"],"sources":["../../../../../src/deckgl/shapes/shared/utils/layer-config.ts"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { DISTANCE_UNIT_BY_SYMBOL } from '@accelint/constants/units';\nimport { DEFAULT_DISTANCE_UNITS } from '@/shared/units';\nimport {\n DEFAULT_EDIT_HANDLE_COLOR,\n EDITABLE_LAYER_SUBLAYER_PROPS,\n} from '../constants';\nimport type {\n DistanceUnit,\n DistanceUnitSymbol,\n} from '@accelint/constants/units';\nimport type { Color } from '@deck.gl/core';\n\n/**\n * Props returned by getDefaultEditableLayerProps.\n * These are common configuration props shared between DrawShapeLayer and EditShapeLayer.\n */\nexport type EditableLayerDefaultProps = {\n /** Edit handle point color. */\n getEditHandlePointColor: Color;\n /** Edit handle point outline color. */\n getEditHandlePointOutlineColor: Color;\n /** Mode configuration with distance units. */\n modeConfig: {\n distanceUnits: DistanceUnit;\n };\n /** Sublayer props for tooltips and edit handles. */\n _subLayerProps: typeof EDITABLE_LAYER_SUBLAYER_PROPS;\n};\n\nlet cachedSymbol: DistanceUnitSymbol | undefined;\nlet cachedProps: EditableLayerDefaultProps | undefined;\nlet hasCache = false;\n\n/**\n * Returns default props for EditableGeoJsonLayer configuration.\n *\n * This consolidates the common configuration shared between DrawShapeLayer and EditShapeLayer:\n * - Edit handle colors\n * - Mode configuration with distance units\n * - Sublayer props for tooltips and handles\n *\n * @param unitSymbol - Optional unit symbol (e.g., 'km', 'mi'). Defaults to DEFAULT_DISTANCE_UNITS.\n * @returns Default props to spread onto EditableGeoJsonLayer.\n *\n * @example\n * ```tsx\n * <editableGeoJsonLayer\n * {...getDefaultEditableLayerProps(unit)}\n * // other props\n * />\n * ```\n */\nexport function getDefaultEditableLayerProps(\n unitSymbol?: DistanceUnitSymbol,\n): EditableLayerDefaultProps {\n if (hasCache && cachedSymbol === unitSymbol && cachedProps) {\n return cachedProps;\n }\n\n hasCache = true;\n cachedSymbol = unitSymbol;\n cachedProps = {\n getEditHandlePointColor: DEFAULT_EDIT_HANDLE_COLOR,\n getEditHandlePointOutlineColor: DEFAULT_EDIT_HANDLE_COLOR,\n modeConfig: {\n distanceUnits: unitSymbol\n ? (DISTANCE_UNIT_BY_SYMBOL[unitSymbol] ?? DEFAULT_DISTANCE_UNITS)\n : DEFAULT_DISTANCE_UNITS,\n },\n // biome-ignore lint/style/useNamingConvention: deck.gl API convention\n _subLayerProps: EDITABLE_LAYER_SUBLAYER_PROPS,\n };\n\n return cachedProps;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyCA,IAAIA;AACJ,IAAIC;AACJ,IAAI,WAAW;;;;;;;;;;;;;;;;;;;;AAqBf,SAAgB,6BACd,YAC2B;AAC3B,KAAI,YAAY,iBAAiB,cAAc,YAC7C,QAAO;AAGT,YAAW;AACX,gBAAe;AACf,eAAc;EACZ,yBAAyB;EACzB,gCAAgC;EAChC,YAAY,EACV,eAAe,aACV,wBAAwB,eAAe,yBACxC,wBACL;EAED,gBAAgB;EACjB;AAED,QAAO"}
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import { CoffinCornerExtensionProps } from "../extensions/coffin-corner/types.js";
|
|
14
|
+
import "../extensions/index.js";
|
|
13
15
|
import { SymbolLayerProps } from "./index.js";
|
|
14
16
|
|
|
15
17
|
//#region src/deckgl/symbol-layer/fiber.d.ts
|
|
@@ -35,7 +37,7 @@ declare global {
|
|
|
35
37
|
* />
|
|
36
38
|
* ```
|
|
37
39
|
*/
|
|
38
|
-
symbolLayer: SymbolLayerProps
|
|
40
|
+
symbolLayer: CoffinCornerExtensionProps<SymbolLayerProps>;
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fiber.js","names":[],"sources":["../../../src/deckgl/symbol-layer/fiber.ts"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { extend } from '@deckgl-fiber-renderer/dom';\nimport { SymbolLayer, type SymbolLayerProps } from './index';\n\nextend({ SymbolLayer });\n\ndeclare global {\n namespace React {\n // biome-ignore lint/style/useNamingConvention: Built-in React namespace.\n namespace JSX {\n interface IntrinsicElements {\n /**\n * A Deck.gl Fiber layer for rendering MIL-STD-2525 and APP-6 military symbols.\n *\n * Automatically generates symbol icons from SIDC codes with support for\n * multiple symbology standards and customizable rendering options.\n *\n * @example\n * ```tsx\n * <symbolLayer\n * id=\"military-units\"\n * data={units}\n * getSidc={d => d.sidc}\n * getPosition={d => d.position}\n * getSize={32}\n * defaultSymbolOptions={{ colorMode: 'Dark' }}\n * />\n * ```\n */\n symbolLayer: SymbolLayerProps
|
|
1
|
+
{"version":3,"file":"fiber.js","names":[],"sources":["../../../src/deckgl/symbol-layer/fiber.ts"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { extend } from '@deckgl-fiber-renderer/dom';\nimport { SymbolLayer, type SymbolLayerProps } from './index';\nimport type { CoffinCornerExtensionProps } from '../extensions';\n\nextend({ SymbolLayer });\n\ndeclare global {\n namespace React {\n // biome-ignore lint/style/useNamingConvention: Built-in React namespace.\n namespace JSX {\n interface IntrinsicElements {\n /**\n * A Deck.gl Fiber layer for rendering MIL-STD-2525 and APP-6 military symbols.\n *\n * Automatically generates symbol icons from SIDC codes with support for\n * multiple symbology standards and customizable rendering options.\n *\n * @example\n * ```tsx\n * <symbolLayer\n * id=\"military-units\"\n * data={units}\n * getSidc={d => d.sidc}\n * getPosition={d => d.position}\n * getSize={32}\n * defaultSymbolOptions={{ colorMode: 'Dark' }}\n * />\n * ```\n */\n symbolLayer: CoffinCornerExtensionProps<SymbolLayerProps>;\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,OAAO,EAAE,aAAa,CAAC"}
|
package/dist/shared/units.d.ts
CHANGED
|
@@ -1,63 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
readonly feet: "ft";
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Turf.js unit name (e.g., 'kilometers', 'nauticalmiles').
|
|
15
|
-
*/
|
|
16
|
-
type DistanceUnit = keyof typeof DISTANCE_UNIT_ABBREVIATIONS;
|
|
17
|
-
/**
|
|
18
|
-
* Display abbreviation (e.g., 'km', 'nm').
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
19
11
|
*/
|
|
20
|
-
|
|
12
|
+
|
|
13
|
+
import { DistanceUnit } from "@accelint/constants/units";
|
|
14
|
+
|
|
15
|
+
//#region src/shared/units.d.ts
|
|
21
16
|
/**
|
|
22
17
|
* Default distance units for geographic measurements.
|
|
23
18
|
*/
|
|
24
19
|
declare const DEFAULT_DISTANCE_UNITS: DistanceUnit;
|
|
25
|
-
/**
|
|
26
|
-
* Get the full Turf.js unit name from an abbreviation.
|
|
27
|
-
*
|
|
28
|
-
* @param abbrev - The abbreviation (e.g., 'km', 'nm')
|
|
29
|
-
* @returns The full unit name (e.g., 'kilometers', 'nauticalmiles') or undefined
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```typescript
|
|
33
|
-
* import { getDistanceUnitFromAbbreviation } from '@accelint/map-toolkit/shared';
|
|
34
|
-
*
|
|
35
|
-
* const unit = getDistanceUnitFromAbbreviation('km');
|
|
36
|
-
* console.log(unit); // 'kilometers'
|
|
37
|
-
*
|
|
38
|
-
* const unknown = getDistanceUnitFromAbbreviation('invalid');
|
|
39
|
-
* console.log(unknown); // undefined
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
declare function getDistanceUnitFromAbbreviation(abbrev: string): DistanceUnit | undefined;
|
|
43
|
-
/**
|
|
44
|
-
* Get the abbreviation for a Turf.js unit name.
|
|
45
|
-
*
|
|
46
|
-
* @param unit - The full unit name (e.g., 'kilometers')
|
|
47
|
-
* @returns The abbreviation (e.g., 'km') or the input if not found
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* ```typescript
|
|
51
|
-
* import { getDistanceUnitAbbreviation } from '@accelint/map-toolkit/shared';
|
|
52
|
-
*
|
|
53
|
-
* const abbrev = getDistanceUnitAbbreviation('kilometers');
|
|
54
|
-
* console.log(abbrev); // 'km'
|
|
55
|
-
*
|
|
56
|
-
* const fallback = getDistanceUnitAbbreviation('unknown');
|
|
57
|
-
* console.log(fallback); // 'unknown'
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
declare function getDistanceUnitAbbreviation(unit: string): string;
|
|
61
20
|
//#endregion
|
|
62
|
-
export { DEFAULT_DISTANCE_UNITS
|
|
21
|
+
export { DEFAULT_DISTANCE_UNITS };
|
|
63
22
|
//# sourceMappingURL=units.d.ts.map
|
package/dist/shared/units.js
CHANGED
|
@@ -13,61 +13,10 @@
|
|
|
13
13
|
|
|
14
14
|
//#region src/shared/units.ts
|
|
15
15
|
/**
|
|
16
|
-
* Map of Turf.js unit names to display abbreviations.
|
|
17
|
-
* These are the practical units users would select for map measurements.
|
|
18
|
-
*/
|
|
19
|
-
const DISTANCE_UNIT_ABBREVIATIONS = {
|
|
20
|
-
kilometers: "km",
|
|
21
|
-
meters: "m",
|
|
22
|
-
nauticalmiles: "nm",
|
|
23
|
-
miles: "mi",
|
|
24
|
-
feet: "ft"
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
16
|
* Default distance units for geographic measurements.
|
|
28
17
|
*/
|
|
29
18
|
const DEFAULT_DISTANCE_UNITS = "kilometers";
|
|
30
|
-
/**
|
|
31
|
-
* Get the full Turf.js unit name from an abbreviation.
|
|
32
|
-
*
|
|
33
|
-
* @param abbrev - The abbreviation (e.g., 'km', 'nm')
|
|
34
|
-
* @returns The full unit name (e.g., 'kilometers', 'nauticalmiles') or undefined
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```typescript
|
|
38
|
-
* import { getDistanceUnitFromAbbreviation } from '@accelint/map-toolkit/shared';
|
|
39
|
-
*
|
|
40
|
-
* const unit = getDistanceUnitFromAbbreviation('km');
|
|
41
|
-
* console.log(unit); // 'kilometers'
|
|
42
|
-
*
|
|
43
|
-
* const unknown = getDistanceUnitFromAbbreviation('invalid');
|
|
44
|
-
* console.log(unknown); // undefined
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
function getDistanceUnitFromAbbreviation(abbrev) {
|
|
48
|
-
return Object.entries(DISTANCE_UNIT_ABBREVIATIONS).find(([, a]) => a === abbrev)?.[0];
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Get the abbreviation for a Turf.js unit name.
|
|
52
|
-
*
|
|
53
|
-
* @param unit - The full unit name (e.g., 'kilometers')
|
|
54
|
-
* @returns The abbreviation (e.g., 'km') or the input if not found
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* ```typescript
|
|
58
|
-
* import { getDistanceUnitAbbreviation } from '@accelint/map-toolkit/shared';
|
|
59
|
-
*
|
|
60
|
-
* const abbrev = getDistanceUnitAbbreviation('kilometers');
|
|
61
|
-
* console.log(abbrev); // 'km'
|
|
62
|
-
*
|
|
63
|
-
* const fallback = getDistanceUnitAbbreviation('unknown');
|
|
64
|
-
* console.log(fallback); // 'unknown'
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
function getDistanceUnitAbbreviation(unit) {
|
|
68
|
-
return DISTANCE_UNIT_ABBREVIATIONS[unit] ?? unit;
|
|
69
|
-
}
|
|
70
19
|
|
|
71
20
|
//#endregion
|
|
72
|
-
export { DEFAULT_DISTANCE_UNITS
|
|
21
|
+
export { DEFAULT_DISTANCE_UNITS };
|
|
73
22
|
//# sourceMappingURL=units.js.map
|
package/dist/shared/units.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"units.js","names":["DEFAULT_DISTANCE_UNITS: DistanceUnit"],"sources":["../../src/shared/units.ts"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\
|
|
1
|
+
{"version":3,"file":"units.js","names":["DEFAULT_DISTANCE_UNITS: DistanceUnit"],"sources":["../../src/shared/units.ts"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type { DistanceUnit } from '@accelint/constants/units';\n\n/**\n * Default distance units for geographic measurements.\n */\nexport const DEFAULT_DISTANCE_UNITS: DistanceUnit = 'kilometers';\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAaA,yBAAuC"}
|
package/dist/viewport/index.d.ts
CHANGED
|
@@ -10,9 +10,8 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { DISTANCE_UNIT_ABBREVIATIONS, DistanceUnit, DistanceUnitAbbreviation, getDistanceUnitFromAbbreviation } from "../shared/units.js";
|
|
14
13
|
import { clearViewportState, useMapViewport, viewportStore } from "./store.js";
|
|
15
|
-
import { GeoCoordinate, GetViewportSizeArgs
|
|
14
|
+
import { GeoCoordinate, GetViewportSizeArgs } from "./types.js";
|
|
16
15
|
import { getViewportSize } from "./utils.js";
|
|
17
16
|
import { ViewportSize, ViewportSizeProps } from "./viewport-size.js";
|
|
18
|
-
export {
|
|
17
|
+
export { type GeoCoordinate, type GetViewportSizeArgs, ViewportSize, type ViewportSizeProps, clearViewportState, getViewportSize, useMapViewport, viewportStore };
|
package/dist/viewport/index.js
CHANGED
|
@@ -11,9 +11,8 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
import { DISTANCE_UNIT_ABBREVIATIONS, getDistanceUnitFromAbbreviation } from "../shared/units.js";
|
|
15
14
|
import { clearViewportState, useMapViewport, viewportStore } from "./store.js";
|
|
16
15
|
import { getViewportSize } from "./utils.js";
|
|
17
16
|
import { ViewportSize } from "./viewport-size.js";
|
|
18
17
|
|
|
19
|
-
export {
|
|
18
|
+
export { ViewportSize, clearViewportState, getViewportSize, useMapViewport, viewportStore };
|
package/dist/viewport/types.d.ts
CHANGED
|
@@ -11,22 +11,26 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { Bounds } from "../deckgl/base-map/types.js";
|
|
14
|
-
import {
|
|
14
|
+
import { DistanceUnitSymbol } from "@accelint/constants/units";
|
|
15
15
|
|
|
16
16
|
//#region src/viewport/types.d.ts
|
|
17
|
-
|
|
17
|
+
/** Arguments for {@link getViewportSize}. */
|
|
18
18
|
type GetViewportSizeArgs = {
|
|
19
19
|
/** Geographic bounds, undefined if viewport not yet initialized */
|
|
20
20
|
bounds?: Bounds;
|
|
21
|
+
/** Map zoom level for meters-per-pixel calculation. */
|
|
21
22
|
zoom: number;
|
|
22
23
|
/** Viewport width in pixels */
|
|
23
24
|
width: number;
|
|
24
25
|
/** Viewport height in pixels */
|
|
25
26
|
height: number;
|
|
26
|
-
unit
|
|
27
|
+
/** Distance unit symbol. Defaults to `'NM'`. */
|
|
28
|
+
unit?: DistanceUnitSymbol;
|
|
29
|
+
/** Number formatter for localization. Defaults to `en-US`. */
|
|
27
30
|
formatter?: Intl.NumberFormat;
|
|
28
31
|
};
|
|
32
|
+
/** A geographic coordinate as `[longitude, latitude]`. */
|
|
29
33
|
type GeoCoordinate = [longitude: number, latitude: number];
|
|
30
34
|
//#endregion
|
|
31
|
-
export { GeoCoordinate, GetViewportSizeArgs
|
|
35
|
+
export { GeoCoordinate, GetViewportSizeArgs };
|
|
32
36
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/viewport/utils.d.ts
CHANGED
|
@@ -26,17 +26,17 @@ import { GetViewportSizeArgs } from "./types.js";
|
|
|
26
26
|
* @param args.zoom - Zoom level for meters-per-pixel calculation
|
|
27
27
|
* @param args.width - Viewport width in pixels
|
|
28
28
|
* @param args.height - Viewport height in pixels
|
|
29
|
-
* @param args.unit - Unit
|
|
29
|
+
* @param args.unit - Unit symbol: `km | m | NM | mi | ft`. Defaults to `NM`
|
|
30
30
|
* @param args.formatter - Number formatter for localization (defaults to en-US)
|
|
31
31
|
* @returns Formatted string like "660 x 1,801 NM" or "-- x -- NM" if invalid
|
|
32
32
|
*
|
|
33
33
|
* @example
|
|
34
34
|
* ```typescript
|
|
35
|
-
* getViewportSize({ bounds: [-82, 22, -71, 52], zoom: 5, width: 800, height: 600, unit: '
|
|
35
|
+
* getViewportSize({ bounds: [-82, 22, -71, 52], zoom: 5, width: 800, height: 600, unit: 'NM' })
|
|
36
36
|
* // returns "612 x 459 NM"
|
|
37
37
|
*
|
|
38
38
|
* getViewportSize({ bounds: [170, 50, -170, 60], zoom: 4, width: 1024, height: 768, unit: 'km' })
|
|
39
|
-
* // returns "2,050 x 1,538
|
|
39
|
+
* // returns "2,050 x 1,538 km"
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
|
42
42
|
declare function getViewportSize({
|
package/dist/viewport/utils.js
CHANGED
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { createLoggerDomain } from "../shared/logger.js";
|
|
15
|
+
import { DISTANCE_UNIT_BY_SYMBOL, DISTANCE_UNIT_SYMBOLS } from "@accelint/constants/units";
|
|
15
16
|
|
|
16
17
|
//#region src/viewport/utils.ts
|
|
18
|
+
const logger = createLoggerDomain("[Viewport]");
|
|
17
19
|
const numberFormatter = Intl.NumberFormat("en-US");
|
|
18
20
|
/**
|
|
19
21
|
* Web Mercator constant: meters per pixel at zoom 0, equator.
|
|
@@ -42,21 +44,27 @@ const METERS_TO_UNIT = {
|
|
|
42
44
|
* @param args.zoom - Zoom level for meters-per-pixel calculation
|
|
43
45
|
* @param args.width - Viewport width in pixels
|
|
44
46
|
* @param args.height - Viewport height in pixels
|
|
45
|
-
* @param args.unit - Unit
|
|
47
|
+
* @param args.unit - Unit symbol: `km | m | NM | mi | ft`. Defaults to `NM`
|
|
46
48
|
* @param args.formatter - Number formatter for localization (defaults to en-US)
|
|
47
49
|
* @returns Formatted string like "660 x 1,801 NM" or "-- x -- NM" if invalid
|
|
48
50
|
*
|
|
49
51
|
* @example
|
|
50
52
|
* ```typescript
|
|
51
|
-
* getViewportSize({ bounds: [-82, 22, -71, 52], zoom: 5, width: 800, height: 600, unit: '
|
|
53
|
+
* getViewportSize({ bounds: [-82, 22, -71, 52], zoom: 5, width: 800, height: 600, unit: 'NM' })
|
|
52
54
|
* // returns "612 x 459 NM"
|
|
53
55
|
*
|
|
54
56
|
* getViewportSize({ bounds: [170, 50, -170, 60], zoom: 4, width: 1024, height: 768, unit: 'km' })
|
|
55
|
-
* // returns "2,050 x 1,538
|
|
57
|
+
* // returns "2,050 x 1,538 km"
|
|
56
58
|
* ```
|
|
57
59
|
*/
|
|
58
|
-
function getViewportSize({ bounds, zoom, width: pixelWidth, height: pixelHeight, unit = "
|
|
59
|
-
const defaultValue = `-- x -- ${unit
|
|
60
|
+
function getViewportSize({ bounds, zoom, width: pixelWidth, height: pixelHeight, unit = "NM", formatter = numberFormatter }) {
|
|
61
|
+
const defaultValue = `-- x -- ${unit}`;
|
|
62
|
+
const unitKey = DISTANCE_UNIT_BY_SYMBOL[unit];
|
|
63
|
+
if (!unitKey) {
|
|
64
|
+
const validSymbols = Object.values(DISTANCE_UNIT_SYMBOLS).join(", ");
|
|
65
|
+
logger.error(`Invalid distance unit symbol: "${unit}". Expected one of: ${validSymbols}`);
|
|
66
|
+
return defaultValue;
|
|
67
|
+
}
|
|
60
68
|
if (!bounds || bounds.every((b) => Number.isNaN(b))) return defaultValue;
|
|
61
69
|
if (Number.isNaN(zoom) || pixelWidth === 0 || pixelHeight === 0) return defaultValue;
|
|
62
70
|
const [, minLat, , maxLat] = bounds;
|
|
@@ -65,10 +73,10 @@ function getViewportSize({ bounds, zoom, width: pixelWidth, height: pixelHeight,
|
|
|
65
73
|
const metersPerPixel = METERS_PER_PIXEL_AT_ZOOM_0 * Math.cos(centerLat * Math.PI / 180) / 2 ** zoom;
|
|
66
74
|
const widthMeters = pixelWidth * metersPerPixel;
|
|
67
75
|
const heightMeters = pixelHeight * metersPerPixel;
|
|
68
|
-
const conversionFactor = METERS_TO_UNIT[
|
|
76
|
+
const conversionFactor = METERS_TO_UNIT[unitKey];
|
|
69
77
|
const widthDistance = Math.round(widthMeters * conversionFactor);
|
|
70
78
|
const heightDistance = Math.round(heightMeters * conversionFactor);
|
|
71
|
-
return `${formatter.format(widthDistance)} x ${formatter.format(heightDistance)} ${unit
|
|
79
|
+
return `${formatter.format(widthDistance)} x ${formatter.format(heightDistance)} ${unit}`;
|
|
72
80
|
}
|
|
73
81
|
|
|
74
82
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../src/viewport/utils.ts"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../src/viewport/utils.ts"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n DISTANCE_UNIT_BY_SYMBOL,\n DISTANCE_UNIT_SYMBOLS,\n} from '@accelint/constants/units';\nimport { createLoggerDomain } from '../shared/logger';\nimport type { GetViewportSizeArgs } from './types';\n\nconst logger = createLoggerDomain('[Viewport]');\n\nconst numberFormatter = Intl.NumberFormat('en-US');\n\n/**\n * Web Mercator constant: meters per pixel at zoom 0, equator.\n * This is Earth's circumference (40075016.686m) divided by 256 (tile size).\n */\nconst METERS_PER_PIXEL_AT_ZOOM_0 = 156543.03392;\n\n/**\n * Unit conversion factors from meters.\n */\nconst METERS_TO_UNIT = {\n kilometers: 0.001,\n meters: 1,\n nauticalmiles: 0.000539957,\n miles: 0.000621371,\n feet: 3.28084,\n} as const;\n\n/**\n * Returns a formatted viewport size string i.e. `660 x 1,801 NM`\n *\n * Calculates the geographic distance of the viewport using zoom level and\n * pixel dimensions with the Web Mercator projection formula. This approach\n * provides stable results without the edge cases of bounds-based calculations.\n *\n * @param args - Viewport size calculation arguments\n * @param args.bounds - Geographic bounds [minLon, minLat, maxLon, maxLat]\n * @param args.zoom - Zoom level for meters-per-pixel calculation\n * @param args.width - Viewport width in pixels\n * @param args.height - Viewport height in pixels\n * @param args.unit - Unit symbol: `km | m | NM | mi | ft`. Defaults to `NM`\n * @param args.formatter - Number formatter for localization (defaults to en-US)\n * @returns Formatted string like \"660 x 1,801 NM\" or \"-- x -- NM\" if invalid\n *\n * @example\n * ```typescript\n * getViewportSize({ bounds: [-82, 22, -71, 52], zoom: 5, width: 800, height: 600, unit: 'NM' })\n * // returns \"612 x 459 NM\"\n *\n * getViewportSize({ bounds: [170, 50, -170, 60], zoom: 4, width: 1024, height: 768, unit: 'km' })\n * // returns \"2,050 x 1,538 km\"\n * ```\n */\nexport function getViewportSize({\n bounds,\n zoom,\n width: pixelWidth,\n height: pixelHeight,\n unit = 'NM',\n formatter = numberFormatter,\n}: GetViewportSizeArgs) {\n const defaultValue = `-- x -- ${unit}`;\n const unitKey = DISTANCE_UNIT_BY_SYMBOL[unit];\n\n if (!unitKey) {\n const validSymbols = Object.values(DISTANCE_UNIT_SYMBOLS).join(', ');\n\n logger.error(\n `Invalid distance unit symbol: \"${unit}\". Expected one of: ${validSymbols}`,\n );\n\n return defaultValue;\n }\n\n // Validate inputs\n if (!bounds || bounds.every((b) => Number.isNaN(b))) {\n return defaultValue;\n }\n\n if (Number.isNaN(zoom) || pixelWidth === 0 || pixelHeight === 0) {\n return defaultValue;\n }\n\n const [, minLat, , maxLat] = bounds;\n\n // Validate latitude bounds are within valid geographic ranges\n if (minLat < -90 || minLat > 90 || maxLat < -90 || maxLat > 90) {\n return defaultValue;\n }\n\n // Calculate center latitude for the viewport\n const centerLat = (minLat + maxLat) / 2;\n\n // Web Mercator formula: meters per pixel at given zoom and latitude\n // Resolution = 156543.03392 * cos(latitude * π/180) / 2^zoom\n const metersPerPixel =\n (METERS_PER_PIXEL_AT_ZOOM_0 * Math.cos((centerLat * Math.PI) / 180)) /\n 2 ** zoom;\n\n // Calculate distances in meters\n const widthMeters = pixelWidth * metersPerPixel;\n const heightMeters = pixelHeight * metersPerPixel;\n\n // Convert to requested unit\n const conversionFactor = METERS_TO_UNIT[unitKey];\n\n const widthDistance = Math.round(widthMeters * conversionFactor);\n const heightDistance = Math.round(heightMeters * conversionFactor);\n\n const width = formatter.format(widthDistance);\n const height = formatter.format(heightDistance);\n\n return `${width} x ${height} ${unit}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,MAAM,SAAS,mBAAmB,aAAa;AAE/C,MAAM,kBAAkB,KAAK,aAAa,QAAQ;;;;;AAMlD,MAAM,6BAA6B;;;;AAKnC,MAAM,iBAAiB;CACrB,YAAY;CACZ,QAAQ;CACR,eAAe;CACf,OAAO;CACP,MAAM;CACP;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BD,SAAgB,gBAAgB,EAC9B,QACA,MACA,OAAO,YACP,QAAQ,aACR,OAAO,MACP,YAAY,mBACU;CACtB,MAAM,eAAe,WAAW;CAChC,MAAM,UAAU,wBAAwB;AAExC,KAAI,CAAC,SAAS;EACZ,MAAM,eAAe,OAAO,OAAO,sBAAsB,CAAC,KAAK,KAAK;AAEpE,SAAO,MACL,kCAAkC,KAAK,sBAAsB,eAC9D;AAED,SAAO;;AAIT,KAAI,CAAC,UAAU,OAAO,OAAO,MAAM,OAAO,MAAM,EAAE,CAAC,CACjD,QAAO;AAGT,KAAI,OAAO,MAAM,KAAK,IAAI,eAAe,KAAK,gBAAgB,EAC5D,QAAO;CAGT,MAAM,GAAG,UAAU,UAAU;AAG7B,KAAI,SAAS,OAAO,SAAS,MAAM,SAAS,OAAO,SAAS,GAC1D,QAAO;CAIT,MAAM,aAAa,SAAS,UAAU;CAItC,MAAM,iBACH,6BAA6B,KAAK,IAAK,YAAY,KAAK,KAAM,IAAI,GACnE,KAAK;CAGP,MAAM,cAAc,aAAa;CACjC,MAAM,eAAe,cAAc;CAGnC,MAAM,mBAAmB,eAAe;CAExC,MAAM,gBAAgB,KAAK,MAAM,cAAc,iBAAiB;CAChE,MAAM,iBAAiB,KAAK,MAAM,eAAe,iBAAiB;AAKlE,QAAO,GAHO,UAAU,OAAO,cAAc,CAG7B,KAFD,UAAU,OAAO,eAAe,CAEnB,GAAG"}
|
|
@@ -10,15 +10,16 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { SupportedDistanceUnit } from "./types.js";
|
|
14
13
|
import { ComponentPropsWithRef } from "react";
|
|
15
14
|
import { UniqueId } from "@accelint/core";
|
|
16
15
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
16
|
+
import { DistanceUnitSymbol } from "@accelint/constants/units";
|
|
17
17
|
|
|
18
18
|
//#region src/viewport/viewport-size.d.ts
|
|
19
|
+
/** Props for {@link ViewportSize}. */
|
|
19
20
|
type ViewportSizeProps = ComponentPropsWithRef<'span'> & {
|
|
20
21
|
instanceId: UniqueId;
|
|
21
|
-
unit?:
|
|
22
|
+
unit?: DistanceUnitSymbol;
|
|
22
23
|
};
|
|
23
24
|
/**
|
|
24
25
|
* A span element displaying the current viewport bounds in the specified unit.
|
|
@@ -28,7 +29,7 @@ type ViewportSizeProps = ComponentPropsWithRef<'span'> & {
|
|
|
28
29
|
*
|
|
29
30
|
* @param props - Extends `<span>` props
|
|
30
31
|
* @param props.instanceId - The id of the view to subscribe to
|
|
31
|
-
* @param props.unit - Measure of distance: `km | m |
|
|
32
|
+
* @param props.unit - Measure of distance: `km | m | NM | mi | ft`. Defaults to `NM`
|
|
32
33
|
* @param props.className - CSS classes for styling
|
|
33
34
|
*
|
|
34
35
|
* @example
|
|
@@ -24,7 +24,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
24
24
|
*
|
|
25
25
|
* @param props - Extends `<span>` props
|
|
26
26
|
* @param props.instanceId - The id of the view to subscribe to
|
|
27
|
-
* @param props.unit - Measure of distance: `km | m |
|
|
27
|
+
* @param props.unit - Measure of distance: `km | m | NM | mi | ft`. Defaults to `NM`
|
|
28
28
|
* @param props.className - CSS classes for styling
|
|
29
29
|
*
|
|
30
30
|
* @example
|
|
@@ -40,7 +40,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
40
40
|
* />
|
|
41
41
|
* ```
|
|
42
42
|
*/
|
|
43
|
-
function ViewportSize({ instanceId, unit = "
|
|
43
|
+
function ViewportSize({ instanceId, unit = "NM", ...rest }) {
|
|
44
44
|
const { bounds, zoom, width, height } = useMapViewport(instanceId);
|
|
45
45
|
return /* @__PURE__ */ jsx("span", {
|
|
46
46
|
...rest,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewport-size.js","names":[],"sources":["../../src/viewport/viewport-size.tsx"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { useMapViewport } from './store';\nimport { getViewportSize } from './utils';\nimport type {
|
|
1
|
+
{"version":3,"file":"viewport-size.js","names":[],"sources":["../../src/viewport/viewport-size.tsx"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { useMapViewport } from './store';\nimport { getViewportSize } from './utils';\nimport type { DistanceUnitSymbol } from '@accelint/constants/units';\nimport type { UniqueId } from '@accelint/core';\nimport type { ComponentPropsWithRef } from 'react';\n\n/** Props for {@link ViewportSize}. */\nexport type ViewportSizeProps = ComponentPropsWithRef<'span'> & {\n instanceId: UniqueId;\n unit?: DistanceUnitSymbol;\n};\n\n/**\n * A span element displaying the current viewport bounds in the specified unit.\n *\n * Displays the viewport dimensions in a format like `660 x 1,801 NM`.\n * Updates automatically as the viewport changes by subscribing to viewport events.\n *\n * @param props - Extends `<span>` props\n * @param props.instanceId - The id of the view to subscribe to\n * @param props.unit - Measure of distance: `km | m | NM | mi | ft`. Defaults to `NM`\n * @param props.className - CSS classes for styling\n *\n * @example\n * ```tsx\n * // Basic usage with default nautical miles\n * <ViewportSize instanceId=\"some-uuid\" />\n *\n * // With custom unit and styling\n * <ViewportSize\n * instanceId=\"some-uuid\"\n * unit=\"km\"\n * className=\"text-sm text-gray-600\"\n * />\n * ```\n */\nexport function ViewportSize({\n instanceId,\n unit = 'NM',\n ...rest\n}: ViewportSizeProps) {\n const { bounds, zoom, width, height } = useMapViewport(instanceId);\n\n return (\n <span {...rest}>\n {getViewportSize({ bounds, unit, zoom, width, height })}\n </span>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,aAAa,EAC3B,YACA,OAAO,MACP,GAAG,QACiB;CACpB,MAAM,EAAE,QAAQ,MAAM,OAAO,WAAW,eAAe,WAAW;AAElE,QACE,oBAAC;EAAK,GAAI;YACP,gBAAgB;GAAE;GAAQ;GAAM;GAAM;GAAO;GAAQ,CAAC;GAClD"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@accelint/map-toolkit",
|
|
3
3
|
"description": "A collection of components and utilities to simplify visualizing and working with geospatial data.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0",
|
|
5
5
|
"author": "https://hypergiant.com",
|
|
6
6
|
"$schema": "https://json.schemastore.org/package",
|
|
7
7
|
"devDependencies": {
|
|
@@ -44,14 +44,15 @@
|
|
|
44
44
|
"vitest": "^4.0.15",
|
|
45
45
|
"@accelint/biome-config": "1.1.0",
|
|
46
46
|
"@accelint/bus": "4.0.0",
|
|
47
|
+
"@accelint/constants": "0.3.0",
|
|
47
48
|
"@accelint/core": "0.6.0",
|
|
48
|
-
"@accelint/design-foundation": "3.0.
|
|
49
|
-
"@accelint/design-toolkit": "9.
|
|
49
|
+
"@accelint/design-foundation": "3.0.2",
|
|
50
|
+
"@accelint/design-toolkit": "9.9.0",
|
|
50
51
|
"@accelint/geo": "0.6.0",
|
|
51
52
|
"@accelint/hotkey-manager": "1.0.2",
|
|
52
|
-
"@accelint/logger": "1.0
|
|
53
|
+
"@accelint/logger": "1.1.0",
|
|
53
54
|
"@accelint/postcss-tailwind-css-modules": "1.0.1",
|
|
54
|
-
"@accelint/predicates": "0.5.
|
|
55
|
+
"@accelint/predicates": "0.5.2",
|
|
55
56
|
"@accelint/smeegl": "0.3.5",
|
|
56
57
|
"@accelint/typescript-config": "0.1.4",
|
|
57
58
|
"@accelint/vitest-config": "0.1.6"
|
|
@@ -77,6 +78,11 @@
|
|
|
77
78
|
"./deckgl/base-map/events": "./dist/deckgl/base-map/events.js",
|
|
78
79
|
"./deckgl/base-map/provider": "./dist/deckgl/base-map/provider.js",
|
|
79
80
|
"./deckgl/base-map/types": "./dist/deckgl/base-map/types.js",
|
|
81
|
+
"./deckgl/extensions": "./dist/deckgl/extensions/index.js",
|
|
82
|
+
"./deckgl/extensions/coffin-corner": "./dist/deckgl/extensions/coffin-corner/index.js",
|
|
83
|
+
"./deckgl/extensions/coffin-corner/coffin-corner-extension": "./dist/deckgl/extensions/coffin-corner/coffin-corner-extension.js",
|
|
84
|
+
"./deckgl/extensions/coffin-corner/types": "./dist/deckgl/extensions/coffin-corner/types.js",
|
|
85
|
+
"./deckgl/extensions/coffin-corner/use-coffin-corner": "./dist/deckgl/extensions/coffin-corner/use-coffin-corner.js",
|
|
80
86
|
"./deckgl/saved-viewports": "./dist/deckgl/saved-viewports/index.js",
|
|
81
87
|
"./deckgl/saved-viewports/storage": "./dist/deckgl/saved-viewports/storage.js",
|
|
82
88
|
"./deckgl/shapes": "./dist/deckgl/shapes/index.js",
|
|
@@ -161,10 +167,11 @@
|
|
|
161
167
|
"@types/geojson": "^7946.0.14",
|
|
162
168
|
"react": "^19",
|
|
163
169
|
"@accelint/bus": "4.0.0",
|
|
170
|
+
"@accelint/constants": "0.3.0",
|
|
164
171
|
"@accelint/core": "0.6.0",
|
|
165
172
|
"@accelint/geo": "0.6.0",
|
|
166
173
|
"@accelint/hotkey-manager": "1.0.2",
|
|
167
|
-
"@accelint/logger": "1.0
|
|
174
|
+
"@accelint/logger": "1.1.0"
|
|
168
175
|
},
|
|
169
176
|
"private": false,
|
|
170
177
|
"publishConfig": {
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
'use client';
|
|
15
|
-
|
|
16
|
-
//#region src/deckgl/shapes/display-shape-layer/utils/interaction.ts
|
|
17
|
-
/**
|
|
18
|
-
* Compute hover/selection interaction state for a feature by index.
|
|
19
|
-
*
|
|
20
|
-
* @param feature - The feature to check
|
|
21
|
-
* @param selectedShapeId - Currently selected shape ID
|
|
22
|
-
* @param hoverIndex - Currently hovered feature index
|
|
23
|
-
* @param shapeIdToIndex - Map of shapeId to feature index for O(1) lookup
|
|
24
|
-
* @returns `{ isSelected, isHovered }`
|
|
25
|
-
* @example
|
|
26
|
-
* ```typescript
|
|
27
|
-
* const { isSelected, isHovered } = getPointInteractionState(
|
|
28
|
-
* feature,
|
|
29
|
-
* selectedShapeId,
|
|
30
|
-
* hoverIndex,
|
|
31
|
-
* shapeIdToIndex, // Map<ShapeId, number> from getFeaturesWithId()
|
|
32
|
-
* );
|
|
33
|
-
* if (isSelected || isHovered) {
|
|
34
|
-
* // render interaction feedback
|
|
35
|
-
* }
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
function getPointInteractionState(feature, selectedShapeId, hoverIndex, shapeIdToIndex) {
|
|
39
|
-
const shapeId = feature.properties?.shapeId;
|
|
40
|
-
const isSelected = shapeId != null && shapeId === selectedShapeId;
|
|
41
|
-
const featureIndex = shapeId ? shapeIdToIndex.get(shapeId) : void 0;
|
|
42
|
-
return {
|
|
43
|
-
isSelected,
|
|
44
|
-
isHovered: hoverIndex !== void 0 && featureIndex === hoverIndex
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
//#endregion
|
|
49
|
-
export { getPointInteractionState };
|
|
50
|
-
//# sourceMappingURL=interaction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interaction.js","names":[],"sources":["../../../../../src/deckgl/shapes/display-shape-layer/utils/interaction.ts"],"sourcesContent":["/*\n * Copyright 2026 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n'use client';\n\nimport type { Shape, ShapeId } from '../../shared/types';\n\n/**\n * Compute hover/selection interaction state for a feature by index.\n *\n * @param feature - The feature to check\n * @param selectedShapeId - Currently selected shape ID\n * @param hoverIndex - Currently hovered feature index\n * @param shapeIdToIndex - Map of shapeId to feature index for O(1) lookup\n * @returns `{ isSelected, isHovered }`\n * @example\n * ```typescript\n * const { isSelected, isHovered } = getPointInteractionState(\n * feature,\n * selectedShapeId,\n * hoverIndex,\n * shapeIdToIndex, // Map<ShapeId, number> from getFeaturesWithId()\n * );\n * if (isSelected || isHovered) {\n * // render interaction feedback\n * }\n * ```\n */\nexport function getPointInteractionState(\n feature: Shape['feature'],\n selectedShapeId: ShapeId | undefined,\n hoverIndex: number | undefined,\n shapeIdToIndex: Map<ShapeId, number>,\n): { isSelected: boolean; isHovered: boolean } {\n const shapeId = feature.properties?.shapeId;\n const isSelected = shapeId != null && shapeId === selectedShapeId;\n const featureIndex = shapeId ? shapeIdToIndex.get(shapeId) : undefined;\n const isHovered = hoverIndex !== undefined && featureIndex === hoverIndex;\n return { isSelected, isHovered };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,yBACd,SACA,iBACA,YACA,gBAC6C;CAC7C,MAAM,UAAU,QAAQ,YAAY;CACpC,MAAM,aAAa,WAAW,QAAQ,YAAY;CAClD,MAAM,eAAe,UAAU,eAAe,IAAI,QAAQ,GAAG;AAE7D,QAAO;EAAE;EAAY,WADH,eAAe,UAAa,iBAAiB;EAC/B"}
|