@mailwoman/ogc 11.2.0 → 11.3.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 +167 -28
- package/cli/geocoder.ts +50 -0
- package/cli/main.ts +303 -49
- package/lib/app.ts +9 -1
- package/lib/bbox.ts +69 -0
- package/lib/collections.ts +63 -9
- package/lib/engine.ts +72 -0
- package/lib/html.ts +64 -2
- package/lib/index.ts +4 -0
- package/lib/items.ts +169 -0
- package/lib/projection.ts +28 -8
- package/lib/provenance.ts +86 -0
- package/lib/refusal.ts +34 -0
- package/lib/routes.ts +326 -61
- package/lib/schema.ts +164 -3
- package/out/app.d.ts +8 -0
- package/out/app.d.ts.map +1 -1
- package/out/app.js +1 -1
- package/out/app.js.map +1 -1
- package/out/bbox.d.ts +23 -0
- package/out/bbox.d.ts.map +1 -0
- package/out/bbox.js +54 -0
- package/out/bbox.js.map +1 -0
- package/out/cli/geocoder.d.ts +24 -0
- package/out/cli/geocoder.d.ts.map +1 -0
- package/out/cli/geocoder.js +28 -0
- package/out/cli/geocoder.js.map +1 -0
- package/out/cli/main.js +225 -46
- package/out/cli/main.js.map +1 -1
- package/out/collections.d.ts +31 -4
- package/out/collections.d.ts.map +1 -1
- package/out/collections.js +32 -3
- package/out/collections.js.map +1 -1
- package/out/engine.d.ts +68 -0
- package/out/engine.d.ts.map +1 -1
- package/out/html.d.ts +11 -1
- package/out/html.d.ts.map +1 -1
- package/out/html.js +49 -2
- package/out/html.js.map +1 -1
- package/out/index.d.ts +4 -0
- package/out/index.d.ts.map +1 -1
- package/out/index.js +4 -0
- package/out/index.js.map +1 -1
- package/out/items.d.ts +38 -0
- package/out/items.d.ts.map +1 -0
- package/out/items.js +136 -0
- package/out/items.js.map +1 -0
- package/out/projection.d.ts +15 -1
- package/out/projection.d.ts.map +1 -1
- package/out/projection.js +21 -8
- package/out/projection.js.map +1 -1
- package/out/provenance.d.ts +41 -0
- package/out/provenance.d.ts.map +1 -0
- package/out/provenance.js +60 -0
- package/out/provenance.js.map +1 -0
- package/out/refusal.d.ts +18 -0
- package/out/refusal.d.ts.map +1 -0
- package/out/refusal.js +30 -0
- package/out/refusal.js.map +1 -0
- package/out/routes.d.ts +24 -22
- package/out/routes.d.ts.map +1 -1
- package/out/routes.js +246 -51
- package/out/routes.js.map +1 -1
- package/out/schema.d.ts +157 -2
- package/out/schema.d.ts.map +1 -1
- package/out/schema.js +140 -3
- package/out/schema.js.map +1 -1
- package/out/tools/ets.run.d.ts +2 -0
- package/out/tools/ets.run.d.ts.map +1 -0
- package/out/tools/ets.run.js +187 -0
- package/out/tools/ets.run.js.map +1 -0
- package/package.json +32 -10
- package/tools/ets.run.ts +258 -0
package/lib/schema.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { z } from "@hono/zod-openapi"
|
|
16
|
-
import { featureCollectionSchema, featureSchema } from "@mailwoman/api-kit"
|
|
16
|
+
import { BBoxSchema, featureCollectionSchema, featureSchema } from "@mailwoman/api-kit"
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* The media types this surface serves, keyed by their role.
|
|
@@ -53,6 +53,11 @@ export const OGCLinkRelation = {
|
|
|
53
53
|
Data: "data",
|
|
54
54
|
OGCData: "http://www.opengis.net/def/rel/ogc/1.0/data",
|
|
55
55
|
Search: "search",
|
|
56
|
+
Items: "items",
|
|
57
|
+
Next: "next",
|
|
58
|
+
Collection: "collection",
|
|
59
|
+
License: "license",
|
|
60
|
+
Via: "via",
|
|
56
61
|
} as const
|
|
57
62
|
|
|
58
63
|
export type OGCLinkRelation = (typeof OGCLinkRelation)[keyof typeof OGCLinkRelation]
|
|
@@ -61,6 +66,8 @@ const COMMON_PART_1 = "http://www.opengis.net/spec/ogcapi-common-1/1.0/conf"
|
|
|
61
66
|
|
|
62
67
|
const COMMON_PART_2 = "http://www.opengis.net/spec/ogcapi-common-2/1.0/conf"
|
|
63
68
|
|
|
69
|
+
const FEATURES_PART_1 = "http://www.opengis.net/spec/ogcapi-features-1/1.0/conf"
|
|
70
|
+
|
|
64
71
|
/**
|
|
65
72
|
* The OGC API conformance classes this surface implements.
|
|
66
73
|
*
|
|
@@ -73,6 +80,12 @@ const COMMON_PART_2 = "http://www.opengis.net/spec/ogcapi-common-2/1.0/conf"
|
|
|
73
80
|
* - `oas30`: an OpenAPI 3.0 document as `service-desc` and its HTML form as `service-doc`.
|
|
74
81
|
* - `collections` (Common Part 2): `GET /collections` linked from the landing page as `data`,
|
|
75
82
|
* `GET /collections/{collectionId}` for every listed id, each with `self` and `alternate` links.
|
|
83
|
+
* - Features Part 1 `core`: `GET /collections/{collectionId}/items` with `limit`,
|
|
84
|
+
* `bbox` and `datetime`, and `GET /collections/{collectionId}/items/{featureId}`,
|
|
85
|
+
* for each collection whose description lists an `items` link.
|
|
86
|
+
* - Features Part 1 `geojson`: both items resources as `application/geo+json`.
|
|
87
|
+
* - Features Part 1 `html`: both items resources as HTML5, every link an `<a>`.
|
|
88
|
+
* - Features Part 1 `oas30`: the OpenAPI 3.0 definition declares both items resources and their parameters.
|
|
76
89
|
*/
|
|
77
90
|
export const OGCConformanceClass = {
|
|
78
91
|
Core: `${COMMON_PART_1}/core`,
|
|
@@ -81,6 +94,10 @@ export const OGCConformanceClass = {
|
|
|
81
94
|
HTML: `${COMMON_PART_1}/html`,
|
|
82
95
|
OAS30: `${COMMON_PART_1}/oas30`,
|
|
83
96
|
Collections: `${COMMON_PART_2}/collections`,
|
|
97
|
+
FeaturesCore: `${FEATURES_PART_1}/core`,
|
|
98
|
+
FeaturesGeoJSON: `${FEATURES_PART_1}/geojson`,
|
|
99
|
+
FeaturesHTML: `${FEATURES_PART_1}/html`,
|
|
100
|
+
FeaturesOAS30: `${FEATURES_PART_1}/oas30`,
|
|
84
101
|
} as const
|
|
85
102
|
|
|
86
103
|
export type OGCConformanceClass = (typeof OGCConformanceClass)[keyof typeof OGCConformanceClass]
|
|
@@ -124,6 +141,25 @@ export const OGCConformanceSchema = z
|
|
|
124
141
|
|
|
125
142
|
export type OGCConformance = z.infer<typeof OGCConformanceSchema>
|
|
126
143
|
|
|
144
|
+
/**
|
|
145
|
+
* The CRS84 coordinate reference system: WGS 84 longitude and latitude, in that order.
|
|
146
|
+
*/
|
|
147
|
+
export const OGC_CRS84 = "http://www.opengis.net/def/crs/OGC/1.3/CRS84"
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* A collection's extent, from OGC API Features Part 1's `extent.yaml`.
|
|
151
|
+
*/
|
|
152
|
+
export const OGCExtentSchema = z
|
|
153
|
+
.object({
|
|
154
|
+
spatial: z.object({
|
|
155
|
+
bbox: z.array(BBoxSchema),
|
|
156
|
+
crs: z.literal(OGC_CRS84),
|
|
157
|
+
}),
|
|
158
|
+
})
|
|
159
|
+
.openapi("OGCExtent")
|
|
160
|
+
|
|
161
|
+
export type OGCExtent = z.infer<typeof OGCExtentSchema>
|
|
162
|
+
|
|
127
163
|
const formatParameter = z.enum([OGCFormat.JSON, OGCFormat.HTML]).optional().openapi({
|
|
128
164
|
description: "The response encoding. Without it the `Accept` header decides, and JSON is the default.",
|
|
129
165
|
})
|
|
@@ -140,8 +176,9 @@ export const OGCFormatQuerySchema = z.object({ f: formatParameter }).strict()
|
|
|
140
176
|
* One collection description, from OGC API Common Part 2's `collectionDesc.yaml`.
|
|
141
177
|
*
|
|
142
178
|
* `id` and `links` are the two members the schema requires.
|
|
143
|
-
*
|
|
144
|
-
*
|
|
179
|
+
* A collection that serves `/collections/{collectionId}/items` adds `itemType`,
|
|
180
|
+
* the `items` link and the `extent` OGC API Features Part 1 describes.
|
|
181
|
+
* Another collection omits all three.
|
|
145
182
|
*/
|
|
146
183
|
export const OGCCollectionSchema = z
|
|
147
184
|
.object({
|
|
@@ -149,6 +186,12 @@ export const OGCCollectionSchema = z
|
|
|
149
186
|
title: z.string(),
|
|
150
187
|
description: z.string(),
|
|
151
188
|
links: z.array(OGCLinkSchema),
|
|
189
|
+
attribution: z.string().optional().openapi({
|
|
190
|
+
description:
|
|
191
|
+
"A short credit for the data, present when a layer's license requires attribution. OGC API Common Part 2 defines the member.",
|
|
192
|
+
}),
|
|
193
|
+
itemType: z.literal("feature").optional(),
|
|
194
|
+
extent: OGCExtentSchema.optional(),
|
|
152
195
|
geometryDimension: z.literal(0).openapi({ description: "Every feature in the collection is a point." }),
|
|
153
196
|
version: z.number().int().openapi({
|
|
154
197
|
description: "The collection version, the value `/search` takes in `<collectionId>[version]`, as on PDOK.",
|
|
@@ -199,6 +242,10 @@ export const OGCSearchPropertiesSchema = z
|
|
|
199
242
|
description:
|
|
200
243
|
"The gazetteer placetype of a place or postcode, such as `locality`, `localadmin` or `postalcode`. Absent for an address, a street or a plus code.",
|
|
201
244
|
}),
|
|
245
|
+
href: z.string().optional().openapi({
|
|
246
|
+
description:
|
|
247
|
+
"The URL of the same place at `/collections/{collectionId}/items/{featureId}`, as on PDOK. Absent when the collection serves no items or holds no item for the place.",
|
|
248
|
+
}),
|
|
202
249
|
})
|
|
203
250
|
.openapi("OGCSearchProperties")
|
|
204
251
|
|
|
@@ -294,3 +341,117 @@ export function searchQuerySchema(collectionIDs: readonly string[]) {
|
|
|
294
341
|
})
|
|
295
342
|
.strict()
|
|
296
343
|
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* The number of items `/collections/{collectionId}/items` returns when the request omits `limit`.
|
|
347
|
+
*/
|
|
348
|
+
export const OGC_ITEMS_DEFAULT_LIMIT = 10
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* The most items one `/collections/{collectionId}/items` page returns.
|
|
352
|
+
*
|
|
353
|
+
* A larger `limit` is served as this one, because OGC API Features Part 1 requires
|
|
354
|
+
* a `limit` above the maximum to succeed rather than fail.
|
|
355
|
+
*/
|
|
356
|
+
export const OGC_ITEMS_MAX_LIMIT = 1000
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* The properties of one item.
|
|
360
|
+
*/
|
|
361
|
+
export const OGCItemPropertiesSchema = z
|
|
362
|
+
.object({
|
|
363
|
+
name: z.string().openapi({ description: "The place's name, as the gazetteer records it." }),
|
|
364
|
+
placetype: z.string().openapi({ description: "The gazetteer placetype, such as `locality` or `region`." }),
|
|
365
|
+
country_code: z.string().nullable().openapi({
|
|
366
|
+
description: "The ISO 3166-1 alpha-2 country code the gazetteer records, or null when it records none.",
|
|
367
|
+
}),
|
|
368
|
+
display_name: z.string().openapi({
|
|
369
|
+
description:
|
|
370
|
+
"The place's name, then its ancestors, most specific first, then its country, as `/search` labels it.",
|
|
371
|
+
}),
|
|
372
|
+
})
|
|
373
|
+
.openapi("OGCItemProperties")
|
|
374
|
+
|
|
375
|
+
export type OGCItemProperties = z.infer<typeof OGCItemPropertiesSchema>
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* One item, a GeoJSON point feature with its gazetteer place ID as `id`.
|
|
379
|
+
*/
|
|
380
|
+
export const OGCItemFeatureSchema = featureSchema(OGCItemPropertiesSchema)
|
|
381
|
+
.extend({
|
|
382
|
+
id: z.string().openapi({ description: "The gazetteer place ID, such as `wof:85975673`, as `/search` reports it." }),
|
|
383
|
+
links: z.array(OGCLinkSchema).optional(),
|
|
384
|
+
})
|
|
385
|
+
.openapi("OGCItemFeature")
|
|
386
|
+
|
|
387
|
+
export type OGCItemFeature = z.infer<typeof OGCItemFeatureSchema>
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* One page of items: a GeoJSON FeatureCollection with the members OGC API Features Part 1 adds.
|
|
391
|
+
*
|
|
392
|
+
* `numberMatched` is omitted, as the standard permits, because counting a box's places costs a scan.
|
|
393
|
+
*/
|
|
394
|
+
export const OGCItemsResponseSchema = featureCollectionSchema(OGCItemFeatureSchema)
|
|
395
|
+
.extend({
|
|
396
|
+
timeStamp: z.string().openapi({ description: "When the response was generated, as an RFC 3339 UTC timestamp." }),
|
|
397
|
+
links: z.array(OGCLinkSchema),
|
|
398
|
+
numberReturned: z.number().int(),
|
|
399
|
+
})
|
|
400
|
+
.openapi("OGCItemsResponse")
|
|
401
|
+
|
|
402
|
+
export type OGCItemsResponse = z.infer<typeof OGCItemsResponseSchema>
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* The path parameters of `/collections/{collectionId}/items/{featureId}`.
|
|
406
|
+
*/
|
|
407
|
+
export const OGCItemPathSchema = OGCCollectionPathSchema.extend({
|
|
408
|
+
featureId: z.string().openapi({ param: { name: "featureId", in: "path" }, example: "wof:101751893" }),
|
|
409
|
+
})
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* The query of `/collections/{collectionId}/items`.
|
|
413
|
+
*
|
|
414
|
+
* The parameter definitions follow OGC API Features Part 1, Requirements 21, 23 and 25,
|
|
415
|
+
* including the `form` style without `explode` that a client reads from the API definition.
|
|
416
|
+
* The values arrive as strings, and the route parses them.
|
|
417
|
+
*/
|
|
418
|
+
export const OGCItemsQuerySchema = z
|
|
419
|
+
.object({
|
|
420
|
+
limit: z
|
|
421
|
+
.string()
|
|
422
|
+
.optional()
|
|
423
|
+
.openapi({
|
|
424
|
+
param: { style: "form", explode: false },
|
|
425
|
+
type: "integer",
|
|
426
|
+
minimum: 1,
|
|
427
|
+
maximum: OGC_ITEMS_MAX_LIMIT,
|
|
428
|
+
default: OGC_ITEMS_DEFAULT_LIMIT,
|
|
429
|
+
description: `The most features to return. The default is ${OGC_ITEMS_DEFAULT_LIMIT}, and a larger value than ${OGC_ITEMS_MAX_LIMIT} returns ${OGC_ITEMS_MAX_LIMIT}.`,
|
|
430
|
+
}),
|
|
431
|
+
bbox: z
|
|
432
|
+
.string()
|
|
433
|
+
.optional()
|
|
434
|
+
.openapi({
|
|
435
|
+
param: { style: "form", explode: false },
|
|
436
|
+
type: "array",
|
|
437
|
+
minItems: 4,
|
|
438
|
+
maxItems: 6,
|
|
439
|
+
items: { type: "number" },
|
|
440
|
+
description:
|
|
441
|
+
"Keep only features whose point lies inside the box: `minLon,minLat,maxLon,maxLat` in WGS 84 longitude and latitude, or six numbers with a minimum and maximum height after each latitude. The features have no height, so the height bounds select nothing out. A minimum longitude above the maximum crosses the antimeridian.",
|
|
442
|
+
}),
|
|
443
|
+
datetime: z
|
|
444
|
+
.string()
|
|
445
|
+
.optional()
|
|
446
|
+
.openapi({
|
|
447
|
+
param: { style: "form", explode: false },
|
|
448
|
+
description:
|
|
449
|
+
"An RFC 3339 date-time, or an interval of two separated by `/` with `..` or an empty string for an open end. The places carry no time, so every valid value matches every place, as OGC API Features Part 1 requires for features without a temporal geometry.",
|
|
450
|
+
}),
|
|
451
|
+
after: z.string().optional().openapi({
|
|
452
|
+
description:
|
|
453
|
+
"Start after the item with this WOF id. The `next` link sets it, and a client follows that link rather than building the value.",
|
|
454
|
+
}),
|
|
455
|
+
f: formatParameter,
|
|
456
|
+
})
|
|
457
|
+
.strict()
|
package/out/app.d.ts
CHANGED
|
@@ -22,6 +22,14 @@ export interface OGCAppOptions extends CompatibilityAppOptions {
|
|
|
22
22
|
* @defaultValue The request's own origin.
|
|
23
23
|
*/
|
|
24
24
|
baseURL?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Serve the items routes for the collections whose engine entry has an item source.
|
|
27
|
+
*
|
|
28
|
+
* Bulk browsing is opt-in, so the default leaves every collection without items.
|
|
29
|
+
*
|
|
30
|
+
* @defaultValue `false`
|
|
31
|
+
*/
|
|
32
|
+
serveItems?: boolean;
|
|
25
33
|
}
|
|
26
34
|
/**
|
|
27
35
|
* Builds the OGC API app around the given {@link OGCEngine}: the landing page at `/`,
|
package/out/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../lib/app.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAEN,KAAK,uBAAuB,EAG5B,KAAK,cAAc,EAEnB,MAAM,oBAAoB,CAAA;AAG3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAGxC;;GAEG;AACH,eAAO,MAAM,gBAAgB,OAAO,CAAA;AAEpC;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,cAmB1B,CAAA;AAED;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,uBAAuB;IAC7D;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../lib/app.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAEN,KAAK,uBAAuB,EAG5B,KAAK,cAAc,EAEnB,MAAM,oBAAoB,CAAA;AAG3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAGxC;;GAEG;AACH,eAAO,MAAM,gBAAgB,OAAO,CAAA;AAEpC;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,cAmB1B,CAAA;AAED;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,uBAAuB;IAC7D;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,GAAE,aAAkB,GAAG,WAAW,CA+BxF"}
|
package/out/app.js
CHANGED
|
@@ -60,7 +60,7 @@ export function createOGCApp(engine, options = {}) {
|
|
|
60
60
|
const docInfo = options.baseURL
|
|
61
61
|
? { ...OGC_DOC_INFO, servers: [{ url: options.baseURL }] }
|
|
62
62
|
: OGC_DOC_INFO;
|
|
63
|
-
registerOGCRoutes(app, engine, { baseURL: options.baseURL, docInfo });
|
|
63
|
+
registerOGCRoutes(app, engine, { baseURL: options.baseURL, docInfo, serveItems: options.serveItems === true });
|
|
64
64
|
attachOpenAPIDocs(app, docInfo);
|
|
65
65
|
return app;
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O,CAAC,OAAO,EAAE,CAAC,EAAE;QAC1D,CAAC,CAAC,YAAY,CAAA;IAEf,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,KAAK,IAAI,EAAE,CAAC,CAAA;IAC9G,iBAAiB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IAE/B,OAAO,GAAG,CAAA;AACX,CAAC"}
|
package/out/bbox.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A `[minLon, minLat, maxLon, maxLat]` box in WGS 84 degrees.
|
|
3
|
+
*/
|
|
4
|
+
export type OGCBBox = readonly [number, number, number, number];
|
|
5
|
+
/**
|
|
6
|
+
* Parse a `bbox` value.
|
|
7
|
+
*
|
|
8
|
+
* @param options.withHeight Admit the six-number form of OGC API Features Part 1,
|
|
9
|
+
* Requirement 23 D: `minLon,minLat,minHeight,maxLon,maxLat,maxHeight`.
|
|
10
|
+
* Every feature here is a point without a height, so the returned box keeps the
|
|
11
|
+
* longitudes and latitudes and drops the heights.
|
|
12
|
+
* @returns The box, or a message that states the problem with the value.
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseBBox(raw: string, options?: {
|
|
15
|
+
withHeight?: boolean;
|
|
16
|
+
}): OGCBBox | string;
|
|
17
|
+
/**
|
|
18
|
+
* Whether a point lies inside the box, edges included.
|
|
19
|
+
*
|
|
20
|
+
* A box whose minimum longitude exceeds its maximum crosses the antimeridian, as OGC API boxes may.
|
|
21
|
+
*/
|
|
22
|
+
export declare function searchBoxContains([minLon, minLat, maxLon, maxLat]: OGCBBox, lon: number, lat: number): boolean;
|
|
23
|
+
//# sourceMappingURL=bbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bbox.d.ts","sourceRoot":"","sources":["../lib/bbox.ts"],"names":[],"mappings":"AASA;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AAY/D;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,OAAO,GAAG,MAAM,CAwB/F;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAI9G"}
|
package/out/bbox.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
/**
|
|
4
|
+
* The `bbox` parameter `/search` and `/collections/{collectionId}/items` share.
|
|
5
|
+
*/
|
|
6
|
+
import { isValidLatitude, isValidLongitude } from "@mailwoman/spatial/coordinate/bounds";
|
|
7
|
+
/**
|
|
8
|
+
* The count of numbers in a two-dimensional `bbox`: two longitudes and two latitudes.
|
|
9
|
+
*/
|
|
10
|
+
const BBOX_CORNERS = 4;
|
|
11
|
+
/**
|
|
12
|
+
* The count of numbers in a three-dimensional `bbox`, which adds a minimum and maximum height.
|
|
13
|
+
*/
|
|
14
|
+
const BBOX_CORNERS_WITH_HEIGHT = 6;
|
|
15
|
+
/**
|
|
16
|
+
* Parse a `bbox` value.
|
|
17
|
+
*
|
|
18
|
+
* @param options.withHeight Admit the six-number form of OGC API Features Part 1,
|
|
19
|
+
* Requirement 23 D: `minLon,minLat,minHeight,maxLon,maxLat,maxHeight`.
|
|
20
|
+
* Every feature here is a point without a height, so the returned box keeps the
|
|
21
|
+
* longitudes and latitudes and drops the heights.
|
|
22
|
+
* @returns The box, or a message that states the problem with the value.
|
|
23
|
+
*/
|
|
24
|
+
export function parseBBox(raw, options = {}) {
|
|
25
|
+
const parts = raw.split(",").map((part) => part.trim());
|
|
26
|
+
const numbers = parts.map((part) => (part === "" ? Number.NaN : Number(part)));
|
|
27
|
+
const sixNumbers = options.withHeight === true && numbers.length === BBOX_CORNERS_WITH_HEIGHT;
|
|
28
|
+
if ((numbers.length !== BBOX_CORNERS && !sixNumbers) || !numbers.every(Number.isFinite)) {
|
|
29
|
+
return options.withHeight
|
|
30
|
+
? "bbox: four or six comma-separated numbers are required, minLon,minLat,maxLon,maxLat or minLon,minLat,minHeight,maxLon,maxLat,maxHeight"
|
|
31
|
+
: "bbox: four comma-separated numbers are required, minLon,minLat,maxLon,maxLat";
|
|
32
|
+
}
|
|
33
|
+
if (sixNumbers && numbers[2] > numbers[5])
|
|
34
|
+
return "bbox: the minimum height exceeds the maximum";
|
|
35
|
+
const [minLon, minLat, maxLon, maxLat] = (sixNumbers ? [numbers[0], numbers[1], numbers[3], numbers[4]] : numbers);
|
|
36
|
+
if (!isValidLongitude(minLon) || !isValidLongitude(maxLon))
|
|
37
|
+
return "bbox: longitudes must lie in [-180, 180]";
|
|
38
|
+
if (!isValidLatitude(minLat) || !isValidLatitude(maxLat))
|
|
39
|
+
return "bbox: latitudes must lie in [-90, 90]";
|
|
40
|
+
if (minLat > maxLat)
|
|
41
|
+
return "bbox: the minimum latitude exceeds the maximum";
|
|
42
|
+
return [minLon, minLat, maxLon, maxLat];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Whether a point lies inside the box, edges included.
|
|
46
|
+
*
|
|
47
|
+
* A box whose minimum longitude exceeds its maximum crosses the antimeridian, as OGC API boxes may.
|
|
48
|
+
*/
|
|
49
|
+
export function searchBoxContains([minLon, minLat, maxLon, maxLat], lon, lat) {
|
|
50
|
+
if (lat < minLat || lat > maxLat)
|
|
51
|
+
return false;
|
|
52
|
+
return minLon <= maxLon ? lon >= minLon && lon <= maxLon : lon >= minLon || lon <= maxLon;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=bbox.js.map
|
package/out/bbox.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bbox.js","sourceRoot":"","sources":["../lib/bbox.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAElE;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAA;AAOxF;;GAEG;AACH,MAAM,YAAY,GAAG,CAAC,CAAA;AAEtB;;GAEG;AACH,MAAM,wBAAwB,GAAG,CAAC,CAAA;AAElC;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW,EAAE,OAAO,GAA6B,EAAE;IAC5E,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;IACvD,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAC9E,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,KAAK,IAAI,IAAI,OAAO,CAAC,MAAM,KAAK,wBAAwB,CAAA;IAE7F,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,YAAY,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzF,OAAO,OAAO,CAAC,UAAU;YACxB,CAAC,CAAC,wIAAwI;YAC1I,CAAC,CAAC,8EAA8E,CAAA;IAClF,CAAC;IAED,IAAI,UAAU,IAAI,OAAO,CAAC,CAAC,CAAE,GAAG,OAAO,CAAC,CAAC,CAAE;QAAE,OAAO,8CAA8C,CAAA;IAElG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CACxC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CACnC,CAAA;IAErC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC;QAAE,OAAO,0CAA0C,CAAA;IAE7G,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC;QAAE,OAAO,uCAAuC,CAAA;IAExG,IAAI,MAAM,GAAG,MAAM;QAAE,OAAO,gDAAgD,CAAA;IAE5E,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;AACxC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAU,EAAE,GAAW,EAAE,GAAW;IACpG,IAAI,GAAG,GAAG,MAAM,IAAI,GAAG,GAAG,MAAM;QAAE,OAAO,KAAK,CAAA;IAE9C,OAAO,MAAM,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,CAAA;AAC1F,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The forward geocoder behind `mailwoman-ogc serve`: the data layers the server composes,
|
|
3
|
+
* and the geocode of one query through its session.
|
|
4
|
+
*
|
|
5
|
+
* The module is separate from `main.ts` because that file runs the command line when it loads.
|
|
6
|
+
*/
|
|
7
|
+
import type { GeocodeResult } from "@mailwoman/core/geocode";
|
|
8
|
+
import { type DropInGeocoder } from "mailwoman/cli/kit/dropin";
|
|
9
|
+
/**
|
|
10
|
+
* What `mailwoman-ogc serve` opens to answer `/search` and to list its collections.
|
|
11
|
+
*/
|
|
12
|
+
export interface OGCGeocoder extends DropInGeocoder {
|
|
13
|
+
/**
|
|
14
|
+
* Geocodes one query.
|
|
15
|
+
*/
|
|
16
|
+
geocode(query: string): Promise<GeocodeResult>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Opens the gazetteer and the server's session, and ends the process when either is unavailable.
|
|
20
|
+
*
|
|
21
|
+
* @param candidateDBFlag The `--candidate-db` value, or `null` to read the conventional path.
|
|
22
|
+
*/
|
|
23
|
+
export declare function openOGCGeocoder(candidateDBFlag: string | null): Promise<OGCGeocoder>;
|
|
24
|
+
//# sourceMappingURL=geocoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geocoder.d.ts","sourceRoot":"","sources":["../../cli/geocoder.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,KAAK,cAAc,EAAsB,MAAM,0BAA0B,CAAA;AAmBlF;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,cAAc;IAClD;;OAEG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;CAC9C;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,CAI1F"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Teffen Ellis and Mailwoman contributors
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
|
|
3
|
+
import { openDropInGeocoder } from "mailwoman/cli/kit/dropin";
|
|
4
|
+
import { banLayer, forkEntityProbe, observationRoutes, osmLayer, regionDatabases } from "mailwoman/services/entry/node";
|
|
5
|
+
/**
|
|
6
|
+
* The data layers the OGC server composes.
|
|
7
|
+
*
|
|
8
|
+
* The server consults the national open register (BAN) and then the OpenStreetMap tier,
|
|
9
|
+
* as the Photon and Nominatim servers do.
|
|
10
|
+
* It leaves national Overture out, so `/search` reads every collection it lists.
|
|
11
|
+
*/
|
|
12
|
+
const OGC_LAYERS = [
|
|
13
|
+
banLayer,
|
|
14
|
+
osmLayer,
|
|
15
|
+
regionDatabases,
|
|
16
|
+
forkEntityProbe,
|
|
17
|
+
observationRoutes,
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* Opens the gazetteer and the server's session, and ends the process when either is unavailable.
|
|
21
|
+
*
|
|
22
|
+
* @param candidateDBFlag The `--candidate-db` value, or `null` to read the conventional path.
|
|
23
|
+
*/
|
|
24
|
+
export async function openOGCGeocoder(candidateDBFlag) {
|
|
25
|
+
const opened = await openDropInGeocoder(candidateDBFlag, OGC_LAYERS);
|
|
26
|
+
return { ...opened, geocode: async (query) => (await opened.session.geocode(query)).result };
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=geocoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geocoder.js","sourceRoot":"","sources":["../../cli/geocoder.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,kEAAkE;AAUlE,OAAO,EAAuB,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAElF,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,iBAAiB,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAEvH;;;;;;GAMG;AACH,MAAM,UAAU,GAAiC;IAChD,QAAQ;IACR,QAAQ;IACR,eAAe;IACf,eAAe;IACf,iBAAiB;CACjB,CAAA;AAYD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,eAA8B;IACnE,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC,eAAe,EAAE,UAAU,CAAC,CAAA;IAEpE,OAAO,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAA;AAC7F,CAAC"}
|