05-05-2017 05:12 AM - edited 05-05-2017 05:18 AM
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
05-15-2017 06:56 AM
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.
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:
01-23-2018 07:19 PM
Thanks, @jan.neumann for the code... Maybe can replace the eventListener to:
document.getElementById("MainMapControlContainer").onmousemove = function () { ConvertToDecimal(); }
... to avoid the pressing-CTRL-key
01-24-2018 02:38 AM
Yeah, but that will work only if you hover over the coordinates by mouse which isn't perfect solution either But at least we have few alternatives
Jan
01-25-2018 04:09 AM
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.
01-28-2018 08:41 PM
Yes @pszrajber, it's working. Thanks
06-04-2018 10:40 AM
So where do I put the snippet of code? Thanks!
06-04-2018 11:24 AM
Hi Kathleen,
You can append the code to js\MapConfig.js
06-04-2018 11:40 AM
Thank you piotr.szrajber for responding so quickly.
I was actually hoping to accomplish this on the desktop. Is that possible?
06-06-2018 12:51 AM
Hi, I believe that the desktop needs another solution as this one is just for the web client.