Comparing version 2.0.17 to 2.0.18
@@ -1,2 +0,2 @@ | ||
/*! geolib.elevation 2.0.17 by Manuel Bieh | ||
/*! geolib.elevation 2.0.18 by Manuel Bieh | ||
* | ||
@@ -7,3 +7,3 @@ * Elevation Addon for Geolib.js | ||
* @url http://www.manuelbieh.com/ | ||
* @version 2.0.17 | ||
* @version 2.0.18 | ||
* @license MIT | ||
@@ -10,0 +10,0 @@ */ |
@@ -1,2 +0,2 @@ | ||
/*! geolib 2.0.17 by Manuel Bieh | ||
/*! geolib 2.0.18 by Manuel Bieh | ||
* Library to provide geo functions like distance calculation, | ||
@@ -8,3 +8,3 @@ * conversion of decimal coordinates to sexagesimal and vice versa, etc. | ||
* @url http://www.manuelbieh.com/ | ||
* @version 2.0.17 | ||
* @version 2.0.18 | ||
* @license MIT | ||
@@ -17,6 +17,12 @@ **/;(function(global, undefined) { | ||
// Constants | ||
Geolib.TO_RAD = Math.PI / 180; | ||
Geolib.TO_DEG = 180 / Math.PI; | ||
Geolib.PI_X2 = Math.PI * 2; | ||
Geolib.PI_DIV4 = Math.PI / 4; | ||
// Setting readonly defaults | ||
var geolib = Object.create(Geolib.prototype, { | ||
version: { | ||
value: "2.0.17" | ||
value: "2.0.18" | ||
}, | ||
@@ -74,3 +80,3 @@ radius: { | ||
Number.prototype.toRad = function() { | ||
return this * Math.PI / 180; | ||
return this * Geolib.TO_RAD; | ||
}; | ||
@@ -81,3 +87,3 @@ } | ||
Number.prototype.toDeg = function() { | ||
return this * 180 / Math.PI; | ||
return this * Geolib.TO_DEG; | ||
}; | ||
@@ -436,4 +442,4 @@ } | ||
lat = coord.latitude * Math.PI / 180; | ||
lon = coord.longitude * Math.PI / 180; | ||
lat = coord.latitude * Geolib.TO_RAD; | ||
lon = coord.longitude * Geolib.TO_RAD; | ||
@@ -456,4 +462,4 @@ X += Math.cos(lat) * Math.cos(lon); | ||
return { | ||
latitude: (lat * 180 / Math.PI).toFixed(6), | ||
longitude: (lon * 180 / Math.PI).toFixed(6) | ||
latitude: (lat * Geolib.TO_DEG).toFixed(6), | ||
longitude: (lon * Geolib.TO_DEG).toFixed(6) | ||
}; | ||
@@ -548,3 +554,3 @@ | ||
if (minLon < MIN_LON_RAD) { | ||
minLon += 2 * Math.PI; | ||
minLon += Geolib.PI_X2; | ||
} | ||
@@ -555,3 +561,3 @@ | ||
if (maxLon > MAX_LON_RAD) { | ||
maxLon -= 2 * Math.PI; | ||
maxLon -= Geolib.PI_X2; | ||
} | ||
@@ -743,6 +749,6 @@ | ||
Math.tan( | ||
this.latitude(destLL).toRad() / 2 + Math.PI / 4 | ||
this.latitude(destLL).toRad() / 2 + Geolib.PI_DIV4 | ||
) / | ||
Math.tan( | ||
this.latitude(originLL).toRad() / 2 + Math.PI / 4 | ||
this.latitude(originLL).toRad() / 2 + Geolib.PI_DIV4 | ||
) | ||
@@ -754,6 +760,6 @@ ); | ||
if(diffLon > 0) { | ||
diffLon = (2 * Math.PI - diffLon) * -1; | ||
diffLon = (Geolib.PI_X2 - diffLon) * -1; | ||
} | ||
else { | ||
diffLon = 2 * Math.PI + diffLon; | ||
diffLon = Geolib.PI_X2 + diffLon; | ||
} | ||
@@ -1134,7 +1140,7 @@ } | ||
var deg = Math.abs(tmp[0]); | ||
var min = ('0.' + tmp[1])*60; | ||
var min = ('0.' + (tmp[1] || 0))*60; | ||
var sec = min.toString().split('.'); | ||
min = Math.floor(min); | ||
sec = (('0.' + sec[1]) * 60).toFixed(2); | ||
sec = (('0.' + (sec[1] || 0)) * 60).toFixed(2); | ||
@@ -1141,0 +1147,0 @@ this.sexagesimal[dec] = (deg + '° ' + min + "' " + sec + '"'); |
@@ -50,4 +50,4 @@ { | ||
}, | ||
"version": "2.0.17", | ||
"version": "2.0.18", | ||
"main": "dist/geolib.js" | ||
} |
@@ -1,2 +0,2 @@ | ||
# Geolib v2.0.17 | ||
# Geolib v2.0.18 | ||
[![Build Status](https://secure.travis-ci.org/manuelbieh/Geolib.png?branch=master)](http://travis-ci.org/manuelbieh/Geolib) | ||
@@ -52,3 +52,3 @@ | ||
Returns an object: `{"latitude": centerLat, "longitude": centerLng, "distance": diagonalDistance}` | ||
Returns an object: `{"latitude": centerLat, "longitude": centerLng}` | ||
@@ -55,0 +55,0 @@ <h4>Examples</h4> |
56841
1088