@vectoriahq/quac 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/README.md +35 -2
- package/dist/generate/arcgisStacCatalogue.d.ts +46 -0
- package/dist/generate/arcgisStacCatalogue.js +189 -0
- package/dist/generate/externalStacCatalogue.d.ts +53 -0
- package/dist/generate/externalStacCatalogue.js +145 -0
- package/dist/generate/fileLayerCollection.d.ts +44 -0
- package/dist/generate/fileLayerCollection.js +72 -0
- package/dist/generate/folderStacCatalogue.d.ts +48 -0
- package/dist/generate/folderStacCatalogue.js +69 -0
- package/dist/generate/normalizedProject.d.ts +451 -0
- package/dist/generate/normalizedProject.js +925 -0
- package/dist/generate/ogcFeaturesStacCatalogue.d.ts +49 -0
- package/dist/generate/ogcFeaturesStacCatalogue.js +207 -0
- package/dist/generate/qmlForLayer.d.ts +17 -0
- package/dist/generate/qmlForLayer.js +36 -0
- package/dist/generate/serverLayerTree.d.ts +44 -0
- package/dist/generate/serverLayerTree.js +50 -0
- package/dist/generate/serverStacCatalogue.d.ts +84 -0
- package/dist/generate/serverStacCatalogue.js +327 -0
- package/dist/generate/stacCatalogue.d.ts +110 -0
- package/dist/generate/stacCatalogue.js +882 -0
- package/dist/generate/wfsStacCatalogue.d.ts +37 -0
- package/dist/generate/wfsStacCatalogue.js +127 -0
- package/dist/generate/wmsStacCatalogue.d.ts +46 -0
- package/dist/generate/wmsStacCatalogue.js +228 -0
- package/dist/index.d.ts +77 -0
- package/dist/index.js +52 -0
- package/dist/model/QgsProject.d.ts +722 -0
- package/dist/model/QgsProject.js +15 -0
- package/dist/model/Stac.d.ts +320 -0
- package/dist/model/Stac.js +16 -0
- package/dist/model/WmsProject.d.ts +105 -0
- package/dist/model/WmsProject.js +1 -0
- package/dist/model/arcgis.d.ts +134 -0
- package/dist/model/arcgis.js +1 -0
- package/dist/model/delimitedText.d.ts +38 -0
- package/dist/model/delimitedText.js +46 -0
- package/dist/model/featureFilter.d.ts +41 -0
- package/dist/model/featureFilter.js +24 -0
- package/dist/model/fieldIconAddress.d.ts +27 -0
- package/dist/model/fieldIconAddress.js +93 -0
- package/dist/model/ogcFeatures.d.ts +40 -0
- package/dist/model/ogcFeatures.js +6 -0
- package/dist/model/quacExtension.d.ts +28 -0
- package/dist/model/quacExtension.js +75 -0
- package/dist/model/stacAssetRoles.d.ts +33 -0
- package/dist/model/stacAssetRoles.js +44 -0
- package/dist/model/stacCollectionNotes.d.ts +21 -0
- package/dist/model/stacCollectionNotes.js +44 -0
- package/dist/model/stacHref.d.ts +56 -0
- package/dist/model/stacHref.js +93 -0
- package/dist/model/stacPmtiles.d.ts +38 -0
- package/dist/model/stacPmtiles.js +69 -0
- package/dist/model/stacSizeAndCount.d.ts +14 -0
- package/dist/model/stacSizeAndCount.js +20 -0
- package/dist/model/stacStyles.d.ts +93 -0
- package/dist/model/stacStyles.js +87 -0
- package/dist/model/stacTreeWalk.d.ts +36 -0
- package/dist/model/stacTreeWalk.js +76 -0
- package/dist/model/stacWms.d.ts +18 -0
- package/dist/model/stacWms.js +73 -0
- package/dist/model/stacWmts.d.ts +34 -0
- package/dist/model/stacWmts.js +90 -0
- package/dist/model/stacXyz.d.ts +24 -0
- package/dist/model/stacXyz.js +46 -0
- package/dist/model/wfs.d.ts +136 -0
- package/dist/model/wfs.js +1 -0
- package/dist/parse/collectLayerVisibility.d.ts +10 -0
- package/dist/parse/collectLayerVisibility.js +22 -0
- package/dist/parse/customProperties.d.ts +18 -0
- package/dist/parse/customProperties.js +43 -0
- package/dist/parse/geometrySiblings.d.ts +25 -0
- package/dist/parse/geometrySiblings.js +83 -0
- package/dist/parse/parseBrandColour.d.ts +14 -0
- package/dist/parse/parseBrandColour.js +25 -0
- package/dist/parse/parseDataDefinedEditable.d.ts +38 -0
- package/dist/parse/parseDataDefinedEditable.js +76 -0
- package/dist/parse/parseDataSource.d.ts +53 -0
- package/dist/parse/parseDataSource.js +484 -0
- package/dist/parse/parseExtent.d.ts +17 -0
- package/dist/parse/parseExtent.js +49 -0
- package/dist/parse/parseFormLayout.d.ts +26 -0
- package/dist/parse/parseFormLayout.js +60 -0
- package/dist/parse/parseGetProjectSettings.d.ts +15 -0
- package/dist/parse/parseGetProjectSettings.js +172 -0
- package/dist/parse/parseLayers.d.ts +23 -0
- package/dist/parse/parseLayers.js +1122 -0
- package/dist/parse/parseLegendTree.d.ts +20 -0
- package/dist/parse/parseLegendTree.js +66 -0
- package/dist/parse/parseMeasurement.d.ts +21 -0
- package/dist/parse/parseMeasurement.js +67 -0
- package/dist/parse/parseMergin.d.ts +19 -0
- package/dist/parse/parseMergin.js +51 -0
- package/dist/parse/parseProjectVariables.d.ts +9 -0
- package/dist/parse/parseProjectVariables.js +19 -0
- package/dist/parse/parseQfieldSync.d.ts +47 -0
- package/dist/parse/parseQfieldSync.js +95 -0
- package/dist/parse/parseQgsXml.d.ts +15 -0
- package/dist/parse/parseQgsXml.js +100 -0
- package/dist/parse/parseRelations.d.ts +19 -0
- package/dist/parse/parseRelations.js +64 -0
- package/dist/parse/parseStyle.d.ts +33 -0
- package/dist/parse/parseStyle.js +128 -0
- package/dist/parse/parseWmsPublishing.d.ts +21 -0
- package/dist/parse/parseWmsPublishing.js +38 -0
- package/dist/parse/projectProperties.d.ts +15 -0
- package/dist/parse/projectProperties.js +27 -0
- package/dist/parse/qgisExpression.d.ts +194 -0
- package/dist/parse/qgisExpression.js +859 -0
- package/dist/parse/qtDateFormat.d.ts +74 -0
- package/dist/parse/qtDateFormat.js +324 -0
- package/dist/parse/qtRegex.d.ts +67 -0
- package/dist/parse/qtRegex.js +397 -0
- package/dist/parse/readProjectFile.d.ts +7 -0
- package/dist/parse/readProjectFile.js +27 -0
- package/dist/sources/qgisServerUrl.d.ts +6 -0
- package/dist/sources/qgisServerUrl.js +17 -0
- package/dist/sources/stacDocuments.d.ts +40 -0
- package/dist/sources/stacDocuments.js +85 -0
- package/dist/sources/stacItems.d.ts +109 -0
- package/dist/sources/stacItems.js +287 -0
- package/dist/util/catalogueFileFormats.d.ts +58 -0
- package/dist/util/catalogueFileFormats.js +64 -0
- package/dist/util/devLog.d.ts +11 -0
- package/dist/util/devLog.js +23 -0
- package/dist/util/fileName.d.ts +18 -0
- package/dist/util/fileName.js +45 -0
- package/dist/util/wfsVersions.d.ts +9 -0
- package/dist/util/wfsVersions.js +13 -0
- package/package.json +47 -4
- package/src/schema/quac.schema.json +935 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { StacCollection, StacItem } from '../model/Stac.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Reading the Items inside a STAC API's Collection.
|
|
4
|
+
*
|
|
5
|
+
* A static catalogue puts its data on the Collection — one downloadable asset,
|
|
6
|
+
* which `classifyStacCollectionFormat` reads and the rest of the app loads. A
|
|
7
|
+
* STAC API does not: its Collections have no such asset, and every file sits on
|
|
8
|
+
* an Item inside, reached through the Collection's `rel: "items"` link. Without
|
|
9
|
+
* this module every Collection a STAC API lists classifies as unsupported.
|
|
10
|
+
*
|
|
11
|
+
* The one deliberate shape here is `itemAsCollection`: rather than teach the
|
|
12
|
+
* four load paths about a second kind of thing, an Item is rewritten as a
|
|
13
|
+
* Collection with the same assets. `classifyStacCollectionFormat`,
|
|
14
|
+
* `readCogDisplaySource`, `readPmtilesDisplaySource` and
|
|
15
|
+
* `loadStacCollectionData` then all work on an Item with no change of their
|
|
16
|
+
* own, and an item-backed layer is the same kind of layer as a collection-backed
|
|
17
|
+
* one everywhere downstream.
|
|
18
|
+
*/
|
|
19
|
+
/** How many Items one page of the list asks for. */
|
|
20
|
+
export declare const ITEMS_PAGE_SIZE = 20;
|
|
21
|
+
/** The row id recording which Item inside which Collection. */
|
|
22
|
+
export declare function encodeItemRowId(collectionId: string, itemId: string): string;
|
|
23
|
+
/** The Collection and Item ids back out of a row id, or null if it is not one. */
|
|
24
|
+
export declare function decodeItemRowId(rowId: string): {
|
|
25
|
+
collectionId: string;
|
|
26
|
+
itemId: string;
|
|
27
|
+
} | null;
|
|
28
|
+
/** The Collection's `rel: "items"` link href, or null when it has none. */
|
|
29
|
+
export declare function readItemsHref(collection: StacCollection): string | null;
|
|
30
|
+
/** One page of Items, and where the next page is if the service returned one. */
|
|
31
|
+
export interface StacItemsPage {
|
|
32
|
+
items: StacItem[];
|
|
33
|
+
/** The `rel: "next"` href, or null at the end of the list. */
|
|
34
|
+
nextHref: string | null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Adds the paging and ordering parameters to a Collection's items href.
|
|
38
|
+
*
|
|
39
|
+
* `sortby=-datetime` and `limit` are the parameters a STAC API is expected to
|
|
40
|
+
* accept for ordering and page size. Which specification defines each, and what
|
|
41
|
+
* a service implementing neither does with them, were not established here — no
|
|
42
|
+
* STAC API and no specification document was reachable from the environment this
|
|
43
|
+
* was written in — so nothing downstream relies on either being honoured:
|
|
44
|
+
* `sortItemsNewestFirst` re-sorts whatever page comes back.
|
|
45
|
+
*
|
|
46
|
+
* An href that already has either parameter is left with what it declares.
|
|
47
|
+
*/
|
|
48
|
+
export declare function buildItemsPageUrl(itemsHref: string, pageSize?: number): string;
|
|
49
|
+
/**
|
|
50
|
+
* The instant an Item is filed under, as an epoch milliseconds number, or null
|
|
51
|
+
* when it declares none.
|
|
52
|
+
*
|
|
53
|
+
* `properties.datetime` is the usual field; an Item with `start_datetime`
|
|
54
|
+
* instead is placed by that. Whichever is present is taken rather than assuming
|
|
55
|
+
* `datetime`.
|
|
56
|
+
*/
|
|
57
|
+
export declare function readItemTimestamp(item: StacItem): number | null;
|
|
58
|
+
/**
|
|
59
|
+
* Orders Items newest first, leaving those with no date at the end in the order
|
|
60
|
+
* the service listed them.
|
|
61
|
+
*
|
|
62
|
+
* This runs over the page the service returned, and is what makes the list read
|
|
63
|
+
* newest-first against a service that ignored `sortby`. It cannot make the page
|
|
64
|
+
* itself the newest Items in the Collection — only the service can choose which
|
|
65
|
+
* Items a page holds — so against such a service the ordering is within the page
|
|
66
|
+
* rather than across the whole list.
|
|
67
|
+
*/
|
|
68
|
+
export declare function sortItemsNewestFirst(items: StacItem[]): StacItem[];
|
|
69
|
+
/**
|
|
70
|
+
* Type-checks one fetched page of Items and resolves each Item's hrefs against
|
|
71
|
+
* the address it is served at. `url` is the address the page was fetched from.
|
|
72
|
+
* Throws when the response is not a GeoJSON FeatureCollection.
|
|
73
|
+
*/
|
|
74
|
+
export declare function readItemsPage(json: unknown, url: string): StacItemsPage;
|
|
75
|
+
/**
|
|
76
|
+
* The address of one Item under a Collection's items href.
|
|
77
|
+
*
|
|
78
|
+
* Both ways into an Item build their base through here, so the item list and the
|
|
79
|
+
* item document agree on where an Item's relative assets are even when the Item
|
|
80
|
+
* has no `self` link to settle it.
|
|
81
|
+
*
|
|
82
|
+
* The items href's own query string is kept. It is the service's, not this
|
|
83
|
+
* module's — an items link with an API key or a format selector needs it on
|
|
84
|
+
* the item request too, and dropping it turns a browsable Collection into one
|
|
85
|
+
* that fails on reopening.
|
|
86
|
+
*/
|
|
87
|
+
export declare function buildItemUrl(itemsHref: string, itemId: string): string;
|
|
88
|
+
/**
|
|
89
|
+
* Type-checks one fetched Item and resolves its hrefs. `url` is the address it
|
|
90
|
+
* was fetched from, as `buildItemUrl` builds it. Throws when the response is
|
|
91
|
+
* not a STAC Item.
|
|
92
|
+
*/
|
|
93
|
+
export declare function readItem(json: unknown, url: string): StacItem;
|
|
94
|
+
/**
|
|
95
|
+
* Rewrites an Item as a Collection with the same assets, so every existing
|
|
96
|
+
* load path reads it without knowing it came from an Item.
|
|
97
|
+
*
|
|
98
|
+
* The parent Collection supplies the licence, which an Item does not have. The
|
|
99
|
+
* Item's own `bbox` becomes the spatial extent; an Item without one falls back to
|
|
100
|
+
* the parent's, because an absent bbox says nothing about where the data is
|
|
101
|
+
* rather than saying it is nowhere. Its dates are its own — see the extent below.
|
|
102
|
+
*
|
|
103
|
+
* The id is the encoded pair, not the Item's own id: it is what the workspace
|
|
104
|
+
* connection records, and the Item's id alone would not say which Collection to
|
|
105
|
+
* look in when the map is rebuilt.
|
|
106
|
+
*/
|
|
107
|
+
export declare function itemAsCollection(item: StacItem, parent: StacCollection): StacCollection;
|
|
108
|
+
/** What an Item is called on screen — its own title, else its id. */
|
|
109
|
+
export declare function describeItem(item: StacItem): string;
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { STAC_VERSION } from "../model/Stac.js";
|
|
2
|
+
/**
|
|
3
|
+
* Reading the Items inside a STAC API's Collection.
|
|
4
|
+
*
|
|
5
|
+
* A static catalogue puts its data on the Collection — one downloadable asset,
|
|
6
|
+
* which `classifyStacCollectionFormat` reads and the rest of the app loads. A
|
|
7
|
+
* STAC API does not: its Collections have no such asset, and every file sits on
|
|
8
|
+
* an Item inside, reached through the Collection's `rel: "items"` link. Without
|
|
9
|
+
* this module every Collection a STAC API lists classifies as unsupported.
|
|
10
|
+
*
|
|
11
|
+
* The one deliberate shape here is `itemAsCollection`: rather than teach the
|
|
12
|
+
* four load paths about a second kind of thing, an Item is rewritten as a
|
|
13
|
+
* Collection with the same assets. `classifyStacCollectionFormat`,
|
|
14
|
+
* `readCogDisplaySource`, `readPmtilesDisplaySource` and
|
|
15
|
+
* `loadStacCollectionData` then all work on an Item with no change of their
|
|
16
|
+
* own, and an item-backed layer is the same kind of layer as a collection-backed
|
|
17
|
+
* one everywhere downstream.
|
|
18
|
+
*/
|
|
19
|
+
/** How many Items one page of the list asks for. */
|
|
20
|
+
export const ITEMS_PAGE_SIZE = 20;
|
|
21
|
+
/**
|
|
22
|
+
* Separates the two halves of an item row's id. An Item is identified by the
|
|
23
|
+
* Collection holding it as well as by its own id, and both are needed to fetch
|
|
24
|
+
* it again — so the pair is passed as one string through the picker's selection
|
|
25
|
+
* set, the workspace connection's `collectionIds`, and a share link.
|
|
26
|
+
*
|
|
27
|
+
* Shaped like the path `buildItemUrl` builds from the Collection's items href
|
|
28
|
+
* (`<items href>/<item id>`), so the recorded value reads as what it addresses.
|
|
29
|
+
* Whether every STAC API serves an Item at that address was not established
|
|
30
|
+
* here. Split on the last occurrence, not the first: a Collection id may itself
|
|
31
|
+
* contain a slash.
|
|
32
|
+
*/
|
|
33
|
+
const ITEM_ID_SEPARATOR = '/items/';
|
|
34
|
+
/** The row id recording which Item inside which Collection. */
|
|
35
|
+
export function encodeItemRowId(collectionId, itemId) {
|
|
36
|
+
return `${collectionId}${ITEM_ID_SEPARATOR}${itemId}`;
|
|
37
|
+
}
|
|
38
|
+
/** The Collection and Item ids back out of a row id, or null if it is not one. */
|
|
39
|
+
export function decodeItemRowId(rowId) {
|
|
40
|
+
const index = rowId.lastIndexOf(ITEM_ID_SEPARATOR);
|
|
41
|
+
if (index <= 0)
|
|
42
|
+
return null;
|
|
43
|
+
const collectionId = rowId.slice(0, index);
|
|
44
|
+
const itemId = rowId.slice(index + ITEM_ID_SEPARATOR.length);
|
|
45
|
+
if (!collectionId || !itemId)
|
|
46
|
+
return null;
|
|
47
|
+
return { collectionId, itemId };
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The link with a relation, preferring one that answers JSON.
|
|
51
|
+
*
|
|
52
|
+
* A document may list the same relation more than once in different renditions —
|
|
53
|
+
* an HTML page beside the JSON. Taking the first match blindly can hand an HTML
|
|
54
|
+
* address to a JSON parser, so a link declaring a JSON media type wins, and a
|
|
55
|
+
* link declaring no type is taken over one declaring something else.
|
|
56
|
+
*/
|
|
57
|
+
function findLink(links, rel) {
|
|
58
|
+
const candidates = (links ?? []).filter((link) => link.rel === rel && link.href);
|
|
59
|
+
return candidates.find((link) => link.type?.includes('json'))
|
|
60
|
+
?? candidates.find((link) => !link.type)
|
|
61
|
+
?? candidates[0]
|
|
62
|
+
?? null;
|
|
63
|
+
}
|
|
64
|
+
/** The Collection's `rel: "items"` link href, or null when it has none. */
|
|
65
|
+
export function readItemsHref(collection) {
|
|
66
|
+
return findLink(collection.links, 'items')?.href ?? null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Adds the paging and ordering parameters to a Collection's items href.
|
|
70
|
+
*
|
|
71
|
+
* `sortby=-datetime` and `limit` are the parameters a STAC API is expected to
|
|
72
|
+
* accept for ordering and page size. Which specification defines each, and what
|
|
73
|
+
* a service implementing neither does with them, were not established here — no
|
|
74
|
+
* STAC API and no specification document was reachable from the environment this
|
|
75
|
+
* was written in — so nothing downstream relies on either being honoured:
|
|
76
|
+
* `sortItemsNewestFirst` re-sorts whatever page comes back.
|
|
77
|
+
*
|
|
78
|
+
* An href that already has either parameter is left with what it declares.
|
|
79
|
+
*/
|
|
80
|
+
export function buildItemsPageUrl(itemsHref, pageSize = ITEMS_PAGE_SIZE) {
|
|
81
|
+
try {
|
|
82
|
+
const url = new URL(itemsHref);
|
|
83
|
+
if (!url.searchParams.has('limit'))
|
|
84
|
+
url.searchParams.set('limit', String(pageSize));
|
|
85
|
+
if (!url.searchParams.has('sortby'))
|
|
86
|
+
url.searchParams.set('sortby', '-datetime');
|
|
87
|
+
return url.toString();
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
// A relative or malformed href is left exactly as it stands: the caller
|
|
91
|
+
// resolved it against its document already, and guessing here would only
|
|
92
|
+
// turn a fetchable address into an unfetchable one.
|
|
93
|
+
return itemsHref;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The instant an Item is filed under, as an epoch milliseconds number, or null
|
|
98
|
+
* when it declares none.
|
|
99
|
+
*
|
|
100
|
+
* `properties.datetime` is the usual field; an Item with `start_datetime`
|
|
101
|
+
* instead is placed by that. Whichever is present is taken rather than assuming
|
|
102
|
+
* `datetime`.
|
|
103
|
+
*/
|
|
104
|
+
export function readItemTimestamp(item) {
|
|
105
|
+
const raw = item.properties?.datetime ?? item.properties?.start_datetime;
|
|
106
|
+
if (typeof raw !== 'string')
|
|
107
|
+
return null;
|
|
108
|
+
const parsed = Date.parse(raw);
|
|
109
|
+
return Number.isNaN(parsed) ? null : parsed;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Orders Items newest first, leaving those with no date at the end in the order
|
|
113
|
+
* the service listed them.
|
|
114
|
+
*
|
|
115
|
+
* This runs over the page the service returned, and is what makes the list read
|
|
116
|
+
* newest-first against a service that ignored `sortby`. It cannot make the page
|
|
117
|
+
* itself the newest Items in the Collection — only the service can choose which
|
|
118
|
+
* Items a page holds — so against such a service the ordering is within the page
|
|
119
|
+
* rather than across the whole list.
|
|
120
|
+
*/
|
|
121
|
+
export function sortItemsNewestFirst(items) {
|
|
122
|
+
return [...items]
|
|
123
|
+
.map((item, index) => ({ item, index, at: readItemTimestamp(item) }))
|
|
124
|
+
.sort((left, right) => {
|
|
125
|
+
if (left.at === right.at)
|
|
126
|
+
return left.index - right.index;
|
|
127
|
+
if (left.at === null)
|
|
128
|
+
return 1;
|
|
129
|
+
if (right.at === null)
|
|
130
|
+
return -1;
|
|
131
|
+
return right.at - left.at;
|
|
132
|
+
})
|
|
133
|
+
.map((entry) => entry.item);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Type-checks one fetched page of Items and resolves each Item's hrefs against
|
|
137
|
+
* the address it is served at. `url` is the address the page was fetched from.
|
|
138
|
+
* Throws when the response is not a GeoJSON FeatureCollection.
|
|
139
|
+
*/
|
|
140
|
+
export function readItemsPage(json, url) {
|
|
141
|
+
const page = json;
|
|
142
|
+
if (!Array.isArray(page?.features)) {
|
|
143
|
+
throw new Error('Item list did not return a GeoJSON FeatureCollection');
|
|
144
|
+
}
|
|
145
|
+
const items = page.features
|
|
146
|
+
.filter((feature) => feature?.type === 'Feature' && Boolean(feature.id))
|
|
147
|
+
.map((feature) => resolveItemHrefs(feature, itemBaseUrl(feature, buildItemUrl(url, String(feature.id)))));
|
|
148
|
+
// Resolved against the page it came from: a `next` href may come back
|
|
149
|
+
// relative, and by the time it is followed this URL is gone.
|
|
150
|
+
const nextLink = findLink(page.links, 'next');
|
|
151
|
+
let nextHref = null;
|
|
152
|
+
if (nextLink?.href) {
|
|
153
|
+
try {
|
|
154
|
+
nextHref = new URL(nextLink.href, url).toString();
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
nextHref = null;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return { items: sortItemsNewestFirst(items), nextHref };
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* The address of one Item under a Collection's items href.
|
|
164
|
+
*
|
|
165
|
+
* Both ways into an Item build their base through here, so the item list and the
|
|
166
|
+
* item document agree on where an Item's relative assets are even when the Item
|
|
167
|
+
* has no `self` link to settle it.
|
|
168
|
+
*
|
|
169
|
+
* The items href's own query string is kept. It is the service's, not this
|
|
170
|
+
* module's — an items link with an API key or a format selector needs it on
|
|
171
|
+
* the item request too, and dropping it turns a browsable Collection into one
|
|
172
|
+
* that fails on reopening.
|
|
173
|
+
*/
|
|
174
|
+
export function buildItemUrl(itemsHref, itemId) {
|
|
175
|
+
const [path, query] = itemsHref.split('?');
|
|
176
|
+
const base = `${path.replace(/\/$/, '')}/${encodeURIComponent(itemId)}`;
|
|
177
|
+
return query ? `${base}?${query}` : base;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Type-checks one fetched Item and resolves its hrefs. `url` is the address it
|
|
181
|
+
* was fetched from, as `buildItemUrl` builds it. Throws when the response is
|
|
182
|
+
* not a STAC Item.
|
|
183
|
+
*/
|
|
184
|
+
export function readItem(json, url) {
|
|
185
|
+
const item = json;
|
|
186
|
+
if (item?.type !== 'Feature' || !item.id) {
|
|
187
|
+
throw new Error(`Response is not a STAC Item (type=${item?.type})`);
|
|
188
|
+
}
|
|
189
|
+
return resolveItemHrefs(item, itemBaseUrl(item, url));
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* The address an Item's relative hrefs resolve against: its own `rel: "self"`
|
|
193
|
+
* link, falling back to `itemAddress` — which both callers build through
|
|
194
|
+
* `buildItemUrl`, so the fallback resolves to the same place either way.
|
|
195
|
+
*
|
|
196
|
+
* The same Item is read through the item list when it is picked and through its
|
|
197
|
+
* own document when the map is rebuilt. Resolving `./scene.tif` against whichever
|
|
198
|
+
* URL happened to fetch it would give two different addresses for one file, and
|
|
199
|
+
* at most one of them exists — so the layer would load when added and fail on
|
|
200
|
+
* reopening.
|
|
201
|
+
*/
|
|
202
|
+
function itemBaseUrl(item, itemAddress) {
|
|
203
|
+
const self = findLink(item.links, 'self')?.href;
|
|
204
|
+
if (!self)
|
|
205
|
+
return itemAddress;
|
|
206
|
+
try {
|
|
207
|
+
return new URL(self, itemAddress).toString();
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
return itemAddress;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Rewrites an Item's asset and link hrefs to absolute addresses against the URL
|
|
215
|
+
* the Item came from, the same way `resolveDocumentHrefs` does for a Catalog or
|
|
216
|
+
* Collection in `stacDocuments.ts`.
|
|
217
|
+
*
|
|
218
|
+
* An Item's asset href may be relative to the item document — `./scene.tif`
|
|
219
|
+
* beside it. By the time a loader reads that href the document it was relative
|
|
220
|
+
* to is gone, so without this the app resolves it against its own address and
|
|
221
|
+
* fetches nothing. An href already absolute passes through
|
|
222
|
+
* unchanged, and one that cannot be resolved is left as it stands.
|
|
223
|
+
*/
|
|
224
|
+
function resolveItemHrefs(item, url) {
|
|
225
|
+
const absolute = (href) => {
|
|
226
|
+
if (!href || href.startsWith('#'))
|
|
227
|
+
return href;
|
|
228
|
+
try {
|
|
229
|
+
return new URL(href, url).toString();
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
return href;
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
return {
|
|
236
|
+
...item,
|
|
237
|
+
...(item.assets
|
|
238
|
+
? {
|
|
239
|
+
assets: Object.fromEntries(Object.entries(item.assets).map(([key, asset]) => [key, { ...asset, href: absolute(asset.href) }]))
|
|
240
|
+
}
|
|
241
|
+
: {}),
|
|
242
|
+
...(item.links ? { links: item.links.map((link) => ({ ...link, href: absolute(link.href) })) } : {})
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Rewrites an Item as a Collection with the same assets, so every existing
|
|
247
|
+
* load path reads it without knowing it came from an Item.
|
|
248
|
+
*
|
|
249
|
+
* The parent Collection supplies the licence, which an Item does not have. The
|
|
250
|
+
* Item's own `bbox` becomes the spatial extent; an Item without one falls back to
|
|
251
|
+
* the parent's, because an absent bbox says nothing about where the data is
|
|
252
|
+
* rather than saying it is nowhere. Its dates are its own — see the extent below.
|
|
253
|
+
*
|
|
254
|
+
* The id is the encoded pair, not the Item's own id: it is what the workspace
|
|
255
|
+
* connection records, and the Item's id alone would not say which Collection to
|
|
256
|
+
* look in when the map is rebuilt.
|
|
257
|
+
*/
|
|
258
|
+
export function itemAsCollection(item, parent) {
|
|
259
|
+
const bbox = Array.isArray(item.bbox) && item.bbox.length >= 4
|
|
260
|
+
? [item.bbox]
|
|
261
|
+
: parent.extent?.spatial?.bbox ?? [[-180, -90, 180, 90]];
|
|
262
|
+
// The item's own dates only. An item declaring none gets STAC's open interval
|
|
263
|
+
// rather than the parent's extent: the Collection's range is not this item's
|
|
264
|
+
// date, and borrowing it would put a date on screen that nothing declared.
|
|
265
|
+
const at = item.properties?.datetime ?? item.properties?.start_datetime ?? null;
|
|
266
|
+
const end = item.properties?.end_datetime ?? item.properties?.datetime ?? null;
|
|
267
|
+
const interval = [[at, end]];
|
|
268
|
+
return {
|
|
269
|
+
type: 'Collection',
|
|
270
|
+
stac_version: STAC_VERSION,
|
|
271
|
+
id: encodeItemRowId(parent.id, item.id),
|
|
272
|
+
title: describeItem(item),
|
|
273
|
+
description: typeof item.properties?.description === 'string'
|
|
274
|
+
? item.properties.description
|
|
275
|
+
: `Item ${item.id} from ${parent.title ?? parent.id}.`,
|
|
276
|
+
license: parent.license ?? 'other',
|
|
277
|
+
...(parent.providers ? { providers: parent.providers } : {}),
|
|
278
|
+
extent: { spatial: { bbox }, temporal: { interval } },
|
|
279
|
+
...(item.assets ? { assets: item.assets } : {}),
|
|
280
|
+
links: item.links ?? []
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
/** What an Item is called on screen — its own title, else its id. */
|
|
284
|
+
export function describeItem(item) {
|
|
285
|
+
const title = item.properties?.title;
|
|
286
|
+
return typeof title === 'string' && title.trim() ? title.trim() : item.id;
|
|
287
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a catalogue says about each file format: its extensions and the media
|
|
3
|
+
* type an asset of that format declares. What an application does with a
|
|
4
|
+
* format, such as its name on screen or whether a layer from it saves, is the
|
|
5
|
+
* application's own.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* What a file is for: a layer's data, a table a project reads, a style for a
|
|
9
|
+
* layer, or a project of layers. A table is read where a project names it, as
|
|
10
|
+
* a lookup, a related dataset or a layer, and never on its own.
|
|
11
|
+
*/
|
|
12
|
+
export type LayerFileRole = 'data' | 'table' | 'style' | 'project';
|
|
13
|
+
/** The roles of a file a project layer's data source can name. */
|
|
14
|
+
export declare const PROJECT_DATA_ROLES: readonly LayerFileRole[];
|
|
15
|
+
/** One role, or any of several. */
|
|
16
|
+
export type RoleFilter = LayerFileRole | readonly LayerFileRole[];
|
|
17
|
+
export declare function hasRole(format: {
|
|
18
|
+
role: LayerFileRole;
|
|
19
|
+
}, role: RoleFilter | undefined): boolean;
|
|
20
|
+
export type LayerFileFormatId = 'geojson' | 'geoparquet' | 'flatgeobuf' | 'cog' | 'csv' | 'geopackage' | 'shapefile' | 'sld' | 'qml' | 'qgis-project';
|
|
21
|
+
export interface CatalogueFileFormat {
|
|
22
|
+
id: LayerFileFormatId;
|
|
23
|
+
role: LayerFileRole;
|
|
24
|
+
/** Lower-case, no leading dot. The first is the one written when a file is named. */
|
|
25
|
+
extensions: readonly string[];
|
|
26
|
+
/** Null for a project, which no Collection asset declares. */
|
|
27
|
+
mediaType: string | null;
|
|
28
|
+
}
|
|
29
|
+
export declare const GEOJSON_MEDIA_TYPE = "application/geo+json";
|
|
30
|
+
/** GeoParquet and plain Parquet, per Portolan's media-type registry. */
|
|
31
|
+
export declare const PARQUET_MEDIA_TYPE = "application/vnd.apache.parquet";
|
|
32
|
+
/**
|
|
33
|
+
* FlatGeobuf, as Portolan's CLI registers `.fgb`
|
|
34
|
+
* (`portolan_cli/extension_registry.py`, `portolan-sdi/portolan-cli@main`,
|
|
35
|
+
* read 2026-10-04).
|
|
36
|
+
*/
|
|
37
|
+
export declare const FLATGEOBUF_MEDIA_TYPE = "application/vnd.flatgeobuf";
|
|
38
|
+
/**
|
|
39
|
+
* COG (Cloud Optimized GeoTIFF), per Portolan's media-type registry. Stored as
|
|
40
|
+
* the Collection's `data`-role asset.
|
|
41
|
+
*/
|
|
42
|
+
export declare const COG_MEDIA_TYPE = "image/tiff; application=geotiff; profile=cloud-optimized";
|
|
43
|
+
/**
|
|
44
|
+
* GeoPackage, as IANA registers it with OGC as change controller
|
|
45
|
+
* (`iana.org/assignments/media-types/application/geopackage+sqlite3`, read
|
|
46
|
+
* 2026-10-26).
|
|
47
|
+
*/
|
|
48
|
+
export declare const GEOPACKAGE_MEDIA_TYPE = "application/geopackage+sqlite3";
|
|
49
|
+
/** CSV, as IANA registers it (RFC 4180). Portolan's registry names no CSV. */
|
|
50
|
+
export declare const CSV_MEDIA_TYPE = "text/csv";
|
|
51
|
+
/** QGIS layer style. QML has no registered media type, so this is an unregistered one. */
|
|
52
|
+
export declare const QML_STYLE_MEDIA_TYPE = "application/x-qgis-qml+xml";
|
|
53
|
+
/** In the order `LAYER_FILE_FORMATS` lists them, which is the order a lookup by extension tries. */
|
|
54
|
+
export declare const CATALOGUE_FILE_FORMATS: readonly CatalogueFileFormat[];
|
|
55
|
+
/** Whether a file name is in the given format, whatever route it came by. */
|
|
56
|
+
export declare function isLayerFileOfFormat(nameOrPath: string, id: LayerFileFormatId): boolean;
|
|
57
|
+
/** The media type a file is declared as in a catalogue, or `application/octet-stream`. */
|
|
58
|
+
export declare function declaredMediaTypeForFile(filename: string, role: RoleFilter): string;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { getLowerCaseExtension } from "./fileName.js";
|
|
2
|
+
/** The roles of a file a project layer's data source can name. */
|
|
3
|
+
export const PROJECT_DATA_ROLES = ['data', 'table'];
|
|
4
|
+
export function hasRole(format, role) {
|
|
5
|
+
if (!role)
|
|
6
|
+
return true;
|
|
7
|
+
return typeof role === 'string' ? format.role === role : role.includes(format.role);
|
|
8
|
+
}
|
|
9
|
+
export const GEOJSON_MEDIA_TYPE = 'application/geo+json';
|
|
10
|
+
/** GeoParquet and plain Parquet, per Portolan's media-type registry. */
|
|
11
|
+
export const PARQUET_MEDIA_TYPE = 'application/vnd.apache.parquet';
|
|
12
|
+
/**
|
|
13
|
+
* FlatGeobuf, as Portolan's CLI registers `.fgb`
|
|
14
|
+
* (`portolan_cli/extension_registry.py`, `portolan-sdi/portolan-cli@main`,
|
|
15
|
+
* read 2026-10-04).
|
|
16
|
+
*/
|
|
17
|
+
export const FLATGEOBUF_MEDIA_TYPE = 'application/vnd.flatgeobuf';
|
|
18
|
+
/**
|
|
19
|
+
* COG (Cloud Optimized GeoTIFF), per Portolan's media-type registry. Stored as
|
|
20
|
+
* the Collection's `data`-role asset.
|
|
21
|
+
*/
|
|
22
|
+
export const COG_MEDIA_TYPE = 'image/tiff; application=geotiff; profile=cloud-optimized';
|
|
23
|
+
/**
|
|
24
|
+
* GeoPackage, as IANA registers it with OGC as change controller
|
|
25
|
+
* (`iana.org/assignments/media-types/application/geopackage+sqlite3`, read
|
|
26
|
+
* 2026-10-26).
|
|
27
|
+
*/
|
|
28
|
+
export const GEOPACKAGE_MEDIA_TYPE = 'application/geopackage+sqlite3';
|
|
29
|
+
/** CSV, as IANA registers it (RFC 4180). Portolan's registry names no CSV. */
|
|
30
|
+
export const CSV_MEDIA_TYPE = 'text/csv';
|
|
31
|
+
/** QGIS layer style. QML has no registered media type, so this is an unregistered one. */
|
|
32
|
+
export const QML_STYLE_MEDIA_TYPE = 'application/x-qgis-qml+xml';
|
|
33
|
+
/** In the order `LAYER_FILE_FORMATS` lists them, which is the order a lookup by extension tries. */
|
|
34
|
+
export const CATALOGUE_FILE_FORMATS = [
|
|
35
|
+
{ id: 'geojson', role: 'data', extensions: ['geojson', 'json'], mediaType: GEOJSON_MEDIA_TYPE },
|
|
36
|
+
{ id: 'geoparquet', role: 'data', extensions: ['parquet'], mediaType: PARQUET_MEDIA_TYPE },
|
|
37
|
+
{ id: 'flatgeobuf', role: 'data', extensions: ['fgb'], mediaType: FLATGEOBUF_MEDIA_TYPE },
|
|
38
|
+
{ id: 'geopackage', role: 'data', extensions: ['gpkg'], mediaType: GEOPACKAGE_MEDIA_TYPE },
|
|
39
|
+
{ id: 'cog', role: 'data', extensions: ['tif', 'tiff'], mediaType: COG_MEDIA_TYPE },
|
|
40
|
+
{ id: 'csv', role: 'table', extensions: ['csv'], mediaType: CSV_MEDIA_TYPE },
|
|
41
|
+
{ id: 'shapefile', role: 'data', extensions: ['shp'], mediaType: 'application/x-esri-shape' },
|
|
42
|
+
{ id: 'sld', role: 'style', extensions: ['sld'], mediaType: 'application/vnd.ogc.sld+xml' },
|
|
43
|
+
{ id: 'qml', role: 'style', extensions: ['qml'], mediaType: QML_STYLE_MEDIA_TYPE },
|
|
44
|
+
{ id: 'qgis-project', role: 'project', extensions: ['qgs', 'qgz'], mediaType: null }
|
|
45
|
+
];
|
|
46
|
+
/** The format a file name's last extension belongs to, optionally only where it has the given role. */
|
|
47
|
+
function findCatalogueFileFormatByName(nameOrPath, role) {
|
|
48
|
+
const extension = getLowerCaseExtension(nameOrPath);
|
|
49
|
+
if (!extension)
|
|
50
|
+
return undefined;
|
|
51
|
+
return CATALOGUE_FILE_FORMATS.find((format) => format.extensions.includes(extension) && hasRole(format, role));
|
|
52
|
+
}
|
|
53
|
+
/** Whether a file name is in the given format, whatever route it came by. */
|
|
54
|
+
export function isLayerFileOfFormat(nameOrPath, id) {
|
|
55
|
+
return findCatalogueFileFormatByName(nameOrPath)?.id === id;
|
|
56
|
+
}
|
|
57
|
+
/** The media type a file is declared as in a catalogue, or `application/octet-stream`. */
|
|
58
|
+
export function declaredMediaTypeForFile(filename, role) {
|
|
59
|
+
const extension = filename.split('.').pop()?.toLowerCase() ?? '';
|
|
60
|
+
if (!extension)
|
|
61
|
+
return 'application/octet-stream';
|
|
62
|
+
return CATALOGUE_FILE_FORMATS.find((format) => format.extensions.includes(extension) && hasRole(format, role))?.mediaType
|
|
63
|
+
?? 'application/octet-stream';
|
|
64
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turns the package's logging on or off. It is off until an application turns
|
|
3
|
+
* it on; Groundwork turns it on in its development builds
|
|
4
|
+
* (`src/startDevLogging.ts`, which `src/main.tsx` imports first).
|
|
5
|
+
*/
|
|
6
|
+
export declare function setDevLogging(on: boolean): void;
|
|
7
|
+
/**
|
|
8
|
+
* Logs a message to the console while logging is on, and does nothing while
|
|
9
|
+
* it is off.
|
|
10
|
+
*/
|
|
11
|
+
export declare function devLog(category: string, message: string, data?: object): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
let enabled = false;
|
|
2
|
+
/**
|
|
3
|
+
* Turns the package's logging on or off. It is off until an application turns
|
|
4
|
+
* it on; Groundwork turns it on in its development builds
|
|
5
|
+
* (`src/startDevLogging.ts`, which `src/main.tsx` imports first).
|
|
6
|
+
*/
|
|
7
|
+
export function setDevLogging(on) {
|
|
8
|
+
enabled = on;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Logs a message to the console while logging is on, and does nothing while
|
|
12
|
+
* it is off.
|
|
13
|
+
*/
|
|
14
|
+
export function devLog(category, message, data) {
|
|
15
|
+
if (!enabled)
|
|
16
|
+
return;
|
|
17
|
+
if (data !== undefined) {
|
|
18
|
+
console.info(`[${category}] ${message}`, data);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
console.info(`[${category}] ${message}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts the trailing filename segment from a path-like string.
|
|
3
|
+
*/
|
|
4
|
+
export declare function getFileNameFromPath(nameOrPath: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Returns the lower-cased file extension (without dot), or null when absent.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getLowerCaseExtension(nameOrPath: string): string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Returns a trimmed, lower-cased basename without extension.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getNormalisedFileBasename(nameOrPath: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* The directory part of a path, or '' when there is none. Folder drops and file-layer
|
|
15
|
+
* collection ids both have a relative path, so this is what tells `north/sites.geojson`
|
|
16
|
+
* and `south/sites.geojson` apart.
|
|
17
|
+
*/
|
|
18
|
+
export declare function getParentFolderPath(nameOrPath: string): string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const PATH_SEPARATOR_PATTERN = /[/\\]/;
|
|
2
|
+
/**
|
|
3
|
+
* Extracts the trailing filename segment from a path-like string.
|
|
4
|
+
*/
|
|
5
|
+
export function getFileNameFromPath(nameOrPath) {
|
|
6
|
+
const trimmedValue = nameOrPath.trim();
|
|
7
|
+
if (!trimmedValue)
|
|
8
|
+
return '';
|
|
9
|
+
const pathSegments = trimmedValue.split(PATH_SEPARATOR_PATTERN);
|
|
10
|
+
return pathSegments[pathSegments.length - 1] ?? '';
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Returns the lower-cased file extension (without dot), or null when absent.
|
|
14
|
+
*/
|
|
15
|
+
export function getLowerCaseExtension(nameOrPath) {
|
|
16
|
+
const fileName = getFileNameFromPath(nameOrPath);
|
|
17
|
+
if (!fileName)
|
|
18
|
+
return null;
|
|
19
|
+
const extensionMatch = /\.([^.]+)$/.exec(fileName);
|
|
20
|
+
const extension = extensionMatch?.[1]?.trim().toLowerCase() ?? '';
|
|
21
|
+
return extension || null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns a trimmed, lower-cased basename without extension.
|
|
25
|
+
*/
|
|
26
|
+
export function getNormalisedFileBasename(nameOrPath) {
|
|
27
|
+
const fileName = getFileNameFromPath(nameOrPath);
|
|
28
|
+
if (!fileName)
|
|
29
|
+
return '';
|
|
30
|
+
const extensionMatch = /\.([^.]+)$/.exec(fileName);
|
|
31
|
+
const baseName = extensionMatch
|
|
32
|
+
? fileName.slice(0, Math.max(extensionMatch.index, 0))
|
|
33
|
+
: fileName;
|
|
34
|
+
return baseName.trim().toLowerCase();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The directory part of a path, or '' when there is none. Folder drops and file-layer
|
|
38
|
+
* collection ids both have a relative path, so this is what tells `north/sites.geojson`
|
|
39
|
+
* and `south/sites.geojson` apart.
|
|
40
|
+
*/
|
|
41
|
+
export function getParentFolderPath(nameOrPath) {
|
|
42
|
+
const forwardSlashPath = nameOrPath.trim().replace(/\\/g, '/');
|
|
43
|
+
const lastSeparatorIndex = forwardSlashPath.lastIndexOf('/');
|
|
44
|
+
return lastSeparatorIndex > 0 ? forwardSlashPath.slice(0, lastSeparatorIndex) : '';
|
|
45
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const DEFAULT_WFS_VERSION = "1.1.0";
|
|
2
|
+
export declare const WFS_FALLBACK_VERSION = "2.0.0";
|
|
3
|
+
/**
|
|
4
|
+
* The versions requests are sent and parsed in, highest first. 1.0.0 is left
|
|
5
|
+
* out: it has no `resultType=hits`, so a layer could not be counted in it.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SPOKEN_WFS_VERSIONS: readonly ["2.0.0", "1.1.0"];
|
|
8
|
+
/** The version a capabilities request asks for. */
|
|
9
|
+
export declare const WFS_CAPABILITIES_VERSION: "2.0.0";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// The WFS versions Groundwork speaks. Kept free of imports so a catalogue
|
|
2
|
+
// generator can read them without loading the WFS client, which loads OpenLayers.
|
|
3
|
+
export const DEFAULT_WFS_VERSION = '1.1.0';
|
|
4
|
+
// WFS 2.0.0 is used as a fallback for Esri servers, which require it for GeoJSON output and
|
|
5
|
+
// for accurate hits counts. See fetchWfsFeatureCollection and fetchWfsFeatureCount.
|
|
6
|
+
export const WFS_FALLBACK_VERSION = '2.0.0';
|
|
7
|
+
/**
|
|
8
|
+
* The versions requests are sent and parsed in, highest first. 1.0.0 is left
|
|
9
|
+
* out: it has no `resultType=hits`, so a layer could not be counted in it.
|
|
10
|
+
*/
|
|
11
|
+
export const SPOKEN_WFS_VERSIONS = ['2.0.0', DEFAULT_WFS_VERSION];
|
|
12
|
+
/** The version a capabilities request asks for. */
|
|
13
|
+
export const WFS_CAPABILITIES_VERSION = SPOKEN_WFS_VERSIONS[0];
|