Comparing version 2.0.20 to 2.0.21
@@ -1,2 +0,2 @@ | ||
/*! geolib.elevation 2.0.20 by Manuel Bieh | ||
/*! geolib.elevation 2.0.21 by Manuel Bieh | ||
* | ||
@@ -7,3 +7,3 @@ * Elevation Addon for Geolib.js | ||
* @url http://www.manuelbieh.com/ | ||
* @version 2.0.20 | ||
* @version 2.0.21 | ||
* @license MIT | ||
@@ -10,0 +10,0 @@ */ |
@@ -1,2 +0,2 @@ | ||
/*! geolib 2.0.20 by Manuel Bieh | ||
/*! geolib 2.0.21 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.20 | ||
* @version 2.0.21 | ||
* @license MIT | ||
@@ -26,3 +26,3 @@ **/;(function(global, undefined) { | ||
version: { | ||
value: "2.0.20" | ||
value: "2.0.21" | ||
}, | ||
@@ -45,3 +45,3 @@ radius: { | ||
sexagesimalPattern: { | ||
value: /^([0-9]{1,3})°\s*([0-9]{1,3}(?:\.(?:[0-9]{1,2}))?)'\s*(([0-9]{1,3}(\.([0-9]{1,2}))?)"\s*)?([NEOSW]?)$/ | ||
value: /^([0-9]{1,3})°\s*([0-9]{1,3}(?:\.(?:[0-9]{1,2}))?)'\s*(([0-9]{1,3}(\.([0-9]{1,4}))?)"\s*)?([NEOSW]?)$/ | ||
}, | ||
@@ -528,3 +528,27 @@ measures: { | ||
/** | ||
* Calculates the center of the bounds of geo coordinates. | ||
* | ||
* On polygons like political borders (eg. states) | ||
* this may gives a closer result to human expectation, than `getCenter`, | ||
* because that function can be disturbed by uneven distribution of | ||
* point in different sides. | ||
* Imagine the US state Oklahoma: `getCenter` on that gives a southern | ||
* point, because the southern border contains a lot more nodes, | ||
* than the others. | ||
* | ||
* @param array Collection of coords [{latitude: 51.510, longitude: 7.1321}, {latitude: 49.1238, longitude: "8° 30' W"}, ...] | ||
* @return object {latitude: centerLat, longitude: centerLng} | ||
*/ | ||
getCenterOfBounds: function(coords) { | ||
var b = this.getBounds(coords); | ||
var latitude = b.minLat + ((b.maxLat - b.minLat) / 2); | ||
var longitude = b.minLng + ((b.maxLng - b.minLng) / 2); | ||
return { | ||
latitude: parseFloat(latitude.toFixed(6)), | ||
longitude: parseFloat(longitude.toFixed(6)) | ||
}; | ||
}, | ||
/** | ||
@@ -1085,3 +1109,3 @@ * Computes the bounding coordinates of all points on the surface | ||
* | ||
* @param float latitude of the inital point in degree | ||
* @param object start coordinate (e.g. {latitude: 51.5023, longitude: 7.3815}) | ||
* @param float longitude of the inital point in degree | ||
@@ -1091,3 +1115,3 @@ * @param float distance to go from the inital point in meter | ||
* @param float optional (in meter), defaults to mean radius of the earth | ||
* @return object {latitude: destLat (in degree), longitude: destLng (in degree)} | ||
* @return object {latitude: destLat (in degree), longitude: destLng (in degree)} | ||
*/ | ||
@@ -1341,4 +1365,9 @@ computeDestinationPoint: function(start, distance, bearing, radius) { | ||
global.geolib = module.exports = geolib; | ||
module.exports = geolib; | ||
// react native | ||
if (typeof global === 'object') { | ||
global.geolib = geolib; | ||
} | ||
// AMD module | ||
@@ -1345,0 +1374,0 @@ } else if (typeof define === "function" && define.amd) { |
@@ -50,4 +50,4 @@ { | ||
}, | ||
"version": "2.0.20", | ||
"version": "2.0.21", | ||
"main": "dist/geolib.js" | ||
} |
128
README.md
@@ -1,2 +0,2 @@ | ||
# Geolib v2.0.20 | ||
# Geolib v2.0.21 | ||
[![Build Status](https://secure.travis-ci.org/manuelbieh/Geolib.png?branch=master)](http://travis-ci.org/manuelbieh/Geolib) | ||
@@ -21,8 +21,8 @@ | ||
<pre>geolib.getDistance( | ||
{latitude: 51.5103, longitude: 7.49347}, | ||
{latitude: "51° 31' N", longitude: "7° 28' E"} | ||
{latitude: 51.5103, longitude: 7.49347}, | ||
{latitude: "51° 31' N", longitude: "7° 28' E"} | ||
); | ||
geolib.getDistance( | ||
{latitude: 51.5103, longitude: 7.49347}, | ||
{latitude: "51° 31' N", longitude: "7° 28' E"} | ||
{latitude: 51.5103, longitude: 7.49347}, | ||
{latitude: "51° 31' N", longitude: "7° 28' E"} | ||
); | ||
@@ -32,14 +32,14 @@ | ||
navigator.geolocation.getCurrentPosition( | ||
function(position) { | ||
alert('You are ' + geolib.getDistance(position.coords, { | ||
latitude: 51.525, | ||
longitude: 7.4575 | ||
}) + ' meters away from 51.525, 7.4575'); | ||
}, | ||
function() { | ||
alert('Position could not be determined.') | ||
}, | ||
{ | ||
enableHighAccuracy: true | ||
} | ||
function(position) { | ||
alert('You are ' + geolib.getDistance(position.coords, { | ||
latitude: 51.525, | ||
longitude: 7.4575 | ||
}) + ' meters away from 51.525, 7.4575'); | ||
}, | ||
function() { | ||
alert('Position could not be determined.') | ||
}, | ||
{ | ||
enableHighAccuracy: true | ||
} | ||
); | ||
@@ -59,9 +59,9 @@ </pre> | ||
<pre>var spots = { | ||
"Brandenburg Gate, Berlin": {latitude: 52.516272, longitude: 13.377722}, | ||
"Dortmund U-Tower": {latitude: 51.515, longitude: 7.453619}, | ||
"London Eye": {latitude: 51.503333, longitude: -0.119722}, | ||
"Kremlin, Moscow": {latitude: 55.751667, longitude: 37.617778}, | ||
"Eiffel Tower, Paris": {latitude: 48.8583, longitude: 2.2945}, | ||
"Riksdag building, Stockholm": {latitude: 59.3275, longitude: 18.0675}, | ||
"Royal Palace, Oslo": {latitude: 59.916911, longitude: 10.727567} | ||
"Brandenburg Gate, Berlin": {latitude: 52.516272, longitude: 13.377722}, | ||
"Dortmund U-Tower": {latitude: 51.515, longitude: 7.453619}, | ||
"London Eye": {latitude: 51.503333, longitude: -0.119722}, | ||
"Kremlin, Moscow": {latitude: 55.751667, longitude: 37.617778}, | ||
"Eiffel Tower, Paris": {latitude: 48.8583, longitude: 2.2945}, | ||
"Riksdag building, Stockholm": {latitude: 59.3275, longitude: 18.0675}, | ||
"Royal Palace, Oslo": {latitude: 59.916911, longitude: 10.727567} | ||
} | ||
@@ -72,8 +72,24 @@ | ||
geolib.getCenter([ | ||
{latitude: 52.516272, longitude: 13.377722}, | ||
{latitude: 51.515, longitude: 7.453619}, | ||
{latitude: 51.503333, longitude: -0.119722} | ||
{latitude: 52.516272, longitude: 13.377722}, | ||
{latitude: 51.515, longitude: 7.453619}, | ||
{latitude: 51.503333, longitude: -0.119722} | ||
]); | ||
</pre> | ||
<h3>geolib.getCenterOfBounds(array coords)</h3> | ||
Calculates the center of the bounds of geo coordinates. | ||
Takes an array of coordinates, calculate the border of those, and gives back | ||
the center of that rectangle. | ||
On polygons like political borders (eg. states), this may gives a closer | ||
result to human expectation, than `getCenter`, because that function can be | ||
disturbed by uneven distribution of point in different sides. | ||
Imagine the US state Oklahoma: `getCenter` on that gives a southern | ||
point, because the southern border contains a lot more nodes, than the others. | ||
Returns an object: `{"latitude": centerLat, "longitude": centerLng}` | ||
<h3>geolib.isPointInside(object latlng, array polygon)</h3> | ||
@@ -90,9 +106,9 @@ | ||
geolib.isPointInside( | ||
{latitude: 51.5125, longitude: 7.485}, | ||
[ | ||
{latitude: 51.50, longitude: 7.40}, | ||
{latitude: 51.555, longitude: 7.40}, | ||
{latitude: 51.555, longitude: 7.625}, | ||
{latitude: 51.5125, longitude: 7.625} | ||
] | ||
{latitude: 51.5125, longitude: 7.485}, | ||
[ | ||
{latitude: 51.50, longitude: 7.40}, | ||
{latitude: 51.555, longitude: 7.40}, | ||
{latitude: 51.555, longitude: 7.625}, | ||
{latitude: 51.5125, longitude: 7.625} | ||
] | ||
); // -> true</pre> | ||
@@ -110,5 +126,5 @@ | ||
geolib.isPointInCircle( | ||
{latitude: 51.525, longitude: 7.4575}, | ||
{latitude: 51.5175, longitude: 7.4678}, | ||
5000 | ||
{latitude: 51.525, longitude: 7.4575}, | ||
{latitude: 51.5175, longitude: 7.4678}, | ||
5000 | ||
);</pre> | ||
@@ -127,5 +143,5 @@ | ||
geolib.orderByDistance({latitude: 51.515, longitude: 7.453619}, [ | ||
{latitude: 52.516272, longitude: 13.377722}, | ||
{latitude: 51.518, longitude: 7.45425}, | ||
{latitude: 51.503333, longitude: -0.119722} | ||
{latitude: 52.516272, longitude: 13.377722}, | ||
{latitude: 51.518, longitude: 7.45425}, | ||
{latitude: 51.503333, longitude: -0.119722} | ||
]); | ||
@@ -135,5 +151,5 @@ | ||
geolib.orderByDistance({latitude: 51.515, longitude: 7.453619}, { | ||
a: {latitude: 52.516272, longitude: 13.377722}, | ||
b: {latitude: 51.518, longitude: 7.45425}, | ||
c: {latitude: 51.503333, longitude: -0.119722} | ||
a: {latitude: 52.516272, longitude: 13.377722}, | ||
b: {latitude: 51.518, longitude: 7.45425}, | ||
c: {latitude: 51.503333, longitude: -0.119722} | ||
}); | ||
@@ -149,9 +165,9 @@ </pre> | ||
<pre>var spots = { | ||
"Brandenburg Gate, Berlin": {latitude: 52.516272, longitude: 13.377722}, | ||
"Dortmund U-Tower": {latitude: 51.515, longitude: 7.453619}, | ||
"London Eye": {latitude: 51.503333, longitude: -0.119722}, | ||
"Kremlin, Moscow": {latitude: 55.751667, longitude: 37.617778}, | ||
"Eiffel Tower, Paris": {latitude: 48.8583, longitude: 2.2945}, | ||
"Riksdag building, Stockholm": {latitude: 59.3275, longitude: 18.0675}, | ||
"Royal Palace, Oslo": {latitude: 59.916911, longitude: 10.727567} | ||
"Brandenburg Gate, Berlin": {latitude: 52.516272, longitude: 13.377722}, | ||
"Dortmund U-Tower": {latitude: 51.515, longitude: 7.453619}, | ||
"London Eye": {latitude: 51.503333, longitude: -0.119722}, | ||
"Kremlin, Moscow": {latitude: 55.751667, longitude: 37.617778}, | ||
"Eiffel Tower, Paris": {latitude: 48.8583, longitude: 2.2945}, | ||
"Riksdag building, Stockholm": {latitude: 59.3275, longitude: 18.0675}, | ||
"Royal Palace, Oslo": {latitude: 59.916911, longitude: 10.727567} | ||
} | ||
@@ -174,5 +190,5 @@ | ||
geolib.getPathLength([ | ||
{latitude: 52.516272, longitude: 13.377722}, // Berlin | ||
{latitude: 51.515, longitude: 7.453619}, // Dortmund | ||
{latitude: 51.503333, longitude: -0.119722} // London | ||
{latitude: 52.516272, longitude: 13.377722}, // Berlin | ||
{latitude: 51.515, longitude: 7.453619}, // Dortmund | ||
{latitude: 51.503333, longitude: -0.119722} // London | ||
]); // -> 945235</pre> | ||
@@ -190,5 +206,5 @@ | ||
geolib.getSpeed( | ||
{lat: 51.567294, lng: 7.38896, time: 1360231200880}, | ||
{lat: 52.54944, lng: 13.468509, time: 1360245600880}, | ||
{unit: 'mph'} | ||
{lat: 51.567294, lng: 7.38896, time: 1360231200880}, | ||
{lat: 52.54944, lng: 13.468509, time: 1360245600880}, | ||
{unit: 'mph'} | ||
); // -> 66.9408 (mph)</pre> | ||
@@ -195,0 +211,0 @@ |
Sorry, the diff of this file is not supported yet
63586
1211
318