@ulrik.ek/wgs84 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  A tiny library fully implemented in Typescript to handle WGS84 coordinates in GeoJson and "small" distances between them with very high accuracy (~1 cm), based on a local, flat earth approximation.
6
6
 
7
+ - All functions uses degrees for latitude and longitude, and meters for distances.
7
8
  - Parses and gives output in GeoJson using the [Point definition](https://en.wikipedia.org/wiki/GeoJSON). If you already have imported the typescript definition for Point in the geojson package you can use that (that is what I do in unit testing). Otherwise you can import `Point` from this package.
8
9
  - No dependencies to other NPM modules.
9
10
  - The math is based on [Aviation Formulary V1.47 by Ed Williams](https://edwilliams.org/avform147.htm#flat).
@@ -18,7 +19,7 @@ Include in your project as any other NPM package
18
19
  ## Usage
19
20
 
20
21
  ```typescript
21
- import * as wgs84 from '@ulrik.ek/wgs84';
22
+ import * as wgs84 from '@ulrik.ek/wgs84'; // The functions can obviously also be imported separately
22
23
 
23
24
  // helper function to construct a GeoJSON Point
24
25
  const lat = 15;
@@ -26,25 +27,43 @@ const lon = 25;
26
27
  const p: wgs84.Point = wgs84.point(lat, lon);
27
28
 
28
29
  // Getting a new point 100m north and 200m east of the first point
29
- const p1: wgs84.Point = wgs84.pointEastOf(wgs84.pointNorthOf(p, 100), 200);
30
+ const p1: wgs84.Point = wgs84.pointEastOf(wgs84.pointNorthOf(p, 300), 400);
30
31
  const newLat = p1.coordinates[1]; // GeoJSON uses [lon, lat] order!
31
32
  const newLon = p1.coordinates[0];
32
33
  console.log(`lat=${newLat}, lon=${newLon}`);
33
34
 
34
35
  // get the distance along north between the 2 points
35
- console.log(`distance along north=${wgs84.distanceNorth(p, p1)}`);
36
- console.log(`distance along east=${wgs84.distanceEast(p, p1)}`);
36
+ console.log(`Distance along north=${wgs84.distanceNorth(p, p1)}`);
37
+ console.log(`Distance along east=${wgs84.distanceEast(p, p1)}`);
38
+ console.log(`Total distance=${wgs84.distance(p, p1)}`);
37
39
  ```
38
40
 
39
41
  This will produce the following output
40
42
 
41
- > lat=15.000903761214213, lon=25.001859599546577
42
- > distance along north=99.99999999991357
43
- > distance along east=200.00084005143466
43
+ > lat=15.002711283642645, lon=25.003719230339353
44
+ > Distance along north=300.00000000009265
45
+ > Distance along east=400.00504064747975
46
+ > Total distance=500.0040325271862
44
47
 
45
48
  ## Documention
46
49
 
47
- [Typedoc](https://github.com/UEk/wgs84/blob/main/doc/modules.md)
50
+ The following functions are available:
51
+
52
+ ```Typescript
53
+ point(lat: number, lon: number, height?: number): Point;
54
+ R1(position: Point): number;
55
+ R2(position: Point): number;
56
+ distanceNorth(origin: Point, target: Point): number;
57
+ distanceEast(origin: Point, target: Point): number;
58
+ distanceUp(origin: Point, target: Point): number;
59
+ distance(origin: Point, target: Point): number;
60
+ bearing(origin: Point, target: Point): number;
61
+ pointNorthOf(origin: Point, dN: number): Point;
62
+ pointEastOf(origin: Point, dE: number): Point;
63
+ pointAbove(origin: Point, dH: number): Point;
64
+ ```
65
+
66
+ [Full Typedoc documentation](https://github.com/UEk/wgs84/blob/main/doc/modules.md)
48
67
 
49
68
  # Build and Test
50
69
 
package/dist/index.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- export interface Point {
2
- type: 'Point';
3
- coordinates: number[];
4
- }
5
- export declare function point(lat: number, lon: number, height?: number): Point;
6
- export declare function R1(position: Point): number;
7
- export declare function R2(position: Point): number;
8
- export declare function distanceNorth(origin: Point, target: Point): number;
9
- export declare function distanceEast(origin: Point, target: Point): number;
10
- export declare function distanceUp(origin: Point, target: Point): number;
11
- export declare function distance(origin: Point, target: Point): number;
12
- export declare function bearing(origin: Point, target: Point): number;
13
- export declare function pointNorthOf(origin: Point, dN: number): Point;
14
- export declare function pointEastOf(origin: Point, dE: number): Point;
15
- export declare function pointAbove(origin: Point, dH: number): Point;
1
+ export interface Point {
2
+ type: 'Point';
3
+ coordinates: number[];
4
+ }
5
+ export declare function point(lat: number, lon: number, height?: number): Point;
6
+ export declare function R1(position: Point): number;
7
+ export declare function R2(position: Point): number;
8
+ export declare function distanceNorth(origin: Point, target: Point): number;
9
+ export declare function distanceEast(origin: Point, target: Point): number;
10
+ export declare function distanceUp(origin: Point, target: Point): number;
11
+ export declare function distance(origin: Point, target: Point): number;
12
+ export declare function bearing(origin: Point, target: Point): number;
13
+ export declare function pointNorthOf(origin: Point, dN: number): Point;
14
+ export declare function pointEastOf(origin: Point, dE: number): Point;
15
+ export declare function pointAbove(origin: Point, dH: number): Point;
package/dist/index.js CHANGED
@@ -1,144 +1,140 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pointAbove = exports.pointEastOf = exports.pointNorthOf = exports.bearing = exports.distance = exports.distanceUp = exports.distanceEast = exports.distanceNorth = exports.R2 = exports.R1 = exports.point = void 0;
4
- function point(lat, lon, height) {
5
- const result = height
6
- ? { coordinates: [lon, lat, height], type: 'Point' }
7
- : { coordinates: [lon, lat], type: 'Point' };
8
- validCoord(result);
9
- return result;
10
- }
11
- exports.point = point;
12
- const R = 6378.137 * 1000;
13
- const f = 1 / 298.257223563;
14
- const eSquared = f * (2 - f);
15
- function R1(position) {
16
- validCoord(position);
17
- const lat = degToRad(position.coordinates[1]);
18
- return (R * (1 - eSquared)) / Math.pow(1 - eSquared * Math.pow(Math.sin(lat), 2), 3 / 2);
19
- }
20
- exports.R1 = R1;
21
- function R2(position) {
22
- validCoord(position);
23
- const lat = degToRad(position.coordinates[1]);
24
- return R / Math.sqrt(1 - eSquared * Math.pow(Math.sin(lat), 2));
25
- }
26
- exports.R2 = R2;
27
- function distanceNorth(origin, target) {
28
- validCoord(origin);
29
- validCoord(target);
30
- const xLat = degToRad(origin.coordinates[1]);
31
- const yLat = degToRad(target.coordinates[1]);
32
- return R1(origin) * (yLat - xLat);
33
- }
34
- exports.distanceNorth = distanceNorth;
35
- function distanceEast(origin, target) {
36
- validCoord(origin);
37
- validCoord(target);
38
- const xLat = degToRad(origin.coordinates[1]);
39
- const xLon = degToRad(origin.coordinates[0]);
40
- const yLon = degToRad(target.coordinates[0]);
41
- let deltaAngle;
42
- if (yLon - xLon > Math.PI) {
43
- deltaAngle = yLon - xLon - 2 * Math.PI;
44
- }
45
- else if (yLon - xLon < -Math.PI) {
46
- deltaAngle = yLon - xLon + 2 * Math.PI;
47
- }
48
- else {
49
- deltaAngle = yLon - xLon;
50
- }
51
- return R2(origin) * Math.cos(xLat) * deltaAngle;
52
- }
53
- exports.distanceEast = distanceEast;
54
- function distanceUp(origin, target) {
55
- if (origin.coordinates.length === 3 && target.coordinates.length === 3) {
56
- return target.coordinates[2] - origin.coordinates[2];
57
- }
58
- else {
59
- throw new Error('Input is not GeoJSON Point with height.');
60
- }
61
- }
62
- exports.distanceUp = distanceUp;
63
- function distance(origin, target) {
64
- if (origin.coordinates.length === 2 || target.coordinates.length === 2) {
65
- return Math.sqrt(distanceNorth(origin, target) ** 2 + distanceEast(origin, target) ** 2);
66
- }
67
- else if (origin.coordinates.length === 3 && target.coordinates.length === 3) {
68
- return Math.sqrt(distanceNorth(origin, target) ** 2 +
69
- distanceEast(origin, target) ** 2 +
70
- distanceUp(origin, target) ** 2);
71
- }
72
- else {
73
- throw new Error('Inputs are not GeoJSON Points.');
74
- }
75
- }
76
- exports.distance = distance;
77
- function bearing(origin, target) {
78
- validCoord(origin);
79
- validCoord(target);
80
- return ((radToDeg(Math.atan2(distanceEast(origin, target), distanceNorth(origin, target))) + 360) %
81
- 360);
82
- }
83
- exports.bearing = bearing;
84
- function pointNorthOf(origin, dN) {
85
- validCoord(origin);
86
- const lon = origin.coordinates[0];
87
- const lat = radToDeg(degToRad(origin.coordinates[1]) + dN / R1(origin));
88
- let result;
89
- if (origin.coordinates[2]) {
90
- const h = origin.coordinates[2];
91
- result = { coordinates: [lon, lat, h], type: 'Point' };
92
- }
93
- else {
94
- result = { coordinates: [lon, lat], type: 'Point' };
95
- }
96
- validCoord(result);
97
- return result;
98
- }
99
- exports.pointNorthOf = pointNorthOf;
100
- function pointEastOf(origin, dE) {
101
- validCoord(origin);
102
- const lat = origin.coordinates[1];
103
- let lon = radToDeg(degToRad(origin.coordinates[0]) + dE / (R2(origin) * Math.cos(degToRad(lat))));
104
- if (lon > 180) {
105
- lon -= 360;
106
- }
107
- else if (lon < -180) {
108
- lon += 360;
109
- }
110
- if (origin.coordinates[2]) {
111
- const h = origin.coordinates[2];
112
- return { coordinates: [lon, lat, h], type: 'Point' };
113
- }
114
- else {
115
- return { coordinates: [lon, lat], type: 'Point' };
116
- }
117
- }
118
- exports.pointEastOf = pointEastOf;
119
- function pointAbove(origin, dH) {
120
- validCoord(origin);
121
- return {
122
- coordinates: [origin.coordinates[0], origin.coordinates[1], origin.coordinates[2] + dH],
123
- type: 'Point'
124
- };
125
- }
126
- exports.pointAbove = pointAbove;
127
- function degToRad(deg) {
128
- return (deg * Math.PI) / 180;
129
- }
130
- function radToDeg(rad) {
131
- return (rad * 180) / Math.PI;
132
- }
133
- function validCoord(p) {
134
- if (-90 <= p.coordinates[1] &&
135
- p.coordinates[1] < 90 &&
136
- -180 <= p.coordinates[0] &&
137
- p.coordinates[0] <= 180) {
138
- return true;
139
- }
140
- else {
141
- throw new Error(`Lat=$(lat)) or lon=$(lon) out of range`);
142
- }
143
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pointAbove = exports.pointEastOf = exports.pointNorthOf = exports.bearing = exports.distance = exports.distanceUp = exports.distanceEast = exports.distanceNorth = exports.R2 = exports.R1 = exports.point = void 0;
4
+ function point(lat, lon, height) {
5
+ const result = height
6
+ ? { coordinates: [lon, lat, height], type: 'Point' }
7
+ : { coordinates: [lon, lat], type: 'Point' };
8
+ validCoord(result);
9
+ return result;
10
+ }
11
+ exports.point = point;
12
+ const R = 6378.137 * 1000;
13
+ const f = 1 / 298.257_223_563;
14
+ const eSquared = f * (2 - f);
15
+ function R1(position) {
16
+ validCoord(position);
17
+ const lat = degToRad(position.coordinates[1]);
18
+ return (R * (1 - eSquared)) / Math.pow(1 - eSquared * Math.pow(Math.sin(lat), 2), 3 / 2);
19
+ }
20
+ exports.R1 = R1;
21
+ function R2(position) {
22
+ validCoord(position);
23
+ const lat = degToRad(position.coordinates[1]);
24
+ return R / Math.sqrt(1 - eSquared * Math.pow(Math.sin(lat), 2));
25
+ }
26
+ exports.R2 = R2;
27
+ function distanceNorth(origin, target) {
28
+ validCoord(origin);
29
+ validCoord(target);
30
+ const originLat = degToRad(origin.coordinates[1]);
31
+ const targetLat = degToRad(target.coordinates[1]);
32
+ return R1(origin) * (targetLat - originLat);
33
+ }
34
+ exports.distanceNorth = distanceNorth;
35
+ function distanceEast(origin, target) {
36
+ validCoord(origin);
37
+ validCoord(target);
38
+ const originLat = degToRad(origin.coordinates[1]);
39
+ const originLon = degToRad(origin.coordinates[0]);
40
+ const targetLon = degToRad(target.coordinates[0]);
41
+ let deltaAngle = targetLon - originLon;
42
+ if (deltaAngle > Math.PI) {
43
+ deltaAngle -= 2 * Math.PI;
44
+ }
45
+ else if (targetLon - originLon < -Math.PI) {
46
+ deltaAngle += 2 * Math.PI;
47
+ }
48
+ return R2(origin) * Math.cos(originLat) * deltaAngle;
49
+ }
50
+ exports.distanceEast = distanceEast;
51
+ function distanceUp(origin, target) {
52
+ if (origin.coordinates.length === 3 && target.coordinates.length === 3) {
53
+ return target.coordinates[2] - origin.coordinates[2];
54
+ }
55
+ else {
56
+ throw new Error('Input is not GeoJSON Point with height.');
57
+ }
58
+ }
59
+ exports.distanceUp = distanceUp;
60
+ function distance(origin, target) {
61
+ if (origin.coordinates.length === 2 || target.coordinates.length === 2) {
62
+ return Math.hypot(distanceNorth(origin, target), distanceEast(origin, target));
63
+ }
64
+ else if (origin.coordinates.length === 3 && target.coordinates.length === 3) {
65
+ return Math.hypot(distanceNorth(origin, target), distanceEast(origin, target), distanceUp(origin, target));
66
+ }
67
+ else {
68
+ throw new Error('Inputs are not GeoJSON Points.');
69
+ }
70
+ }
71
+ exports.distance = distance;
72
+ function bearing(origin, target) {
73
+ validCoord(origin);
74
+ validCoord(target);
75
+ return ((radToDeg(Math.atan2(distanceEast(origin, target), distanceNorth(origin, target))) + 360) %
76
+ 360);
77
+ }
78
+ exports.bearing = bearing;
79
+ function pointNorthOf(origin, dN) {
80
+ validCoord(origin);
81
+ const lon = origin.coordinates[0];
82
+ const lat = radToDeg(degToRad(origin.coordinates[1]) + dN / R1(origin));
83
+ let result;
84
+ if (origin.coordinates[2]) {
85
+ const h = origin.coordinates[2];
86
+ result = { coordinates: [lon, lat, h], type: 'Point' };
87
+ }
88
+ else {
89
+ result = { coordinates: [lon, lat], type: 'Point' };
90
+ }
91
+ validCoord(result);
92
+ return result;
93
+ }
94
+ exports.pointNorthOf = pointNorthOf;
95
+ function pointEastOf(origin, dE) {
96
+ validCoord(origin);
97
+ const lat = origin.coordinates[1];
98
+ let lon = radToDeg(degToRad(origin.coordinates[0]) + dE / (R2(origin) * Math.cos(degToRad(lat))));
99
+ if (lon > 180) {
100
+ lon -= 360;
101
+ }
102
+ else if (lon < -180) {
103
+ lon += 360;
104
+ }
105
+ if (origin.coordinates[2]) {
106
+ const h = origin.coordinates[2];
107
+ return { coordinates: [lon, lat, h], type: 'Point' };
108
+ }
109
+ else {
110
+ return { coordinates: [lon, lat], type: 'Point' };
111
+ }
112
+ }
113
+ exports.pointEastOf = pointEastOf;
114
+ function pointAbove(origin, dH) {
115
+ validCoord(origin);
116
+ return {
117
+ coordinates: [origin.coordinates[0], origin.coordinates[1], origin.coordinates[2] + dH],
118
+ type: 'Point'
119
+ };
120
+ }
121
+ exports.pointAbove = pointAbove;
122
+ function degToRad(deg) {
123
+ return (deg * Math.PI) / 180;
124
+ }
125
+ function radToDeg(rad) {
126
+ return (rad * 180) / Math.PI;
127
+ }
128
+ function validCoord(p) {
129
+ if ((p.coordinates.length === 2 || p.coordinates.length === 3) &&
130
+ -90 <= p.coordinates[1] &&
131
+ p.coordinates[1] < 90 &&
132
+ -180 <= p.coordinates[0] &&
133
+ p.coordinates[0] <= 180) {
134
+ return true;
135
+ }
136
+ else {
137
+ throw new Error(`Invalid GeoJson or lat/lon out of range`);
138
+ }
139
+ }
144
140
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAiBA,SAAgB,KAAK,CAAC,GAAW,EAAE,GAAW,EAAE,MAAe;IAC3D,MAAM,MAAM,GAAU,MAAM;QACxB,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE;QACpD,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACjD,UAAU,CAAC,MAAM,CAAC,CAAC;IACnB,OAAO,MAAM,CAAC;AAClB,CAAC;AAND,sBAMC;AAGD,MAAM,CAAC,GAAW,QAAQ,GAAG,IAAI,CAAC;AAElC,MAAM,CAAC,GAAW,CAAC,GAAG,aAAe,CAAC;AAEtC,MAAM,QAAQ,GAAW,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAQrC,SAAgB,EAAE,CAAC,QAAe;IAC9B,UAAU,CAAC,QAAQ,CAAC,CAAC;IACrB,MAAM,GAAG,GAAG,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;AAC7F,CAAC;AAJD,g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"@ulrik.ek/wgs84",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Basic library for computing small distances between WGS84 coordinates using a flat earth approximation.",
5
5
  "author": "Ulrik E.",
6
6
  "license": "MIT",
@@ -25,28 +25,28 @@
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/geojson": "^7946.0.8",
28
- "@types/jest": "^27.4.1",
29
- "@types/node": "^17.0.23",
30
- "@typescript-eslint/eslint-plugin": "^5.16.0",
31
- "@typescript-eslint/parser": "^5.16.0",
32
- "eslint": "^8.12.0",
33
- "eslint-plugin-import": "^2.25.4",
34
- "eslint-plugin-jest": "26.1.3",
28
+ "@types/jest": "^29.5.12",
29
+ "@types/node": "^20.12.4",
30
+ "@typescript-eslint/eslint-plugin": "^7.5.0",
31
+ "@typescript-eslint/parser": "^7.5.0",
32
+ "eslint": "^8.57.0",
33
+ "eslint-plugin-import": "^2.29.1",
34
+ "eslint-plugin-jest": "^27.9.0",
35
35
  "eslint-plugin-json": "^3.1.0",
36
- "eslint-plugin-simple-import-sort": "^7.0.0",
37
- "eslint-plugin-sort-class-members": "^1.14.1",
36
+ "eslint-plugin-simple-import-sort": "^12.0.0",
37
+ "eslint-plugin-sort-class-members": "^1.20.0",
38
38
  "eslint-plugin-sort-keys-fix": "^1.1.2",
39
- "eslint-plugin-unicorn": "^41.0.1",
39
+ "eslint-plugin-unicorn": "^52.0.0",
40
40
  "eslint-plugin-yaml": "^0.5.0",
41
- "jest": "^27.5.1",
42
- "jest-junit": "^13.0.0",
43
- "prettier": "^2.6.1",
41
+ "jest": "^29.7.0",
42
+ "jest-junit": "^16.0.0",
43
+ "prettier": "^3.2.5",
44
44
  "shx": "^0.3.4",
45
- "ts-jest": "^27.1.4",
46
- "ts-node": "^10.7.0",
47
- "typedoc": "^0.22.13",
48
- "typedoc-plugin-markdown": "^3.11.14",
49
- "typescript": "^4.6.3"
45
+ "ts-jest": "^29.1.2",
46
+ "ts-node": "^10.9.2",
47
+ "typedoc": "^0.25.12",
48
+ "typedoc-plugin-markdown": "^3.17.1",
49
+ "typescript": "^5.4.4"
50
50
  },
51
51
  "types": "./dist/index.d.ts",
52
52
  "repository": {
@@ -57,5 +57,5 @@
57
57
  "url": "https://github.com/UEk/wgs84/issues"
58
58
  },
59
59
  "homepage": "https://github.com/UEk/wgs84#readme",
60
- "keywords": ["wgs84", "geojson"]
60
+ "keywords": ["wgs84", "geojson", "latitude", "longitude"]
61
61
  }