@mailwoman/spatial 4.9.0 → 4.10.0
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/out/bbox.d.ts +206 -0
- package/out/bbox.d.ts.map +1 -0
- package/out/bbox.js +267 -0
- package/out/bbox.js.map +1 -0
- package/out/countries/codes.d.ts +528 -0
- package/out/countries/codes.d.ts.map +1 -0
- package/out/countries/codes.js +520 -0
- package/out/countries/codes.js.map +1 -0
- package/out/countries/index.d.ts +8 -0
- package/out/countries/index.d.ts.map +1 -0
- package/out/countries/index.js +8 -0
- package/out/countries/index.js.map +1 -0
- package/out/countries/names.d.ts +23 -0
- package/out/countries/names.d.ts.map +1 -0
- package/out/countries/names.js +264 -0
- package/out/countries/names.js.map +1 -0
- package/out/feature.d.ts +70 -0
- package/out/feature.d.ts.map +1 -0
- package/out/feature.js +8 -0
- package/out/feature.js.map +1 -0
- package/out/geometries/collection.d.ts +29 -0
- package/out/geometries/collection.d.ts.map +1 -0
- package/out/geometries/collection.js +9 -0
- package/out/geometries/collection.js.map +1 -0
- package/out/geometries/index.d.ts +12 -0
- package/out/geometries/index.d.ts.map +1 -0
- package/out/geometries/index.js +12 -0
- package/out/geometries/index.js.map +1 -0
- package/out/geometries/line-string.d.ts +44 -0
- package/out/geometries/line-string.d.ts.map +1 -0
- package/out/geometries/line-string.js +9 -0
- package/out/geometries/line-string.js.map +1 -0
- package/out/geometries/point.d.ts +208 -0
- package/out/geometries/point.d.ts.map +1 -0
- package/out/geometries/point.js +258 -0
- package/out/geometries/point.js.map +1 -0
- package/out/geometries/polygon.d.ts +175 -0
- package/out/geometries/polygon.d.ts.map +1 -0
- package/out/geometries/polygon.js +94 -0
- package/out/geometries/polygon.js.map +1 -0
- package/out/google/index.d.ts +7 -0
- package/out/google/index.d.ts.map +1 -0
- package/out/google/index.js +7 -0
- package/out/google/index.js.map +1 -0
- package/out/google/place-id.d.ts +39 -0
- package/out/google/place-id.d.ts.map +1 -0
- package/out/google/place-id.js +22 -0
- package/out/google/place-id.js.map +1 -0
- package/out/h3/index.d.ts +38 -0
- package/out/h3/index.d.ts.map +1 -0
- package/out/h3/index.js +57 -0
- package/out/h3/index.js.map +1 -0
- package/out/index.d.ts +16 -0
- package/out/index.d.ts.map +1 -0
- package/out/index.js +16 -0
- package/out/index.js.map +1 -0
- package/out/objects.d.ts +93 -0
- package/out/objects.d.ts.map +1 -0
- package/out/objects.js +42 -0
- package/out/objects.js.map +1 -0
- package/out/position.d.ts +176 -0
- package/out/position.d.ts.map +1 -0
- package/out/position.js +169 -0
- package/out/position.js.map +1 -0
- package/out/projection.d.ts +23 -0
- package/out/projection.d.ts.map +1 -0
- package/out/projection.js +24 -0
- package/out/projection.js.map +1 -0
- package/out/regions/codes.d.ts +30 -0
- package/out/regions/codes.d.ts.map +1 -0
- package/out/regions/codes.js +33 -0
- package/out/regions/codes.js.map +1 -0
- package/out/regions/index.d.ts +8 -0
- package/out/regions/index.d.ts.map +1 -0
- package/out/regions/index.js +8 -0
- package/out/regions/index.js.map +1 -0
- package/out/regions/names.d.ts +20 -0
- package/out/regions/names.d.ts.map +1 -0
- package/out/regions/names.js +20 -0
- package/out/regions/names.js.map +1 -0
- package/out/sdk/index.d.ts +7 -0
- package/out/sdk/index.d.ts.map +1 -0
- package/out/sdk/index.js +7 -0
- package/out/sdk/index.js.map +1 -0
- package/out/sdk/well-known-text.d.ts +62 -0
- package/out/sdk/well-known-text.d.ts.map +1 -0
- package/out/sdk/well-known-text.js +61 -0
- package/out/sdk/well-known-text.js.map +1 -0
- package/out/tsconfig.tsbuildinfo +1 -0
- package/package.json +48 -43
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import { ResourceError } from "@mailwoman/core/errors";
|
|
7
|
+
/**
|
|
8
|
+
* Predicate for checking if a GeoJSON object is a `Polygon` geometry.
|
|
9
|
+
*/
|
|
10
|
+
export function isPolygonLiteral(input) {
|
|
11
|
+
if (typeof input !== "object" || input === null)
|
|
12
|
+
return false;
|
|
13
|
+
return "type" in input && input.type === "Polygon" && "coordinates" in input && Array.isArray(input.coordinates);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Predicate for checking if a polygon geometry is a solid, i.e. it has no holes.
|
|
17
|
+
*/
|
|
18
|
+
export function isSolidPolygonPath(input) {
|
|
19
|
+
return input.coordinates.length === 1;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Predicate for checking if a GeoJSON object is a `MultiPolygon` geometry.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Given a polygon geometry, return an OSM filter string.
|
|
26
|
+
*
|
|
27
|
+
* This is useful when working with the Overpass API.
|
|
28
|
+
*/
|
|
29
|
+
export function polygonToOSMFilter(input) {
|
|
30
|
+
if (!isPolygonLiteral(input))
|
|
31
|
+
return "";
|
|
32
|
+
const [exteriorRing] = input.coordinates;
|
|
33
|
+
const filter = exteriorRing.map(([lon, lat]) => `${lat} ${lon}`).join(" ");
|
|
34
|
+
return `poly:'${filter}'`;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Tags returned by the Overpass API for a node.
|
|
38
|
+
*
|
|
39
|
+
* @category OSM
|
|
40
|
+
*/
|
|
41
|
+
export var OSMNodeTag;
|
|
42
|
+
(function (OSMNodeTag) {
|
|
43
|
+
OSMNodeTag["HouseNumber"] = "addr:housenumber";
|
|
44
|
+
OSMNodeTag["PostCode"] = "addr:postcode";
|
|
45
|
+
OSMNodeTag["Street"] = "addr:street";
|
|
46
|
+
OSMNodeTag["State"] = "addr:state";
|
|
47
|
+
OSMNodeTag["City"] = "addr:city";
|
|
48
|
+
OSMNodeTag["Website"] = "website";
|
|
49
|
+
OSMNodeTag["Email"] = "email";
|
|
50
|
+
OSMNodeTag["Phone"] = "phone";
|
|
51
|
+
OSMNodeTag["Shop"] = "shop";
|
|
52
|
+
OSMNodeTag["Brand"] = "brand";
|
|
53
|
+
OSMNodeTag["Cuisine"] = "cuisine";
|
|
54
|
+
OSMNodeTag["Name"] = "name";
|
|
55
|
+
OSMNodeTag["Healthcare"] = "healthcare";
|
|
56
|
+
OSMNodeTag["Office"] = "office";
|
|
57
|
+
OSMNodeTag["Amenity"] = "amenity";
|
|
58
|
+
})(OSMNodeTag || (OSMNodeTag = {}));
|
|
59
|
+
export const ForbiddenResidentialOSMNodeTags = new Set([
|
|
60
|
+
OSMNodeTag.Shop,
|
|
61
|
+
OSMNodeTag.Brand,
|
|
62
|
+
OSMNodeTag.Cuisine,
|
|
63
|
+
OSMNodeTag.Office,
|
|
64
|
+
OSMNodeTag.Healthcare,
|
|
65
|
+
]);
|
|
66
|
+
/**
|
|
67
|
+
* Given an OSM element, attempts to infer if the result is a residential address.
|
|
68
|
+
*/
|
|
69
|
+
export function isResidentialElement(element) {
|
|
70
|
+
for (const key in element.tags) {
|
|
71
|
+
if (ForbiddenResidentialOSMNodeTags.has(key))
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
if (element.tags[OSMNodeTag.Amenity] === "restaurant")
|
|
75
|
+
return false;
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
export function fetchOSMElementViaOverpassAPI(input) {
|
|
79
|
+
const filter = polygonToOSMFilter(input);
|
|
80
|
+
const url = new URL("http://overpass-api.de/api/interpreter");
|
|
81
|
+
url.searchParams.set("data", `[out:json];(node['addr:housenumber'](${filter}););out body;>;out skel qt;`);
|
|
82
|
+
return fetch(url)
|
|
83
|
+
.then((response) => {
|
|
84
|
+
if (!response.ok)
|
|
85
|
+
throw ResourceError.from(response.status, response.statusText, "osm", "overpass-api", "fetch");
|
|
86
|
+
return response;
|
|
87
|
+
})
|
|
88
|
+
.then((response) => response.json())
|
|
89
|
+
.then((body) => body.elements)
|
|
90
|
+
.catch((error) => {
|
|
91
|
+
throw ResourceError.wrap(error, "osm", "overpass-api", "fetch");
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=polygon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polygon.js","sourceRoot":"","sources":["../../geometries/polygon.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAuGtD;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAsC,KAAc;IACnF,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAA;IAE7D,OAAO,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,aAAa,IAAI,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;AACjH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAqB;IACvD,OAAO,KAAK,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,CAAA;AACtC,CAAC;AAaD;;GAEG;AAEH;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAqB;IACvD,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IAEvC,MAAM,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,WAAW,CAAA;IAExC,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAE1E,OAAO,SAAS,MAAM,GAAG,CAAA;AAC1B,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,UAgBX;AAhBD,WAAY,UAAU;IACrB,8CAAgC,CAAA;IAChC,wCAA0B,CAAA;IAC1B,oCAAs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AAM,EAAE,QAAQ,CAAC,UAAU,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,CAAC,CAAA;QAEhH,OAAO,QAAQ,CAAA;IAChB,CAAC,CAAC;SACD,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAsC,CAAC;SACvE,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC;SAC7B,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QAChB,MAAM,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,CAAC,CAAA;IAChE,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../google/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,eAAe,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../google/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,eAAe,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Google Place ID utilities.
|
|
7
|
+
*/
|
|
8
|
+
import type { Tagged } from "type-fest";
|
|
9
|
+
/**
|
|
10
|
+
* A Place ID uniquely identifies a place in the Google Places database and on Google Maps.
|
|
11
|
+
*
|
|
12
|
+
* The length of the identifier may vary. Generally, the identifier is a 27-character string,
|
|
13
|
+
* however, more specific places may have longer identifiers.
|
|
14
|
+
*
|
|
15
|
+
* Place IDs appear to be base64-encoded strings, delimited by underscores and dashes.
|
|
16
|
+
*
|
|
17
|
+
* Note that Place IDs do change. Consider a them stale after a few days.
|
|
18
|
+
*
|
|
19
|
+
* @category Google
|
|
20
|
+
* @category Geocoding
|
|
21
|
+
* @type {string}
|
|
22
|
+
* @minLength 1
|
|
23
|
+
* @pattern ^[A-Za-z0-9_-]+$
|
|
24
|
+
* @title Google Place ID
|
|
25
|
+
*/
|
|
26
|
+
export type GooglePlaceID = Tagged<string, "GooglePlaceID">;
|
|
27
|
+
/**
|
|
28
|
+
* Pattern for validating a Google Place ID.
|
|
29
|
+
*/
|
|
30
|
+
export declare const GOOGLE_PLACE_ID_PATTERN: RegExp;
|
|
31
|
+
/**
|
|
32
|
+
* Type-predicate for checking if a value appears to be a valid Google Place ID.
|
|
33
|
+
*
|
|
34
|
+
* @category Google
|
|
35
|
+
* @category Geocoding
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
export declare function isGooglePlaceID(input: string): input is GooglePlaceID;
|
|
39
|
+
//# sourceMappingURL=place-id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"place-id.d.ts","sourceRoot":"","sources":["../../google/place-id.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAEvC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;AAE3D;;GAEG;AACH,eAAO,MAAM,uBAAuB,QAAqB,CAAA;AAEzD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,aAAa,CAErE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Google Place ID utilities.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Pattern for validating a Google Place ID.
|
|
10
|
+
*/
|
|
11
|
+
export const GOOGLE_PLACE_ID_PATTERN = /^[A-Za-z0-9_-]+$/;
|
|
12
|
+
/**
|
|
13
|
+
* Type-predicate for checking if a value appears to be a valid Google Place ID.
|
|
14
|
+
*
|
|
15
|
+
* @category Google
|
|
16
|
+
* @category Geocoding
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export function isGooglePlaceID(input) {
|
|
20
|
+
return GOOGLE_PLACE_ID_PATTERN.test(input.toString());
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=place-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"place-id.js","sourceRoot":"","sources":["../../google/place-id.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAuBH;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,kBAAkB,CAAA;AAEzD;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa;IAC5C,OAAO,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;AACtD,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import type { Tagged } from "type-fest";
|
|
7
|
+
import { GeoPoint, type PointLiteral } from "../geometries/point.js";
|
|
8
|
+
/**
|
|
9
|
+
* A H3 cell index, full 64 bits.
|
|
10
|
+
*
|
|
11
|
+
* @type {string}
|
|
12
|
+
* @title H3 Cell Index
|
|
13
|
+
* @pattern ^[0-9a-f]{15}$
|
|
14
|
+
*/
|
|
15
|
+
export type H3Cell = Tagged<string, "H3Cell">;
|
|
16
|
+
export declare function isH3Cell(value: string): value is H3Cell;
|
|
17
|
+
/**
|
|
18
|
+
* A H3 cell index, shortened to 48 bits.
|
|
19
|
+
*
|
|
20
|
+
* @type {string}
|
|
21
|
+
* @title H3 Cell Index (Short)
|
|
22
|
+
* @pattern ^[0-9a-f]{12}$
|
|
23
|
+
*/
|
|
24
|
+
export type H3CellShort = Tagged<string, "H3CellShort">;
|
|
25
|
+
/**
|
|
26
|
+
* Given a full H3 cell index, shorten it to 48 bits.
|
|
27
|
+
*/
|
|
28
|
+
export declare function shortenH3Cell(cell: H3Cell): H3CellShort;
|
|
29
|
+
/**
|
|
30
|
+
* Given a short cell address, expand it to a full H3 cell index.
|
|
31
|
+
*/
|
|
32
|
+
export declare function expandH3Cell(h3CellShort: H3CellShort, resolution?: number): H3Cell;
|
|
33
|
+
/**
|
|
34
|
+
* Given a geographic point, return a short cell address.
|
|
35
|
+
*/
|
|
36
|
+
export declare function shortCellToPoint(shortCell: H3CellShort, resolution?: number): GeoPoint;
|
|
37
|
+
export declare function cellToPointLiteral(cell: H3Cell): PointLiteral;
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../h3/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAEpE;;;;;;GAMG;AACH,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;AAE7C,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,MAAM,CAEvD;AAED;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;AAEvD;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAYvD;AAKD;;GAEG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,WAAW,EAAE,UAAU,SAAK,GAAG,MAAM,CAa9E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,WAAW,EAAE,UAAU,SAAK,GAAG,QAAQ,CAOlF;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAO7D"}
|
package/out/h3/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import { cellToLatLng } from "h3-js";
|
|
7
|
+
import { GeoPoint } from "../geometries/point.js";
|
|
8
|
+
export function isH3Cell(value) {
|
|
9
|
+
return /^[0-9a-f]{15}$/.test(value);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Given a full H3 cell index, shorten it to 48 bits.
|
|
13
|
+
*/
|
|
14
|
+
export function shortenH3Cell(cell) {
|
|
15
|
+
// ...and convert it to a 48-bit cell address.
|
|
16
|
+
const cellBigInt = BigInt(`0x${cell}`);
|
|
17
|
+
// 8 f 2 aa 84 5a 18 ac 6b
|
|
18
|
+
// aa 84 5a 18 ac 6b
|
|
19
|
+
// Extract the cell address without the resolution
|
|
20
|
+
const h3CellShortBigInt = cellBigInt & 0xfffffffffffffn;
|
|
21
|
+
const h3CellShortHex = h3CellShortBigInt.toString(16);
|
|
22
|
+
return h3CellShortHex;
|
|
23
|
+
}
|
|
24
|
+
//2 aa 84 5a 18 ac 6b
|
|
25
|
+
// 8 f2 aa 84 5a 18 ac 6b
|
|
26
|
+
/**
|
|
27
|
+
* Given a short cell address, expand it to a full H3 cell index.
|
|
28
|
+
*/
|
|
29
|
+
export function expandH3Cell(h3CellShort, resolution = 15) {
|
|
30
|
+
// Convert the short cell address back to BigInt
|
|
31
|
+
const h3CellShortBigInt = BigInt(`0x${h3CellShort}`);
|
|
32
|
+
const resolutionHex = resolution.toString(16);
|
|
33
|
+
// Reassemble the H3 cell index portion...
|
|
34
|
+
const cellBigInt = h3CellShortBigInt << BigInt(8 * (15 - resolution));
|
|
35
|
+
// Back to a string...
|
|
36
|
+
const partialCell = cellBigInt.toString(16);
|
|
37
|
+
// Finally, we add the resolution back to the cell index.
|
|
38
|
+
const cell = `8${resolutionHex}${partialCell}`;
|
|
39
|
+
return cell;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Given a geographic point, return a short cell address.
|
|
43
|
+
*/
|
|
44
|
+
export function shortCellToPoint(shortCell, resolution = 15) {
|
|
45
|
+
const cell = expandH3Cell(shortCell, resolution);
|
|
46
|
+
// Convert the H3 cell index back to latitude and longitude
|
|
47
|
+
const [latitude, longitude] = cellToLatLng(cell);
|
|
48
|
+
return new GeoPoint([longitude, latitude]);
|
|
49
|
+
}
|
|
50
|
+
export function cellToPointLiteral(cell) {
|
|
51
|
+
const [latitude, longitude] = cellToLatLng(cell);
|
|
52
|
+
return {
|
|
53
|
+
type: "Point",
|
|
54
|
+
coordinates: [longitude, latitude],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../h3/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAA;AAEpC,OAAO,EAAE,QAAQ,EAAqB,MAAM,wBAAwB,CAAA;AAWpE,MAAM,UAAU,QAAQ,CAAC,KAAa;IACrC,OAAO,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;AACpC,CAAC;AAWD;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACzC,8CAA8C;IAC9C,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAA;IACtC,0BAA0B;IAC1B,wBAAwB;IAExB,kDAAkD;IAClD,MAAM,iBAAiB,GAAG,UAAU,GAA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A;AACF,CAAC"}
|
package/out/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
export * from "./bbox.js";
|
|
7
|
+
export * from "./countries/index.js";
|
|
8
|
+
export * from "./feature.js";
|
|
9
|
+
export * from "./geometries/index.js";
|
|
10
|
+
export * from "./google/index.js";
|
|
11
|
+
export * from "./h3/index.js";
|
|
12
|
+
export * from "./objects.js";
|
|
13
|
+
export * from "./position.js";
|
|
14
|
+
export * from "./projection.js";
|
|
15
|
+
export * from "./regions/index.js";
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,WAAW,CAAA;AACzB,cAAc,sBAAsB,CAAA;AACpC,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA"}
|
package/out/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
export * from "./bbox.js";
|
|
7
|
+
export * from "./countries/index.js";
|
|
8
|
+
export * from "./feature.js";
|
|
9
|
+
export * from "./geometries/index.js";
|
|
10
|
+
export * from "./google/index.js";
|
|
11
|
+
export * from "./h3/index.js";
|
|
12
|
+
export * from "./objects.js";
|
|
13
|
+
export * from "./position.js";
|
|
14
|
+
export * from "./projection.js";
|
|
15
|
+
export * from "./regions/index.js";
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
package/out/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,WAAW,CAAA;AACzB,cAAc,sBAAsB,CAAA;AACpC,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA"}
|
package/out/objects.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import { type BBox2DLiteral, type BBox3DLiteral } from "./bbox.js";
|
|
7
|
+
/**
|
|
8
|
+
* GeoJSON object types.
|
|
9
|
+
*/
|
|
10
|
+
export type GeometryType = "Point" | "MultiPoint" | "LineString" | "MultiLineString" | "Polygon" | "MultiPolygon" | "GeometryCollection" | "FeatureCollection";
|
|
11
|
+
/**
|
|
12
|
+
* Shadow enum-like record of valid GeoJSON object types.
|
|
13
|
+
*/
|
|
14
|
+
export declare const GeometryType: {
|
|
15
|
+
readonly Point: "Point";
|
|
16
|
+
readonly MultiPoint: "MultiPoint";
|
|
17
|
+
readonly LineString: "LineString";
|
|
18
|
+
readonly MultiLineString: "MultiLineString";
|
|
19
|
+
readonly Polygon: "Polygon";
|
|
20
|
+
readonly MultiPolygon: "MultiPolygon";
|
|
21
|
+
readonly GeometryCollection: "GeometryCollection";
|
|
22
|
+
readonly FeatureCollection: "FeatureCollection";
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The base GeoJSON object.
|
|
26
|
+
*
|
|
27
|
+
* The GeoJSON specification also allows foreign members
|
|
28
|
+
* (https://tools.ietf.org/html/rfc7946#section-6.1) to be included in the object.
|
|
29
|
+
*
|
|
30
|
+
* @see {@link https://tools.ietf.org/html/rfc7946#section-3 GeoJSON Object}
|
|
31
|
+
* @title Geo Object
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export interface GeoObjectLiteral {
|
|
35
|
+
/**
|
|
36
|
+
* Specifies the type of GeoJSON object.
|
|
37
|
+
*/
|
|
38
|
+
type: GeometryType;
|
|
39
|
+
/**
|
|
40
|
+
* A unique identifier for the feature, such as a UUID, a serial number, or a name.
|
|
41
|
+
*/
|
|
42
|
+
id?: string | number | undefined | null;
|
|
43
|
+
/**
|
|
44
|
+
* A bounding box of the coordinate range of the object's Geometries, Features, or Feature
|
|
45
|
+
* Collections.
|
|
46
|
+
*
|
|
47
|
+
* This is useful when defining the extent of a GeoJSON object, i.e. the minimum and maximum
|
|
48
|
+
* coordinates of the object's Geometries, Features, or Feature Collections.
|
|
49
|
+
*
|
|
50
|
+
* @see {@link https://tools.ietf.org/html/rfc7946#section-5 GeoJSON Bounding Boxes}
|
|
51
|
+
*/
|
|
52
|
+
bbox?: BBox2DLiteral | BBox3DLiteral;
|
|
53
|
+
/**
|
|
54
|
+
* Coordinate reference system for GeoJSON objects.
|
|
55
|
+
*
|
|
56
|
+
* @see {@link https://tools.ietf.org/html/rfc7946#section-4 Coordinate Reference Systems}
|
|
57
|
+
* @title Coordinate Reference System
|
|
58
|
+
*/
|
|
59
|
+
crs?: {
|
|
60
|
+
type: "name";
|
|
61
|
+
properties: {
|
|
62
|
+
/**
|
|
63
|
+
* The name of the coordinate reference system.
|
|
64
|
+
*
|
|
65
|
+
* @default "EPSG:4326"
|
|
66
|
+
*/
|
|
67
|
+
name: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Abstract base-class for all GeoJSON class constructors.
|
|
73
|
+
*/
|
|
74
|
+
export declare abstract class GeoObject implements GeoObjectLiteral {
|
|
75
|
+
/**
|
|
76
|
+
* The JSON literal type of the GeoJSON object.
|
|
77
|
+
*/
|
|
78
|
+
abstract type: GeometryType;
|
|
79
|
+
/**
|
|
80
|
+
* A bounding box of the coordinate range of the object's Geometries, Features, or Feature.
|
|
81
|
+
*
|
|
82
|
+
* @see {@linkcode BBox2DLiteral} for 2-dimensional bounding boxes.
|
|
83
|
+
* @see {@linkcode BBox3DLiteral} for 3-dimensional bounding boxes.
|
|
84
|
+
* @see
|
|
85
|
+
*/
|
|
86
|
+
bbox?: BBox2DLiteral | BBox3DLiteral;
|
|
87
|
+
protected constructor(bbox?: BBox2DLiteral | BBox3DLiteral);
|
|
88
|
+
/**
|
|
89
|
+
* Predicate to determine if the GeoJSON object is 2-dimensional.
|
|
90
|
+
*/
|
|
91
|
+
is2D(): boolean;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=objects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../objects.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAY,MAAM,WAAW,CAAA;AAE5E;;GAEG;AACH,MAAM,MAAM,YAAY,GACrB,OAAO,GACP,YAAY,GACZ,YAAY,GACZ,iBAAiB,GACjB,SAAS,GACT,cAAc,GACd,oBAAoB,GACpB,mBAAmB,CAAA;AAEtB;;GAEG;AACH,eAAO,MAAM,YAAY;;;;;;;;;CASsB,CAAA;AAE/C;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAChC;;OAEG;IACH,IAAI,EAAE,YAAY,CAAA;IAElB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAA;IAEvC;;;;;;;;OAQG;IACH,IAAI,CAAC,EAAE,aAAa,GAAG,aAAa,CAAA;IAEpC;;;;;OAKG;IACH,GAAG,CAAC,EAAE;QACL,IAAI,EAAE,MAAM,CAAA;QAEZ,UAAU,EAAE;YACX;;;;eAIG;YACH,IAAI,EAAE,MAAM,CAAA;SACZ,CAAA;KACD,CAAA;CACD;AAED;;GAEG;AACH,8BAAsB,SAAU,YAAW,gBAAgB;IAC1D;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;IAE3B;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,aAAa,GAAG,aAAa,CAAA;IAEpC,SAAS,aAAa,IAAI,CAAC,EAAE,aAAa,GAAG,aAAa;IAI1D;;OAEG;IACI,IAAI;CAGX"}
|
package/out/objects.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
import { is2DBBox } from "./bbox.js";
|
|
7
|
+
/**
|
|
8
|
+
* Shadow enum-like record of valid GeoJSON object types.
|
|
9
|
+
*/
|
|
10
|
+
export const GeometryType = {
|
|
11
|
+
Point: "Point",
|
|
12
|
+
MultiPoint: "MultiPoint",
|
|
13
|
+
LineString: "LineString",
|
|
14
|
+
MultiLineString: "MultiLineString",
|
|
15
|
+
Polygon: "Polygon",
|
|
16
|
+
MultiPolygon: "MultiPolygon",
|
|
17
|
+
GeometryCollection: "GeometryCollection",
|
|
18
|
+
FeatureCollection: "FeatureCollection",
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Abstract base-class for all GeoJSON class constructors.
|
|
22
|
+
*/
|
|
23
|
+
export class GeoObject {
|
|
24
|
+
/**
|
|
25
|
+
* A bounding box of the coordinate range of the object's Geometries, Features, or Feature.
|
|
26
|
+
*
|
|
27
|
+
* @see {@linkcode BBox2DLiteral} for 2-dimensional bounding boxes.
|
|
28
|
+
* @see {@linkcode BBox3DLiteral} for 3-dimensional bounding boxes.
|
|
29
|
+
* @see
|
|
30
|
+
*/
|
|
31
|
+
bbox;
|
|
32
|
+
constructor(bbox) {
|
|
33
|
+
this.bbox = bbox;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Predicate to determine if the GeoJSON object is 2-dimensional.
|
|
37
|
+
*/
|
|
38
|
+
is2D() {
|
|
39
|
+
return is2DBBox(this.bbox);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=objects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objects.js","sourceRoot":"","sources":["../objects.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAA0C,QAAQ,EAAE,MAAM,WAAW,CAAA;AAe5E;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC3B,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,YAAY;IACxB,UAAU,EAAE,YAAY;IACxB,eAAe,EAAE,iBAAiB;IAClC,OAAO,EAAE,SAAS;IAClB,YAAY,EAAE,cAAc;IAC5B,kBAAkB,EAAE,oBAAoB;IACxC,iBAAiB,EAAE,mBAAmB;CACQ,CAAA;AAsD/C;;GAEG;AACH,MAAM,OAAgB,SAAS;IAM9B;;;;;;OAMG;IACH,IAAI,CAAgC;IAEpC,YAAsB,IAAoC;QACzD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IACjB,CAAC;IAED;;OAEG;IACI,IAAI;QACV,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;CACD"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* This file contains types and utilities for working with geographic positions.
|
|
7
|
+
*/
|
|
8
|
+
import { type LatLngLiteral } from "@googlemaps/google-maps-services-js";
|
|
9
|
+
import { type GeoPointInput } from "@mailwoman/spatial";
|
|
10
|
+
/**
|
|
11
|
+
* An ordered pair of coordinates in the form of [longitude, latitude].
|
|
12
|
+
*
|
|
13
|
+
* Note that unlike the typical order, GeoJSON coordinates are in the order of [longitude, latitude]
|
|
14
|
+
* to match the order of [x, y] in Cartesian coordinates.
|
|
15
|
+
*
|
|
16
|
+
* @category Position
|
|
17
|
+
* @category GeoJSON
|
|
18
|
+
* @see {@linkcode Coordinates3D} for 3D coordinates.
|
|
19
|
+
*/
|
|
20
|
+
export type Coordinates2D = [
|
|
21
|
+
/**
|
|
22
|
+
* The longitude of the point, i.e. the x-coordinate.
|
|
23
|
+
*
|
|
24
|
+
* @minimum -180
|
|
25
|
+
* @maximum 180
|
|
26
|
+
*/
|
|
27
|
+
longitude: number,
|
|
28
|
+
/**
|
|
29
|
+
* The latitude of the point, i.e. the y-coordinate.
|
|
30
|
+
*
|
|
31
|
+
* @minimum -90
|
|
32
|
+
* @maximum 90
|
|
33
|
+
*/
|
|
34
|
+
latitude: number
|
|
35
|
+
];
|
|
36
|
+
/**
|
|
37
|
+
* Orders the given coordinates as [longitude, latitude].
|
|
38
|
+
*
|
|
39
|
+
* This is useful when converting into GeoJSON format.
|
|
40
|
+
*
|
|
41
|
+
* @category GeoJSON
|
|
42
|
+
* @category Position
|
|
43
|
+
*/
|
|
44
|
+
export declare function orderCoordPairToGeoJSON([latitude, longitude]: [number, number]): Coordinates2D;
|
|
45
|
+
/**
|
|
46
|
+
* Orders the given coordinates as [latitude, longitude].
|
|
47
|
+
*
|
|
48
|
+
* This is useful when converting into Google Maps format.
|
|
49
|
+
*
|
|
50
|
+
* @category GeoJSON
|
|
51
|
+
* @category Position
|
|
52
|
+
*/
|
|
53
|
+
export declare function orderGeoJSONToCoordPair([longitude, latitude]: Coordinates2D): [number, number];
|
|
54
|
+
/**
|
|
55
|
+
* Given an input which appears to be reversed GeoJSON coordinates (i.e. [latitude, longitude]),
|
|
56
|
+
* returns the coordinates in the correct order of [longitude, latitude].
|
|
57
|
+
*
|
|
58
|
+
* Note that this is a heuristic and is only accurate for North American coordinates.
|
|
59
|
+
*
|
|
60
|
+
* @category GeoJSON
|
|
61
|
+
* @category Position
|
|
62
|
+
*/
|
|
63
|
+
export declare function inferGeoJSONCoordOrder([coordA, coordB]: [number, number]): Coordinates2D;
|
|
64
|
+
/**
|
|
65
|
+
* An ordered triple of coordinates in the form of [longitude, latitude, altitude].
|
|
66
|
+
*
|
|
67
|
+
* @category Position
|
|
68
|
+
* @category GeoJSON
|
|
69
|
+
* @see {@linkcode Coordinates2D} for 2D coordinates.
|
|
70
|
+
*/
|
|
71
|
+
export type Coordinates3D = [
|
|
72
|
+
/**
|
|
73
|
+
* The longitude of the point, i.e. the x-coordinate.
|
|
74
|
+
*
|
|
75
|
+
* @minimum -180
|
|
76
|
+
* @maximum 180
|
|
77
|
+
*/
|
|
78
|
+
longitude: number,
|
|
79
|
+
/**
|
|
80
|
+
* The latitude of the point, i.e. the y-coordinate.
|
|
81
|
+
*
|
|
82
|
+
* @minimum -90
|
|
83
|
+
* @maximum 90
|
|
84
|
+
*/
|
|
85
|
+
latitude: number,
|
|
86
|
+
/**
|
|
87
|
+
* The altitude of the point, i.e. the z-coordinate.
|
|
88
|
+
*/
|
|
89
|
+
altitude: number
|
|
90
|
+
];
|
|
91
|
+
/**
|
|
92
|
+
* A record of internal coordinates, typically used by the US Census.
|
|
93
|
+
*/
|
|
94
|
+
export type InternalPointCoordinates = {
|
|
95
|
+
/**
|
|
96
|
+
* Internal Longitude (X) Coordinates
|
|
97
|
+
*
|
|
98
|
+
* @minimum -180
|
|
99
|
+
* @maximum 180
|
|
100
|
+
*/
|
|
101
|
+
x: number;
|
|
102
|
+
/**
|
|
103
|
+
* Internal Latitude (Y) Coordinates
|
|
104
|
+
*
|
|
105
|
+
* @minimum -90
|
|
106
|
+
* @maximum 90
|
|
107
|
+
*/
|
|
108
|
+
y: number;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Type-predicate to determine if the given input is a GeoJSON Point geometry.
|
|
112
|
+
*
|
|
113
|
+
* @category Type Predicates
|
|
114
|
+
* @category GeoJSON
|
|
115
|
+
*/
|
|
116
|
+
export declare function isCoordPairLiteral(input: unknown): input is [number, number] | [number, number, number];
|
|
117
|
+
/**
|
|
118
|
+
* Type-predicate to determine if the given input is a {@linkcode LatLngLiteral} object.
|
|
119
|
+
*
|
|
120
|
+
* @category Position
|
|
121
|
+
* @category Type Predicates
|
|
122
|
+
* @see {@link https://developers.google.com/maps/documentation/javascript/reference/coordinates#LatLngLiteral Google Maps API Documentation}
|
|
123
|
+
*/
|
|
124
|
+
export declare function isGoogleMapsLatLngLiteral(input: unknown): input is LatLngLiteral;
|
|
125
|
+
/**
|
|
126
|
+
* Type-predicate to determine if the given input is a {@linkcode InternalPointCoordinates} object.
|
|
127
|
+
*
|
|
128
|
+
* @category Position
|
|
129
|
+
* @category Type Predicates
|
|
130
|
+
*/
|
|
131
|
+
export declare function isInterpolatedCoordinates(input: unknown): input is InternalPointCoordinates;
|
|
132
|
+
/**
|
|
133
|
+
* Given a longitude value, wraps it to the range of [-180, 180].
|
|
134
|
+
*
|
|
135
|
+
* This is useful when normalizing longitude values.
|
|
136
|
+
*
|
|
137
|
+
* @category Position
|
|
138
|
+
* @param longitude The longitude value to wrap.
|
|
139
|
+
*/
|
|
140
|
+
export declare function wrapLongitude(longitude: number): number;
|
|
141
|
+
/**
|
|
142
|
+
* Given a latitude value, clamps it to the range of [-90, 90].
|
|
143
|
+
*
|
|
144
|
+
* This is useful when normalizing latitude values.
|
|
145
|
+
*
|
|
146
|
+
* @category Position
|
|
147
|
+
* @param value The latitude value to clamp.
|
|
148
|
+
*/
|
|
149
|
+
export declare function clampLatitude(value: number): number;
|
|
150
|
+
/**
|
|
151
|
+
* Conversion factors for converting between degrees and radians.
|
|
152
|
+
*
|
|
153
|
+
* @category Position
|
|
154
|
+
* @see {@link https://en.wikipedia.org/wiki/Radian Wikipedia: Radian}
|
|
155
|
+
* @see {@link https://en.wikipedia.org/wiki/Degree_(angle) Wikipedia: Degree (angle)}
|
|
156
|
+
*/
|
|
157
|
+
export declare const ConversionFactor: {
|
|
158
|
+
readonly DegreesToRadians: 0.01745329251;
|
|
159
|
+
readonly RadiansToDegrees: 57.2957795131;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Available conversion units for the radius of the Earth.
|
|
163
|
+
*/
|
|
164
|
+
export type EarthRadiusUnit = "km" | "miles" | "meters";
|
|
165
|
+
/**
|
|
166
|
+
* Calculate the distance between two points on the Earth's surface.
|
|
167
|
+
*
|
|
168
|
+
* @category Position
|
|
169
|
+
* @param point1 The first point to calculate the distance from.
|
|
170
|
+
* @param point2 The second point to calculate the distance to.
|
|
171
|
+
* @param unit The unit of measurement to return the distance in.
|
|
172
|
+
*
|
|
173
|
+
* @returns The distance between the two points in the specified unit.
|
|
174
|
+
*/
|
|
175
|
+
export declare function haversine(point1: GeoPointInput, point2: GeoPointInput, unit?: EarthRadiusUnit): number;
|
|
176
|
+
//# sourceMappingURL=position.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../position.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACxE,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEjE;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG;IAC3B;;;;;OAKG;IACH,SAAS,EAAE,MAAM;IACjB;;;;;OAKG;IACH,QAAQ,EAAE,MAAM;CAChB,CAAA;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,aAAa,CAE9F;AAED;;;;;;;GAOG;AAC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