I am attempting to convert DD to DMS for a feature layer (WKID 4326) that provides a global lat/lon grid. The grid displays labels in DD.ddd format. I have written the follow Arcade expression which works wonders with one exception: I am getting values of 60", which doesn't exist. For instance, 125° 15' 60" instead of 125° 16' 00". It is only on about half the labels and isn't consistent as to how often it appears at various scales/areas.
Any ideas as to what I need to alter in the expression to correct this issue?
(I am doing this on a disconnected Enterprise system, so I have fat fingered in the expression here. Any typos are just here as it works as described above in production.)
if (dd < 0) {
var quad = '-';
} else {
var quad = '';
}
var degrees = Floor(Abs(dd), 0);
var mm = (Abs(dd) - degrees) * 60;
var minutes = Floor(mm);
var seconds = (mm - minutes) * 60;
var dms = quad + Text(degrees, "###") + "° " + Text(minutes, "00") + "' " + Text(seconds, "00") + '" ';
return dms;
Thanks!
Hi amy.b.everett ,
Have a look at the examples here: Converting geometry($feature) coordinates in a pop-up to decimal degrees?
Thanks Xander. Totally a delayed response, so I apologize. I had already referenced that example, but the question was a step beyond that because the values were not calculating properly so I was attempting to write into the expression a means of checking values for invalid values (i.e. 60) and adjusting accordingly.
Hi amy.b.everett ,
Can you provide an example where you have invalid results? I would like to take a look and update the expression accordingly if the results are not correct.
The service wasn’t one I can share here, but I’ll look to see if I can locate it with a link I can share here...
Hi amy.b.everett ,
Or just some example values that caused the problems. It is not necessary to share the actual data. Just some example values will do.