@ulrik.ek/wgs84 1.1.0 → 1.1.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/doc/README.md +74 -0
- package/doc/functions/R1.md +28 -0
- package/doc/functions/R2.md +28 -0
- package/doc/functions/bearing.md +35 -0
- package/doc/functions/distance.md +35 -0
- package/doc/functions/distanceEast.md +34 -0
- package/doc/functions/distanceNorth.md +34 -0
- package/doc/functions/distanceUp.md +33 -0
- package/doc/functions/point.md +40 -0
- package/doc/functions/pointAbove.md +34 -0
- package/doc/functions/pointEastOf.md +34 -0
- package/doc/functions/pointNorthOf.md +34 -0
- package/doc/globals.md +23 -0
- package/doc/interfaces/Point.md +12 -0
- package/package.json +17 -13
- package/eslint.config.mjs +0 -79
- package/tsconfig.tsbuildinfo +0 -1
- package/vitest.config.ts +0 -12
package/doc/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
**@ulrik.ek/wgs84**
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
# wgs84
|
|
6
|
+
|
|
7
|
+
## Introduction
|
|
8
|
+
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
- All functions uses degrees for latitude and longitude, and meters for distances.
|
|
12
|
+
- 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.
|
|
13
|
+
- No dependencies to other NPM modules.
|
|
14
|
+
- The math is based on [Aviation Formulary V1.47 by Ed Williams](https://edwilliams.org/avform147.htm#flat).
|
|
15
|
+
- Functions will throw `Error` if fed impossible values, e.g. incorrectly formatted GeoJSON or lat >= 90 degrees (math will not work!). _Make sure to handle that!_
|
|
16
|
+
|
|
17
|
+
## Getting Started
|
|
18
|
+
|
|
19
|
+
Include in your project as any other NPM package
|
|
20
|
+
|
|
21
|
+
> npm install @ulrik.ek/wgs84
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import * as wgs84 from '@ulrik.ek/wgs84'; // The functions can obviously also be imported separately
|
|
27
|
+
|
|
28
|
+
// helper function to construct a GeoJSON Point
|
|
29
|
+
const lat = 15;
|
|
30
|
+
const lon = 25;
|
|
31
|
+
const p: wgs84.Point = wgs84.point(lat, lon);
|
|
32
|
+
|
|
33
|
+
// Getting a new point 300m north and 400m east of the first point
|
|
34
|
+
const p1: wgs84.Point = wgs84.pointEastOf(wgs84.pointNorthOf(p, 300), 400);
|
|
35
|
+
const newLat = p1.coordinates[1]; // GeoJSON uses [lon, lat] order!
|
|
36
|
+
const newLon = p1.coordinates[0];
|
|
37
|
+
console.log(`lat=${newLat}, lon=${newLon}`);
|
|
38
|
+
|
|
39
|
+
// get the distance along north between the 2 points
|
|
40
|
+
console.log(`Distance along north=${wgs84.distanceNorth(p, p1)}`);
|
|
41
|
+
console.log(`Distance along east=${wgs84.distanceEast(p, p1)}`);
|
|
42
|
+
console.log(`Total distance=${wgs84.distance(p, p1)}`);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
This will produce the following output
|
|
46
|
+
|
|
47
|
+
> lat=15.002711283642645, lon=25.003719230339353
|
|
48
|
+
> Distance along north=300.00000000009265
|
|
49
|
+
> Distance along east=400.00504064747975
|
|
50
|
+
> Total distance=500.0040325271862
|
|
51
|
+
|
|
52
|
+
## Documentation
|
|
53
|
+
|
|
54
|
+
The following functions are available:
|
|
55
|
+
|
|
56
|
+
```Typescript
|
|
57
|
+
point(lat: number, lon: number, height?: number): Point;
|
|
58
|
+
R1(position: Point): number;
|
|
59
|
+
R2(position: Point): number;
|
|
60
|
+
distanceNorth(origin: Point, target: Point): number;
|
|
61
|
+
distanceEast(origin: Point, target: Point): number;
|
|
62
|
+
distanceUp(origin: Point, target: Point): number;
|
|
63
|
+
distance(origin: Point, target: Point): number;
|
|
64
|
+
bearing(origin: Point, target: Point): number;
|
|
65
|
+
pointNorthOf(origin: Point, dN: number): Point;
|
|
66
|
+
pointEastOf(origin: Point, dE: number): Point;
|
|
67
|
+
pointAbove(origin: Point, dH: number): Point;
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
[Full Typedoc documentation](https://github.com/UEk/wgs84/blob/main/doc/globals.md)
|
|
71
|
+
|
|
72
|
+
# Build and Test
|
|
73
|
+
|
|
74
|
+
All functions are unit tested.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[**@ulrik.ek/wgs84**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@ulrik.ek/wgs84](../globals.md) / R1
|
|
6
|
+
|
|
7
|
+
# Function: R1()
|
|
8
|
+
|
|
9
|
+
> **R1**(`position`): `number`
|
|
10
|
+
|
|
11
|
+
Defined in: [index.ts:193](https://github.com/UEk/wgs84/blob/e8e4bbfd1d8ff81410dce1ae7afe5436fa6e0608/src/index.ts#L193)
|
|
12
|
+
|
|
13
|
+
The meridional radius of curvature at a certain geographical position
|
|
14
|
+
will throw for impossible input
|
|
15
|
+
|
|
16
|
+
## Parameters
|
|
17
|
+
|
|
18
|
+
### position
|
|
19
|
+
|
|
20
|
+
[`Point`](../interfaces/Point.md)
|
|
21
|
+
|
|
22
|
+
The current position in GeoJson
|
|
23
|
+
|
|
24
|
+
## Returns
|
|
25
|
+
|
|
26
|
+
`number`
|
|
27
|
+
|
|
28
|
+
meters
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[**@ulrik.ek/wgs84**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@ulrik.ek/wgs84](../globals.md) / R2
|
|
6
|
+
|
|
7
|
+
# Function: R2()
|
|
8
|
+
|
|
9
|
+
> **R2**(`position`): `number`
|
|
10
|
+
|
|
11
|
+
Defined in: [index.ts:205](https://github.com/UEk/wgs84/blob/e8e4bbfd1d8ff81410dce1ae7afe5436fa6e0608/src/index.ts#L205)
|
|
12
|
+
|
|
13
|
+
The radius of curvature in the prime vertical at a certain geographical position
|
|
14
|
+
will throw for impossible input
|
|
15
|
+
|
|
16
|
+
## Parameters
|
|
17
|
+
|
|
18
|
+
### position
|
|
19
|
+
|
|
20
|
+
[`Point`](../interfaces/Point.md)
|
|
21
|
+
|
|
22
|
+
The current position in GeoJson
|
|
23
|
+
|
|
24
|
+
## Returns
|
|
25
|
+
|
|
26
|
+
`number`
|
|
27
|
+
|
|
28
|
+
meters
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[**@ulrik.ek/wgs84**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@ulrik.ek/wgs84](../globals.md) / bearing
|
|
6
|
+
|
|
7
|
+
# Function: bearing()
|
|
8
|
+
|
|
9
|
+
> **bearing**(`origin`, `target`): `number`
|
|
10
|
+
|
|
11
|
+
Defined in: [index.ts:41](https://github.com/UEk/wgs84/blob/e8e4bbfd1d8ff81410dce1ae7afe5436fa6e0608/src/index.ts#L41)
|
|
12
|
+
|
|
13
|
+
Calculates the bearing from origin to target in the plane
|
|
14
|
+
with 0 degrees being north, and 90 degrees being east
|
|
15
|
+
will throw for impossible input
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
### origin
|
|
20
|
+
|
|
21
|
+
[`Point`](../interfaces/Point.md)
|
|
22
|
+
|
|
23
|
+
the origin point in GeoJson
|
|
24
|
+
|
|
25
|
+
### target
|
|
26
|
+
|
|
27
|
+
[`Point`](../interfaces/Point.md)
|
|
28
|
+
|
|
29
|
+
the target point in GeoJson
|
|
30
|
+
|
|
31
|
+
## Returns
|
|
32
|
+
|
|
33
|
+
`number`
|
|
34
|
+
|
|
35
|
+
degrees
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[**@ulrik.ek/wgs84**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@ulrik.ek/wgs84](../globals.md) / distance
|
|
6
|
+
|
|
7
|
+
# Function: distance()
|
|
8
|
+
|
|
9
|
+
> **distance**(`origin`, `target`): `number`
|
|
10
|
+
|
|
11
|
+
Defined in: [index.ts:59](https://github.com/UEk/wgs84/blob/e8e4bbfd1d8ff81410dce1ae7afe5436fa6e0608/src/index.ts#L59)
|
|
12
|
+
|
|
13
|
+
Calculates the distance in meters between origin and target
|
|
14
|
+
Will take height into consideration, if given for both points
|
|
15
|
+
will throw for impossible input
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
### origin
|
|
20
|
+
|
|
21
|
+
[`Point`](../interfaces/Point.md)
|
|
22
|
+
|
|
23
|
+
the origin point in GeoJson
|
|
24
|
+
|
|
25
|
+
### target
|
|
26
|
+
|
|
27
|
+
[`Point`](../interfaces/Point.md)
|
|
28
|
+
|
|
29
|
+
the resulting point in GeoJson
|
|
30
|
+
|
|
31
|
+
## Returns
|
|
32
|
+
|
|
33
|
+
`number`
|
|
34
|
+
|
|
35
|
+
meters
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[**@ulrik.ek/wgs84**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@ulrik.ek/wgs84](../globals.md) / distanceEast
|
|
6
|
+
|
|
7
|
+
# Function: distanceEast()
|
|
8
|
+
|
|
9
|
+
> **distanceEast**(`origin`, `target`): `number`
|
|
10
|
+
|
|
11
|
+
Defined in: [index.ts:80](https://github.com/UEk/wgs84/blob/e8e4bbfd1d8ff81410dce1ae7afe5436fa6e0608/src/index.ts#L80)
|
|
12
|
+
|
|
13
|
+
Calculates the distance in meters along an eastern meridian
|
|
14
|
+
will throw for impossible input
|
|
15
|
+
|
|
16
|
+
## Parameters
|
|
17
|
+
|
|
18
|
+
### origin
|
|
19
|
+
|
|
20
|
+
[`Point`](../interfaces/Point.md)
|
|
21
|
+
|
|
22
|
+
the starting point in GeoJson
|
|
23
|
+
|
|
24
|
+
### target
|
|
25
|
+
|
|
26
|
+
[`Point`](../interfaces/Point.md)
|
|
27
|
+
|
|
28
|
+
the ending point in GeoJson
|
|
29
|
+
|
|
30
|
+
## Returns
|
|
31
|
+
|
|
32
|
+
`number`
|
|
33
|
+
|
|
34
|
+
meters
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[**@ulrik.ek/wgs84**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@ulrik.ek/wgs84](../globals.md) / distanceNorth
|
|
6
|
+
|
|
7
|
+
# Function: distanceNorth()
|
|
8
|
+
|
|
9
|
+
> **distanceNorth**(`origin`, `target`): `number`
|
|
10
|
+
|
|
11
|
+
Defined in: [index.ts:102](https://github.com/UEk/wgs84/blob/e8e4bbfd1d8ff81410dce1ae7afe5436fa6e0608/src/index.ts#L102)
|
|
12
|
+
|
|
13
|
+
Calculates the distance in meters along a northern meridian
|
|
14
|
+
will throw for impossible input
|
|
15
|
+
|
|
16
|
+
## Parameters
|
|
17
|
+
|
|
18
|
+
### origin
|
|
19
|
+
|
|
20
|
+
[`Point`](../interfaces/Point.md)
|
|
21
|
+
|
|
22
|
+
the starting point in GeoJson
|
|
23
|
+
|
|
24
|
+
### target
|
|
25
|
+
|
|
26
|
+
[`Point`](../interfaces/Point.md)
|
|
27
|
+
|
|
28
|
+
the ending point in GeoJson
|
|
29
|
+
|
|
30
|
+
## Returns
|
|
31
|
+
|
|
32
|
+
`number`
|
|
33
|
+
|
|
34
|
+
meters
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[**@ulrik.ek/wgs84**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@ulrik.ek/wgs84](../globals.md) / distanceUp
|
|
6
|
+
|
|
7
|
+
# Function: distanceUp()
|
|
8
|
+
|
|
9
|
+
> **distanceUp**(`origin`, `target`): `number`
|
|
10
|
+
|
|
11
|
+
Defined in: [index.ts:116](https://github.com/UEk/wgs84/blob/e8e4bbfd1d8ff81410dce1ae7afe5436fa6e0608/src/index.ts#L116)
|
|
12
|
+
|
|
13
|
+
Calculates the vertical distance in meters
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
### origin
|
|
18
|
+
|
|
19
|
+
[`Point`](../interfaces/Point.md)
|
|
20
|
+
|
|
21
|
+
the starting point in GeoJson
|
|
22
|
+
|
|
23
|
+
### target
|
|
24
|
+
|
|
25
|
+
[`Point`](../interfaces/Point.md)
|
|
26
|
+
|
|
27
|
+
the ending point in GeoJson
|
|
28
|
+
|
|
29
|
+
## Returns
|
|
30
|
+
|
|
31
|
+
`number`
|
|
32
|
+
|
|
33
|
+
meters
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[**@ulrik.ek/wgs84**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@ulrik.ek/wgs84](../globals.md) / point
|
|
6
|
+
|
|
7
|
+
# Function: point()
|
|
8
|
+
|
|
9
|
+
> **point**(`lat`, `lon`, `height?`): [`Point`](../interfaces/Point.md)
|
|
10
|
+
|
|
11
|
+
Defined in: [index.ts:18](https://github.com/UEk/wgs84/blob/e8e4bbfd1d8ff81410dce1ae7afe5436fa6e0608/src/index.ts#L18)
|
|
12
|
+
|
|
13
|
+
creates a GeoJSON Point
|
|
14
|
+
will throw for impossible input
|
|
15
|
+
|
|
16
|
+
## Parameters
|
|
17
|
+
|
|
18
|
+
### lat
|
|
19
|
+
|
|
20
|
+
`number`
|
|
21
|
+
|
|
22
|
+
in degrees, has to be -90 < lat < 90
|
|
23
|
+
|
|
24
|
+
### lon
|
|
25
|
+
|
|
26
|
+
`number`
|
|
27
|
+
|
|
28
|
+
in degrees, has to be -180 <= lon <= 180
|
|
29
|
+
|
|
30
|
+
### height?
|
|
31
|
+
|
|
32
|
+
`number`
|
|
33
|
+
|
|
34
|
+
in meters
|
|
35
|
+
|
|
36
|
+
## Returns
|
|
37
|
+
|
|
38
|
+
[`Point`](../interfaces/Point.md)
|
|
39
|
+
|
|
40
|
+
GeoJSON Point
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[**@ulrik.ek/wgs84**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@ulrik.ek/wgs84](../globals.md) / pointAbove
|
|
6
|
+
|
|
7
|
+
# Function: pointAbove()
|
|
8
|
+
|
|
9
|
+
> **pointAbove**(`origin`, `dH`): [`Point`](../interfaces/Point.md)
|
|
10
|
+
|
|
11
|
+
Defined in: [index.ts:131](https://github.com/UEk/wgs84/blob/e8e4bbfd1d8ff81410dce1ae7afe5436fa6e0608/src/index.ts#L131)
|
|
12
|
+
|
|
13
|
+
Gives a new point at a height dH above the current point
|
|
14
|
+
will throw for impossible input
|
|
15
|
+
|
|
16
|
+
## Parameters
|
|
17
|
+
|
|
18
|
+
### origin
|
|
19
|
+
|
|
20
|
+
[`Point`](../interfaces/Point.md)
|
|
21
|
+
|
|
22
|
+
the origin point in GeoJson
|
|
23
|
+
|
|
24
|
+
### dH
|
|
25
|
+
|
|
26
|
+
`number`
|
|
27
|
+
|
|
28
|
+
the distance up in meters, negative number gives a lower height
|
|
29
|
+
|
|
30
|
+
## Returns
|
|
31
|
+
|
|
32
|
+
[`Point`](../interfaces/Point.md)
|
|
33
|
+
|
|
34
|
+
GeoJson Point
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[**@ulrik.ek/wgs84**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@ulrik.ek/wgs84](../globals.md) / pointEastOf
|
|
6
|
+
|
|
7
|
+
# Function: pointEastOf()
|
|
8
|
+
|
|
9
|
+
> **pointEastOf**(`origin`, `dE`): [`Point`](../interfaces/Point.md)
|
|
10
|
+
|
|
11
|
+
Defined in: [index.ts:146](https://github.com/UEk/wgs84/blob/e8e4bbfd1d8ff81410dce1ae7afe5436fa6e0608/src/index.ts#L146)
|
|
12
|
+
|
|
13
|
+
Gives a new point at a distance dE east of the current point
|
|
14
|
+
will throw for impossible input
|
|
15
|
+
|
|
16
|
+
## Parameters
|
|
17
|
+
|
|
18
|
+
### origin
|
|
19
|
+
|
|
20
|
+
[`Point`](../interfaces/Point.md)
|
|
21
|
+
|
|
22
|
+
the origin point in GeoJson
|
|
23
|
+
|
|
24
|
+
### dE
|
|
25
|
+
|
|
26
|
+
`number`
|
|
27
|
+
|
|
28
|
+
the distance in meters along an eastern meridian, negative number gives distance to west
|
|
29
|
+
|
|
30
|
+
## Returns
|
|
31
|
+
|
|
32
|
+
[`Point`](../interfaces/Point.md)
|
|
33
|
+
|
|
34
|
+
GeoJson Point
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[**@ulrik.ek/wgs84**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@ulrik.ek/wgs84](../globals.md) / pointNorthOf
|
|
6
|
+
|
|
7
|
+
# Function: pointNorthOf()
|
|
8
|
+
|
|
9
|
+
> **pointNorthOf**(`origin`, `dN`): [`Point`](../interfaces/Point.md)
|
|
10
|
+
|
|
11
|
+
Defined in: [index.ts:172](https://github.com/UEk/wgs84/blob/e8e4bbfd1d8ff81410dce1ae7afe5436fa6e0608/src/index.ts#L172)
|
|
12
|
+
|
|
13
|
+
Gives a new point at a distance dN north of the current point
|
|
14
|
+
will throw for impossible input
|
|
15
|
+
|
|
16
|
+
## Parameters
|
|
17
|
+
|
|
18
|
+
### origin
|
|
19
|
+
|
|
20
|
+
[`Point`](../interfaces/Point.md)
|
|
21
|
+
|
|
22
|
+
the origin point in GeoJson
|
|
23
|
+
|
|
24
|
+
### dN
|
|
25
|
+
|
|
26
|
+
`number`
|
|
27
|
+
|
|
28
|
+
the distance in meters along a northern meridian, negative number gives distance to south
|
|
29
|
+
|
|
30
|
+
## Returns
|
|
31
|
+
|
|
32
|
+
[`Point`](../interfaces/Point.md)
|
|
33
|
+
|
|
34
|
+
GeoJson Point
|
package/doc/globals.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
[**@ulrik.ek/wgs84**](README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
# @ulrik.ek/wgs84
|
|
6
|
+
|
|
7
|
+
## Interfaces
|
|
8
|
+
|
|
9
|
+
- [Point](interfaces/Point.md)
|
|
10
|
+
|
|
11
|
+
## Functions
|
|
12
|
+
|
|
13
|
+
- [bearing](functions/bearing.md)
|
|
14
|
+
- [distance](functions/distance.md)
|
|
15
|
+
- [distanceEast](functions/distanceEast.md)
|
|
16
|
+
- [distanceNorth](functions/distanceNorth.md)
|
|
17
|
+
- [distanceUp](functions/distanceUp.md)
|
|
18
|
+
- [point](functions/point.md)
|
|
19
|
+
- [pointAbove](functions/pointAbove.md)
|
|
20
|
+
- [pointEastOf](functions/pointEastOf.md)
|
|
21
|
+
- [pointNorthOf](functions/pointNorthOf.md)
|
|
22
|
+
- [R1](functions/R1.md)
|
|
23
|
+
- [R2](functions/R2.md)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[**@ulrik.ek/wgs84**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@ulrik.ek/wgs84](../globals.md) / Point
|
|
6
|
+
|
|
7
|
+
# Interface: Point
|
|
8
|
+
|
|
9
|
+
Defined in: [index.ts:5](https://github.com/UEk/wgs84/blob/e8e4bbfd1d8ff81410dce1ae7afe5436fa6e0608/src/index.ts#L5)
|
|
10
|
+
|
|
11
|
+
GeoJSON definition from
|
|
12
|
+
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/geojson/index.d.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ulrik.ek/wgs84",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.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",
|
|
@@ -9,6 +9,12 @@
|
|
|
9
9
|
"doc": "doc",
|
|
10
10
|
"test": "test"
|
|
11
11
|
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"doc",
|
|
15
|
+
"README.md",
|
|
16
|
+
"LICENSE"
|
|
17
|
+
],
|
|
12
18
|
"type": "commonjs",
|
|
13
19
|
"scripts": {
|
|
14
20
|
"audit": "npm audit --registry=https://registry.npmjs.org",
|
|
@@ -27,21 +33,19 @@
|
|
|
27
33
|
"devDependencies": {
|
|
28
34
|
"@eslint/js": "^10.0.1",
|
|
29
35
|
"@types/geojson": "^7946.0.16",
|
|
30
|
-
"@types/
|
|
31
|
-
"@
|
|
32
|
-
"
|
|
33
|
-
"eslint": "^
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"prettier": "^3.8.1",
|
|
36
|
+
"@types/node": "^25.6.0",
|
|
37
|
+
"@vitest/coverage-v8": "^4.1.4",
|
|
38
|
+
"eslint": "^10.2.1",
|
|
39
|
+
"eslint-plugin-perfectionist": "^5.9.0",
|
|
40
|
+
"globals": "^17.5.0",
|
|
41
|
+
"prettier": "^3.8.3",
|
|
37
42
|
"shx": "^0.4.0",
|
|
38
|
-
"ts-jest": "^29.4.9",
|
|
39
43
|
"tsx": "^4.21.0",
|
|
40
|
-
"typedoc": "^0.28.
|
|
44
|
+
"typedoc": "^0.28.19",
|
|
41
45
|
"typedoc-plugin-markdown": "^4.11.0",
|
|
42
|
-
"typescript": "^6.0.
|
|
43
|
-
"typescript-eslint": "^8.58.
|
|
44
|
-
"vitest": "^4.1.
|
|
46
|
+
"typescript": "^6.0.3",
|
|
47
|
+
"typescript-eslint": "^8.58.2",
|
|
48
|
+
"vitest": "^4.1.4"
|
|
45
49
|
},
|
|
46
50
|
"types": "./dist/index.d.ts",
|
|
47
51
|
"repository": {
|
package/eslint.config.mjs
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
import eslint from '@eslint/js';
|
|
3
|
-
import tseslint from 'typescript-eslint';
|
|
4
|
-
import perfectionist from 'eslint-plugin-perfectionist';
|
|
5
|
-
import globals from 'globals';
|
|
6
|
-
|
|
7
|
-
export default tseslint.config(
|
|
8
|
-
// 1. Globala ignoreringar (ersätter din gamla ignores-block)
|
|
9
|
-
{
|
|
10
|
-
ignores: [
|
|
11
|
-
'dist/**',
|
|
12
|
-
'coverage/**',
|
|
13
|
-
'report/**',
|
|
14
|
-
'node_modules/**',
|
|
15
|
-
'doc/**',
|
|
16
|
-
'*.config.*'
|
|
17
|
-
],
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
// 2. Bas-konfiguration (JS & TS Rekommenderat + Sortering)
|
|
21
|
-
eslint.configs.recommended,
|
|
22
|
-
...tseslint.configs.recommended,
|
|
23
|
-
perfectionist.configs['recommended-natural'],
|
|
24
|
-
|
|
25
|
-
// 3. Gemensamma inställningar för alla filer
|
|
26
|
-
{
|
|
27
|
-
languageOptions: {
|
|
28
|
-
ecmaVersion: 'latest',
|
|
29
|
-
sourceType: 'module',
|
|
30
|
-
globals: {
|
|
31
|
-
...globals.node,
|
|
32
|
-
...globals.vitest, // Lägger till describe, it, expect etc. automatiskt
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
rules: {
|
|
36
|
-
// Allmänna regler
|
|
37
|
-
'no-console': 'error',
|
|
38
|
-
'no-var': 'error',
|
|
39
|
-
'prefer-const': 'error',
|
|
40
|
-
'eqeqeq': ['error', 'always'],
|
|
41
|
-
'curly': 'error',
|
|
42
|
-
'no-throw-literal': 'error',
|
|
43
|
-
|
|
44
|
-
// TypeScript-specifika regler (utan typ-check krav)
|
|
45
|
-
'@typescript-eslint/no-unused-vars': 'warn',
|
|
46
|
-
'@typescript-eslint/explicit-function-return-type': 'error',
|
|
47
|
-
'@typescript-eslint/no-explicit-any': 'warn',
|
|
48
|
-
'@typescript-eslint/consistent-type-assertions': ['error', { assertionStyle: 'as' }],
|
|
49
|
-
|
|
50
|
-
// Perfectionist sköter nu all sortering (imports, keys, class members)
|
|
51
|
-
// Du behöver inte längre definiera order[] manuellt om du inte vill ha en special-ordning.
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
// 4. Konfiguration för källkod med strikt typ-check
|
|
56
|
-
{
|
|
57
|
-
files: ['src/**/*.ts'],
|
|
58
|
-
languageOptions: {
|
|
59
|
-
parserOptions: {
|
|
60
|
-
project: './tsconfig.json',
|
|
61
|
-
tsconfigRootDir: import.meta.dirname,
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
rules: {
|
|
65
|
-
// Här kan du lägga till regler som kräver projekt-context
|
|
66
|
-
'@typescript-eslint/prefer-readonly': 'error',
|
|
67
|
-
'@typescript-eslint/require-array-sort-compare': 'error',
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
// 5. Undantag för tester och exempel (tillåt console etc.)
|
|
72
|
-
{
|
|
73
|
-
files: ['test/**/*.ts', 'example/**/*.ts'],
|
|
74
|
-
rules: {
|
|
75
|
-
'no-console': 'off', // Tillåt console i exempel och tester
|
|
76
|
-
'@typescript-eslint/no-explicit-any': 'off',
|
|
77
|
-
},
|
|
78
|
-
}
|
|
79
|
-
);
|
package/tsconfig.tsbuildinfo
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"root":["./src/index.ts"],"version":"6.0.2"}
|
package/vitest.config.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vitest/config';
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
test: {
|
|
5
|
-
globals: true, // Gör att 'describe', 'it', 'expect' finns tillgängliga globalt (som i Jest)
|
|
6
|
-
environment: 'node',
|
|
7
|
-
coverage: {
|
|
8
|
-
provider: 'v8',
|
|
9
|
-
reporter: ['text', 'json', 'html']
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
});
|