@open-pioneer/coordinate-viewer 0.10.0 → 0.11.0-dev.20250515143825
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/CoordinateViewer.js +1 -1
- package/CoordinateViewer.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @open-pioneer/coordinate-viewer
|
|
2
2
|
|
|
3
|
+
## 0.11.0-dev.20250515143825
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 738390e: Update to Chakra v3
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [738390e]
|
|
12
|
+
- Updated dependencies [738390e]
|
|
13
|
+
- @open-pioneer/map@0.11.0-dev.20250515143825
|
|
14
|
+
|
|
3
15
|
## 0.10.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/CoordinateViewer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { Box, Text } from '@
|
|
2
|
+
import { Box, Text } from '@chakra-ui/react';
|
|
3
3
|
import { useMapModel } from '@open-pioneer/map';
|
|
4
4
|
import { useCommonComponentProps } from '@open-pioneer/react-utils';
|
|
5
5
|
import { useReactiveSnapshot } from '@open-pioneer/reactivity';
|
package/CoordinateViewer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoordinateViewer.js","sources":["CoordinateViewer.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Box, Text } from \"@
|
|
1
|
+
{"version":3,"file":"CoordinateViewer.js","sources":["CoordinateViewer.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Box, Text } from \"@chakra-ui/react\";\nimport { MapModelProps, useMapModel } from \"@open-pioneer/map\";\nimport { CommonComponentProps, useCommonComponentProps } from \"@open-pioneer/react-utils\";\nimport { useReactiveSnapshot } from \"@open-pioneer/reactivity\";\nimport { PackageIntl } from \"@open-pioneer/runtime\";\nimport OlMap from \"ol/Map\";\nimport { unByKey } from \"ol/Observable\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { EventsKey } from \"ol/events\";\nimport { transform } from \"ol/proj\";\nimport { useIntl } from \"open-pioneer:react-hooks\";\nimport { FC, useEffect, useState } from \"react\";\n\nconst DEFAULT_PRECISION = 4;\nconst DEFAULT_DISPLAY_FORMAT = \"decimal\";\n\n/**\n * These are special properties for the CoordinateViewer.\n */\nexport interface CoordinateViewerProps extends CommonComponentProps, MapModelProps {\n /**\n * Number of decimal places shown for coordinates.\n */\n precision?: number;\n\n /**\n * Projection of the coordinates shown in the rendered HTML, does not affect the map projection\n */\n displayProjectionCode?: string;\n\n /**\n * Configures the display format.\n * By default, the current coordinates are shown as decimal numbers (format: \"decimal\").\n *\n * If the format is set to \"degree\", the coordinates are shown in angular degrees (DMS).\n * This can only be used meaningfully (at this time) if the underlying projection provides lat/lon coordinates.\n */\n format?: \"decimal\" | \"degree\";\n}\n\n/**\n * The `CoordinateViewer` component can be used in an app to render the coordinates at the current mouse position.\n */\nexport const CoordinateViewer: FC<CoordinateViewerProps> = (props) => {\n const { precision, displayProjectionCode, format } = props;\n const { containerProps } = useCommonComponentProps(\"coordinate-viewer\", props);\n const { map } = useMapModel(props);\n const olMap = map?.olMap;\n const mapProjectionCode = useReactiveSnapshot(() => {\n return map?.projection.getCode() ?? \"\";\n }, [map]);\n let { coordinates } = useCoordinates(olMap);\n coordinates =\n coordinates && displayProjectionCode\n ? transformCoordinates(coordinates, mapProjectionCode, displayProjectionCode)\n : coordinates;\n const coordinatesString = useCoordinatesString(coordinates, precision, format);\n const projectionString = displayProjectionCode ? displayProjectionCode : mapProjectionCode;\n const displayString = coordinatesString ? coordinatesString + \" \" + projectionString : \"\";\n return (\n <Box {...containerProps}>\n <Text className=\"coordinate-viewer-text\">{displayString}</Text>\n </Box>\n );\n};\n\n/* Separate function for easier testing */\nexport function useCoordinatesString(\n coordinates: number[] | undefined,\n precision: number | undefined,\n format: CoordinateViewerProps[\"format\"]\n): string {\n const intl = useIntl();\n const coordinatesString = coordinates\n ? formatCoordinates(coordinates, precision, intl, format)\n : \"\";\n return coordinatesString;\n}\n\nfunction useCoordinates(map: OlMap | undefined): { coordinates: Coordinate | undefined } {\n const [coordinates, setCoordinates] = useState<Coordinate | undefined>();\n\n useEffect(() => {\n if (!map) {\n return;\n }\n\n const eventsKey: EventsKey = map.on(\"pointermove\", (evt) => {\n setCoordinates(evt.coordinate);\n });\n\n return () => unByKey(eventsKey);\n }, [map]);\n\n return { coordinates };\n}\n\nfunction formatCoordinates(\n coordinates: number[],\n configuredPrecision: number | undefined,\n intl: PackageIntl,\n configuredFormat: CoordinateViewerProps[\"format\"]\n) {\n if (coordinates[0] == null || coordinates[1] == null) {\n return \"\";\n }\n\n const precision = configuredPrecision ?? DEFAULT_PRECISION;\n const format = configuredFormat ?? DEFAULT_DISPLAY_FORMAT;\n const [x, y] = coordinates;\n\n let str;\n if (format === \"degree\" && isFinite(x) && isFinite(y)) {\n const [xHour, xMin, xSek] = toDegree(x, intl, precision);\n const [yHour, yMin, ySek] = toDegree(y, intl, precision);\n\n const xString = `${Math.abs(xHour)}°${xMin}'${xSek}\"${0 <= xHour ? \"(E)\" : \"(W)\"}`;\n const yString = `${Math.abs(yHour)}°${yMin}'${ySek}\"${0 <= yHour ? \"(N)\" : \"(S)\"}`;\n\n str = xString + \" \" + yString;\n } else {\n const xString = intl.formatNumber(x, {\n maximumFractionDigits: precision,\n minimumFractionDigits: precision\n });\n const yString = intl.formatNumber(y, {\n maximumFractionDigits: precision,\n minimumFractionDigits: precision\n });\n str = xString + \" \" + yString;\n }\n return str;\n}\n\nfunction toDegree(\n coordPart: number,\n intl: PackageIntl,\n precision: number\n): [number, number, string] {\n const cHour = Math.floor(coordPart);\n const cNach = coordPart - cHour;\n\n const cMin = Math.floor(60 * cNach);\n const cMinNach = 60 * cNach - cMin;\n\n const cSek = 60 * cMinNach;\n const cSekRounded = intl.formatNumber(cSek, {\n maximumFractionDigits: precision,\n minimumFractionDigits: precision\n });\n\n return [cHour, cMin, cSekRounded];\n}\n\nfunction transformCoordinates(\n coordinates: number[],\n source: string,\n destination: string\n): number[] {\n const transformed = transform(coordinates, source, destination);\n return transformed;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAeA,MAAM,iBAAoB,GAAA,CAAA;AAC1B,MAAM,sBAAyB,GAAA,SAAA;AA6BlB,MAAA,gBAAA,GAA8C,CAAC,KAAU,KAAA;AAClE,EAAA,MAAM,EAAE,SAAA,EAAW,qBAAuB,EAAA,MAAA,EAAW,GAAA,KAAA;AACrD,EAAA,MAAM,EAAE,cAAA,EAAmB,GAAA,uBAAA,CAAwB,qBAAqB,KAAK,CAAA;AAC7E,EAAA,MAAM,EAAE,GAAA,EAAQ,GAAA,WAAA,CAAY,KAAK,CAAA;AACjC,EAAA,MAAM,QAAQ,GAAK,EAAA,KAAA;AACnB,EAAM,MAAA,iBAAA,GAAoB,oBAAoB,MAAM;AAChD,IAAO,OAAA,GAAA,EAAK,UAAW,CAAA,OAAA,EAAa,IAAA,EAAA;AAAA,GACxC,EAAG,CAAC,GAAG,CAAC,CAAA;AACR,EAAA,IAAI,EAAE,WAAA,EAAgB,GAAA,cAAA,CAAe,KAAK,CAAA;AAC1C,EAAA,WAAA,GACI,eAAe,qBACT,GAAA,oBAAA,CAAqB,WAAa,EAAA,iBAAA,EAAmB,qBAAqB,CAC1E,GAAA,WAAA;AACV,EAAA,MAAM,iBAAoB,GAAA,oBAAA,CAAqB,WAAa,EAAA,SAAA,EAAW,MAAM,CAAA;AAC7E,EAAM,MAAA,gBAAA,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CACL,SACA,EAAA,IAAA,EACA,SACwB,EAAA;AACxB,EAAM,MAAA,KAAA,GAAQ,IAAK,CAAA,KAAA,CAAM,SAAS,CAAA;AAClC,EAAA,MAAM,QAAQ,SAAY,GAAA,KAAA;AAE1B,EAAA,MAAM,IAAO,GAAA,IAAA,CAAK,KAAM,CAAA,EAAA,GAAK,KAAK,CAAA;AAClC,EAAM,MAAA,QAAA,GAAW,KAAK,KAAQ,GAAA,IAAA;AAE9B,EAAA,MAAM,OAAO,EAAK,GAAA,QAAA;AAClB,EAAM,MAAA,WAAA,GAAc,IAAK,CAAA,YAAA,CAAa,IAAM,EAAA;AAAA,IACxC,qBAAuB,EAAA,SAAA;AAAA,IACvB,qBAAuB,EAAA;AAAA,GAC1B,CAAA;AAED,EAAO,OAAA,CAAC,KAAO,EAAA,IAAA,EAAM,WAAW,CAAA;AACpC;AAEA,SAAS,oBAAA,CACL,WACA,EAAA,MAAA,EACA,WACQ,EAAA;AACR,EAAA,MAAM,WAAc,GAAA,SAAA,CAAU,WAAa,EAAA,MAAA,EAAQ,WAAW,CAAA;AAC9D,EAAO,OAAA,WAAA;AACX;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/coordinate-viewer",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.11.0-dev.20250515143825",
|
|
5
5
|
"description": "This package provides a UI component to show the current coordinates at the users current mouse position.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"open-pioneer-trails"
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"directory": "src/packages/coordinate-viewer"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@
|
|
18
|
-
"@open-pioneer/react-utils": "
|
|
19
|
-
"@open-pioneer/runtime": "
|
|
20
|
-
"@open-pioneer/reactivity": "
|
|
17
|
+
"@chakra-ui/react": "^3.17.0",
|
|
18
|
+
"@open-pioneer/react-utils": "4.0.0-dev.20250512105016",
|
|
19
|
+
"@open-pioneer/runtime": "4.0.0-dev.20250512105016",
|
|
20
|
+
"@open-pioneer/reactivity": "4.0.0-dev.20250512105016",
|
|
21
21
|
"ol": "^10.5.0",
|
|
22
22
|
"react": "^19.1.0",
|
|
23
|
-
"@open-pioneer/map": "
|
|
23
|
+
"@open-pioneer/map": "0.11.0-dev.20250515143825"
|
|
24
24
|
},
|
|
25
25
|
"exports": {
|
|
26
26
|
"./package.json": "./package.json",
|