From daf1fd2102e786044362fcca8223fb20e0e318a1 Mon Sep 17 00:00:00 2001 From: Aho Henri Date: Tue, 8 Aug 2023 13:40:50 +0300 Subject: [PATCH] Check format from config. --- .../plugin/CoordinatePluginHandler.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/bundles/framework/coordinatetool/plugin/CoordinatePluginHandler.js b/bundles/framework/coordinatetool/plugin/CoordinatePluginHandler.js index 231830a6a4..834ce12646 100644 --- a/bundles/framework/coordinatetool/plugin/CoordinatePluginHandler.js +++ b/bundles/framework/coordinatetool/plugin/CoordinatePluginHandler.js @@ -104,11 +104,16 @@ class UIHandler extends StateHandler { } }; - // Special treatment for these degree format projections to allow coordinates in decimal format as well - if (this.state.selectedProjection === 'EPSG:4258' || this.state.selectedProjection === 'LATLON:kkj') { - const regexp = /^\d+(\.|,)\d+$/; - if (regexp.test(data.lonlat.lon)) data.lonlat.lon = data.lonlat.lon + '°'; - if (regexp.test(data.lonlat.lat)) data.lonlat.lat = data.lonlat.lat + '°'; + // Check if format should be degrees and add '°' symbol if needed + let isDegrees = false; + if (this.config.projectionShowFormat[this.state.selectedProjection]) { + isDegrees = this.config.projectionShowFormat[this.state.selectedProjection].format === 'degrees'; + } else { + isDegrees = this.config.projectionShowFormat.format === 'degrees'; + } + if (isDegrees) { + if (data.lonlat.lon.indexOf('°') < 0) data.lonlat.lon = data.lonlat.lon + '°'; + if (data.lonlat.lat.indexOf('°') < 0) data.lonlat.lat = data.lonlat.lat + '°'; } const converted = await this.convertCoordinates(data, this.state.selectedProjection, this.originalProjection);