Update of multiple frontend libs.

This commit is contained in:
baldo 2017-05-13 13:25:33 +02:00
commit a9c6ddc03b
276 changed files with 41257 additions and 19300 deletions

View file

@ -1,7 +1,7 @@
{
"name": "Geolib",
"main": "dist/geolib.js",
"version": "2.0.21",
"version": "2.0.22",
"homepage": "https://github.com/manuelbieh/Geolib",
"authors": [
"Manuel Bieh <github@manuelbieh.de>"
@ -20,13 +20,13 @@
"test",
"tests"
],
"_release": "2.0.21",
"_release": "2.0.22",
"_resolution": {
"type": "version",
"tag": "2.0.21",
"commit": "0406fbd120cb371a89a1676e47e9de5f0e51a4a5"
"tag": "v2.0.22",
"commit": "cfa4d4f1a887a3327507f7dde452953c7497db33"
},
"_source": "https://github.com/manuelbieh/Geolib.git",
"_target": "2.0.21",
"_target": "2.0.22",
"_originalSource": "geolib"
}

View file

@ -5,62 +5,6 @@ module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.registerTask('version', function(target, op) {
var fs = require('fs');
var data = JSON.parse(fs.readFileSync('package.json', {encoding: 'utf-8'}));
var version = data.version.split('.');
var major = parseInt(version[0], 10);
var minor = parseInt(version[1], 10);
var patch = parseInt(version[2].split('+')[0], 10);
var info = version[2].split('+')[1];
var log = '';
if(typeof op == 'undefined' || op === '+') {
op = '+';
log += 'Incrementing ';
} else if(op === '-') {
op = op;
log += 'Decrementing ';
} else if(!isNaN(parseInt(op, 10))) {
op = parseInt(op, 10);
log += 'Using ' + op + ' as new ';
} else {
grunt.log.fail('Illegal operation.');
return false;
}
if(['major', 'minor', 'patch'].indexOf(target) > -1) {
log += target + ' version. ';
}
switch(target) {
case 'major':
major = op == '-' ? major-1 : (op == '+' ? major+1 : op);
if(major < 0) major = 0;
break;
case 'minor':
minor = op == '-' ? minor-1 : (op == '+' ? minor+1 : op);
if(minor < 0) minor = 0;
break;
case 'patch':
patch = op == '-' ? patch-1 : (op == '+' ? patch+1 : op);
if(patch < 0) patch = 0;
break;
}
data.version = [major, minor, patch].join('.') + (info ? '+' + info : '');
grunt.log.writeln(log + 'New version is ' + data.version);
fs.writeFileSync('package.json', JSON.stringify(data, null, 2), {encoding: 'utf-8'})
grunt.config.data.pkg.version = data.version;
grunt.task.run('default');
});
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

View file

@ -13,7 +13,7 @@ Calculates the distance between two geo coordinates
Takes 2 or 4 arguments. First 2 arguments must be objects that each have latitude and longitude properties (e.g. `{latitude: 52.518611, longitude: 13.408056}`)Works with:. Coordinates can be in sexagesimal or decimal format. 3rd argument is accuracy (in meters). So a calculated distaWorks with:nce of 1248 meters with an accuracy of 100 is returned as `1200` (accuracy 10 = `1250` etc.). 4th argument is precision in sub-meters (1 is meter presicion, 2 is decimeters, 3 is centimeters, etc).
Return value is always an float and represents the distance in meters.
Return value is always float and represents the distance in meters.
<h4>Examples</h4>
@ -43,6 +43,21 @@ navigator.geolocation.getCurrentPosition(
);
</pre>
<h3>geolib.getDistanceSimple(object start, object end[, int accuracy])</h3>
Calculates the distance between two geo coordinates but this method is far more inaccurate as compared to getDistance.
It can take up 2 to 3 arguments. start, end and accuracy can be defined in the same as in getDistance.
Return value is always float that represents the distance in meters.
<h4>Examples</h4>
<pre>geolib.getDistanceSimple(
{latitude: 51.5103, longitude: 7.49347},
{latitude: "51° 31' N", longitude: "7° 28' E"}
);</pre>
<h3>geolib.getCenter(array coords)</h3>
Calculates the geographical center of all points in a collection of geo coordinates
@ -88,6 +103,28 @@ point, because the southern border contains a lot more nodes, than the others.
Returns an object: `{"latitude": centerLat, "longitude": centerLng}`
<h3>geolib.getBounds(array coords)</h3>
Calculates the bounds of geo coordinates.
It returns maximum and minimum, latitude, longitude, and elevation (if provided) in form of an object of form:
<pre>{
"minLat": minimumLatitude,
"maxLat": maximumLatitude,
"minLng": minimumLongitude,
"maxLng": maximumLongitude,
"minElev": minimumElevation,
"maxElev": maximumElevation
}</pre>
<h4>Example</h4>
<pre>geolib.getCenter([
{latitude: 52.516272, longitude: 13.377722},
{latitude: 51.515, longitude: 7.453619},
{latitude: 51.503333, longitude: -0.119722}
]);</pre>
<h3>geolib.isPointInside(object latlng, array polygon)</h3>
Checks whether a point is inside of a polygon or not.
@ -123,6 +160,55 @@ geolib.isPointInCircle(
5000
);</pre>
<h3>geolib.getRhumbLineBearing(object originLL, object destLL)</h3>
Gets rhumb line bearing of two points. Find out about the difference between rhumb line and
great circle bearing on Wikipedia. Rhumb line should be fine in most cases:
http://en.wikipedia.org/wiki/Rhumb_line#General_and_mathematical_description
Function is heavily based on Doug Vanderweide's great PHP version (licensed under GPL 3.0)
http://www.dougv.com/2009/07/13/calculating-the-bearing-and-compass-rose-direction-between-two-latitude-longitude-coordinates-in-php/
Returns calculated bearing as integer.
<h4>Example</h4>
<pre>geolib.getRhumbLineBearing(
{latitude: 52.518611, longitude: 13.408056},
{latitude: 51.519475, longitude: 7.46694444}
);</pre>
<h3>geolib.getBearing(object originLL, object destLL)</h3>
Gets great circle bearing of two points. See description of getRhumbLineBearing for more information.
Returns calculated bearing as integer.
<h4>Example</h4>
<pre>geolib.getBearing(
{latitude: 52.518611, longitude: 13.408056},
{latitude: 51.519475, longitude: 7.46694444}
);</pre>
<h3>geolib.getCompassDirection(object originLL, object destLL, string bearingMode (optional))</h3>
Gets the compass direction from an origin coordinate (originLL) to a destination coordinate (destLL).
Bearing mode. Can be either circle or rhumbline (default).
Returns an object with a rough (NESW) and an exact direction (NNE, NE, ENE, E, ESE, etc).
<h4>Example</h4>
<pre>geolib.getCompassDirection(
{latitude: 52.518611, longitude: 13.408056},
{latitude: 51.519475, longitude: 7.46694444}
);
//Output
{
rough: 'W',
exact: 'WSW'
}</pre>
<h3>geolib.orderByDistance(object latlng, mixed coords)</h3>
Sorts an object or array of coords by distance from a reference coordinate
@ -300,7 +386,7 @@ Returns an object: `{"latitude": destLat, "longitude": destLng}`
var dist = 1234;
var bearing = 45;
geolib.computeDestinationPoint(initialPoint.lat, initialPoint.lon, dist, bearing);
geolib.computeDestinationPoint(initialPoint, dist, bearing);
// -> {"latitude":51.52411853234181,"longitude":0.4668623365950795}
</pre>

View file

@ -364,7 +364,7 @@
distance = Math.sqrt(distance * distance + climb * climb);
}
return this.distance = parseFloat((Math.round(distance / accuracy) * accuracy).toFixed(precision));
return this.distance = Math.round(distance * Math.pow(10, precision) / accuracy) * accuracy / Math.pow(10, precision);
/*
// note: to return initial/final bearings in addition to distance, use something like:
@ -946,7 +946,7 @@
for(var coord in coords) {
var distance = this.getDistance(latlng, coords[coord]);
var augmentedCoord = Object(coords[coord]);
var augmentedCoord = Object.create(coords[coord]);
augmentedCoord.distance = distance;
augmentedCoord.key = coord;
@ -970,7 +970,7 @@
*/
isPointInLine: function(point, start, end) {
return this.getDistance(start, point, 1, 3)+this.getDistance(point, end, 1, 3)==this.getDistance(start, end, 1, 3);
return (this.getDistance(start, point, 1, 3)+this.getDistance(point, end, 1, 3)).toFixed(3)==this.getDistance(start, end, 1, 3);
},
/**
@ -1017,7 +1017,7 @@
// otherwise the minimum distance is achieved through a line perpendular to the start-end line,
// which goes from the start-end line to the point //
else {
distance = Math.sin(alpha)/d1;
distance = Math.sin(alpha) * d1;
}
return distance;

File diff suppressed because one or more lines are too long

View file

@ -47,6 +47,6 @@
"scripts": {
"test": "grunt travis --verbose"
},
"version": "2.0.21",
"version": "2.0.22",
"main": "dist/geolib.js"
}

View file

@ -355,7 +355,7 @@
distance = Math.sqrt(distance * distance + climb * climb);
}
return this.distance = parseFloat((Math.round(distance / accuracy) * accuracy).toFixed(precision));
return this.distance = Math.round(distance * Math.pow(10, precision) / accuracy) * accuracy / Math.pow(10, precision);
/*
// note: to return initial/final bearings in addition to distance, use something like:
@ -937,7 +937,7 @@
for(var coord in coords) {
var distance = this.getDistance(latlng, coords[coord]);
var augmentedCoord = Object(coords[coord]);
var augmentedCoord = Object.create(coords[coord]);
augmentedCoord.distance = distance;
augmentedCoord.key = coord;
@ -961,7 +961,7 @@
*/
isPointInLine: function(point, start, end) {
return this.getDistance(start, point, 1, 3)+this.getDistance(point, end, 1, 3)==this.getDistance(start, end, 1, 3);
return (this.getDistance(start, point, 1, 3)+this.getDistance(point, end, 1, 3)).toFixed(3)==this.getDistance(start, end, 1, 3);
},
/**
@ -1008,7 +1008,7 @@
// otherwise the minimum distance is achieved through a line perpendular to the start-end line,
// which goes from the start-end line to the point //
else {
distance = Math.sin(alpha)/d1;
distance = Math.sin(alpha) * d1;
}
return distance;