@open-pioneer/coordinate-viewer 0.9.0-dev.20250220091855 → 0.9.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 CHANGED
@@ -1,145 +1,154 @@
1
1
  # @open-pioneer/coordinate-viewer
2
2
 
3
- ## 0.9.0-dev.20250220091855
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - cb94c75: update dependencies
4
8
 
5
9
  ### Patch Changes
6
10
 
7
- - Updated dependencies [f327eec]
8
- - Updated dependencies [f327eec]
9
- - Updated dependencies [209eb8e]
10
- - @open-pioneer/map@0.9.0-dev.20250220091855
11
+ - Updated dependencies [e7fdc5d]
12
+ - Updated dependencies [cb94c75]
13
+ - Updated dependencies [37cd707]
14
+ - Updated dependencies [32ed2cd]
15
+ - Updated dependencies [f327eec]
16
+ - Updated dependencies [f327eec]
17
+ - Updated dependencies [209eb8e]
18
+ - Updated dependencies [d72e42c]
19
+ - @open-pioneer/map@0.9.0
11
20
 
12
21
  ## 0.8.0
13
22
 
14
23
  ### Minor Changes
15
24
 
16
- - 2fa8020: Update trails core package dependencies.
25
+ - 2fa8020: Update trails core package dependencies.
17
26
 
18
- - Also updates Chakra UI to the latest 2.x version and Chakra React Select to version 5.
19
- - Removes any obsolete references to `@chakra-ui/system`.
20
- This dependency seems to be no longer required and may lead to duplicate packages in your dependency tree.
27
+ - Also updates Chakra UI to the latest 2.x version and Chakra React Select to version 5.
28
+ - Removes any obsolete references to `@chakra-ui/system`.
29
+ This dependency seems to be no longer required and may lead to duplicate packages in your dependency tree.
21
30
 
22
31
  ### Patch Changes
23
32
 
24
- - 49f0207: Update trails core packages to version 2.4.0
25
- - d8337a6: Refactor implementation to use the new reactive properties of the map model.
26
- - Updated dependencies [b717121]
27
- - Updated dependencies [e7978a8]
28
- - Updated dependencies [7a5f1e1]
29
- - Updated dependencies [7ae9f90]
30
- - Updated dependencies [d8337a6]
31
- - Updated dependencies [49f0207]
32
- - Updated dependencies [b2127df]
33
- - Updated dependencies [2fa8020]
34
- - Updated dependencies [7ae9f90]
35
- - Updated dependencies [d8337a6]
36
- - @open-pioneer/map@0.8.0
33
+ - 49f0207: Update trails core packages to version 2.4.0
34
+ - d8337a6: Refactor implementation to use the new reactive properties of the map model.
35
+ - Updated dependencies [b717121]
36
+ - Updated dependencies [e7978a8]
37
+ - Updated dependencies [7a5f1e1]
38
+ - Updated dependencies [7ae9f90]
39
+ - Updated dependencies [d8337a6]
40
+ - Updated dependencies [49f0207]
41
+ - Updated dependencies [b2127df]
42
+ - Updated dependencies [2fa8020]
43
+ - Updated dependencies [7ae9f90]
44
+ - Updated dependencies [d8337a6]
45
+ - @open-pioneer/map@0.8.0
37
46
 
38
47
  ## 0.7.0
39
48
 
40
49
  ### Minor Changes
41
50
 
42
- - 310800c: Switch from `peerDependencies` to normal `dependencies`. Peer dependencies have some usability problems when used at scale.
51
+ - 310800c: Switch from `peerDependencies` to normal `dependencies`. Peer dependencies have some usability problems when used at scale.
43
52
 
44
53
  ### Patch Changes
45
54
 
46
- - 310800c: Update core packages version.
47
- - 583f1d6: The `mapId` or `map` properties are now optional on individual components.
48
- You can use the `DefaultMapProvider` to configure an implicit default value.
55
+ - 310800c: Update core packages version.
56
+ - 583f1d6: The `mapId` or `map` properties are now optional on individual components.
57
+ You can use the `DefaultMapProvider` to configure an implicit default value.
49
58
 
