@open-pioneer/coordinate-viewer 0.7.0 → 0.8.0-dev.20241120115147
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 +23 -0
- package/CoordinateViewer.d.ts +1 -1
- package/CoordinateViewer.js +5 -2
- package/CoordinateViewer.js.map +1 -1
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @open-pioneer/coordinate-viewer
|
|
2
2
|
|
|
3
|
+
## 0.8.0-dev.20241120115147
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2fa8020: Update trails core package dependencies.
|
|
8
|
+
|
|
9
|
+
- Also updates Chakra UI to the latest 2.x version and Chakra React Select to version 5.
|
|
10
|
+
- Removes any obsolete references to `@chakra-ui/system`.
|
|
11
|
+
This dependency seems to be no longer required and may lead to duplicate packages in your dependency tree.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- d8337a6: Refactor implementation to use the new reactive properties of the map model.
|
|
16
|
+
- Updated dependencies [b717121]
|
|
17
|
+
- Updated dependencies [e7978a8]
|
|
18
|
+
- Updated dependencies [7ae9f90]
|
|
19
|
+
- Updated dependencies [d8337a6]
|
|
20
|
+
- Updated dependencies [b2127df]
|
|
21
|
+
- Updated dependencies [2fa8020]
|
|
22
|
+
- Updated dependencies [7ae9f90]
|
|
23
|
+
- Updated dependencies [d8337a6]
|
|
24
|
+
- @open-pioneer/map@0.8.0-dev.20241120115147
|
|
25
|
+
|
|
3
26
|
## 0.7.0
|
|
4
27
|
|
|
5
28
|
### Minor Changes
|
package/CoordinateViewer.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export interface CoordinateViewerProps extends CommonComponentProps, MapModelPro
|
|
|
23
23
|
format?: "decimal" | "degree";
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
* The `CoordinateViewer`component can be used in an app to render the coordinates at the current mouse position.
|
|
26
|
+
* The `CoordinateViewer` component can be used in an app to render the coordinates at the current mouse position.
|
|
27
27
|
*/
|
|
28
28
|
export declare const CoordinateViewer: FC<CoordinateViewerProps>;
|
|
29
29
|
export declare function useCoordinatesString(coordinates: number[] | undefined, precision: number | undefined, format: CoordinateViewerProps["format"]): string;
|
package/CoordinateViewer.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { Box, Text } from '@open-pioneer/chakra-integration';
|
|
3
|
-
import { useMapModel
|
|
3
|
+
import { useMapModel } from '@open-pioneer/map';
|
|
4
4
|
import { useCommonComponentProps } from '@open-pioneer/react-utils';
|
|
5
|
+
import { useReactiveSnapshot } from '@open-pioneer/reactivity';
|
|
5
6
|
import { unByKey } from 'ol/Observable.js';
|
|
6
7
|
import { transform } from 'ol/proj.js';
|
|
7
8
|
import { useIntl } from './_virtual/_virtual-pioneer-module_react-hooks.js';
|
|
@@ -14,7 +15,9 @@ const CoordinateViewer = (props) => {
|
|
|
14
15
|
const { containerProps } = useCommonComponentProps("coordinate-viewer", props);
|
|
15
16
|
const { map } = useMapModel(props);
|
|
16
17
|
const olMap = map?.olMap;
|
|
17
|
-
const mapProjectionCode =
|
|
18
|
+
const mapProjectionCode = useReactiveSnapshot(() => {
|
|
19
|
+
return map?.projection.getCode() ?? "";
|
|
20
|
+
}, [map]);
|
|
18
21
|
let { coordinates } = useCoordinates(olMap);
|
|
19
22
|
coordinates = coordinates && displayProjectionCode ? transformCoordinates(coordinates, mapProjectionCode, displayProjectionCode) : coordinates;
|
|
20
23
|
const coordinatesString = useCoordinatesString(coordinates, precision, format);
|
package/CoordinateViewer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoordinateViewer.js","sources":["CoordinateViewer.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Box, Text } from \"@open-pioneer/chakra-integration\";\nimport { MapModelProps, useMapModel
|
|
1
|
+
{"version":3,"file":"CoordinateViewer.js","sources":["CoordinateViewer.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Box, Text } from \"@open-pioneer/chakra-integration\";\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,CAAA;AAC1B,MAAM,sBAAyB,GAAA,SAAA,CAAA;AA6BlB,MAAA,gBAAA,GAA8C,CAAC,KAAU,KAAA;AAClE,EAAA,MAAM,EAAE,SAAA,EAAW,qBAAuB,EAAA,MAAA,EAAW,GAAA,KAAA,CAAA;AACrD,EAAA,MAAM,EAAE,cAAA,EAAmB,GAAA,uBAAA,CAAwB,qBAAqB,KAAK,CAAA,CAAA;AAC7E,EAAA,MAAM,EAAE,GAAA,EAAQ,GAAA,WAAA,CAAY,KAAK,CAAA,CAAA;AACjC,EAAA,MAAM,QAAQ,GAAK,EAAA,KAAA,CAAA;AACnB,EAAM,MAAA,iBAAA,GAAoB,oBAAoB,MAAM;AAChD,IAAO,OAAA,GAAA,EAAK,UAAW,CAAA,OAAA,EAAa,IAAA,EAAA,CAAA;AAAA,GACxC,EAAG,CAAC,GAAG,CAAC,CAAA,CAAA;AACR,EAAA,IAAI,EAAE,WAAA,EAAgB,GAAA,cAAA,C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ACX;;;;"}
|
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.8.0-dev.20241120115147",
|
|
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,12 +14,13 @@
|
|
|
14
14
|
"directory": "src/packages/coordinate-viewer"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@open-pioneer/chakra-integration": "^2.
|
|
18
|
-
"@open-pioneer/react-utils": "^2.
|
|
19
|
-
"@open-pioneer/runtime": "^2.
|
|
20
|
-
"
|
|
17
|
+
"@open-pioneer/chakra-integration": "^2.4.0-dev.20241120092632",
|
|
18
|
+
"@open-pioneer/react-utils": "^2.4.0-dev.20241120092632",
|
|
19
|
+
"@open-pioneer/runtime": "^2.4.0-dev.20241120092632",
|
|
20
|
+
"@open-pioneer/reactivity": "^2.4.0-dev.20241120092632",
|
|
21
|
+
"ol": "^10.2.1",
|
|
21
22
|
"react": "^18.3.1",
|
|
22
|
-
"@open-pioneer/map": "^0.
|
|
23
|
+
"@open-pioneer/map": "^0.8.0-dev.20241120115147"
|
|
23
24
|
},
|
|
24
25
|
"exports": {
|
|
25
26
|
"./package.json": "./package.json",
|