Skip to content

Commit

Permalink
Check format from config.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aho Henri committed Aug 8, 2023
1 parent d6dbd74 commit daf1fd2
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions bundles/framework/coordinatetool/plugin/CoordinatePluginHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit daf1fd2

Please sign in to comment.