@mailwoman/spatial 4.9.0 → 4.11.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/README.md +45 -2
- 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
package/out/position.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
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 {} from "@googlemaps/google-maps-services-js";
|
|
9
|
+
import { GeoPoint } from "@mailwoman/spatial";
|
|
10
|
+
/**
|
|
11
|
+
* Orders the given coordinates as [longitude, latitude].
|
|
12
|
+
*
|
|
13
|
+
* This is useful when converting into GeoJSON format.
|
|
14
|
+
*
|
|
15
|
+
* @category GeoJSON
|
|
16
|
+
* @category Position
|
|
17
|
+
*/
|
|
18
|
+
export function orderCoordPairToGeoJSON([latitude, longitude]) {
|
|
19
|
+
return [longitude, latitude];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Orders the given coordinates as [latitude, longitude].
|
|
23
|
+
*
|
|
24
|
+
* This is useful when converting into Google Maps format.
|
|
25
|
+
*
|
|
26
|
+
* @category GeoJSON
|
|
27
|
+
* @category Position
|
|
28
|
+
*/
|
|
29
|
+
export function orderGeoJSONToCoordPair([longitude, latitude]) {
|
|
30
|
+
return [latitude, longitude];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Given an input which appears to be reversed GeoJSON coordinates (i.e. [latitude, longitude]),
|
|
34
|
+
* returns the coordinates in the correct order of [longitude, latitude].
|
|
35
|
+
*
|
|
36
|
+
* Note that this is a heuristic and is only accurate for North American coordinates.
|
|
37
|
+
*
|
|
38
|
+
* @category GeoJSON
|
|
39
|
+
* @category Position
|
|
40
|
+
*/
|
|
41
|
+
export function inferGeoJSONCoordOrder([coordA, coordB]) {
|
|
42
|
+
// Latitude values typically range from -90 to 90
|
|
43
|
+
const isCoordALat = coordA >= -90 && coordA <= 90;
|
|
44
|
+
const isCoordBLat = coordB >= -90 && coordB <= 90;
|
|
45
|
+
if (isCoordALat && !isCoordBLat) {
|
|
46
|
+
// coordA is latitude, coordB is longitude
|
|
47
|
+
return [coordB, coordA];
|
|
48
|
+
}
|
|
49
|
+
if (!isCoordALat && isCoordBLat) {
|
|
50
|
+
// coordB is latitude, coordA is longitude
|
|
51
|
+
return [coordA, coordB];
|
|
52
|
+
}
|
|
53
|
+
// In case both appear to be latitudes (unlikely) or longitudes (out of range for US),
|
|
54
|
+
// assume coordA is longitude and coordB is latitude as default.
|
|
55
|
+
return [coordA, coordB];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Type-predicate to determine if the given input is a GeoJSON Point geometry.
|
|
59
|
+
*
|
|
60
|
+
* @category Type Predicates
|
|
61
|
+
* @category GeoJSON
|
|
62
|
+
*/
|
|
63
|
+
export function isCoordPairLiteral(input) {
|
|
64
|
+
if (!Array.isArray(input))
|
|
65
|
+
return false;
|
|
66
|
+
if (input.length !== 2 && input.length !== 3)
|
|
67
|
+
return false;
|
|
68
|
+
return input.every((coord) => typeof coord === "number");
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Type-predicate to determine if the given input is a {@linkcode LatLngLiteral} object.
|
|
72
|
+
*
|
|
73
|
+
* @category Position
|
|
74
|
+
* @category Type Predicates
|
|
75
|
+
* @see {@link https://developers.google.com/maps/documentation/javascript/reference/coordinates#LatLngLiteral Google Maps API Documentation}
|
|
76
|
+
*/
|
|
77
|
+
export function isGoogleMapsLatLngLiteral(input) {
|
|
78
|
+
if (!input || typeof input !== "object")
|
|
79
|
+
return false;
|
|
80
|
+
if (!Object.hasOwn(input, "lat") || !Object.hasOwn(input, "lng"))
|
|
81
|
+
return false;
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Type-predicate to determine if the given input is a {@linkcode InternalPointCoordinates} object.
|
|
86
|
+
*
|
|
87
|
+
* @category Position
|
|
88
|
+
* @category Type Predicates
|
|
89
|
+
*/
|
|
90
|
+
export function isInterpolatedCoordinates(input) {
|
|
91
|
+
if (!input || typeof input !== "object")
|
|
92
|
+
return false;
|
|
93
|
+
if (!("x" in input))
|
|
94
|
+
return false;
|
|
95
|
+
if (!("y" in input))
|
|
96
|
+
return false;
|
|
97
|
+
return typeof input.x === "number" && typeof input.y === "number";
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Given a longitude value, wraps it to the range of [-180, 180].
|
|
101
|
+
*
|
|
102
|
+
* This is useful when normalizing longitude values.
|
|
103
|
+
*
|
|
104
|
+
* @category Position
|
|
105
|
+
* @param longitude The longitude value to wrap.
|
|
106
|
+
*/
|
|
107
|
+
export function wrapLongitude(longitude) {
|
|
108
|
+
return ((((longitude + 180) % 360) + 360) % 360) - 180;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Given a latitude value, clamps it to the range of [-90, 90].
|
|
112
|
+
*
|
|
113
|
+
* This is useful when normalizing latitude values.
|
|
114
|
+
*
|
|
115
|
+
* @category Position
|
|
116
|
+
* @param value The latitude value to clamp.
|
|
117
|
+
*/
|
|
118
|
+
export function clampLatitude(value) {
|
|
119
|
+
return Math.min(90, Math.max(-90, value));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Conversion factors for converting between degrees and radians.
|
|
123
|
+
*
|
|
124
|
+
* @category Position
|
|
125
|
+
* @see {@link https://en.wikipedia.org/wiki/Radian Wikipedia: Radian}
|
|
126
|
+
* @see {@link https://en.wikipedia.org/wiki/Degree_(angle) Wikipedia: Degree (angle)}
|
|
127
|
+
*/
|
|
128
|
+
export const ConversionFactor = {
|
|
129
|
+
DegreesToRadians: (Math.PI / 180),
|
|
130
|
+
RadiansToDegrees: (180 / Math.PI),
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Radius of the Earth in various units
|
|
134
|
+
*/
|
|
135
|
+
const RADII = {
|
|
136
|
+
km: 6371,
|
|
137
|
+
miles: 3958.8,
|
|
138
|
+
meters: 6371000,
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Calculate the distance between two points on the Earth's surface.
|
|
142
|
+
*
|
|
143
|
+
* @category Position
|
|
144
|
+
* @param point1 The first point to calculate the distance from.
|
|
145
|
+
* @param point2 The second point to calculate the distance to.
|
|
146
|
+
* @param unit The unit of measurement to return the distance in.
|
|
147
|
+
*
|
|
148
|
+
* @returns The distance between the two points in the specified unit.
|
|
149
|
+
*/
|
|
150
|
+
export function haversine(point1, point2, unit = "km") {
|
|
151
|
+
const p1 = GeoPoint.from(point1);
|
|
152
|
+
const p2 = GeoPoint.from(point2);
|
|
153
|
+
if (!p1 || !p2)
|
|
154
|
+
return NaN;
|
|
155
|
+
const lat1 = p1.latitude;
|
|
156
|
+
const lon1 = p1.longitude;
|
|
157
|
+
const lat2 = p2.latitude;
|
|
158
|
+
const lon2 = p2.longitude;
|
|
159
|
+
const dLat = (lat2 - lat1) * ConversionFactor.DegreesToRadians;
|
|
160
|
+
const dLon = (lon2 - lon1) * ConversionFactor.DegreesToRadians;
|
|
161
|
+
const a = Math.pow(Math.sin(dLat / 2), 2) +
|
|
162
|
+
Math.cos(lat1 * ConversionFactor.DegreesToRadians) *
|
|
163
|
+
Math.cos(lat2 * ConversionFactor.DegreesToRadians) *
|
|
164
|
+
Math.pow(Math.sin(dLon / 2), 2);
|
|
165
|
+
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
166
|
+
const radius = RADII[unit];
|
|
167
|
+
return radius * c;
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=position.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"position.js","sourceRoot":"","sources":["../position.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAsB,MAAM,qCAAqC,CAAA;AACxE,OAAO,EAAE,QAAQ,EAAsB,MAAM,oBAAoB,CAAA;AA6BjE;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAmB;IAC9E,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;AAC7B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAgB;IAC3E,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;A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**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A coordinate system used to represent the Earth's surface.
|
|
8
|
+
*
|
|
9
|
+
* @category Geo
|
|
10
|
+
*/
|
|
11
|
+
export declare enum CoordinateProjection {
|
|
12
|
+
/**
|
|
13
|
+
* Coordinate system used in Google Earth and GSP systems.
|
|
14
|
+
*
|
|
15
|
+
* It represents Earth as a three-dimensional ellipsoid.
|
|
16
|
+
*/
|
|
17
|
+
WGS84 = "4326",
|
|
18
|
+
/**
|
|
19
|
+
* North American Datum 1983, a geodetic reference system used in the TIGER/Line data.
|
|
20
|
+
*/
|
|
21
|
+
NAD83 = "4269"
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../projection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,oBAAY,oBAAoB;IAC/B;;;;OAIG;IACH,KAAK,SAAS;IACd;;OAEG;IACH,KAAK,SAAS;CACd"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A coordinate system used to represent the Earth's surface.
|
|
8
|
+
*
|
|
9
|
+
* @category Geo
|
|
10
|
+
*/
|
|
11
|
+
export var CoordinateProjection;
|
|
12
|
+
(function (CoordinateProjection) {
|
|
13
|
+
/**
|
|
14
|
+
* Coordinate system used in Google Earth and GSP systems.
|
|
15
|
+
*
|
|
16
|
+
* It represents Earth as a three-dimensional ellipsoid.
|
|
17
|
+
*/
|
|
18
|
+
CoordinateProjection["WGS84"] = "4326";
|
|
19
|
+
/**
|
|
20
|
+
* North American Datum 1983, a geodetic reference system used in the TIGER/Line data.
|
|
21
|
+
*/
|
|
22
|
+
CoordinateProjection["NAD83"] = "4269";
|
|
23
|
+
})(CoordinateProjection || (CoordinateProjection = {}));
|
|
24
|
+
//# sourceMappingURL=projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.js","sourceRoot":"","sources":["../projection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,MAAM,CAAN,IAAY,oBAWX;AAXD,WAAY,oBAAoB;IAC/B;;;;OAIG;IACH,sCAAc,CAAA;IACd;;OAEG;IACH,sCAAc,CAAA;AACf,CAAC,EAXW,oBAAoB,KAApB,oBAAoB,QAW/B"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* M.49 region codes for continents.
|
|
8
|
+
*/
|
|
9
|
+
export declare const RegionCodes: readonly ["AF", "AN", "AS", "EU", "NA", "OC", "SA"];
|
|
10
|
+
/**
|
|
11
|
+
* M.49 region code for a specific continent.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export type RegionCode = (typeof RegionCodes)[number];
|
|
16
|
+
/**
|
|
17
|
+
* Continent codes to their full names.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare const RegionCodeToNameRecord: {
|
|
22
|
+
readonly AF: "Africa";
|
|
23
|
+
readonly AN: "Antarctica";
|
|
24
|
+
readonly AS: "Asia";
|
|
25
|
+
readonly EU: "Europe";
|
|
26
|
+
readonly NA: "North America";
|
|
27
|
+
readonly OC: "Oceania";
|
|
28
|
+
readonly SA: "South America";
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=codes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../regions/codes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,eAAO,MAAM,WAAW,qDASc,CAAA;AAEtC;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAA;AAErD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;CAQgB,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* M.49 region codes for continents.
|
|
8
|
+
*/
|
|
9
|
+
export const RegionCodes = [
|
|
10
|
+
// ---
|
|
11
|
+
"AF",
|
|
12
|
+
"AN",
|
|
13
|
+
"AS",
|
|
14
|
+
"EU",
|
|
15
|
+
"NA",
|
|
16
|
+
"OC",
|
|
17
|
+
"SA",
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* Continent codes to their full names.
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export const RegionCodeToNameRecord = {
|
|
25
|
+
AF: "Africa",
|
|
26
|
+
AN: "Antarctica",
|
|
27
|
+
AS: "Asia",
|
|
28
|
+
EU: "Europe",
|
|
29
|
+
NA: "North America",
|
|
30
|
+
OC: "Oceania",
|
|
31
|
+
SA: "South America",
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codes.js","sourceRoot":"","sources":["../../regions/codes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IAC1B,MAAM;IACN,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;CACiC,CAAA;AAStC;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACrC,EAAE,EAAE,QAAQ;IACZ,EAAE,EAAE,YAAY;IAChB,EAAE,EAAE,MAAM;IACV,EAAE,EAAE,QAAQ;IACZ,EAAE,EAAE,eAAe;IACnB,EAAE,EAAE,SAAS;IACb,EAAE,EAAE,eAAe;CAC+B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../regions/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../regions/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A list of geographic regions, i.e. continents.
|
|
8
|
+
*
|
|
9
|
+
* @category Geographic
|
|
10
|
+
*/
|
|
11
|
+
export declare const RegionNames: readonly ["Africa", "Antarctica", "Asia", "Europe", "North America", "Oceania", "South America"];
|
|
12
|
+
/**
|
|
13
|
+
* A region of the world, i.e. a continent.
|
|
14
|
+
*
|
|
15
|
+
* @category Geographic
|
|
16
|
+
* @title Geographic Region
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export type RegionName = (typeof RegionNames)[number];
|
|
20
|
+
//# sourceMappingURL=names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.d.ts","sourceRoot":"","sources":["../../regions/names.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,eAAO,MAAM,WAAW,kGAQc,CAAA;AAEtC;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* A list of geographic regions, i.e. continents.
|
|
8
|
+
*
|
|
9
|
+
* @category Geographic
|
|
10
|
+
*/
|
|
11
|
+
export const RegionNames = [
|
|
12
|
+
"Africa",
|
|
13
|
+
"Antarctica",
|
|
14
|
+
"Asia",
|
|
15
|
+
"Europe",
|
|
16
|
+
"North America",
|
|
17
|
+
"Oceania",
|
|
18
|
+
"South America",
|
|
19
|
+
];
|
|
20
|
+
//# sourceMappingURL=names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../regions/names.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IAC1B,QAAQ;IACR,YAAY;IACZ,MAAM;IACN,QAAQ;IACR,eAAe;IACf,SAAS;IACT,eAAe;CACsB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../sdk/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,sBAAsB,CAAA"}
|
package/out/sdk/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../sdk/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Provides functions for parsing and converting extended Well-Known text and binary data.
|
|
7
|
+
*/
|
|
8
|
+
import type { GeometryCollection, GeometryLiteral } from "@mailwoman/spatial";
|
|
9
|
+
/**
|
|
10
|
+
* Given an extended Well-Known Binary (EWKB) buffer, parse it into a GeoJSON geometry object.
|
|
11
|
+
*
|
|
12
|
+
* @category Geo
|
|
13
|
+
*/
|
|
14
|
+
export declare function wellKnownGeometryToGeoJSON<T = GeometryLiteral>(extendedWellKnownBinary: Buffer): T;
|
|
15
|
+
/**
|
|
16
|
+
* Given an extended Well-Known-Text, parse it into a GeoJSON geometry object.
|
|
17
|
+
*
|
|
18
|
+
* @category Geo
|
|
19
|
+
*/
|
|
20
|
+
export declare function wellKnownGeometryToGeoJSON<T = GeometryLiteral>(wellKnownText: string): T;
|
|
21
|
+
/**
|
|
22
|
+
* Given an extended Well-Known-Text, parse it into a GeoJSON geometry object.
|
|
23
|
+
*
|
|
24
|
+
* @category Geo
|
|
25
|
+
*/
|
|
26
|
+
export declare function wellKnownGeometryToGeoJSON<T = GeometryLiteral>(input: Buffer | string): T;
|
|
27
|
+
/**
|
|
28
|
+
* Given a GeoJSON geometry object, convert it to an well-known binary (EWKB) buffer.
|
|
29
|
+
*
|
|
30
|
+
* @category Geo
|
|
31
|
+
* @returns A hex-encoded EWKB string or WKB buffer.
|
|
32
|
+
*/
|
|
33
|
+
export declare function geometryToWKB(geometry: GeometryLiteral | GeometryCollection): Buffer<ArrayBufferLike>;
|
|
34
|
+
/**
|
|
35
|
+
* Given a GeoJSON geometry object, convert it to an extended well-known binary (EWKB) buffer.
|
|
36
|
+
*
|
|
37
|
+
* @category Geo
|
|
38
|
+
* @returns A buffer representing the EWKB.
|
|
39
|
+
*/
|
|
40
|
+
export declare function geometryToEWKB(geometry: GeometryLiteral | GeometryCollection): Buffer<ArrayBufferLike>;
|
|
41
|
+
/**
|
|
42
|
+
* Given a GeoJSON geometry object, convert it to an extended well-known binary (EWKB) buffer.
|
|
43
|
+
*
|
|
44
|
+
* @category Geo
|
|
45
|
+
* @returns A hex-encoded string representing the EWKB.
|
|
46
|
+
*/
|
|
47
|
+
export declare function geometryToEWKH(geometry: GeometryLiteral | GeometryCollection): string;
|
|
48
|
+
/**
|
|
49
|
+
* Given a GeoJSON geometry object, convert it to an extended well-known text (EWKT) string.
|
|
50
|
+
*
|
|
51
|
+
* @category Geo
|
|
52
|
+
*/
|
|
53
|
+
export declare function geometryToWKT(geometry: GeometryLiteral | GeometryCollection): string;
|
|
54
|
+
/**
|
|
55
|
+
* Given a GeoJSON geometry object, convert it to a SQL geometry string.
|
|
56
|
+
*
|
|
57
|
+
* This is useful for composing SQL queries that require geometry literals.
|
|
58
|
+
*
|
|
59
|
+
* @category Geo
|
|
60
|
+
*/
|
|
61
|
+
export declare function geometryToSQL<T extends GeometryLiteral | GeometryCollection>(geometry: T | null | undefined): () => string;
|
|
62
|
+
//# sourceMappingURL=well-known-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"well-known-text.d.ts","sourceRoot":"","sources":["../../sdk/well-known-text.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAG7E;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,GAAG,eAAe,EAAE,uBAAuB,EAAE,MAAM,GAAG,CAAC,CAAA;AACnG;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,GAAG,eAAe,EAAE,aAAa,EAAE,MAAM,GAAG,CAAC,CAAA;AACzF;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,CAAC,GAAG,eAAe,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,CAAA;AAK1F;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,eAAe,GAAG,kBAAkB,2BAE3E;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,eAAe,GAAG,kBAAkB,2BAE5E;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,eAAe,GAAG,kBAAkB,UAE5E;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,eAAe,GAAG,kBAAkB,GAAG,MAAM,CAEpF;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,eAAe,GAAG,kBAAkB,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,gBAM3G"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software.
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* Provides functions for parsing and converting extended Well-Known text and binary data.
|
|
7
|
+
*/
|
|
8
|
+
import wkx from "wkx";
|
|
9
|
+
export function wellKnownGeometryToGeoJSON(input) {
|
|
10
|
+
return wkx.Geometry.parse(input).toGeoJSON();
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Given a GeoJSON geometry object, convert it to an well-known binary (EWKB) buffer.
|
|
14
|
+
*
|
|
15
|
+
* @category Geo
|
|
16
|
+
* @returns A hex-encoded EWKB string or WKB buffer.
|
|
17
|
+
*/
|
|
18
|
+
export function geometryToWKB(geometry) {
|
|
19
|
+
return wkx.Geometry.parseGeoJSON(geometry).toWkb();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Given a GeoJSON geometry object, convert it to an extended well-known binary (EWKB) buffer.
|
|
23
|
+
*
|
|
24
|
+
* @category Geo
|
|
25
|
+
* @returns A buffer representing the EWKB.
|
|
26
|
+
*/
|
|
27
|
+
export function geometryToEWKB(geometry) {
|
|
28
|
+
return wkx.Geometry.parseGeoJSON(geometry).toEwkb();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Given a GeoJSON geometry object, convert it to an extended well-known binary (EWKB) buffer.
|
|
32
|
+
*
|
|
33
|
+
* @category Geo
|
|
34
|
+
* @returns A hex-encoded string representing the EWKB.
|
|
35
|
+
*/
|
|
36
|
+
export function geometryToEWKH(geometry) {
|
|
37
|
+
return geometryToEWKB(geometry).toString("hex");
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Given a GeoJSON geometry object, convert it to an extended well-known text (EWKT) string.
|
|
41
|
+
*
|
|
42
|
+
* @category Geo
|
|
43
|
+
*/
|
|
44
|
+
export function geometryToWKT(geometry) {
|
|
45
|
+
return wkx.Geometry.parseGeoJSON(geometry).toWkt();
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Given a GeoJSON geometry object, convert it to a SQL geometry string.
|
|
49
|
+
*
|
|
50
|
+
* This is useful for composing SQL queries that require geometry literals.
|
|
51
|
+
*
|
|
52
|
+
* @category Geo
|
|
53
|
+
*/
|
|
54
|
+
export function geometryToSQL(geometry) {
|
|
55
|
+
return () => {
|
|
56
|
+
if (!geometry)
|
|
57
|
+
return `NULL`;
|
|
58
|
+
return /* sql */ `GeomFromEWKB('${geometryToEWKH(geometry)}')`;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=well-known-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"well-known-text.js","sourceRoot":"","sources":["../../sdk/well-known-text.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,GAAG,MAAM,KAAK,CAAA;AAoBrB,MAAM,UAAU,0BAA0B,CAAsB,KAAsB;IACrF,OAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,SAAS,EAAO,CAAA;AAClD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,QAA8C;IAC3E,OAAO,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,CAAA;AACnD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,QAA8C;IAC5E,OAAO,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAA;AACpD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,QAA8C;IAC5E,OAAO,cAAc,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AAChD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,QAA8C;IAC3E,OAAO,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,CAAA;AACnD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAiD,QAA8B;IAC3G,OAAO,GAAG,EAAE;QACX,IAAI,CAAC,QAAQ;YAAE,OAAO,MAAM,CAAA;QAE5B,OAAO,SAAS,CAAC,iBAAiB,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAA;IAC/D,CAAC,CAAA;AACF,CAAC"}
|