50
59
  Note that configuring _neither_ a default _nor_ an explicit `map` or `mapId` will trigger a runtime error.
51
60
 
52
- - 583f1d6: All UI components in this project now accept the `mapId` (a `string`) _or_ the `map` (a `MapModel`) directly.
53
- - a8b3449: Switch to a new versioning strategy.
54
- From now on, packages released by this repository share a common version number.
55
- - 6b59779: Added option to display geographic coordinates in angle format (DMS) in CoordinateViewer:
61
+ - 583f1d6: All UI components in this project now accept the `mapId` (a `string`) _or_ the `map` (a `MapModel`) directly.
62
+ - a8b3449: Switch to a new versioning strategy.
63
+ From now on, packages released by this repository share a common version number.
64
+ - 6b59779: Added option to display geographic coordinates in angle format (DMS) in CoordinateViewer:
56
65
 
57
66
  ```jsx
58
67
  <CoordinateViewer mapId="map_id" format="degree" />
59
68
  ```
60
69
 
61
- - 900eb11: Update dependencies.
62
- - Updated dependencies [310800c]
63
- - Updated dependencies [2502050]
64
- - Updated dependencies [583f1d6]
65
- - Updated dependencies [583f1d6]
66
- - Updated dependencies [397d617]
67
- - Updated dependencies [a8b3449]
68
- - Updated dependencies [310800c]
69
- - Updated dependencies [900eb11]
70
- - Updated dependencies [583f1d6]
71
- - Updated dependencies [397d617]
72
- - @open-pioneer/map@0.7.0
70
+ - 900eb11: Update dependencies.
71
+ - Updated dependencies [310800c]
72
+ - Updated dependencies [2502050]
73
+ - Updated dependencies [583f1d6]
74
+ - Updated dependencies [583f1d6]
75
+ - Updated dependencies [397d617]
76
+ - Updated dependencies [a8b3449]
77
+ - Updated dependencies [310800c]
78
+ - Updated dependencies [900eb11]
79
+ - Updated dependencies [583f1d6]
80
+ - Updated dependencies [397d617]
81
+ - @open-pioneer/map@0.7.0
73
82
 
74
83
  ## 0.5.4
75
84
 
76
85
  ### Patch Changes
77
86
 
78
- - b152428: Update trails dependencies
79
- - Updated dependencies [b152428]
80
- - Updated dependencies [291ccb6]
81
- - @open-pioneer/map@0.6.1
87
+ - b152428: Update trails dependencies
88
+ - Updated dependencies [b152428]
89
+ - Updated dependencies [291ccb6]
90
+ - @open-pioneer/map@0.6.1
82
91
 
83
92
  ## 0.5.3
84
93
 
85
94
  ### Patch Changes
86
95
 
87
- - 28e092a: Update dependencies
88
- - Updated dependencies [28e092a]
89
- - Updated dependencies [0d51d2f]
90
- - Updated dependencies [76f8863]
91
- - @open-pioneer/map@0.6.0
96
+ - 28e092a: Update dependencies
97
+ - Updated dependencies [28e092a]
98
+ - Updated dependencies [0d51d2f]
99
+ - Updated dependencies [76f8863]
100
+ - @open-pioneer/map@0.6.0
92
101
 
93
102
  ## 0.5.2
94
103
 
95
104
  ### Patch Changes
96
105
 
97
- - 4140646: Update trails dependencies
98
- - 4140646: Update to react 18.3.1
99
- - 81bc7da: Update trails dependencies
100
- - 2c092dc: Update dependencies
101
- - Updated dependencies [4140646]
102
- - Updated dependencies [4140646]
103
- - Updated dependencies [b5bb7a1]
104
- - Updated dependencies [81bc7da]
105
- - Updated dependencies [2c092dc]
106
- - Updated dependencies [4140646]
107
- - @open-pioneer/react-utils@0.2.3
108
- - @open-pioneer/map@0.5.1
106
+ - 4140646: Update trails dependencies
107
+ - 4140646: Update to react 18.3.1
108
+ - 81bc7da: Update trails dependencies
109
+ - 2c092dc: Update dependencies
110
+ - Updated dependencies [4140646]
111
+ - Updated dependencies [4140646]
112
+ - Updated dependencies [b5bb7a1]
113
+ - Updated dependencies [81bc7da]
114
+ - Updated dependencies [2c092dc]
115
+ - Updated dependencies [4140646]
116
+ - @open-pioneer/react-utils@0.2.3
117
+ - @open-pioneer/map@0.5.1
109
118
 
