Comparing version
@@ -1,2 +0,2 @@ | ||
/** | ||
/*! geolib 1.2.5 by Manuel Bieh | ||
* A small library to provide some basic 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 1.2.3 | ||
* @version 1.2.5 | ||
* @license LGPL | ||
@@ -11,0 +11,0 @@ **/ |
@@ -36,4 +36,4 @@ { | ||
}, | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"main": "./geolib" | ||
} |
@@ -10,3 +10,3 @@ # Geolib | ||
### getDistance(object start, object end, [int accuracy]) | ||
### geolib.getDistance(object start, object end, [int accuracy]) | ||
@@ -21,12 +21,29 @@ Calculates the distance between two geo coordinates | ||
<pre>geolib.getDistance({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"}); | ||
<pre>geolib.getDistance( | ||
{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"} | ||
); | ||
// Working with W3C Geolocation API | ||
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}); | ||
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 | ||
} | ||
); | ||
</pre> | ||
### getCenter(array coords) | ||
### geolib.getCenter(array coords) | ||
@@ -59,3 +76,3 @@ Calculates the geographical center of all points in a collection of geo coordinates | ||
### isPointInside(object latlng, array coords) | ||
### geolib.isPointInside(object latlng, array coords) | ||
@@ -80,3 +97,3 @@ Checks whether a point is inside of a polygon or not. | ||
<h3>isPointInCircle(object latlng, object center, integer radius)</h3> | ||
<h3>geolib.isPointInCircle(object latlng, object center, integer radius)</h3> | ||
@@ -90,5 +107,9 @@ Similar to is point inside: checks whether a point is inside of a circle or not. | ||
<pre>// checks if 51.525, 7.4575 is within a radius of 5km from 51.5175, 7.4678 | ||
geolib.isPointInCircle({latitude: 51.525, longitude: 7.4575}, {latitude: 51.5175, longitude: 7.4678}, 5000);</pre> | ||
geolib.isPointInCircle( | ||
{latitude: 51.525, longitude: 7.4575}, | ||
{latitude: 51.5175, longitude: 7.4678}, | ||
5000 | ||
);</pre> | ||
<h3>orderByDistance(object latlng, mixed coords)</h3> | ||
<h3>geolib.orderByDistance(object latlng, mixed coords)</h3> | ||
@@ -117,3 +138,3 @@ Sorts an object or array of coords by distance from a reference coordinate | ||
### findNearest(object latlng, mixed coords, int offset) | ||
### geolib.findNearest(object latlng, mixed coords, int offset) | ||
@@ -138,3 +159,3 @@ Finds the nearest coordinate to a reference coordinate. | ||
### getPathLength(mixed coords) | ||
### geolib.getPathLength(mixed coords) | ||
@@ -155,3 +176,3 @@ Calculates the length of a collection of coordinates | ||
### convertUnit(string unit, float distance, [int round]) | ||
### geolib.convertUnit(string unit, float distance, [int round]) | ||
@@ -182,3 +203,3 @@ Converts a given distance (in meters) to another unit. | ||
### sexagesimal2decimal(string coord) | ||
### geolib.sexagesimal2decimal(string coord) | ||
@@ -191,3 +212,3 @@ Converts a sexagesimal coordinate to decimal format | ||
### decimal2sexagesimal(float coord) | ||
### geolib.decimal2sexagesimal(float coord) | ||
@@ -202,3 +223,3 @@ Converts a decimal coordinate to sexagesimal format | ||
### useDecimal(mixed coordinate) | ||
### geolib.useDecimal(mixed coordinate) | ||
@@ -205,0 +226,0 @@ Checks if a coordinate is already in decimal format and, if not, converts it to |
34075
0.51%220
10.55%