@vectoriahq/quac 0.0.0-stage → 0.2.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 +143 -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 +452 -0
- package/dist/generate/normalizedProject.js +877 -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 +887 -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 +229 -0
- package/dist/index.d.ts +77 -0
- package/dist/index.js +52 -0
- package/dist/model/QgsProject.d.ts +724 -0
- package/dist/model/QgsProject.js +15 -0
- package/dist/model/Stac.d.ts +322 -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 +1125 -0
- package/dist/parse/parseLegendTree.d.ts +20 -0
- package/dist/parse/parseLegendTree.js +66 -0
- package/dist/parse/parseMeasurement.d.ts +20 -0
- package/dist/parse/parseMeasurement.js +66 -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 +10 -0
- package/dist/util/devLog.js +22 -0
- package/dist/util/fileName.d.ts +18 -0
- package/dist/util/fileName.js +45 -0
- package/dist/util/nonBlankText.d.ts +2 -0
- package/dist/util/nonBlankText.js +4 -0
- package/dist/util/wfsVersions.d.ts +9 -0
- package/dist/util/wfsVersions.js +13 -0
- package/package.json +55 -4
- package/src/schema/quac.schema.json +939 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { readDataAsset } from "./stacAssetRoles.js";
|
|
2
|
+
/** QGIS's defaults for a Delimited Text source that names nothing (`QgsDelimitedTextFile::setFromUrl`). */
|
|
3
|
+
export const DEFAULT_DELIMITED_TEXT_OPTIONS = {
|
|
4
|
+
delimiter: ',',
|
|
5
|
+
quote: '"',
|
|
6
|
+
escape: '"',
|
|
7
|
+
skipLines: 0,
|
|
8
|
+
header: true,
|
|
9
|
+
trim: false
|
|
10
|
+
};
|
|
11
|
+
/** The key a data asset takes for the options of a Delimited Text source. */
|
|
12
|
+
export const QUAC_DELIMITED_TEXT = 'quac:delimited_text';
|
|
13
|
+
/** The field as the catalogue writes it. */
|
|
14
|
+
export function delimitedTextField(options) {
|
|
15
|
+
return {
|
|
16
|
+
delimiter: options.delimiter,
|
|
17
|
+
quote: options.quote,
|
|
18
|
+
escape: options.escape,
|
|
19
|
+
skip_lines: options.skipLines,
|
|
20
|
+
header: options.header,
|
|
21
|
+
trim: options.trim
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A Collection's Delimited Text options, or null where its data asset names
|
|
26
|
+
* none, which is a file QGIS reads with OGR or no CSV at all. A key the field
|
|
27
|
+
* leaves out takes QGIS's default, and a field with no delimiter is no field.
|
|
28
|
+
*/
|
|
29
|
+
export function readCollectionDelimitedText(collection) {
|
|
30
|
+
const value = readDataAsset(collection)?.[QUAC_DELIMITED_TEXT];
|
|
31
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
32
|
+
return null;
|
|
33
|
+
const field = value;
|
|
34
|
+
const text = (key, fallback) => (typeof field[key] === 'string' ? field[key] : fallback);
|
|
35
|
+
const flag = (key, fallback) => (typeof field[key] === 'boolean' ? field[key] : fallback);
|
|
36
|
+
const skipLines = field['skip_lines'];
|
|
37
|
+
const options = {
|
|
38
|
+
delimiter: text('delimiter', DEFAULT_DELIMITED_TEXT_OPTIONS.delimiter),
|
|
39
|
+
quote: text('quote', DEFAULT_DELIMITED_TEXT_OPTIONS.quote),
|
|
40
|
+
escape: text('escape', DEFAULT_DELIMITED_TEXT_OPTIONS.escape),
|
|
41
|
+
skipLines: typeof skipLines === 'number' && Number.isInteger(skipLines) && skipLines > 0 ? skipLines : 0,
|
|
42
|
+
header: flag('header', DEFAULT_DELIMITED_TEXT_OPTIONS.header),
|
|
43
|
+
trim: flag('trim', DEFAULT_DELIMITED_TEXT_OPTIONS.trim)
|
|
44
|
+
};
|
|
45
|
+
return options.delimiter ? options : null;
|
|
46
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { StacCollection } from './Stac.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The filter a QGIS file layer sets on its data in Layer Properties > Source >
|
|
4
|
+
* Provider Feature Filter, so the layer holds only the features it keeps, and
|
|
5
|
+
* the catalogue field that carries it.
|
|
6
|
+
*
|
|
7
|
+
* Its language is the one the layer's provider reads. OGR writes it as
|
|
8
|
+
* `|subset=` at the end of the data source and hands it to GDAL, whose SQL
|
|
9
|
+
* this is for every file read through OGR (`QgsOgrProviderMetadata::decodeUri`,
|
|
10
|
+
* `src/core/providers/ogr/qgsogrprovidermetadata.cpp`, `qgis/QGIS@master`, read
|
|
11
|
+
* 2026-10-26). The Delimited Text provider writes it as the `subset` query
|
|
12
|
+
* item and reads it as a QGIS expression (`QgsDelimitedTextProvider`,
|
|
13
|
+
* `subsetStringDialect`, `src/providers/delimitedtext/qgsdelimitedtextprovider.cpp`,
|
|
14
|
+
* same commit). The WFS provider writes it as the `filter` parameter, or as a
|
|
15
|
+
* `SELECT` statement in `sql=`, and turns it into an OGC Filter for the server
|
|
16
|
+
* (`QgsWFSSharedData::computeFilter`, `src/providers/wfs/qgswfsshareddata.cpp`,
|
|
17
|
+
* same commit).
|
|
18
|
+
*/
|
|
19
|
+
export interface FeatureFilter {
|
|
20
|
+
/** The filter as the project writes it. */
|
|
21
|
+
expression: string;
|
|
22
|
+
dialect: FeatureFilterDialect;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* `ogr_sql` is GDAL's OGR SQL `WHERE` clause; `qgis_expression` is a QGIS
|
|
26
|
+
* expression; `wfs_sql` is the `SELECT` statement a QGIS WFS layer can carry
|
|
27
|
+
* instead of an expression (`QgsWFSProvider::setSubsetString`,
|
|
28
|
+
* `src/providers/wfs/qgswfsprovider.cpp`, `qgis/QGIS@master`, read 2026-10-26),
|
|
29
|
+
* and `ogc_filter` the OGC Filter XML it can carry in place of either.
|
|
30
|
+
*/
|
|
31
|
+
export type FeatureFilterDialect = 'ogr_sql' | 'qgis_expression' | 'wfs_sql' | 'ogc_filter';
|
|
32
|
+
/** The key a data asset takes for its source's feature filter. */
|
|
33
|
+
export declare const QUAC_FEATURE_FILTER = "quac:feature_filter";
|
|
34
|
+
/** The field as the catalogue writes it. */
|
|
35
|
+
export declare function featureFilterField(filter: FeatureFilter): Record<string, unknown>;
|
|
36
|
+
/**
|
|
37
|
+
* A Collection's feature filter, or null where its data asset names none, so
|
|
38
|
+
* the file is read whole. A field with blank text, or a dialect this does not
|
|
39
|
+
* know, is no field.
|
|
40
|
+
*/
|
|
41
|
+
export declare function readCollectionFeatureFilter(collection: StacCollection): FeatureFilter | null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { readDataAsset } from "./stacAssetRoles.js";
|
|
2
|
+
const DIALECTS = ['ogr_sql', 'qgis_expression', 'wfs_sql', 'ogc_filter'];
|
|
3
|
+
/** The key a data asset takes for its source's feature filter. */
|
|
4
|
+
export const QUAC_FEATURE_FILTER = 'quac:feature_filter';
|
|
5
|
+
/** The field as the catalogue writes it. */
|
|
6
|
+
export function featureFilterField(filter) {
|
|
7
|
+
return { expression: filter.expression, dialect: filter.dialect };
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A Collection's feature filter, or null where its data asset names none, so
|
|
11
|
+
* the file is read whole. A field with blank text, or a dialect this does not
|
|
12
|
+
* know, is no field.
|
|
13
|
+
*/
|
|
14
|
+
export function readCollectionFeatureFilter(collection) {
|
|
15
|
+
const value = readDataAsset(collection)?.[QUAC_FEATURE_FILTER];
|
|
16
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
17
|
+
return null;
|
|
18
|
+
const { expression, dialect } = value;
|
|
19
|
+
if (typeof expression !== 'string' || !expression.trim())
|
|
20
|
+
return null;
|
|
21
|
+
if (!DIALECTS.includes(dialect))
|
|
22
|
+
return null;
|
|
23
|
+
return { expression, dialect: dialect };
|
|
24
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The icon libraries this package addresses on jsDelivr, each pinned to the major
|
|
3
|
+
* version of its package, so a release adds icons but never renames one. A
|
|
4
|
+
* field's icon is named from them, and a
|
|
5
|
+
* map symbol from one of them is painted in its style's colour. This
|
|
6
|
+
* table is the one place a library or a version changes.
|
|
7
|
+
*/
|
|
8
|
+
export interface IconLibrary {
|
|
9
|
+
/** The npm package, without its version. */
|
|
10
|
+
packageName: string;
|
|
11
|
+
/** The major version read. */
|
|
12
|
+
major: number;
|
|
13
|
+
/** The file in the package for the icon of that name. */
|
|
14
|
+
path: (name: string) => string;
|
|
15
|
+
}
|
|
16
|
+
/** Each library, by its prefix in Iconify's naming. The field reference lists them, and a test holds the two equal. */
|
|
17
|
+
export declare const ICON_LIBRARIES: Readonly<Record<string, IconLibrary>>;
|
|
18
|
+
/** The address a field's icon value names, or null for a value that names none. */
|
|
19
|
+
export declare function resolveFieldIconAddress(value: string): string | null;
|
|
20
|
+
/**
|
|
21
|
+
* Whether `url` is a file of one of the libraries on jsDelivr, at any version:
|
|
22
|
+
* an administrator pastes the address the library's own site gives, which may
|
|
23
|
+
* name `@latest` or an exact release.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isIconLibraryAddress(url: string): boolean;
|
|
26
|
+
/** The address as the URL parser writes it, or null where it is not an `https://` address. */
|
|
27
|
+
export declare function readHttpsAddress(value: unknown): string | null;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The icon libraries this package addresses on jsDelivr, each pinned to the major
|
|
3
|
+
* version of its package, so a release adds icons but never renames one. A
|
|
4
|
+
* field's icon is named from them, and a
|
|
5
|
+
* map symbol from one of them is painted in its style's colour. This
|
|
6
|
+
* table is the one place a library or a version changes.
|
|
7
|
+
*/
|
|
8
|
+
const JSDELIVR_NPM = 'https://cdn.jsdelivr.net/npm/';
|
|
9
|
+
/** An icon name as Iconify spells one: lower-case letters and digits joined by single hyphens. */
|
|
10
|
+
const ICON_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
11
|
+
const PHOSPHOR_WEIGHTS = ['thin', 'light', 'bold', 'fill', 'duotone'];
|
|
12
|
+
/** Each library, by its prefix in Iconify's naming. The field reference lists them, and a test holds the two equal. */
|
|
13
|
+
export const ICON_LIBRARIES = {
|
|
14
|
+
tabler: {
|
|
15
|
+
packageName: '@tabler/icons',
|
|
16
|
+
major: 3,
|
|
17
|
+
path: (name) => name.endsWith('-filled') ? `icons/filled/${name.slice(0, -'-filled'.length)}.svg` : `icons/outline/${name}.svg`
|
|
18
|
+
},
|
|
19
|
+
lucide: { packageName: 'lucide-static', major: 1, path: (name) => `icons/${name}.svg` },
|
|
20
|
+
heroicons: {
|
|
21
|
+
packageName: 'heroicons',
|
|
22
|
+
major: 2,
|
|
23
|
+
path: (name) => {
|
|
24
|
+
for (const [suffix, folder] of [['-20-solid', '20/solid'], ['-16-solid', '16/solid'], ['-solid', '24/solid']]) {
|
|
25
|
+
if (name.endsWith(suffix))
|
|
26
|
+
return `${folder}/${name.slice(0, -suffix.length)}.svg`;
|
|
27
|
+
}
|
|
28
|
+
return `24/outline/${name}.svg`;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
// Phosphor's files carry their weight in the name, as Iconify's do: `tree-structure-bold.svg`.
|
|
32
|
+
ph: {
|
|
33
|
+
packageName: '@phosphor-icons/core',
|
|
34
|
+
major: 2,
|
|
35
|
+
path: (name) => `assets/${PHOSPHOR_WEIGHTS.find((weight) => name.endsWith(`-${weight}`)) ?? 'regular'}/${name}.svg`
|
|
36
|
+
},
|
|
37
|
+
bi: { packageName: 'bootstrap-icons', major: 1, path: (name) => `icons/${name}.svg` },
|
|
38
|
+
// Iconify's plain name is Google's filled Outlined icon, `-outline` the unfilled one, and the
|
|
39
|
+
// same two in the Rounded style end `-rounded` and `-outline-rounded`. Google's files join
|
|
40
|
+
// the words of a name with underscores, so `outdoor-grill` is `outlined/outdoor_grill-fill.svg`.
|
|
41
|
+
'material-symbols': {
|
|
42
|
+
packageName: '@material-symbols/svg-400',
|
|
43
|
+
major: 0,
|
|
44
|
+
path: (name) => {
|
|
45
|
+
const file = (base) => base.replaceAll('-', '_');
|
|
46
|
+
if (name.endsWith('-outline-rounded'))
|
|
47
|
+
return `rounded/${file(name.slice(0, -'-outline-rounded'.length))}.svg`;
|
|
48
|
+
if (name.endsWith('-rounded'))
|
|
49
|
+
return `rounded/${file(name.slice(0, -'-rounded'.length))}-fill.svg`;
|
|
50
|
+
if (name.endsWith('-outline'))
|
|
51
|
+
return `outlined/${file(name.slice(0, -'-outline'.length))}.svg`;
|
|
52
|
+
return `outlined/${file(name)}-fill.svg`;
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
maki: { packageName: '@mapbox/maki', major: 8, path: (name) => `icons/${name}.svg` },
|
|
56
|
+
temaki: { packageName: '@rapideditor/temaki', major: 5, path: (name) => `icons/${name}.svg` }
|
|
57
|
+
};
|
|
58
|
+
/** The address a field's icon value names, or null for a value that names none. */
|
|
59
|
+
export function resolveFieldIconAddress(value) {
|
|
60
|
+
const trimmed = value.trim();
|
|
61
|
+
if (/^https:\/\//i.test(trimmed))
|
|
62
|
+
return readHttpsAddress(trimmed);
|
|
63
|
+
const separator = trimmed.indexOf(':');
|
|
64
|
+
const prefix = separator === -1 ? 'tabler' : trimmed.slice(0, separator).toLowerCase();
|
|
65
|
+
const name = (separator === -1 ? trimmed : trimmed.slice(separator + 1)).toLowerCase();
|
|
66
|
+
const library = Object.hasOwn(ICON_LIBRARIES, prefix) ? ICON_LIBRARIES[prefix] : undefined;
|
|
67
|
+
if (!library || !ICON_NAME_PATTERN.test(name))
|
|
68
|
+
return null;
|
|
69
|
+
return `${JSDELIVR_NPM}${library.packageName}@${library.major}/${library.path(name)}`;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Whether `url` is a file of one of the libraries on jsDelivr, at any version:
|
|
73
|
+
* an administrator pastes the address the library's own site gives, which may
|
|
74
|
+
* name `@latest` or an exact release.
|
|
75
|
+
*/
|
|
76
|
+
export function isIconLibraryAddress(url) {
|
|
77
|
+
if (!url.startsWith(JSDELIVR_NPM))
|
|
78
|
+
return false;
|
|
79
|
+
const rest = url.slice(JSDELIVR_NPM.length);
|
|
80
|
+
return Object.values(ICON_LIBRARIES).some((library) => rest.startsWith(`${library.packageName}@`) || rest.startsWith(`${library.packageName}/`));
|
|
81
|
+
}
|
|
82
|
+
/** The address as the URL parser writes it, or null where it is not an `https://` address. */
|
|
83
|
+
export function readHttpsAddress(value) {
|
|
84
|
+
if (typeof value !== 'string')
|
|
85
|
+
return null;
|
|
86
|
+
try {
|
|
87
|
+
const url = new URL(value.trim());
|
|
88
|
+
return url.protocol === 'https:' ? url.href : null;
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parts of an OGC API - Features service's JSON this package reads. Kept
|
|
3
|
+
* apart from any OGC API - Features client so the STAC generators can describe a
|
|
4
|
+
* collection without importing anything that fetches.
|
|
5
|
+
*/
|
|
6
|
+
export interface OgcLink {
|
|
7
|
+
rel: string;
|
|
8
|
+
href: string;
|
|
9
|
+
type?: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* What a collection holds. `feature` is the only kind that holds features to load —
|
|
14
|
+
* `record` is a catalogue's index of itself (OGC API - Records) and `coverage`
|
|
15
|
+
* is raster, which has no `items` endpoint to read.
|
|
16
|
+
*/
|
|
17
|
+
export type OgcItemType = 'feature' | 'record' | 'coverage' | string;
|
|
18
|
+
export interface OgcCollection {
|
|
19
|
+
id: string;
|
|
20
|
+
title?: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
itemType?: OgcItemType;
|
|
23
|
+
keywords?: string[];
|
|
24
|
+
extent?: {
|
|
25
|
+
spatial?: {
|
|
26
|
+
bbox?: number[][];
|
|
27
|
+
crs?: string;
|
|
28
|
+
};
|
|
29
|
+
temporal?: {
|
|
30
|
+
interval?: (string | null)[][];
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
crs?: string[];
|
|
34
|
+
links?: OgcLink[];
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
export interface OgcCollectionsDocument {
|
|
38
|
+
collections: OgcCollection[];
|
|
39
|
+
links?: OgcLink[];
|
|
40
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { StacCatalog, StacCollection } from './Stac.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The QUAC schema's address, as its `$id` gives it. A catalogue lists it in
|
|
4
|
+
* `stac_extensions` to say which QUAC it follows. Written from this one
|
|
5
|
+
* constant, so the address changes in one place when the schema moves.
|
|
6
|
+
*/
|
|
7
|
+
export declare const QUAC_SCHEMA_URL = "https://vectoriahq.github.io/quac/v0.2.0/schema.json";
|
|
8
|
+
/**
|
|
9
|
+
* The QUAC version a document declares, such as `0.1.0`, read from the QUAC
|
|
10
|
+
* schema address in its `stac_extensions`. Null where it lists none.
|
|
11
|
+
*/
|
|
12
|
+
export declare function readQuacVersion(document: {
|
|
13
|
+
stac_extensions?: unknown;
|
|
14
|
+
}): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* Whether `version` has a newer major version than the QUAC this package
|
|
17
|
+
* writes and reads (`QUAC_SCHEMA_URL`). A reader treats such a catalogue as
|
|
18
|
+
* one it cannot read.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isNewerQuacMajor(version: string): boolean;
|
|
21
|
+
/** Adds the QUAC schema to one document's `stac_extensions`, once. */
|
|
22
|
+
export declare function listQuacExtension(document: StacCatalog | StacCollection): void;
|
|
23
|
+
/**
|
|
24
|
+
* Lists the QUAC schema in `stac_extensions` on the top-level Catalog, and on
|
|
25
|
+
* each nested Catalog and Collection that carries a `quac:` field of its own,
|
|
26
|
+
* as STAC lists an extension on each object that uses its fields.
|
|
27
|
+
*/
|
|
28
|
+
export declare function declareQuacExtension(catalog: StacCatalog): StacCatalog;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The QUAC schema's address, as its `$id` gives it. A catalogue lists it in
|
|
3
|
+
* `stac_extensions` to say which QUAC it follows. Written from this one
|
|
4
|
+
* constant, so the address changes in one place when the schema moves.
|
|
5
|
+
*/
|
|
6
|
+
export const QUAC_SCHEMA_URL = 'https://vectoriahq.github.io/quac/v0.2.0/schema.json';
|
|
7
|
+
// A QUAC schema address is a folder named for its version, holding the
|
|
8
|
+
// schema file `QUAC_SCHEMA_URL` names. Only the path is matched, not the host.
|
|
9
|
+
const QUAC_SCHEMA_FILE = QUAC_SCHEMA_URL.slice(QUAC_SCHEMA_URL.lastIndexOf('/'));
|
|
10
|
+
const QUAC_VERSION_FOLDER = /\/quac\/v(\d+)\.(\d+)\.(\d+)$/;
|
|
11
|
+
/**
|
|
12
|
+
* The QUAC version a document declares, such as `0.1.0`, read from the QUAC
|
|
13
|
+
* schema address in its `stac_extensions`. Null where it lists none.
|
|
14
|
+
*/
|
|
15
|
+
export function readQuacVersion(document) {
|
|
16
|
+
const extensions = Array.isArray(document.stac_extensions) ? document.stac_extensions : [];
|
|
17
|
+
for (const extension of extensions) {
|
|
18
|
+
const match = typeof extension === 'string' && extension.endsWith(QUAC_SCHEMA_FILE)
|
|
19
|
+
? QUAC_VERSION_FOLDER.exec(extension.slice(0, -QUAC_SCHEMA_FILE.length))
|
|
20
|
+
: null;
|
|
21
|
+
if (match)
|
|
22
|
+
return `${match[1]}.${match[2]}.${match[3]}`;
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Whether `version` has a newer major version than the QUAC this package
|
|
28
|
+
* writes and reads (`QUAC_SCHEMA_URL`). A reader treats such a catalogue as
|
|
29
|
+
* one it cannot read.
|
|
30
|
+
*/
|
|
31
|
+
export function isNewerQuacMajor(version) {
|
|
32
|
+
const own = readQuacVersion({ stac_extensions: [QUAC_SCHEMA_URL] }) ?? '0';
|
|
33
|
+
return Number(version.split('.')[0]) > Number(own.split('.')[0]);
|
|
34
|
+
}
|
|
35
|
+
function hasQuacKey(value) {
|
|
36
|
+
return Boolean(value) && typeof value === 'object' && Object.keys(value).some((key) => key.startsWith('quac:'));
|
|
37
|
+
}
|
|
38
|
+
/** Whether a Collection carries a `quac:` field: on itself, in its summaries, or on an asset, link or column. */
|
|
39
|
+
function collectionCarriesQuac(collection) {
|
|
40
|
+
if (hasQuacKey(collection) || hasQuacKey(collection.summaries))
|
|
41
|
+
return true;
|
|
42
|
+
if (Object.values(collection.assets ?? {}).some(hasQuacKey))
|
|
43
|
+
return true;
|
|
44
|
+
if ((collection.links ?? []).some(hasQuacKey))
|
|
45
|
+
return true;
|
|
46
|
+
const columns = collection['table:columns'];
|
|
47
|
+
return Array.isArray(columns) && columns.some(hasQuacKey);
|
|
48
|
+
}
|
|
49
|
+
/** Adds the QUAC schema to one document's `stac_extensions`, once. */
|
|
50
|
+
export function listQuacExtension(document) {
|
|
51
|
+
const extensions = document.stac_extensions ?? [];
|
|
52
|
+
if (!extensions.includes(QUAC_SCHEMA_URL))
|
|
53
|
+
document.stac_extensions = [...extensions, QUAC_SCHEMA_URL];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Lists the QUAC schema in `stac_extensions` on the top-level Catalog, and on
|
|
57
|
+
* each nested Catalog and Collection that carries a `quac:` field of its own,
|
|
58
|
+
* as STAC lists an extension on each object that uses its fields.
|
|
59
|
+
*/
|
|
60
|
+
export function declareQuacExtension(catalog) {
|
|
61
|
+
listQuacExtension(catalog);
|
|
62
|
+
const walk = (node) => {
|
|
63
|
+
for (const collection of node.collections ?? []) {
|
|
64
|
+
if (collectionCarriesQuac(collection))
|
|
65
|
+
listQuacExtension(collection);
|
|
66
|
+
}
|
|
67
|
+
for (const child of node.catalogs ?? []) {
|
|
68
|
+
if (hasQuacKey(child))
|
|
69
|
+
listQuacExtension(child);
|
|
70
|
+
walk(child);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
walk(catalog);
|
|
74
|
+
return catalog;
|
|
75
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { StacAsset, StacCollection } from './Stac.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Selecting a Collection's data asset.
|
|
4
|
+
*
|
|
5
|
+
* Portolan addresses assets by role rather than by key
|
|
6
|
+
* (the Portolan convention): `data` is the primary file, `visual`
|
|
7
|
+
* a rendering derivative, `style` a visualisation style. This package's own
|
|
8
|
+
* generators write the primary file under the `data` key *and* the `data` role,
|
|
9
|
+
* so the key stands as the fallback for a document that declares no roles at
|
|
10
|
+
* all — which an external catalogue is free to do.
|
|
11
|
+
*/
|
|
12
|
+
/** The role marking a Collection's primary data file. */
|
|
13
|
+
export declare const DATA_ROLE = "data";
|
|
14
|
+
/**
|
|
15
|
+
* The asset with a role, or null when the Collection declares none.
|
|
16
|
+
*
|
|
17
|
+
* An asset stored under the role's own name is preferred over any other
|
|
18
|
+
* with it, so a Collection that both keys and roles its data asset resolves
|
|
19
|
+
* to the same one either way. Otherwise the first match `Object.entries` yields
|
|
20
|
+
* wins — position in that list is not the document's order (see
|
|
21
|
+
* `DEFAULT_STYLE_ROLE`), so a Collection with two assets in one role has no
|
|
22
|
+
* stable answer here. Portolan gives none either: `specs/portolan/core.md`
|
|
23
|
+
* § Assets lists the roles it uses and calls `data` "for the primary
|
|
24
|
+
* GeoParquet, COG, or Parquet", without a rule for choosing among several
|
|
25
|
+
* with it (read at
|
|
26
|
+
* https://raw.githubusercontent.com/portolan-sdi/portolan-spec/main/specs/portolan/core.md
|
|
27
|
+
* on 2026-08-12). The one role that does have a tie-break is `style`, where a
|
|
28
|
+
* second `default` role marks the winner — which is the shape a `data`
|
|
29
|
+
* tie-break would take if Portolan ever adds one.
|
|
30
|
+
*/
|
|
31
|
+
export declare function findAssetByRole(collection: StacCollection, role: string): StacAsset | null;
|
|
32
|
+
/** A Collection's primary data file — the `data`-role asset. */
|
|
33
|
+
export declare function readDataAsset(collection: StacCollection): StacAsset | null;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Selecting a Collection's data asset.
|
|
3
|
+
*
|
|
4
|
+
* Portolan addresses assets by role rather than by key
|
|
5
|
+
* (the Portolan convention): `data` is the primary file, `visual`
|
|
6
|
+
* a rendering derivative, `style` a visualisation style. This package's own
|
|
7
|
+
* generators write the primary file under the `data` key *and* the `data` role,
|
|
8
|
+
* so the key stands as the fallback for a document that declares no roles at
|
|
9
|
+
* all — which an external catalogue is free to do.
|
|
10
|
+
*/
|
|
11
|
+
/** The role marking a Collection's primary data file. */
|
|
12
|
+
export const DATA_ROLE = 'data';
|
|
13
|
+
/**
|
|
14
|
+
* The asset with a role, or null when the Collection declares none.
|
|
15
|
+
*
|
|
16
|
+
* An asset stored under the role's own name is preferred over any other
|
|
17
|
+
* with it, so a Collection that both keys and roles its data asset resolves
|
|
18
|
+
* to the same one either way. Otherwise the first match `Object.entries` yields
|
|
19
|
+
* wins — position in that list is not the document's order (see
|
|
20
|
+
* `DEFAULT_STYLE_ROLE`), so a Collection with two assets in one role has no
|
|
21
|
+
* stable answer here. Portolan gives none either: `specs/portolan/core.md`
|
|
22
|
+
* § Assets lists the roles it uses and calls `data` "for the primary
|
|
23
|
+
* GeoParquet, COG, or Parquet", without a rule for choosing among several
|
|
24
|
+
* with it (read at
|
|
25
|
+
* https://raw.githubusercontent.com/portolan-sdi/portolan-spec/main/specs/portolan/core.md
|
|
26
|
+
* on 2026-08-12). The one role that does have a tie-break is `style`, where a
|
|
27
|
+
* second `default` role marks the winner — which is the shape a `data`
|
|
28
|
+
* tie-break would take if Portolan ever adds one.
|
|
29
|
+
*/
|
|
30
|
+
export function findAssetByRole(collection, role) {
|
|
31
|
+
const assets = collection.assets ?? {};
|
|
32
|
+
const keyed = assets[role];
|
|
33
|
+
if (keyed?.roles?.includes(role))
|
|
34
|
+
return keyed;
|
|
35
|
+
for (const asset of Object.values(assets)) {
|
|
36
|
+
if (asset.roles?.includes(role))
|
|
37
|
+
return asset;
|
|
38
|
+
}
|
|
39
|
+
return keyed ?? null;
|
|
40
|
+
}
|
|
41
|
+
/** A Collection's primary data file — the `data`-role asset. */
|
|
42
|
+
export function readDataAsset(collection) {
|
|
43
|
+
return findAssetByRole(collection, DATA_ROLE);
|
|
44
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { StacCollection } from './Stac.ts';
|
|
2
|
+
/**
|
|
3
|
+
* What a published catalogue says about a Collection for the person choosing
|
|
4
|
+
* it: a ready-written credit (Attribution extension), whether it is outdated
|
|
5
|
+
* (Version extension), and a preview image (the `thumbnail` asset role).
|
|
6
|
+
*/
|
|
7
|
+
export declare const THUMBNAIL_ROLE = "thumbnail";
|
|
8
|
+
/** The Collection's `attribution`, trimmed, or null where it is absent, blank or not text. */
|
|
9
|
+
export declare function readCollectionAttribution(collection: StacCollection): string | null;
|
|
10
|
+
/**
|
|
11
|
+
* Where the Collection is marked `deprecated: true`, the address of its
|
|
12
|
+
* `latest-version` link, or null where it has none. Undefined where the
|
|
13
|
+
* Collection is not marked outdated.
|
|
14
|
+
*/
|
|
15
|
+
export declare function readCollectionDeprecation(collection: StacCollection): {
|
|
16
|
+
latestVersionHref: string | null;
|
|
17
|
+
} | undefined;
|
|
18
|
+
/** The address of the Collection's `thumbnail` asset, where it is an `http` or `https` one. */
|
|
19
|
+
export declare function readCollectionThumbnail(collection: StacCollection): string | null;
|
|
20
|
+
/** The address the Collection says it was published at: its `self` link, where that is a web address. */
|
|
21
|
+
export declare function readCollectionSelfHref(collection: StacCollection): string | null;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { findAssetByRole } from "./stacAssetRoles.js";
|
|
2
|
+
/**
|
|
3
|
+
* What a published catalogue says about a Collection for the person choosing
|
|
4
|
+
* it: a ready-written credit (Attribution extension), whether it is outdated
|
|
5
|
+
* (Version extension), and a preview image (the `thumbnail` asset role).
|
|
6
|
+
*/
|
|
7
|
+
export const THUMBNAIL_ROLE = 'thumbnail';
|
|
8
|
+
/** The address where it is an `http` or `https` one, else null. */
|
|
9
|
+
function webAddress(href) {
|
|
10
|
+
if (typeof href !== 'string')
|
|
11
|
+
return null;
|
|
12
|
+
try {
|
|
13
|
+
const { protocol } = new URL(href);
|
|
14
|
+
return protocol === 'http:' || protocol === 'https:' ? href : null;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** The Collection's `attribution`, trimmed, or null where it is absent, blank or not text. */
|
|
21
|
+
export function readCollectionAttribution(collection) {
|
|
22
|
+
const attribution = collection['attribution'];
|
|
23
|
+
return typeof attribution === 'string' && attribution.trim() ? attribution.trim() : null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Where the Collection is marked `deprecated: true`, the address of its
|
|
27
|
+
* `latest-version` link, or null where it has none. Undefined where the
|
|
28
|
+
* Collection is not marked outdated.
|
|
29
|
+
*/
|
|
30
|
+
export function readCollectionDeprecation(collection) {
|
|
31
|
+
if (collection['deprecated'] !== true)
|
|
32
|
+
return undefined;
|
|
33
|
+
const link = (collection.links ?? []).find((candidate) => candidate.rel === 'latest-version');
|
|
34
|
+
return { latestVersionHref: webAddress(link?.href) };
|
|
35
|
+
}
|
|
36
|
+
/** The address of the Collection's `thumbnail` asset, where it is an `http` or `https` one. */
|
|
37
|
+
export function readCollectionThumbnail(collection) {
|
|
38
|
+
const asset = findAssetByRole(collection, THUMBNAIL_ROLE);
|
|
39
|
+
return asset?.roles?.includes(THUMBNAIL_ROLE) ? webAddress(asset.href) : null;
|
|
40
|
+
}
|
|
41
|
+
/** The address the Collection says it was published at: its `self` link, where that is a web address. */
|
|
42
|
+
export function readCollectionSelfHref(collection) {
|
|
43
|
+
return webAddress((collection.links ?? []).find((link) => link.rel === 'self')?.href);
|
|
44
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { StacCollection } from './Stac.ts';
|
|
2
|
+
/**
|
|
3
|
+
* How a relative asset href is spelled, and how it is read back.
|
|
4
|
+
*
|
|
5
|
+
* An href is a URI reference, not a file path, so the characters URIs reserve
|
|
6
|
+
* have to be escaped in it. `#` and `?` are the two that bite: both are legal
|
|
7
|
+
* in a cloud folder's file names, and both end the path when
|
|
8
|
+
* a reader takes an href apart. A folder holding `Building #3.geojson` written
|
|
9
|
+
* unescaped publishes `./Building #3.geojson`, which reads back as `Building `
|
|
10
|
+
* — a file no folder holds, so the layer is dropped.
|
|
11
|
+
*
|
|
12
|
+
* Every generator writes its relative hrefs through `encodeAssetPath`, and
|
|
13
|
+
* every reader takes them back through `decodeAssetPath`, so the pair is here
|
|
14
|
+
* rather than in any one of them.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Percent-encodes a relative path for use in an href, keeping `/` as the
|
|
18
|
+
* separator between segments.
|
|
19
|
+
*/
|
|
20
|
+
export declare function encodeAssetPath(path: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* The path an href addresses: its leading `./` removed and its segments
|
|
23
|
+
* decoded.
|
|
24
|
+
*
|
|
25
|
+
* A segment with a stray `%` is left as it stands rather than throwing —
|
|
26
|
+
* that is an href somebody else wrote without escaping, and the file's own name
|
|
27
|
+
* is the best reading available of it.
|
|
28
|
+
*/
|
|
29
|
+
export declare function decodeAssetPath(href: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* True for an href pointing to something inside the published folder, as opposed to
|
|
32
|
+
* an absolute address, another server, or a bare fragment. Only a relative one
|
|
33
|
+
* can be resolved against a folder listing.
|
|
34
|
+
*/
|
|
35
|
+
export declare function isRelativeHref(href: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Reads a Collection's `data` asset back as a path inside the published folder
|
|
38
|
+
* — the counterpart of the data asset both the QGIS project and the folder
|
|
39
|
+
* generators write.
|
|
40
|
+
*
|
|
41
|
+
* Returns null for an asset that is not a relative path: a WFS GetFeature URL,
|
|
42
|
+
* the empty href an unsupported source gets, or any absolute address. Those are
|
|
43
|
+
* not files in the folder, so there is nothing here to look up.
|
|
44
|
+
*/
|
|
45
|
+
export declare function readCollectionDataPath(collection: StacCollection): string | null;
|
|
46
|
+
/**
|
|
47
|
+
* Reads a Collection's `data` asset as an online file: an absolute `http` or
|
|
48
|
+
* `https` address, such as a QGIS layer reading a file through GDAL's
|
|
49
|
+
* `/vsicurl/` prefix publishes. `name` is the address's last path segment.
|
|
50
|
+
* Null for any other href, a relative path in the folder included.
|
|
51
|
+
*/
|
|
52
|
+
export declare function readCollectionOnlineFile(collection: StacCollection): {
|
|
53
|
+
url: string;
|
|
54
|
+
name: string;
|
|
55
|
+
} | null;
|
|
56
|
+
export declare function stripLeadingDotSlash(path: string): string;
|