110
119
  ## 0.5.1
111
120
 
112
121
  ### Patch Changes
113
122
 
114
- - Updated dependencies [520a97b]
115
- - @open-pioneer/map@0.5.0
123
+ - Updated dependencies [520a97b]
124
+ - @open-pioneer/map@0.5.0
116
125
 
117
126
  ## 0.5.0
118
127
 
119
128
  ### Minor Changes
120
129
 
121
- - 9334e81: Update to OpenLayers 9
130
+ - 9334e81: Update to OpenLayers 9
122
131
 
123
132
  ### Patch Changes
124
133
 
125
- - 1a8ad89: Update package.json metadata
126
- - 6162979: Update versions of core packages
127
- - Updated dependencies [1a8ad89]
128
- - Updated dependencies [a11bf72]
129
- - Updated dependencies [fc6bf82]
130
- - Updated dependencies [a0d8882]
131
- - Updated dependencies [6162979]
132
- - Updated dependencies [9334e81]
133
- - Updated dependencies [ac7fdd1]
134
- - Updated dependencies [13ea342]
135
- - @open-pioneer/react-utils@0.2.2
136
- - @open-pioneer/map@0.4.0
134
+ - 1a8ad89: Update package.json metadata
135
+ - 6162979: Update versions of core packages
136
+ - Updated dependencies [1a8ad89]
137
+ - Updated dependencies [a11bf72]
138
+ - Updated dependencies [fc6bf82]
139
+ - Updated dependencies [a0d8882]
140
+ - Updated dependencies [6162979]
141
+ - Updated dependencies [9334e81]
142
+ - Updated dependencies [ac7fdd1]
143
+ - Updated dependencies [13ea342]
144
+ - @open-pioneer/react-utils@0.2.2
145
+ - @open-pioneer/map@0.4.0
137
146
 
138
147
  ## 0.4.0
139
148
 
140
149
  ### Minor Changes
141
150
 
142
- - 66f5733: add optional property for display coordinate projection
151
+ - 66f5733: add optional property for display coordinate projection
143
152
 
144
153
  example (show WGS84 coordinates on display):
145
154
 
@@ -149,55 +158,55 @@
149
158
 
150
159
  ### Patch Changes
151
160
 
152
- - Updated dependencies [611ddb9]
153
- - @open-pioneer/map@0.3.1
161
+ - Updated dependencies [611ddb9]
162
+ - @open-pioneer/map@0.3.1
154
163
 
155
164
  ## 0.3.0
156
165
 
157
166
  ### Minor Changes
158
167
 
159
- - ee7c2d4: Update runtime version.
168
+ - ee7c2d4: Update runtime version.
160
169
 
161
170
  ### Patch Changes
162
171
 
163
- - Updated dependencies [ee7c2d4]
164
- - Updated dependencies [a582e5e]
165
- - Updated dependencies [0456500]
166
- - Updated dependencies [762e7b9]
167
- - @open-pioneer/map@0.3.0
168
- - @open-pioneer/react-utils@0.2.1
172
+ - Updated dependencies [ee7c2d4]
173
+ - Updated dependencies [a582e5e]
174
+ - Updated dependencies [0456500]
175
+ - Updated dependencies [762e7b9]
176
+ - @open-pioneer/map@0.3.0
177
+ - @open-pioneer/react-utils@0.2.1
169
178
 
170
179
  ## 0.2.0
171
180
 
172
181
  ### Minor Changes
173
182
 
174
- - 70349a8: Update to new core packages major versions
183
+ - 70349a8: Update to new core packages major versions
175
184
 
176
185
  ### Patch Changes
177
186
 
