dms2dec-ptbr
v1.0.4
Published
convertion lib from dms to dec coordinates.
Downloads
14
Readme
dms2dec.js
This fork is only a pt-br locale fork
Web
<script language="JavaScript" src="/dms2dec.js"></script>
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 = dms2dec("60/1, 21/1, 4045/100", "N", "5/1, 22/1, 1555/100", "E");
// dec[0] == 60.36123611111111, dec[1] == 5.370986111111111
Parse dms arrays
var dec = dms2dec(["60/1", "21/1", "4045/100"], "N", ["5/1", "22/1", "1555/100"], "E");
// dec[0] == 60.36123611111111, dec[1] == 5.370986111111111
dms arrays as decimal
var dec = dms2dec([60, 21, 40.45], "N", [5, 22, 15.55], "E");
// 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()
};