@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,128 @@
|
|
|
1
|
+
import { devLog } from "../util/devLog.js";
|
|
2
|
+
/**
|
|
3
|
+
* Captures all named styles defined for a layer, plus the index of the
|
|
4
|
+
* active one.
|
|
5
|
+
*
|
|
6
|
+
* QGIS layer style structure:
|
|
7
|
+
* <maplayer>
|
|
8
|
+
* ...
|
|
9
|
+
* <map-layer-style-manager current="Priority">
|
|
10
|
+
* <map-layer-style name="Asset Owner">
|
|
11
|
+
* <style ...><renderer-v2 ...>...</renderer-v2>...</style>
|
|
12
|
+
* </map-layer-style>
|
|
13
|
+
* <map-layer-style name="Priority"/> ← empty: active style's
|
|
14
|
+
* </map-layer-style-manager> contents are duplicated
|
|
15
|
+
* ... at the maplayer level
|
|
16
|
+
* <renderer-v2 ...>...</renderer-v2> ← the active style's renderer
|
|
17
|
+
* </maplayer>
|
|
18
|
+
*
|
|
19
|
+
* If <map-layer-style-manager> is absent (older or simpler projects), we
|
|
20
|
+
* fall back to a single anonymous "default" style sourced from the direct-
|
|
21
|
+
* child <renderer-v2>.
|
|
22
|
+
*
|
|
23
|
+
* A vector tile layer (`type="vector-tile"`) has a `<renderer>` in place of
|
|
24
|
+
* `<renderer-v2>`, in the same places, and its XML is kept as
|
|
25
|
+
* `vectorTileRendererRawXml` instead.
|
|
26
|
+
*
|
|
27
|
+
* Returns { styles: [], activeIndex: -1 } when nothing is found, so callers
|
|
28
|
+
* can downgrade gracefully to default styling.
|
|
29
|
+
*/
|
|
30
|
+
export function parseLayerStyles(maplayer) {
|
|
31
|
+
try {
|
|
32
|
+
const manager = directChild(maplayer, 'map-layer-style-manager');
|
|
33
|
+
const tag = maplayer.getAttribute('type') === 'vector-tile' ? 'renderer' : 'renderer-v2';
|
|
34
|
+
if (!manager) {
|
|
35
|
+
const direct = captureMaplayerRenderer(maplayer, tag);
|
|
36
|
+
if (!direct)
|
|
37
|
+
return { styles: [], activeIndex: -1 };
|
|
38
|
+
return { styles: [{ name: 'default', isActive: true, ...rendererFields(direct, tag) }], activeIndex: 0 };
|
|
39
|
+
}
|
|
40
|
+
const currentName = manager.getAttribute('current') ?? '';
|
|
41
|
+
const styles = [];
|
|
42
|
+
let activeIndex = -1;
|
|
43
|
+
for (const node of Array.from(manager.children)) {
|
|
44
|
+
if (node.tagName !== 'map-layer-style')
|
|
45
|
+
continue;
|
|
46
|
+
const name = node.getAttribute('name') ?? '';
|
|
47
|
+
const isActive = name === currentName;
|
|
48
|
+
// Active style's renderer-v2 is duplicated at the maplayer level (the
|
|
49
|
+
// <map-layer-style> for the active style is typically empty).
|
|
50
|
+
// Non-active styles store their renderer inside <map-layer-style>/<style>/<renderer-v2>.
|
|
51
|
+
const renderer = isActive
|
|
52
|
+
? captureMaplayerRenderer(maplayer, tag)
|
|
53
|
+
: captureNestedRenderer(node, tag);
|
|
54
|
+
if (isActive)
|
|
55
|
+
activeIndex = styles.length;
|
|
56
|
+
styles.push({ name, isActive, ...rendererFields(renderer, tag) });
|
|
57
|
+
}
|
|
58
|
+
return { styles, activeIndex };
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
devLog('qgs/parseStyle', 'failed to capture layer styles', { error: String(err) });
|
|
62
|
+
return { styles: [], activeIndex: -1 };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Lifts the `tag` renderer element directly inside a <maplayer>. This is the
|
|
67
|
+
* shape the active style takes. Falls back to a renderer nested inside
|
|
68
|
+
* <map-layer-style-manager><map-layer-style> in the rare case where QGIS
|
|
69
|
+
* stores the active renderer there too.
|
|
70
|
+
*/
|
|
71
|
+
function captureMaplayerRenderer(maplayer, tag) {
|
|
72
|
+
const direct = directChild(maplayer, tag);
|
|
73
|
+
if (direct)
|
|
74
|
+
return direct;
|
|
75
|
+
const manager = directChild(maplayer, 'map-layer-style-manager');
|
|
76
|
+
if (manager) {
|
|
77
|
+
const nested = manager.querySelector(tag);
|
|
78
|
+
if (nested)
|
|
79
|
+
return nested;
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
/** A style's renderer fields, from its renderer element or none. */
|
|
84
|
+
function rendererFields(renderer, tag) {
|
|
85
|
+
if (tag === 'renderer') {
|
|
86
|
+
return { rendererV2RawXml: null, categorisedField: null, ...(renderer ? { vectorTileRendererRawXml: serialise(renderer) } : {}) };
|
|
87
|
+
}
|
|
88
|
+
return { rendererV2RawXml: renderer ? serialise(renderer) : null, categorisedField: readCategorisedField(renderer) };
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The field a categorised or graduated renderer classifies by — QGIS writes it
|
|
92
|
+
* as the renderer's `attr`, which the graffiti fixture's two categorised styles
|
|
93
|
+
* have. A graduated renderer identifies the same field by the same attribute, one
|
|
94
|
+
* range per rule rather than one value — `geostyler-qgis-parser`'s
|
|
95
|
+
* `QGISStyleParser.js` reads `renderer-v2`'s `attr` for both its categories and
|
|
96
|
+
* ranges branches.
|
|
97
|
+
*
|
|
98
|
+
* Read only from those two renderer types. Another renderer type with an
|
|
99
|
+
* `attr` would not mean the same thing by it, so the gate is on the type
|
|
100
|
+
* rather than on the attribute being present.
|
|
101
|
+
*/
|
|
102
|
+
function readCategorisedField(renderer) {
|
|
103
|
+
if (!renderer)
|
|
104
|
+
return null;
|
|
105
|
+
const type = renderer.getAttribute('type');
|
|
106
|
+
if (type !== 'categorizedSymbol' && type !== 'graduatedSymbol')
|
|
107
|
+
return null;
|
|
108
|
+
return renderer.getAttribute('attr')?.trim() || null;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Lifts the `tag` renderer element nested inside a non-active <map-layer-style>.
|
|
112
|
+
* QGIS embeds the full standalone-QML <qgis> document inside each non-active
|
|
113
|
+
* <map-layer-style>, with the renderer as a descendant — we just need
|
|
114
|
+
* any such element inside the map-layer-style element.
|
|
115
|
+
*/
|
|
116
|
+
function captureNestedRenderer(mapLayerStyle, tag) {
|
|
117
|
+
return mapLayerStyle.querySelector(tag);
|
|
118
|
+
}
|
|
119
|
+
function directChild(parent, tag) {
|
|
120
|
+
for (const child of Array.from(parent.children)) {
|
|
121
|
+
if (child.tagName === tag)
|
|
122
|
+
return child;
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
function serialise(el) {
|
|
127
|
+
return new XMLSerializer().serializeToString(el);
|
|
128
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { WmsPublishing } from '../model/QgsProject.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The project's WMS publishing, from Project Properties → QGIS Server → WMS
|
|
4
|
+
* capabilities: **Use layer ids as names**, saved as `WMSUseLayerIDs`, and the
|
|
5
|
+
* layers left out of WMS, saved by name as `WMSRestrictedLayers`
|
|
6
|
+
* (`QgsServerProjectUtils::wmsUseLayerIds` and `wmsRestrictedLayers`,
|
|
7
|
+
* `src/server/qgsserverprojectutils.cpp`, `qgis/QGIS@master`, read
|
|
8
|
+
* 2026-11-03). Null where the project saves neither.
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseWmsPublishing(qgisRoot: Element): WmsPublishing | null;
|
|
11
|
+
/**
|
|
12
|
+
* The CRSs the project offers its WMS layers in, from Project Properties → QGIS
|
|
13
|
+
* Server → WMS capabilities → **CRS restrictions**: the `WMSCrsList` it saves,
|
|
14
|
+
* else the EPSG codes of the older `WMSEpsgList`, as
|
|
15
|
+
* `QgsServerProjectUtils::wmsOutputCrsList` reads them
|
|
16
|
+
* (`src/server/qgsserverprojectutils.cpp`, `qgis/QGIS@master`, read
|
|
17
|
+
* 2026-11-07). Empty where the project restricts none; QGIS Server then offers
|
|
18
|
+
* the project's own CRS, EPSG:4326 and EPSG:3857, which the server route works
|
|
19
|
+
* out from the project's CRS.
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseWmsCrsList(qgisRoot: Element): string[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { propertyList, propertyText } from "./projectProperties.js";
|
|
2
|
+
/**
|
|
3
|
+
* The project's WMS publishing, from Project Properties → QGIS Server → WMS
|
|
4
|
+
* capabilities: **Use layer ids as names**, saved as `WMSUseLayerIDs`, and the
|
|
5
|
+
* layers left out of WMS, saved by name as `WMSRestrictedLayers`
|
|
6
|
+
* (`QgsServerProjectUtils::wmsUseLayerIds` and `wmsRestrictedLayers`,
|
|
7
|
+
* `src/server/qgsserverprojectutils.cpp`, `qgis/QGIS@master`, read
|
|
8
|
+
* 2026-11-03). Null where the project saves neither.
|
|
9
|
+
*/
|
|
10
|
+
export function parseWmsPublishing(qgisRoot) {
|
|
11
|
+
const properties = qgisRoot.querySelector(':scope > properties');
|
|
12
|
+
if (!properties)
|
|
13
|
+
return null;
|
|
14
|
+
const useLayerIds = propertyText(properties, 'WMSUseLayerIDs');
|
|
15
|
+
const restrictedLayers = propertyList(properties, 'WMSRestrictedLayers');
|
|
16
|
+
if (useLayerIds === null && restrictedLayers.length === 0)
|
|
17
|
+
return null;
|
|
18
|
+
return { useLayerIds: useLayerIds === 'true', restrictedLayers };
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The CRSs the project offers its WMS layers in, from Project Properties → QGIS
|
|
22
|
+
* Server → WMS capabilities → **CRS restrictions**: the `WMSCrsList` it saves,
|
|
23
|
+
* else the EPSG codes of the older `WMSEpsgList`, as
|
|
24
|
+
* `QgsServerProjectUtils::wmsOutputCrsList` reads them
|
|
25
|
+
* (`src/server/qgsserverprojectutils.cpp`, `qgis/QGIS@master`, read
|
|
26
|
+
* 2026-11-07). Empty where the project restricts none; QGIS Server then offers
|
|
27
|
+
* the project's own CRS, EPSG:4326 and EPSG:3857, which the server route works
|
|
28
|
+
* out from the project's CRS.
|
|
29
|
+
*/
|
|
30
|
+
export function parseWmsCrsList(qgisRoot) {
|
|
31
|
+
const properties = qgisRoot.querySelector(':scope > properties');
|
|
32
|
+
if (!properties)
|
|
33
|
+
return [];
|
|
34
|
+
const crsList = propertyList(properties, 'WMSCrsList').filter((crs) => crs !== '');
|
|
35
|
+
if (crsList.length > 0)
|
|
36
|
+
return crsList;
|
|
37
|
+
return propertyList(properties, 'WMSEpsgList').flatMap((code) => /^\s*[+-]?\d+\s*$/.test(code) ? [`EPSG:${Number(code)}`] : []);
|
|
38
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads `<qgis><properties>`, which QGIS writes in two shapes. QGIS 3 names
|
|
3
|
+
* each element after its key (`<Measurement><AreaUnits>`); QGIS 4 writes every
|
|
4
|
+
* key as a `<properties name="…">` element (`QgsProjectPropertyValue::writeXml`,
|
|
5
|
+
* `src/core/project/qgsprojectproperty.cpp`, `qgis/QGIS@master`, read
|
|
6
|
+
* 2026-10-25). Both shapes are in this repository's demo projects.
|
|
7
|
+
*/
|
|
8
|
+
/** The child of `parent` holding `name`, in either shape. */
|
|
9
|
+
export declare function propertyChild(parent: Element, name: string): Element | null;
|
|
10
|
+
/** A top-level block of `<qgis><properties>`, such as `Measurement` or `Palette`. */
|
|
11
|
+
export declare function readPropertyBlock(qgisRoot: Element, name: string): Element | null;
|
|
12
|
+
/** A key's text, trimmed; null where the key is absent or blank. */
|
|
13
|
+
export declare function propertyText(parent: Element, name: string): string | null;
|
|
14
|
+
/** A string-list key's members, one per `<value>` element. */
|
|
15
|
+
export declare function propertyList(parent: Element, name: string): string[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads `<qgis><properties>`, which QGIS writes in two shapes. QGIS 3 names
|
|
3
|
+
* each element after its key (`<Measurement><AreaUnits>`); QGIS 4 writes every
|
|
4
|
+
* key as a `<properties name="…">` element (`QgsProjectPropertyValue::writeXml`,
|
|
5
|
+
* `src/core/project/qgsprojectproperty.cpp`, `qgis/QGIS@master`, read
|
|
6
|
+
* 2026-10-25). Both shapes are in this repository's demo projects.
|
|
7
|
+
*/
|
|
8
|
+
/** The child of `parent` holding `name`, in either shape. */
|
|
9
|
+
export function propertyChild(parent, name) {
|
|
10
|
+
return parent.querySelector(`:scope > ${name}`)
|
|
11
|
+
?? Array.from(parent.querySelectorAll(':scope > properties')).find((child) => child.getAttribute('name') === name)
|
|
12
|
+
?? null;
|
|
13
|
+
}
|
|
14
|
+
/** A top-level block of `<qgis><properties>`, such as `Measurement` or `Palette`. */
|
|
15
|
+
export function readPropertyBlock(qgisRoot, name) {
|
|
16
|
+
const properties = qgisRoot.querySelector(':scope > properties');
|
|
17
|
+
return properties ? propertyChild(properties, name) : null;
|
|
18
|
+
}
|
|
19
|
+
/** A key's text, trimmed; null where the key is absent or blank. */
|
|
20
|
+
export function propertyText(parent, name) {
|
|
21
|
+
return propertyChild(parent, name)?.textContent?.trim() || null;
|
|
22
|
+
}
|
|
23
|
+
/** A string-list key's members, one per `<value>` element. */
|
|
24
|
+
export function propertyList(parent, name) {
|
|
25
|
+
const key = propertyChild(parent, name);
|
|
26
|
+
return key ? Array.from(key.querySelectorAll(':scope > value')).map((value) => value.textContent ?? '') : [];
|
|
27
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import type { MeasureFactors } from './parseMeasurement.ts';
|
|
2
|
+
import type { Filter } from 'geostyler-style';
|
|
3
|
+
type Comparison = '=' | '!=' | '<>' | '<' | '<=' | '>' | '>=';
|
|
4
|
+
type Arithmetic = '+' | '-' | '*' | '/' | '//' | '%' | '^';
|
|
5
|
+
export type ExpressionNode = {
|
|
6
|
+
kind: 'field';
|
|
7
|
+
name: string;
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'text';
|
|
10
|
+
value: string;
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'number';
|
|
13
|
+
value: number;
|
|
14
|
+
} | {
|
|
15
|
+
kind: 'boolean';
|
|
16
|
+
value: boolean;
|
|
17
|
+
} | {
|
|
18
|
+
kind: 'null';
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'call';
|
|
21
|
+
name: string;
|
|
22
|
+
args: ExpressionNode[];
|
|
23
|
+
factor?: number;
|
|
24
|
+
} | {
|
|
25
|
+
kind: 'arithmetic';
|
|
26
|
+
op: Arithmetic;
|
|
27
|
+
left: ExpressionNode;
|
|
28
|
+
right: ExpressionNode;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'negate';
|
|
31
|
+
arg: ExpressionNode;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'compare';
|
|
34
|
+
op: Comparison;
|
|
35
|
+
left: ExpressionNode;
|
|
36
|
+
right: ExpressionNode;
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'predicate';
|
|
39
|
+
op: 'is' | 'like' | 'ilike' | 'in' | 'between' | 'regexp';
|
|
40
|
+
negate: boolean;
|
|
41
|
+
args: ExpressionNode[];
|
|
42
|
+
} | {
|
|
43
|
+
kind: 'logic';
|
|
44
|
+
op: 'and' | 'or';
|
|
45
|
+
args: ExpressionNode[];
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'not';
|
|
48
|
+
arg: ExpressionNode;
|
|
49
|
+
} | {
|
|
50
|
+
kind: 'case';
|
|
51
|
+
whens: Array<{
|
|
52
|
+
when: ExpressionNode;
|
|
53
|
+
then: ExpressionNode;
|
|
54
|
+
}>;
|
|
55
|
+
otherwise: ExpressionNode | null;
|
|
56
|
+
};
|
|
57
|
+
/** The `aggregate` kinds this reader takes, which the caller works out (`QgsAggregateCalculator::aggregates`). */
|
|
58
|
+
export declare const LOOKUP_AGGREGATES: readonly ["count", "min", "max", "concatenate"];
|
|
59
|
+
/**
|
|
60
|
+
* One read of another layer of the project: the features of `layer`, named by
|
|
61
|
+
* its name or its QGIS id, that the record's shape lies within or meets, kept
|
|
62
|
+
* by `filter` and cut to `limit`, each giving the value of `expression`. The
|
|
63
|
+
* answer is the list of those values, in the order the source gave the
|
|
64
|
+
* features. `key` tells one read from another.
|
|
65
|
+
*/
|
|
66
|
+
export interface LayerLookup {
|
|
67
|
+
key: string;
|
|
68
|
+
layer: string;
|
|
69
|
+
predicate: 'within' | 'intersects';
|
|
70
|
+
expression: ExpressionNode;
|
|
71
|
+
filter: ExpressionNode | null;
|
|
72
|
+
limit: number | null;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The `fnName` of the GeoStyler `custom` function that stands for a
|
|
76
|
+
* `LayerLookup`, with its `key` as its one argument. The evaluator is handed
|
|
77
|
+
* the answers before it starts.
|
|
78
|
+
*/
|
|
79
|
+
export declare const LAYER_LOOKUP = "layer_lookup";
|
|
80
|
+
/**
|
|
81
|
+
* The values QGIS gives a feature from its geometry that this reader takes, and
|
|
82
|
+
* the unit each is in: an area or a distance. They are written with no
|
|
83
|
+
* brackets (`$area`).
|
|
84
|
+
*/
|
|
85
|
+
export declare const GEOMETRY_VALUES: Readonly<Record<string, 'area' | 'distance'>>;
|
|
86
|
+
/**
|
|
87
|
+
* The `fnName` of the GeoStyler `custom` function that wraps a condition read
|
|
88
|
+
* from a QGIS rule, which `src/style/labelFunction.ts` works out with QGIS's
|
|
89
|
+
* rules.
|
|
90
|
+
*/
|
|
91
|
+
export declare const QGIS_CONDITION = "qgis_condition";
|
|
92
|
+
/** Whether a filter is a condition `qgisConditionToFilter` wrapped. */
|
|
93
|
+
export declare function isQgisConditionFilter(filter: unknown): filter is {
|
|
94
|
+
name: 'custom';
|
|
95
|
+
fnName: typeof QGIS_CONDITION;
|
|
96
|
+
args: [unknown];
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Reads a QGIS expression into a tree: fields, text, numbers, `TRUE`, `FALSE`,
|
|
100
|
+
* `NULL`, `||`, `+`, `-`, `*`, `/`, `//`, `%`, `^`, conditions, `~`, `CASE`
|
|
101
|
+
* and calls to the functions below, `current_value` among them. Null for any
|
|
102
|
+
* other expression, such as another function, a named argument to a function
|
|
103
|
+
* outside `NAMED_PARAMETERS`, or a variable.
|
|
104
|
+
*
|
|
105
|
+
* A regular expression, the pattern of `~` or of a `regexp_` function, is read
|
|
106
|
+
* where it is text written into the expression that `compileQtRegex` can
|
|
107
|
+
* translate (`qtRegex.ts`).
|
|
108
|
+
*
|
|
109
|
+
* `make_interval` is read only as the right side of a `+` or `-`, where the
|
|
110
|
+
* evaluator adds it to a date or takes it away. QGIS reads an interval
|
|
111
|
+
* elsewhere too, which the evaluator does not.
|
|
112
|
+
*
|
|
113
|
+
* `overlay_within`, `overlay_intersects` and `aggregate` read another layer,
|
|
114
|
+
* and are read only where the caller says `lookups`: the caller then answers
|
|
115
|
+
* each `LayerLookup` before it evaluates (a default value). See
|
|
116
|
+
* `areLookupsReadable` for the forms read.
|
|
117
|
+
*
|
|
118
|
+
* `current_value` is read only where the caller says `currentValue`: the
|
|
119
|
+
* caller then supplies the form's values (a Value Relation's filter), or reads
|
|
120
|
+
* the expression where there is no form, which gives NULL (a label, a style
|
|
121
|
+
* rule). A constraint or a default value is not read when it calls it.
|
|
122
|
+
*
|
|
123
|
+
* `$area`, `$length` and `$perimeter` are read only where the caller says
|
|
124
|
+
* `geometry`: `true` reads their shape alone, as the project reader does before
|
|
125
|
+
* the units are known, and the project's `MeasureFactors` read them in those
|
|
126
|
+
* units. A unit with no factor makes the expression unreadable. A caller that
|
|
127
|
+
* does not pass `geometry` has no feature shape to measure, so the expression
|
|
128
|
+
* is not read.
|
|
129
|
+
*
|
|
130
|
+
* `maximum` and `minimum` are read only where the caller says `aggregates`:
|
|
131
|
+
* the caller then supplies the records to scan (a default value), and every
|
|
132
|
+
* other caller would scan them for each feature drawn or field shown. Only
|
|
133
|
+
* their first argument is read, so `group_by` and `filter` make them
|
|
134
|
+
* unreadable, and so does a shape or another aggregate inside one: the records
|
|
135
|
+
* scanned carry no shape.
|
|
136
|
+
*
|
|
137
|
+
* `format_date` is read where its pattern and any language are text written
|
|
138
|
+
* into the expression, and the pattern holds no `t` (`qtDateFormat.ts`).
|
|
139
|
+
* `now()`, or `$now`, is read only as the date of `format_date` or of a
|
|
140
|
+
* function that takes a part of a date, such as `year`: anywhere else it would
|
|
141
|
+
* be compared or added as a date, which the evaluator does not do.
|
|
142
|
+
*/
|
|
143
|
+
export declare function readQgisExpression(expression: string, options?: {
|
|
144
|
+
currentValue?: boolean;
|
|
145
|
+
geometry?: true | MeasureFactors;
|
|
146
|
+
aggregates?: boolean;
|
|
147
|
+
lookups?: boolean;
|
|
148
|
+
}): ExpressionNode | null;
|
|
149
|
+
/**
|
|
150
|
+
* A QGIS rule's condition as a GeoStyler filter: the condition's GeoStyler
|
|
151
|
+
* function inside a `custom` function named `QGIS_CONDITION`, which
|
|
152
|
+
* `geostyler-openlayers-parser` hands to the evaluator the application gives it.
|
|
153
|
+
* Null for a condition `readQgisExpression` cannot read. `measure` is the
|
|
154
|
+
* project's units, which `$area` and `$length` need.
|
|
155
|
+
*/
|
|
156
|
+
export declare function qgisConditionToFilter(expression: string, measure?: MeasureFactors): Filter | null;
|
|
157
|
+
/**
|
|
158
|
+
* A string literal's text, as QGIS's `stripText` makes it: `''` becomes a
|
|
159
|
+
* quote first, then a backslash and the character after it become that
|
|
160
|
+
* character, `\n` and `\t` as a newline and a tab, and any character but
|
|
161
|
+
* those, `\` and `'` as `?`.
|
|
162
|
+
*/
|
|
163
|
+
export declare function unescapeStringLiteral(text: string): string;
|
|
164
|
+
/**
|
|
165
|
+
* The reads of other layers in an expression `readQgisExpression` read with
|
|
166
|
+
* `lookups`, one per distinct read.
|
|
167
|
+
*/
|
|
168
|
+
export declare function readLayerLookups(node: ExpressionNode): LayerLookup[];
|
|
169
|
+
/**
|
|
170
|
+
* The form fields an expression reads through `current_value`, or null where
|
|
171
|
+
* QGIS could not tell. QGIS names them by evaluating each call's argument with
|
|
172
|
+
* no feature (`expressionFormAttributes`,
|
|
173
|
+
* `src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp`,
|
|
174
|
+
* `qgis/QGIS@master`, read 2026-10-24), so an argument that reads a field
|
|
175
|
+
* gives a blank name and the filter is not used. This reader takes a text
|
|
176
|
+
* literal as the one constant argument. An empty list is an expression that
|
|
177
|
+
* reads no form value.
|
|
178
|
+
*/
|
|
179
|
+
export declare function readCurrentValueFields(node: ExpressionNode): string[] | null;
|
|
180
|
+
/**
|
|
181
|
+
* The `{{field}}` template of a label made only of fields, text and joins, or
|
|
182
|
+
* null where it holds anything else. A template draws a field with no value as
|
|
183
|
+
* blank, which is what `concat` does, so a `||` join is a template only when
|
|
184
|
+
* none of its parts can be NULL.
|
|
185
|
+
*/
|
|
186
|
+
export declare function expressionToTemplate(node: ExpressionNode): string | null;
|
|
187
|
+
/**
|
|
188
|
+
* The GeoStyler function for a label. A comparison, `AND`, `OR`, `NOT`, `IN`,
|
|
189
|
+
* `BETWEEN`, `CASE` and the four arithmetic operators take GeoStyler's own
|
|
190
|
+
* names (`add`, `sub`, `mul`, `div`); `IS`, `LIKE`, `ILIKE` and
|
|
191
|
+
* `QGIS_ONLY_FUNCTIONS` are `custom` functions with the QGIS name.
|
|
192
|
+
*/
|
|
193
|
+
export declare function expressionToGeoStylerFunction(node: ExpressionNode): unknown;
|
|
194
|
+
export {};
|