178
- - Updated dependencies [70349a8]
179
- - @open-pioneer/map@0.2.0
180
- - @open-pioneer/react-utils@0.2.0
187
+ - Updated dependencies [70349a8]
188
+ - @open-pioneer/map@0.2.0
189
+ - @open-pioneer/react-utils@0.2.0
181
190
 
182
191
  ## 0.1.1
183
192
 
184
193
  ### Patch Changes
185
194
 
186
- - Updated dependencies [08bffbc]
187
- - Updated dependencies [a58546b]
188
- - Updated dependencies [a58546b]
189
- - Updated dependencies [0c4ce04]
190
- - @open-pioneer/map@0.1.1
195
+ - Updated dependencies [08bffbc]
196
+ - Updated dependencies [a58546b]
197
+ - Updated dependencies [a58546b]
198
+ - Updated dependencies [0c4ce04]
199
+ - @open-pioneer/map@0.1.1
191
200
 
192
201
  ## 0.1.0
193
202
 
194
203
  ### Minor Changes
195
204
 
196
- - beff789: Initial release.
205
+ - beff789: Initial release.
197
206
 
198
207
  ### Patch Changes
199
208
 
200
- - Updated dependencies [bb2f27a]
201
- - Updated dependencies [182da1c]
202
- - @open-pioneer/map@0.1.0
203
- - @open-pioneer/react-utils@0.1.0
209
+ - Updated dependencies [bb2f27a]
210
+ - Updated dependencies [182da1c]
211
+ - @open-pioneer/map@0.1.0
212
+ - @open-pioneer/react-utils@0.1.0
@@ -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 } 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,GA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AA,CAAA;AAClC,EAAM,MAAA,QAAA,GAAW,KAAK,KAAQ,GAAA,IAAA,CAAA;AAE9B,EAAA,MAAM,OAAO,EAAK,GAAA,QAAA,CAAA;AAClB,EAAM,MAAA,WAAA,GAAc,IAAK,CAAA,YAAA,CAAa,IAAM,EAAA;AAAA,IACxC,qBAAuB,EAAA,SAAA;AAAA,IACvB,qBAAuB,EAAA,SAAA;AAAA,GAC1B,CAAA,CAAA;AAED,EAAO,OAAA,CAAC,KAAO,EAAA,IAAA,EAAM,WAAW,CAAA,CAAA;AACpC,CAAA;AAEA,SAAS,oBAAA,CACL,WACA,EAAA,MAAA,EACA,WACQ,EAAA;AACR,EAAA,MAAM,WAAc,GAAA,SAAA,CAAU,WAAa,EAAA,MAAA,EAAQ,WAAW,CAAA,CAAA;AAC9D,EAAO,OAAA,WAAA,CAAA;AACX;;;;"}
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 \"@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;AAC1B,MAAM,sBAAyB,GAAA,SAAA;AA6BlB,MAAA,gBAAA,GAA8C,CAAC,KAAU,KAAA;AAClE,EAAA,MAAM,EAAE,SAAA,EAAW,qBAAuB,EAAA,MAAA,EAA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,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.9.0-dev.20250220091855",
4
+ "version": "0.9.0",
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
- "@open-pioneer/chakra-integration": "^2.4.0",
18
- "@open-pioneer/react-utils": "^2.4.0",
19
- "@open-pioneer/runtime": "^2.4.0",
20
- "@open-pioneer/reactivity": "^2.4.0",
21
- "ol": "^10.3.0",
22
- "react": "^18.3.1",
23
- "@open-pioneer/map": "^0.9.0-dev.20250220091855"
17
+ "@open-pioneer/chakra-integration": "^3.0.0",
18
+ "@open-pioneer/react-utils": "^3.0.0",
19
+ "@open-pioneer/runtime": "^3.0.0",
20
+ "@open-pioneer/reactivity": "^3.0.0",
21
+ "ol": "^10.4.0",
22
+ "react": "^19.0.0",
23
+ "@open-pioneer/map": "^0.9.0"
24
24
  },
25
25
  "exports": {
26
26
  "./package.json": "./package.json",