Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

geodesy

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geodesy - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

85

latlon-spherical.js

@@ -9,3 +9,3 @@ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

'use strict';
if (typeof module!='undefined' && module.exports) var Dms = require('./dms'); // ≡ import Dms from 'dms.js'
if (typeof module!='undefined' && module.exports) var Dms = require('./dms.js'); // ≡ import Dms from 'dms.js'

@@ -16,2 +16,5 @@

*
* Includes distances, bearings, destinations, etc, for both great circle paths and rhumb lines,
* and other related functions.
*
* @module latlon-spherical

@@ -23,3 +26,3 @@ * @requires dms

/**
* Creates a LatLon point on the earth's surface at the specified latitude / longitude.
* Creates a latitude/longitude point on the earth’s surface, using a spherical model earth.
*

@@ -43,4 +46,6 @@ * @constructor

/**
* Returns the distance from ‘this’ point to destination point (using haversine formula).
* Returns the distance on the surface of the sphere from ‘this’ point to destination point.
*
* Uses haversine formula: a = sin²(Δφ/2) + cosφ1·cosφ2 · sin²(Δλ/2); d = 2 · atan2(√a, √(a-1)).
*
* @param {LatLon} point - Latitude/longitude of destination point.

@@ -53,3 +58,4 @@ * @param {number} [radius=6371e3] - (Mean) radius of earth (defaults to radius in metres).

* var p2 = new LatLon(48.857, 2.351);
* var d = p1.distanceTo(p2); // 404.3 km
* var d = p1.distanceTo(p2); // 404.3 km
* var m = p1.distanceTo(p2, 3959); // 251.2 miles
*/

