dms2dec.js
This fork is only a pt-br locale fork
Web
Usage
[latDec
, lonDec
] = dms2dec(String lat
, String latRef
, String lon
, String lonRef
);
Params
lat
– latitude in "degrees, minutes, seconds" formatlagRef
– latitude hemisphere reference (N or S)lon
– longitude in "degrees, minutes, seconds" formatlonRef
– longitude hemisphere reference (E or W)
Return
latDec
– latitude converted into decimal formatlonDec
– longitude converted into decimal format
Parse dms strings
var dec = ;// dec[0] == 60.36123611111111, dec[1] == 5.370986111111111
Parse dms arrays
var dec = ;// dec[0] == 60.36123611111111, dec[1] == 5.370986111111111
dms arrays as decimal
var dec = ;// dec[0] == 60.36123611111111, dec[1] == 5.370986111111111
GeoJSON
NB!
Remember that GeoJSON stores coordinates in reversed order (longitude
,
latitude
) which means you have to reverse the order of the coordinates
returned from dms2dec()
.
var geojson = {
type: 'Point',
coordinates: dms2dec(lat, latRef, lon, lonRef).reverse()
};