Hexagon Geospatial
MENU

Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Reply
Contributor
Posts: 70
Registered: ‎11-02-2015

Display coordinates in decimal minutes when using EPSG:4326

[ Edited ]

Hi there,

 

perhaps somebody out there can help me with this question.

 

Is there a way to modify the coordinate display of the Geospatial Portal in order to display the coordinates for Lat/Lon (EPSG:4326) based on decimal minutes (e.g. 53°47.0956 - 11°34.8174)? The customer is using a MTP850 TETRA Portable Radio which allows to display his current position. He uese this for making notes during the field work. Back in the office he needs to recap the infromation so the idea is to use the coordinate to navigate to the recorded postion. Unfortunaltey the corrdinates displayed in the GSP are display as D : M : S.ss and not based on decimal minutes.

 

Thanks Fritz

Geography is what geographers do...
Technical Evangelist
Posts: 1,033
Registered: ‎09-11-2015

Re: Display coordinates in decimal minutes when using EPSG:4326

Hi Fritz,

 

I've played for a while with the options that you have in non-SDK Portal, not sure if SDK would actually help much here.

I firstly tried to overwrite the coordinate labels on-the-fly but I suffered issues, because I didn't find a way to overcome the internal updating mechanism fighting with my events. So I created a workaround, that could be either improved or modified.

 

My W/A actually overwrites the coordinates box on request, and only after pressing CTRL key within the Portal window. That key will trigger DMS to Decimal translation and changes the coordinate values. Those new values could also be inserted into some additional textbox/label control placed somewhere in the Portal GUI. That would allow simple copy/paste.

Untitled.png

 

This is the code snippet:

document.addEventListener('keydown', function(e){ 
   if(e.ctrlKey) {
      ConvertToDecimal();      
   }
});

function ParseDMS(input) {
    var parts = input.split(/[^\d\w.^-]+/);
    return ConvertDMSToDD(parts[0], parts[1], parts[2]);
}

function ConvertDMSToDD(degrees, minutes, seconds) {
    var dd = Math.abs(degrees) + minutes/60 + seconds/(60*60);
    if (degrees < 0) {
        dd = dd * -1;
    } 
    return dd;
}

function ConvertToDecimal()
{
   // Northing in D:M:S
   var n = $(".wc_map_coords").find("input")[0].value
   // Easting in D:M:S
   var e = $(".wc_map_coords").find("input")[1].value
   $(".wc_map_coords").find("input")[0].value = roundNumber(ParseDMS(n), 8);
   $(".wc_map_coords").find("input")[1].value = roundNumber(ParseDMS(e), 8);
}

function roundNumber(num, scale) {
  if(!("" + num).includes("e")) {
    return +(Math.round(num + "e+" + scale)  + "e-" + scale);  
  } else {
    var arr = ("" + num).split("e");
    var sig = ""
    if(+arr[1] + scale > 0) {
      sig = "+";
    }
    return +(Math.round(+arr[0] + "e" + sig + (+arr[1] + scale)) + "e-" + scale);
  }
}

And please see this topic how to enable it in Portal instance:

http://community.hexagongeospatial.com/t5/Developer-Discussions/Adding-a-liability-notice-that-will-...

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Dd
Occasional Contributor
Posts: 14
Registered: ‎11-06-2017

Re: Display coordinates in decimal minutes when using EPSG:4326

Thanks, @jan.neumann for the code... Maybe can replace the eventListener to:

 

document.getElementById("MainMapControlContainer").onmousemove = function () {
        ConvertToDecimal();
    } 

 ... to avoid the pressing-CTRL-key  Smiley Wink

Technical Evangelist
Posts: 1,033
Registered: ‎09-11-2015

Re: Display coordinates in decimal minutes when using EPSG:4326

Yeah, but that will work only if you hover over the coordinates by mouse which isn't perfect solution either Smiley Wink But at least we have few alternatives Smiley Happy

 

Jan

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Technical Evangelist
Posts: 132
Registered: ‎08-05-2015

Re: Display coordinates in decimal minutes when using EPSG:4326

I prepared a snippet for updating the coordinates. It is a little simplified, but it may be useful in case you want to customize it.

 

https://bitbucket.org/snippets/pszrajbe/reypaL

 

it is actually hijacking the default function and you can format the coordinates (that are passed as X and Y in units of the current CRS) just as you like.

Dd
Occasional Contributor
Posts: 14
Registered: ‎11-06-2017

Re: Display coordinates in decimal minutes when using EPSG:4326

Yes @pszrajber, it's working. Thanks Smiley Wink

Highlighted
New Contributor
Posts: 3
Registered: ‎06-04-2018

Re: Display coordinates in decimal minutes when using EPSG:4326

So where do I put the snippet of code? Thanks!

Technical Evangelist
Posts: 132
Registered: ‎08-05-2015

Re: Display coordinates in decimal minutes when using EPSG:4326

Hi Kathleen,

 

You can append the code to js\MapConfig.js

New Contributor
Posts: 3
Registered: ‎06-04-2018

Re: Display coordinates in decimal minutes when using EPSG:4326

Thank you piotr.szrajber for responding so quickly.

 

I was actually hoping to accomplish this on the desktop. Is that possible? 

Technical Evangelist
Posts: 132
Registered: ‎08-05-2015

Re: Display coordinates in decimal minutes when using EPSG:4326

Hi, I believe that the desktop needs another solution as this one is just for the web client.

Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.