@@ -61,3 +67,3 @@ LatLon.prototype.distanceTo = function(point, radius) {

// a = sin²(Δφ/2) + cos(φ1)⋅cos(φ2)⋅sin²(Δλ/2)
// tanδ = √(a) / √(1−a)
// δ = 2·atan2(√(a), √(1−a))
// see mathforum.org/library/drmath/view/51879.html for derivation

@@ -100,2 +106,3 @@

var Δλ = (point.lon-this.lon).toRadians();
var y = Math.sin(Δλ) * Math.cos(φ2);

@@ -111,4 +118,4 @@ var x = Math.cos(φ1)*Math.sin(φ2) -

/**
* Returns final bearing arriving at destination destination point from ‘this’ point; the final bearing
* will differ from the initial bearing by varying degrees according to distance and latitude.
* Returns final bearing arriving at destination point from ‘this’ point; the final bearing will
* differ from the initial bearing by varying degrees according to distance and latitude.
*

@@ -132,3 +139,3 @@ * @param {LatLon} point - Latitude/longitude of destination point.

/**
* Returns the midpoint between ‘this’ point and the supplied point.
* Returns the midpoint between ‘this’ point and given point.
*

@@ -152,3 +159,3 @@ * @param {LatLon} point - Latitude/longitude of destination point.

var φ2 = point.lat.toRadians();
var Δλ = (point.lon-this.lon).toRadians();
var Δλ = (point.lon - this.lon).toRadians();

@@ -164,3 +171,3 @@ var Bx = Math.cos(φ2) * Math.cos(Δλ);

return new LatLon(φ3.toDegrees(), (λ3.toDegrees()+540)%360-180); // normalise to −180..+180°
return new LatLon(φ3.toDegrees(), (λ3.toDegrees()+540)%360-180); // normalise lon to −180..+180°
};

@@ -170,3 +177,3 @@

/**
* Returns the point at given fraction between ‘this’ point and specified point.
* Returns the point at given fraction between ‘this’ point and given point.
*

@@ -225,3 +232,3 @@ * @param {LatLon} point - Latitude/longitude of destination point.

LatLon.prototype.destinationPoint = function(distance, bearing, radius) {
radius = (radius === undefined) ? 6371e3 : Number(radius);
radius = (radius === undefined) ? 6371e3 : radius;

@@ -232,3 +239,3 @@ // sinφ2 = sinφ1⋅cosδ + cosφ1⋅sinδ⋅cosθ

var δ = Number(distance) / radius; // angular distance in radians
var δ = Number(distance) / Number(radius); // angular distance in radians
var θ = Number(bearing).toRadians();

@@ -249,3 +256,3 @@

return new LatLon(φ2.toDegrees(), (λ2.toDegrees()+540)%360-180); // normalise to −180..+180°
return new LatLon(φ2.toDegrees(), (λ2.toDegrees()+540)%360-180); // normalise lon to −180..+180°
};

@@ -264,4 +271,4 @@

* @example
* var p1 = LatLon(51.8853, 0.2545), brng1 = 108.547;
* var p2 = LatLon(49.0034, 2.5735), brng2 = 32.435;
* var p1 = new LatLon(51.8853, 0.2545), brng1 = 108.547;
* var p2 = new LatLon(49.0034, 2.5735), brng2 = 32.435;
* var pInt = LatLon.intersection(p1, brng1, p2, brng2); // 50.9078°N, 004.5084°E

@@ -278,3 +285,3 @@ */

var θ13 = Number(brng1).toRadians(), θ23 = Number(brng2).toRadians();
var Δφ = φ2-φ1, Δλ = λ2-λ1;
var Δφ = φ2 - φ1, Δλ = λ2 - λ1;

@@ -300,5 +307,8 @@ // angular distance p1-p2

var α3 = Math.acos( -Math.cos(α1)*Math.cos(α2) + Math.sin(α1)*Math.sin(α2)*Math.cos(δ12) );
var δ13 = Math.atan2( Math.sin(δ12)*Math.sin(α1)*Math.sin(α2), Math.cos(α2)+Math.cos(α1)*Math.cos(α3) );
var cosα3 = -Math.cos(α1)*Math.cos(α2) + Math.sin(α1)*Math.sin(α2)*Math.cos(δ12);
var δ13 = Math.atan2( Math.sin(δ12)*Math.sin(α1)*Math.sin(α2), Math.cos(α2)+Math.cos(α1)*cosα3 );
var φ3 = Math.asin( Math.sin(φ1)*Math.cos(δ13) + Math.cos(φ1)*Math.sin(δ13)*Math.cos(θ13) );
var Δλ13 = Math.atan2( Math.sin(θ13)*Math.sin(δ13)*Math.cos(φ1), Math.cos(δ13)-Math.sin(φ1)*Math.sin(φ3) );

@@ -326,4 +336,4 @@ var λ3 = λ1 + Δλ13;

LatLon.prototype.crossTrackDistanceTo = function(pathStart, pathEnd, radius) {
if (!(pathStart instanceof LatLon)) throw new TypeError('pathStart is not LatLon object');
if (!(pathEnd instanceof LatLon)) throw new TypeError('pathEnd is not LatLon object');
if (!(pathStart instanceof LatLon)) throw new TypeError('‘pathStart’ is not LatLon object');
if (!(pathEnd instanceof LatLon)) throw new TypeError('‘pathEnd’ is not LatLon object');
var R = (radius === undefined) ? 6371e3 : Number(radius);

@@ -335,3 +345,3 @@

var δxt = Math.asin(Math.sin(δ13) * Math.sin(θ13-θ12));
var δxt = Math.asin(Math.sin(δ13) * Math.sin(θ13 - θ12));

@@ -359,5 +369,5 @@ return δxt * R;

LatLon.prototype.alongTrackDistanceTo = function(pathStart, pathEnd, radius) {
if (!(pathStart instanceof LatLon)) throw new TypeError('pathStart is not LatLon object');
if (!(pathEnd instanceof LatLon)) throw new TypeError('pathEnd is not LatLon object');
var R = (radius === undefined) ? 6371e3 : Number(radius);
if (!(pathStart instanceof LatLon)) throw new TypeError('‘pathStart’ is not LatLon object');
if (!(pathEnd instanceof LatLon)) throw new TypeError('‘pathEnd’ is not LatLon object');
var R = (radius === undefined) ? 6371e3 : radius;

@@ -377,11 +387,11 @@ var δ13 = pathStart.distanceTo(this, R) / R;

/**
* Returns maximum latitude reached when travelling on a great circle on given bearing from this
* point ('Clairaut's formula'). Negate the result for the minimum latitude (in the Southern
* hemisphere).
* Returns maximum latitude reached when travelling on a great circle on given bearing from
* ‘this’ point (‘Clairaut’s formula’). Negate the result for the minimum latitude (in the
* Southern hemisphere).
*
* The maximum latitude is independent of longitude; it will be the same for all points on a given
* latitude.
* The maximum latitude is independent of longitude; it will be the same for all points on a
* given latitude.
*
* @param {number} bearing - Initial bearing.
* @param {number} latitude - Starting latitude.
* @param {number} bearing - Initial bearing.
* @returns {number} Maximum latitude reached.
*/

@@ -516,8 +526,9 @@ LatLon.prototype.maxLatitude = function(bearing) {

LatLon.prototype.rhumbDestinationPoint = function(distance, bearing, radius) {
radius = (radius === undefined) ? 6371e3 : Number(radius);
radius = (radius === undefined) ? 6371e3 : radius;
var δ = Number(distance) / radius; // angular distance in radians
var φ1 = this.lat.toRadians(), λ1 = this.lon.toRadians();
var θ = Number(bearing).toRadians();
var δ = distance / radius; // angular distance in radians
var Δφ = δ * Math.cos(θ);

@@ -535,3 +546,3 @@ var φ2 = φ1 + Δφ;

return new LatLon(φ2.toDegrees(), (λ2.toDegrees()+540) % 360 - 180); // normalise to −180..+180°
return new LatLon(φ2.toDegrees(), (λ2.toDegrees()+540) % 360 - 180); // normalise lon to −180..+180°
};

@@ -561,7 +572,7 @@

var φ3 = (φ1+φ2)/2;
var φ3 = (φ1 + φ2) / 2;
var f1 = Math.tan(Math.PI/4 + φ1/2);
var f2 = Math.tan(Math.PI/4 + φ2/2);
var f3 = Math.tan(Math.PI/4 + φ3/2);
var λ3 = ( (λ2-λ1)*Math.log(f3) + λ1*Math.log(f2) - λ2*Math.log(f1) ) / Math.log(f2/f1);
var λ3 = ( (λ2 - λ1) * Math.log(f3) + λ1 * Math.log(f2) - λ2 * Math.log(f1) ) / Math.log(f2 / f1);

@@ -568,0 +579,0 @@ if (!isFinite(λ3)) λ3 = (λ1+λ2)/2; // parallel of latitude

@@ -223,3 +223,3 @@ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

var λ = L, λʹ, iterations = 0;
var λ = L, λʹ, iterations = 0, antimeridian = Math.abs(L) > Math.PI;
do {

@@ -239,3 +239,4 @@ sinλ = Math.sin(λ);

λ = L + (1-C) * f * sinα * (σ + C*sinσ*(cos2σM+C*cosσ*(-1+2*cos2σM*cos2σM)));
if (Math.abs(λ) > Math.PI) throw new Error('λ > π');
var iterationCheck = antimeridian ? Math.abs(λ)-Math.PI : Math.abs(λ);
if (iterationCheck > Math.PI) throw new Error('λ > π');
} while (Math.abs(λ-λʹ) > 1e-12 && ++iterations<1000);

@@ -242,0 +243,0 @@ if (iterations >= 1000) throw new Error('Formula failed to converge');

@@ -8,3 +8,3 @@ {

"author": "Chris Veness",
"version": "1.1.2",
"version": "1.1.3",
"license": "MIT",

@@ -19,7 +19,7 @@ "main": "npm.js",

"chai": "^4.1.2",
"eslint": "^4.6.1",
"jsdoc": "^3.5.4",
"mocha": "^3.5.1",
"npm-check": "^5.4.5",
"npm-check-updates": "^2.12.1"
"eslint": "^4.18.2",
"jsdoc": "^3.5.5",
"mocha": "^5.0.1",
"npm-check": "^5.5.2",
"npm-check-updates": "^2.14.1"
},

@@ -26,0 +26,0 @@ "eslintConfig": {

@@ -49,43 +49,27 @@ Geodesy functions

* *Constructor*
* `new LatLon(lat, lon)`
- Create new latitude/longitude point on a spherical earth model
* *Methods*
* `latlon.distanceTo(point[, radius])`
- Distance to 2nd point (using haversine formula)
* `latlon.bearingTo(point)`
- (Initial) bearing to 2nd point
* `latlon.finalBearingTo(point)`
- Final bearing to 2nd point
* `latlon.midpointTo(point)`
- Midpoint to 2nd point
* `latlon.intermediatePointTo(point, fraction)`
- Point at given fraction towards 2nd point
* `latlon.destinationPoint(distance, bearing[, radius])`
- Destination point travelling given distance on given bearing
* `LatLon.intersection(point1, bearing1, point2, bearing2)`
- Intersection point of two paths defined by point and bearing
* `LatLon.crossTrackDistanceTo(pathStart, pathEnd, radius)`
- Distance to great circle defined by pathStart and pathEnd
* `LatLon.maxLatitude(bearing)`
- Maximum latitude reached travelling on given (initial) bearing
* `LatLon.crossingParallels(point1, point2, latitude)`
- Meridians at which great circle defined by point1 & point2 cross given latitude
* `latlon.rhumbDistanceTo(point[, radius])`
- Distance to point along rhumb line
* `latlon.rhumbBearingTo(point)`
- (Initial) bearing to point along rhumb line
* `latlon.rhumbDestinationPoint(distance, bearing[, radius])`
- Destination point travelling distance on bearing
* `latlon.rhumbMidpointTo(point)`
- Midpoint on rhumb line to 2nd point
* `LatLon.areaOf(polygon[, radius])`
- Area of polygon defined by array of vertex points
* `latlon.equals(point)`
- Equality of points
* `latlon.toString([format[, decimals]])`
- String representation of point, in deg/deg-min/deg-min-sec format to given decimal places
### [LatLon](http://www.movable-type.co.uk/scripts/geodesy/docs/module-latlon-spherical-LatLon.html)
Full details are available at www.movable-type.co.uk/scripts/latlong.html.
* `new LatLon(lat, lon)`
*
* `latlon.distanceTo(point[, radius])`
* `latlon.bearingTo(point)`
* `latlon.finalBearingTo(point)`
* `latlon.midpointTo(point)`
* `latlon.intermediatePointTo(point, fraction)`
* `latlon.destinationPoint(distance, bearing[, radius])`
* `LatLon.intersection(point1, bearing1, point2, bearing2)`
* `LatLon.crossTrackDistanceTo(pathStart, pathEnd, radius)`
* `LatLon.maxLatitude(bearing)`
* `LatLon.crossingParallels(point1, point2, latitude)`
* `latlon.rhumbDistanceTo(point[, radius])`
* `latlon.rhumbBearingTo(point)`
* `latlon.rhumbDestinationPoint(distance, bearing[, radius])`
* `latlon.rhumbMidpointTo(point)`
* `LatLon.areaOf(polygon[, radius])`
* `latlon.equals(point)`
* `latlon.toString([format[, decimals]])`
Further details available at [www.movable-type.co.uk/scripts/latlong.html]
(http://www.movable-type.co.uk/scripts/latlong.html).
*Notes: previously named simply latlon.js; radius moved from constructor to distance calculation

@@ -101,23 +85,19 @@ methods; distances previously in kilometres now default to metres, order of arguments to destination

* *Constructor*
* `new LatLon(lat, lon[, datum])`
- Create new latitude/longitude point on an ellipsoidal earth model using given datum (default WGS84)
* *Properties*
* `datum`
- Associated ellipsoids, and Helmert transform parameters from WGS84, for various datums
* `ellipsoid`
- Ellipsoid parameters major axis (a), minor axis (b), and flattening (f) for various ellipsoids
* *Methods*
* `latlon.convertDatum(datum)`
- Convert point into new datum
* `latlon.toCartesian()`
- Convert point to cartesian Vector3d point
* `vector3d.toLatLon([datum])`
- Convert cartesian (Vector3d) point to (geodetic) latitude/longitude in given datum (default WGS84)
* `latlon.toString([format[, decimals]])`
- String representation of point, in d/dm/dms format to given decimal places
### [LatLon](http://www.movable-type.co.uk/scripts/geodesy/docs/module-latlon-ellipsoidal-LatLon.html)
* `new LatLon(lat, lon[, datum])`
*
* `LatLon.datum`
* `LatLon.ellipsoid`
*
* `latlon.convertDatum(datum)`
* `latlon.toCartesian()`
* `latlon.toString([format[, decimals]])`
*
* `vector3d.toLatLon([datum])`
*Notes: `LatLonE` now simply `LatLon`.*
More information at www.movable-type.co.uk/scripts/latlong-convert-coords.html.
Further details available at [www.movable-type.co.uk/scripts/latlong-convert-coords.html]
(http://www.movable-type.co.uk/scripts/latlong-convert-coords.html).

@@ -131,17 +111,14 @@

* *Methods*
* `latlon.distanceTo(point)`
- Distance to point (using Vincenty calculation)
* `latlon.bearingTo(point)`
- (Initial) bearing to point (using Vincenty calculation)
* `latlon.finalBearingTo(point)`
- Final bearing to point (using Vincenty calculation)
* `latlon.destinationPoint(distance, bearing)`
- Destination point travelling distance on bearing (using Vincenty calculation)
* `latlon.finalBearingOn(distance, initialBearing)`
- Final bearing having travelled along a geodesic given by initial bearing for given distance
### [LatLon](http://www.movable-type.co.uk/scripts/geodesy/docs/module-latlon-vincenty-LatLon.html) *extends latlon-ellipsoidal.js*
Full details are available at www.movable-type.co.uk/scripts/latlong-vincenty.html.
* `latlon.distanceTo(point)`
* `latlon.bearingTo(point)`
* `latlon.finalBearingTo(point)`
* `latlon.destinationPoint(distance, bearing)`
* `latlon.finalBearingOn(distance, initialBearing)`
Further details available at [www.movable-type.co.uk/scripts/latlong-vincenty.html]
(http://www.movable-type.co.uk/scripts/latlong-vincenty.html).
*latlon-vectors.js*: latitude/longitude geodesy functions using vector calculations

@@ -155,43 +132,25 @@ -----------------------------------------------------------------------------------

* *Constructor*
* `new LatLon(lat, lon)`
- Create new latitude/longitude point on a spherical earth model of given radius (default 6371km)
* *Methods*
* `latlon.toVector()`
- Convert (spherical/geodetic) latitude/longitude point to vector
* `vector3d.toLatLonS()`
- Convert cartesian (Vector3d) coordinate to (spherical) latitude/longitude point
* `latlon.greatCircle(bearing)`
- Return vector representing great circle obtained by heading on given bearing from latlon point
* `latlon.distanceTo(point[, radius])`
- Distance to point
* `latlon.bearingTo(point)`
- (Initial) bearing to point
* `latlon.midpointTo(point)`
- Midpoint to 2nd point
* `latlon.intermediatePointTo(point, fraction)`
- Point at given fraction towards 2nd point
* `latlon.intermediatePointOnChordTo(point, fraction)`
- Point at given fraction along straight line towards 2nd point
* `latlon.destinationPoint(distance, bearing[, radius])`
- Destination point travelling distance on bearing
* `LatLon.intersection(path1start, path1brngEnd, path2start, path2brngEnd)`
- Intersection of two paths defined by start+bearing or start+end
* `latlon.crossTrackDistanceTo(pathStart, pathBrngEnd[, radius])`
- Distance to great circle defined by start-point and end-point/bearing
* `latlon.nearestPointOnSegment(point1, point2)`
- Closest point on segment between two other points
* `latlon.isBetween(point1, point2)`
- Whether point is between two other points
* `latlon.enclosedBy(points)`
- Whether point is enclosed by polygon
* `LatLon.areaOf(polygon[, radius])`
- Area of polygon defined by array of vertex points
* `LatLon.meanOf(points)`
- Geographic mean of set of points
* `latlon.equals(point)`
- Whether points are equal
* `latlon.toString([format[, decimals]])`
- String representation of point, in d/dm/dms format to given decimal places
### [LatLon](http://www.movable-type.co.uk/scripts/geodesy/docs/module-latlon-vectors-LatLon.html)
* `new LatLon(lat, lon)`
*
* `latlon.toVector()`
* `vector3d.toLatLonS()`
* `latlon.greatCircle(bearing)`
* `latlon.distanceTo(point[, radius])`
* `latlon.bearingTo(point)`
* `latlon.midpointTo(point)`
* `latlon.intermediatePointTo(point, fraction)`
* `latlon.intermediatePointOnChordTo(point, fraction)`
* `latlon.destinationPoint(distance, bearing[, radius])`
* `LatLon.intersection(path1start, path1brngEnd, path2start, path2brngEnd)`
* `latlon.crossTrackDistanceTo(pathStart, pathBrngEnd[, radius])`
* `latlon.nearestPointOnSegment(point1, point2)`
* `latlon.isBetween(point1, point2)`
* `latlon.enclosedBy(points)`
* `LatLon.areaOf(polygon[, radius])`
* `LatLon.meanOf(points)`
* `latlon.equals(point)`
* `latlon.toString([format[, decimals]])`
*Notes: `LatLonE` now simply `LatLon`; order of arguments to destination point method reversed.

@@ -201,3 +160,4 @@ More thought is required on which of these functions operate on spherical model, which on n-vector

More information at www.movable-type.co.uk/scripts/latlong-vectors.html.
Further details available at [www.movable-type.co.uk/scripts/latlong-vectors.html]
(http://www.movable-type.co.uk/scripts/latlong-vectors.html).

@@ -210,32 +170,20 @@

* *Constructor*
* `new Vector3d(x, y, z)`
- Create new 3-d vector
* *Methods*
* `vector3d.plus(v)`
- Add vector v
* `vector3d.minus(v)`
- Subtract vector v
* `vector3d.times(x)`
- Multiply vector by (scalar) x
* `vector3d.dividedBy(x)`
- Divide vector by (scalar) x
* `vector3d.dot(v)`
- Multiply vector by v using dot (scalar) product
* `vector3d.cross(v)`
- Multiply vector by v using cross (vector) product
* `vector3d.negate()`
- Negate vector to point in the opposite direction
* `vector3d.length()`
- Length (magnitude or norm) of vector
* `vector3d.unit()`
- Normalize a vector to its unit vector
* `vector3d.angleTo(v, vSign)`
- Angle to 2nd vector
* `vector3d.rotateAround(axis, theta)`
- Rotate vector around axis by given angle
* `vector3d.toString(decimals)`
- String representation of vector
### [Vector3d](http://www.movable-type.co.uk/scripts/geodesy/docs/module-vector3d-Vector3d.html)
* `new Vector3d(x, y, z)`
*
* `vector3d.plus(v)`
* `vector3d.minus(v)`
* `vector3d.times(x)`
* `vector3d.dividedBy(x)`
* `vector3d.dot(v)`
* `vector3d.cross(v)`
* `vector3d.negate()`
* `vector3d.length()`
* `vector3d.unit()`
* `vector3d.angleTo(v, vSign)`
* `vector3d.rotateAround(axis, theta)`
* `vector3d.toString(decimals)`
*utm.js*: Universal Transverse Mercator / Latitude-Longitude conversions

@@ -247,18 +195,15 @@ ------------------------------------------------------------------------

* *Constructor*
* `new Utm(zone, hemisphere, easting, northing[, datum[, convergence, scale]])`
- Create new UTM coordinate on given datum (default WGS84)
* *Methods*
* `latlon.toUtm()`
- Convert (geodetic) latitude/longitude point to UTM coordinate
* `utm.toLatLonE()`
- Convert UTM coordinate to latitude/longitude point
* `Utm.parse([utmCoord])`
- Parse string representation of UTM coordinate
* `utm.toString([digits])`
- String representation of UTM coordinate
### [Utm](http://www.movable-type.co.uk/scripts/geodesy/docs/module-utm-Utm.html)
More information at www.movable-type.co.uk/scripts/latlong-utm-mgrs.html.
* `new Utm(zone, hemisphere, easting, northing[, datum[, convergence, scale]])`
*
* `latlon.toUtm()`
* `utm.toLatLonE()`
* `Utm.parse([utmCoord])`
* `utm.toString([digits])`
Further details available at [www.movable-type.co.uk/scripts/latlong-utm-mgrs.html]
(http://www.movable-type.co.uk/scripts/latlong-utm-mgrs.html).
*mgrs.js*: MGRS/NATO grid references

@@ -269,18 +214,15 @@ ------------------------------------

* *Constructor*
* `new Mgrs(zone, band, e100k, n100k, easting, northing[, datum])`
- Create new MGRS grid reference on given datum (default WGS84)
* *Methods*
* `Utm.toMgrs()`
- Convert UTM coordinate to MGRS grid reference
* `mgrs.toUtm()`
- Convert MGRS grid reference to UTM coordinate
* `Mgrs.parse(mgrsGridRef)`
- Parse string representation of MGRS grid reference
* `mgrs.toString([digits])`
- String representation of MGRS grid reference
### [Mgrs](http://www.movable-type.co.uk/scripts/geodesy/docs/module-mgrs-Mgrs.html)
More information at www.movable-type.co.uk/scripts/latlong-utm-mgrs.html.
* `new Mgrs(zone, band, e100k, n100k, easting, northing[, datum])`
*
* `Utm.toMgrs()`
* `mgrs.toUtm()`
* `Mgrs.parse(mgrsGridRef)`
* `mgrs.toString([digits])`
Further details available at [www.movable-type.co.uk/scripts/latlong-utm-mgrs.html]
(http://www.movable-type.co.uk/scripts/latlong-utm-mgrs.html).
*osgridref.js*: UK Ordnance Survey grid references

@@ -292,18 +234,15 @@ --------------------------------------------------

* *Constructor*
* `new OsGridRef(easting, northing)`
- Create new OS grid reference
* *Methods*
* `OsGridRef.latLonToOsGrid(point)`
- Convert UTM coordinate to MGRS grid reference
* `OsGridRef.osGridToLatLon(gridref, datum)`
- Convert OS grid reference to latitude/longitude
* `OsGridRef.parse(gridref)`
- Parse string representation of OS grid reference
* `osGridRef.toString([digits])`
- String representation of OS grid reference
### [OsGridRef](http://www.movable-type.co.uk/scripts/geodesy/docs/module-osgridref-OsGridRef.html)
More information at www.movable-type.co.uk/scripts/latlong-gridref.html.
* `new OsGridRef(easting, northing)`
*
* `OsGridRef.latLonToOsGrid(point)`
* `OsGridRef.osGridToLatLon(gridref, datum)`
* `OsGridRef.parse(gridref)`
* `osGridRef.toString([digits])`
Further details available at [www.movable-type.co.uk/scripts/latlong-gridref.html]
(http://www.movable-type.co.uk/scripts/latlong-gridref.html).
*dms.js*: conversion routines for degrees, minutes, seconds

@@ -314,16 +253,11 @@ -----------------------------------------------------------

* *Methods*
* `Dms.parseDMS(dmsStr)`
- Parse string representing degrees/minutes/seconds into numeric degrees
* `Dms.toDms(degrees[, format[, decimals]])`
- Convert decimal degrees to deg/min/sec format
* `Dms.toLat(degrees[, format[, decimals]])`
- Convert numeric degrees to deg/min/sec latitude (2-digit degrees, suffixed with N/S)
* `Dms.toLon(degrees[, format[, decimals]])`
- Convert numeric degrees to deg/min/sec longitude (2-digit degrees, suffixed with E/W)
* `Dms.toBrng(degrees[, format[, decimals]])`
- Convert numeric degrees to deg/min/sec as a bearing (0°..360°)
* `Dms.compassPoint(bearing[, precision])`
- Return compass point for supplied bearing to given precision (cardinal / intercardinal / secondary-intercardinal)
### [Dms](http://www.movable-type.co.uk/scripts/geodesy/docs/module-dms-Dms.html)
* `Dms.parseDMS(dmsStr)`
* `Dms.toDms(degrees[, format[, decimals]])`
* `Dms.toLat(degrees[, format[, decimals]])`
* `Dms.toLon(degrees[, format[, decimals]])`
* `Dms.toBrng(degrees[, format[, decimals]])`
* `Dms.compassPoint(bearing[, precision])`
*Notes: renamed from `Geo` (geo.js)*

@@ -335,3 +269,4 @@

Documentation for all these methods is available at www.movable-type.co.uk/scripts/js/geodesy/docs.
Documentation for all these methods is available at [www.movable-type.co.uk/scripts/js/geodesy/docs]
(http://www.movable-type.co.uk/scripts/js/geodesy/docs).

@@ -338,0 +273,0 @@

@@ -132,2 +132,4 @@ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

test('dest’n', function() { new LatLon(1, 1).rhumbDestinationPoint(111178, 90).toString('d').should.equal('01.0000°N, 002.0000°E'); });
test('dest’n dateline', function() { new LatLon(1, 179).rhumbDestinationPoint(222356, 90).toString('d').should.equal('01.0000°N, 179.0000°W'); });
test('dest’n dateline', function() { new LatLon(1, -179).rhumbDestinationPoint(222356, 270).toString('d').should.equal('01.0000°N, 179.0000°E'); });
test('midpoint', function() { dov.rhumbMidpointTo(cal).toString('d').should.equal('51.0455°N, 001.5957°E'); });

@@ -134,0 +136,0 @@ test('midpoint dateline', function() { new LatLon(1, -179).rhumbMidpointTo(new LatLon(1, 178)).toString('d').should.equal('01.0000°N, 179.5000°E'); });

@@ -35,2 +35,4 @@ /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

test('crossing antimeridian', function() { new LatLon(30, 120).distanceTo(new LatLon(30, -120)).should.equal(10825924.089); });
test('Q1 a', function() { new LatLon( 30, 30).distanceTo(new LatLon( 60, 60)).should.equal(4015703.021); });

@@ -37,0 +39,0 @@ test('Q1 b', function() { new LatLon( 60, 60).distanceTo(new LatLon( 30, 30)).should.equal(4015703.021); });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc