@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,90 @@
|
|
|
1
|
+
const REQUEST_PARAMETERS = new Set(['SERVICE', 'REQUEST', 'VERSION', 'LAYER', 'STYLE', 'FORMAT', 'TILEMATRIXSET', 'TILEMATRIX', 'TILEROW', 'TILECOL']);
|
|
2
|
+
/**
|
|
3
|
+
* Whether an address is a capabilities document of its own — REST encoding,
|
|
4
|
+
* such as `…/1.0.0/WMTSCapabilities.xml` — rather than a KVP service address.
|
|
5
|
+
*/
|
|
6
|
+
function isCapabilitiesDocument(url) {
|
|
7
|
+
return url.pathname.toLowerCase().endsWith('.xml');
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Removes WMTS request parameters from a KVP service address while retaining
|
|
11
|
+
* service-specific routing parameters. A capabilities document's address is
|
|
12
|
+
* kept as it is. Null for anything but an `http`/`https` address with no
|
|
13
|
+
* credentials in it.
|
|
14
|
+
*/
|
|
15
|
+
export function wmtsEndpoint(href) {
|
|
16
|
+
try {
|
|
17
|
+
const url = new URL(href);
|
|
18
|
+
if (!['https:', 'http:'].includes(url.protocol) || url.username || url.password)
|
|
19
|
+
return null;
|
|
20
|
+
if (!isCapabilitiesDocument(url)) {
|
|
21
|
+
for (const key of Array.from(url.searchParams.keys())) {
|
|
22
|
+
if (REQUEST_PARAMETERS.has(key.toUpperCase()))
|
|
23
|
+
url.searchParams.delete(key);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
url.hash = '';
|
|
27
|
+
return url.toString();
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** The address the layer's capabilities document is requested from. */
|
|
34
|
+
export function wmtsCapabilitiesUrl(source) {
|
|
35
|
+
if (source.encoding === 'rest')
|
|
36
|
+
return source.url;
|
|
37
|
+
const url = new URL(source.url);
|
|
38
|
+
url.searchParams.set('SERVICE', 'WMTS');
|
|
39
|
+
url.searchParams.set('REQUEST', 'GetCapabilities');
|
|
40
|
+
return url.toString();
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The web-map-links v1.3.0 link for a QGIS WMTS layer. `quac:wmts_tile_matrix_set`
|
|
44
|
+
* and `quac:wmts_style` keep the settings the extension does not define. A KVP
|
|
45
|
+
* link states the tile format as its `type`; a REST link's `type` is its
|
|
46
|
+
* capabilities document's, and the format comes from the document.
|
|
47
|
+
*/
|
|
48
|
+
export function buildWmtsLink(source) {
|
|
49
|
+
const href = wmtsEndpoint(source.url);
|
|
50
|
+
if (!href)
|
|
51
|
+
return null;
|
|
52
|
+
const rest = isCapabilitiesDocument(new URL(href));
|
|
53
|
+
return {
|
|
54
|
+
rel: 'wmts', href,
|
|
55
|
+
type: rest ? 'application/xml' : source.format,
|
|
56
|
+
'wmts:layer': source.layer,
|
|
57
|
+
'wmts:encoding': rest ? 'rest' : 'kvp',
|
|
58
|
+
...(Object.keys(source.dimensions).length > 0 ? { 'wmts:dimensions': source.dimensions } : {}),
|
|
59
|
+
'quac:wmts_tile_matrix_set': source.tileMatrixSet,
|
|
60
|
+
...(source.style ? { 'quac:wmts_style': source.style } : {})
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** Reads the first WMTS link naming one layer. */
|
|
64
|
+
export function readCollectionWmts(collection) {
|
|
65
|
+
for (const link of collection.links ?? []) {
|
|
66
|
+
if (link.rel !== 'wmts')
|
|
67
|
+
continue;
|
|
68
|
+
const url = wmtsEndpoint(link.href);
|
|
69
|
+
const layers = link['wmts:layer'];
|
|
70
|
+
const layer = Array.isArray(layers) && layers.length === 1 ? layers[0] : layers;
|
|
71
|
+
const encoding = link['wmts:encoding'] ?? 'kvp';
|
|
72
|
+
if (!url || typeof layer !== 'string' || !layer.trim() || (encoding !== 'kvp' && encoding !== 'rest'))
|
|
73
|
+
continue;
|
|
74
|
+
const dimensions = link['wmts:dimensions'] ?? {};
|
|
75
|
+
if (!dimensions || typeof dimensions !== 'object' || Array.isArray(dimensions)
|
|
76
|
+
|| Object.values(dimensions).some((value) => typeof value !== 'string')
|
|
77
|
+
|| Object.keys(dimensions).some((key) => REQUEST_PARAMETERS.has(key.toUpperCase())))
|
|
78
|
+
continue;
|
|
79
|
+
const tileMatrixSet = link['quac:wmts_tile_matrix_set'];
|
|
80
|
+
const style = link['quac:wmts_style'];
|
|
81
|
+
return {
|
|
82
|
+
url, encoding, layer,
|
|
83
|
+
style: typeof style === 'string' ? style : '',
|
|
84
|
+
tileMatrixSet: typeof tileMatrixSet === 'string' && tileMatrixSet ? tileMatrixSet : null,
|
|
85
|
+
format: encoding === 'kvp' && link.type ? link.type : null,
|
|
86
|
+
dimensions: dimensions
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { StacCollection, StacLink } from './Stac.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The media type of a Mapbox Vector Tile, which a `rel: "xyz"` link's `type`
|
|
4
|
+
* names when its tiles hold vector features rather than images.
|
|
5
|
+
*/
|
|
6
|
+
export declare const VECTOR_TILE_MEDIA_TYPE = "application/vnd.mapbox-vector-tile";
|
|
7
|
+
/**
|
|
8
|
+
* The `rel: "xyz"` link for a tile template, or null for one it cannot express.
|
|
9
|
+
* A link to vector tiles states `VECTOR_TILE_MEDIA_TYPE` as its `type`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildXyzLink(template: string, tiles?: 'image' | 'vector'): StacLink | null;
|
|
12
|
+
/** A Collection's tile template, and whether its tiles hold vector features. */
|
|
13
|
+
export interface XyzTemplate {
|
|
14
|
+
template: string;
|
|
15
|
+
vector: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A Collection's first `rel: "xyz"` link that holds `{z}`, `{x}` and `{y}`, or
|
|
19
|
+
* null when it has none. A template naming its server as `{s}` takes the first
|
|
20
|
+
* of the link's `href:servers`, and is skipped when the link lists none.
|
|
21
|
+
*/
|
|
22
|
+
export declare function readCollectionXyzLink(collection: StacCollection): XyzTemplate | null;
|
|
23
|
+
/** The template of `readCollectionXyzLink`, or null when there is none. */
|
|
24
|
+
export declare function readCollectionXyzTemplate(collection: StacCollection): string | null;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The placeholders a web-map-links v1.3.0 `rel: "xyz"` link's template must
|
|
3
|
+
* hold. A template addressing tiles by Bing's `{quadkey}` has none of them, so
|
|
4
|
+
* it cannot be written as such a link.
|
|
5
|
+
*/
|
|
6
|
+
const XYZ_PLACEHOLDERS = ['{z}', '{x}', '{y}'];
|
|
7
|
+
function holdsXyzPlaceholders(href) {
|
|
8
|
+
return XYZ_PLACEHOLDERS.every((placeholder) => href.includes(placeholder));
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The media type of a Mapbox Vector Tile, which a `rel: "xyz"` link's `type`
|
|
12
|
+
* names when its tiles hold vector features rather than images.
|
|
13
|
+
*/
|
|
14
|
+
export const VECTOR_TILE_MEDIA_TYPE = 'application/vnd.mapbox-vector-tile';
|
|
15
|
+
/**
|
|
16
|
+
* The `rel: "xyz"` link for a tile template, or null for one it cannot express.
|
|
17
|
+
* A link to vector tiles states `VECTOR_TILE_MEDIA_TYPE` as its `type`.
|
|
18
|
+
*/
|
|
19
|
+
export function buildXyzLink(template, tiles = 'image') {
|
|
20
|
+
if (!holdsXyzPlaceholders(template))
|
|
21
|
+
return null;
|
|
22
|
+
return tiles === 'vector' ? { rel: 'xyz', href: template, type: VECTOR_TILE_MEDIA_TYPE } : { rel: 'xyz', href: template };
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A Collection's first `rel: "xyz"` link that holds `{z}`, `{x}` and `{y}`, or
|
|
26
|
+
* null when it has none. A template naming its server as `{s}` takes the first
|
|
27
|
+
* of the link's `href:servers`, and is skipped when the link lists none.
|
|
28
|
+
*/
|
|
29
|
+
export function readCollectionXyzLink(collection) {
|
|
30
|
+
for (const link of collection.links ?? []) {
|
|
31
|
+
if (link.rel !== 'xyz' || typeof link.href !== 'string' || !holdsXyzPlaceholders(link.href))
|
|
32
|
+
continue;
|
|
33
|
+
const vector = link.type === VECTOR_TILE_MEDIA_TYPE;
|
|
34
|
+
if (!link.href.includes('{s}'))
|
|
35
|
+
return { template: link.href, vector };
|
|
36
|
+
const servers = link['href:servers'];
|
|
37
|
+
const server = Array.isArray(servers) ? servers[0] : undefined;
|
|
38
|
+
if (typeof server === 'string' && server)
|
|
39
|
+
return { template: link.href.replaceAll('{s}', server), vector };
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
/** The template of `readCollectionXyzLink`, or null when there is none. */
|
|
44
|
+
export function readCollectionXyzTemplate(collection) {
|
|
45
|
+
return readCollectionXyzLink(collection)?.template ?? null;
|
|
46
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { FeatureFilter } from './featureFilter.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Supported high-level WFS operation names used by the app.
|
|
4
|
+
*/
|
|
5
|
+
export type WfsOperationName = 'GetCapabilities' | 'DescribeFeatureType' | 'GetFeature' | 'Transaction';
|
|
6
|
+
/**
|
|
7
|
+
* Summary of supported operations advertised by the service.
|
|
8
|
+
*/
|
|
9
|
+
export interface WfsOperationsSupport {
|
|
10
|
+
GetCapabilities: boolean;
|
|
11
|
+
DescribeFeatureType: boolean;
|
|
12
|
+
GetFeature: boolean;
|
|
13
|
+
Transaction: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Per-feature-type operation support advertised in GetCapabilities (when provided by the server).
|
|
17
|
+
*/
|
|
18
|
+
export interface WfsFeatureTypeOperationsSupport {
|
|
19
|
+
Query: boolean;
|
|
20
|
+
Insert: boolean;
|
|
21
|
+
Update: boolean;
|
|
22
|
+
Delete: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Parsed WGS84 bounding box (lon/lat order).
|
|
26
|
+
*/
|
|
27
|
+
export interface WfsWgs84BoundingBox {
|
|
28
|
+
minX: number;
|
|
29
|
+
minY: number;
|
|
30
|
+
maxX: number;
|
|
31
|
+
maxY: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Lightweight feature type metadata from WFS GetCapabilities.
|
|
35
|
+
*/
|
|
36
|
+
export interface WfsFeatureTypeSummary {
|
|
37
|
+
name: string;
|
|
38
|
+
title: string;
|
|
39
|
+
abstract: string | null;
|
|
40
|
+
keywords: string[];
|
|
41
|
+
defaultSrs: string | null;
|
|
42
|
+
otherSrs: string[];
|
|
43
|
+
supportedSrs: string[];
|
|
44
|
+
wgs84BoundingBox: WfsWgs84BoundingBox | null;
|
|
45
|
+
operations: WfsFeatureTypeOperationsSupport | null;
|
|
46
|
+
/** Addresses of the layer's metadata records, from its `MetadataURL` elements. */
|
|
47
|
+
metadataUrls: string[];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Parsed WFS service capabilities used by the layer control UI.
|
|
51
|
+
*/
|
|
52
|
+
export interface WfsCapabilities {
|
|
53
|
+
version: string;
|
|
54
|
+
serviceTitle: string | null;
|
|
55
|
+
operations: WfsOperationsSupport;
|
|
56
|
+
getFeatureOutputFormats: string[];
|
|
57
|
+
featureTypes: WfsFeatureTypeSummary[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Primitive XSD field categories used for validation and form hints.
|
|
61
|
+
*/
|
|
62
|
+
export type WfsFieldKind = 'string' | 'integer' | 'number' | 'boolean' | 'date' | 'dateTime' | 'geometry' | 'unknown';
|
|
63
|
+
/**
|
|
64
|
+
* Parsed field definition from DescribeFeatureType.
|
|
65
|
+
*/
|
|
66
|
+
export interface WfsFieldSchema {
|
|
67
|
+
name: string;
|
|
68
|
+
xsdType: string;
|
|
69
|
+
xsdLocalType: string;
|
|
70
|
+
kind: WfsFieldKind;
|
|
71
|
+
minOccurs: number;
|
|
72
|
+
maxOccurs: number | 'unbounded';
|
|
73
|
+
nillable: boolean;
|
|
74
|
+
isGeometry: boolean;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Parsed schema information for a WFS feature type.
|
|
78
|
+
*/
|
|
79
|
+
export interface WfsDescribeFeatureTypeSchema {
|
|
80
|
+
requestedTypeName: string;
|
|
81
|
+
featureTypeName: string;
|
|
82
|
+
targetNamespace: string;
|
|
83
|
+
targetPrefix: string;
|
|
84
|
+
geometryFieldName: string | null;
|
|
85
|
+
fields: WfsFieldSchema[];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Client-side validation error for a single field.
|
|
89
|
+
*/
|
|
90
|
+
export interface WfsValidationError {
|
|
91
|
+
field: string;
|
|
92
|
+
message: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Active WFS layer metadata bound to the currently loaded GeoJSON data.
|
|
96
|
+
*/
|
|
97
|
+
export interface ActiveWfsLayer {
|
|
98
|
+
endpoint: string;
|
|
99
|
+
featureType: WfsFeatureTypeSummary;
|
|
100
|
+
schema: WfsDescribeFeatureTypeSchema;
|
|
101
|
+
getFeatureOutputFormat: string | null;
|
|
102
|
+
getFeatureSrsName: string;
|
|
103
|
+
transactionSrsName: string;
|
|
104
|
+
/** The version the service's capabilities document advertised. */
|
|
105
|
+
version: string;
|
|
106
|
+
/** Map projection at the time the layer was loaded. Captured per-layer to support future multi-CRS map views. */
|
|
107
|
+
sourceMapSrsName: string;
|
|
108
|
+
/**
|
|
109
|
+
* The QGIS project's filter on the layer, sent with every request for its
|
|
110
|
+
* features. A layer with one is read-only (`layerViewOnlyReason`).
|
|
111
|
+
*/
|
|
112
|
+
featureFilter?: FeatureFilter;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* WFS Transaction result summary (when the server returns a standard response).
|
|
116
|
+
*
|
|
117
|
+
* Counts are optional in the WFS schema, and OpenLayers' parser only sets a
|
|
118
|
+
* property when its element is present — so an omitted count is `undefined`
|
|
119
|
+
* here, not zero. A caller reading one must tell those apart: absent means the
|
|
120
|
+
* outcome is unknown, zero means the server changed nothing.
|
|
121
|
+
*/
|
|
122
|
+
export interface WfsTransactionSummary {
|
|
123
|
+
totalInserted: number | undefined;
|
|
124
|
+
totalUpdated: number | undefined;
|
|
125
|
+
totalDeleted: number | undefined;
|
|
126
|
+
}
|
|
127
|
+
/** The change a transaction was posted to make, used to read the matching count back. */
|
|
128
|
+
export type WfsTransactionOperation = 'insert' | 'update' | 'delete';
|
|
129
|
+
/**
|
|
130
|
+
* Parsed result from a posted WFS transaction.
|
|
131
|
+
*/
|
|
132
|
+
export interface WfsTransactionResult {
|
|
133
|
+
summary: WfsTransactionSummary | null;
|
|
134
|
+
insertIds: string[];
|
|
135
|
+
rawXml: string;
|
|
136
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LayerGroup } from '../model/QgsProject.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Walks the QGIS layer tree and records each layer-leaf's effective `checked`
|
|
4
|
+
* state, intersected with the checked state of every group above it.
|
|
5
|
+
*
|
|
6
|
+
* A layer id absent from the returned map was not found in the tree — either
|
|
7
|
+
* the project has no `<layer-tree-group>`, the legend failed to parse, or the
|
|
8
|
+
* leaf had no id. `parseQgsXml` reads such a layer as visible.
|
|
9
|
+
*/
|
|
10
|
+
export declare function collectLayerVisibility(group: LayerGroup): Map<string, boolean>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Walks the QGIS layer tree and records each layer-leaf's effective `checked`
|
|
3
|
+
* state, intersected with the checked state of every group above it.
|
|
4
|
+
*
|
|
5
|
+
* A layer id absent from the returned map was not found in the tree — either
|
|
6
|
+
* the project has no `<layer-tree-group>`, the legend failed to parse, or the
|
|
7
|
+
* leaf had no id. `parseQgsXml` reads such a layer as visible.
|
|
8
|
+
*/
|
|
9
|
+
export function collectLayerVisibility(group) {
|
|
10
|
+
const out = new Map();
|
|
11
|
+
function walk(node, parentChecked) {
|
|
12
|
+
if (node.kind === 'layer') {
|
|
13
|
+
out.set(node.layerId, parentChecked && node.checked);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
for (const child of node.children) {
|
|
17
|
+
walk(child, parentChecked && node.checked);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
walk(group, true);
|
|
21
|
+
return out;
|
|
22
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads a `<maplayer>`'s `<customproperties>`, in either form QGIS reads
|
|
3
|
+
* (`QgsObjectCustomProperties::readXml`, `src/core/qgsobjectcustomproperties.cpp`,
|
|
4
|
+
* `qgis/QGIS@master`, read 2026-10-25). Since QGIS 3.20 the block holds one
|
|
5
|
+
* `<Option type="Map">` with an `<Option name>` per key: a `value` attribute
|
|
6
|
+
* for a single value, or a child `<Option>` per entry of a list. Before that it
|
|
7
|
+
* held a `<property key>` per key, with a `value` attribute or a child `<value>`
|
|
8
|
+
* per entry. Keys are flat, slashes and all (`QFieldSync/action`).
|
|
9
|
+
*/
|
|
10
|
+
/** A key's values, in either form: one item for a single value, none where the key is absent. */
|
|
11
|
+
export declare function readCustomPropertyList(properties: Element, key: string): string[];
|
|
12
|
+
/** A single-valued key's value, or null where the key is absent. */
|
|
13
|
+
export declare function readCustomProperty(properties: Element, key: string): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Whether a saved value reads as true, as Qt's `QVariant::toBool` reads text:
|
|
16
|
+
* anything but blank, `0` and `false`, ignoring case. Null, an absent key, is false.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isTrueValue(value: string | null): boolean;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads a `<maplayer>`'s `<customproperties>`, in either form QGIS reads
|
|
3
|
+
* (`QgsObjectCustomProperties::readXml`, `src/core/qgsobjectcustomproperties.cpp`,
|
|
4
|
+
* `qgis/QGIS@master`, read 2026-10-25). Since QGIS 3.20 the block holds one
|
|
5
|
+
* `<Option type="Map">` with an `<Option name>` per key: a `value` attribute
|
|
6
|
+
* for a single value, or a child `<Option>` per entry of a list. Before that it
|
|
7
|
+
* held a `<property key>` per key, with a `value` attribute or a child `<value>`
|
|
8
|
+
* per entry. Keys are flat, slashes and all (`QFieldSync/action`).
|
|
9
|
+
*/
|
|
10
|
+
/** A key's values, in either form: one item for a single value, none where the key is absent. */
|
|
11
|
+
export function readCustomPropertyList(properties, key) {
|
|
12
|
+
const map = Array.from(properties.children).find((child) => child.tagName === 'Option');
|
|
13
|
+
if (map) {
|
|
14
|
+
const list = Array.from(map.children).find((option) => option.tagName === 'Option' && option.getAttribute('name') === key);
|
|
15
|
+
if (!list)
|
|
16
|
+
return [];
|
|
17
|
+
const single = list.getAttribute('value');
|
|
18
|
+
if (single !== null)
|
|
19
|
+
return [single];
|
|
20
|
+
return Array.from(list.children).flatMap((item) => item.tagName === 'Option' ? [item.getAttribute('value') ?? ''] : []);
|
|
21
|
+
}
|
|
22
|
+
const legacy = Array.from(properties.children).find((property) => property.tagName === 'property' && property.getAttribute('key') === key);
|
|
23
|
+
if (!legacy)
|
|
24
|
+
return [];
|
|
25
|
+
const single = legacy.getAttribute('value');
|
|
26
|
+
if (single !== null)
|
|
27
|
+
return [single];
|
|
28
|
+
return Array.from(legacy.children).flatMap((item) => item.tagName === 'value' ? [item.textContent ?? ''] : []);
|
|
29
|
+
}
|
|
30
|
+
/** A single-valued key's value, or null where the key is absent. */
|
|
31
|
+
export function readCustomProperty(properties, key) {
|
|
32
|
+
return readCustomPropertyList(properties, key)[0] ?? null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Whether a saved value reads as true, as Qt's `QVariant::toBool` reads text:
|
|
36
|
+
* anything but blank, `0` and `false`, ignoring case. Null, an absent key, is false.
|
|
37
|
+
*/
|
|
38
|
+
export function isTrueValue(value) {
|
|
39
|
+
if (value === null)
|
|
40
|
+
return false;
|
|
41
|
+
const text = value.toLowerCase();
|
|
42
|
+
return text !== '' && text !== '0' && text !== 'false';
|
|
43
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { FileDataSource, LayerEntry, QgsProject } from '../model/QgsProject.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The project's layers that QGIS split out of one file by shape, which
|
|
4
|
+
* Groundwork shows as one layer: file layers whose sources are the same but
|
|
5
|
+
* for `|geometrytype=`, each naming a different shape. Keyed by each sibling's
|
|
6
|
+
* layer id, the value lists the whole set in the project's layer order (the
|
|
7
|
+
* layers panel, then layers it does not list, in file order), so its first
|
|
8
|
+
* entry is the layer the set takes its settings from.
|
|
9
|
+
*
|
|
10
|
+
* A set needs two siblings or more. Layers on the same file with no
|
|
11
|
+
* `geometrytype=`, or with any other difference in their source (another
|
|
12
|
+
* option, `subset=`, another spelling of the path), are not siblings, and
|
|
13
|
+
* neither are two naming the same shape: the set is then left as separate
|
|
14
|
+
* layers.
|
|
15
|
+
*/
|
|
16
|
+
export declare function findGeometrySiblings(project: Pick<QgsProject, 'layers' | 'layerTree'>): Map<string, readonly LayerEntry[]>;
|
|
17
|
+
/** The shape each sibling keeps, in their order. */
|
|
18
|
+
export declare function readSiblingShapes(siblings: readonly LayerEntry[]): Array<NonNullable<FileDataSource['geometryTypeFilter']>>;
|
|
19
|
+
/** The id of the Collection a layer is in: the first sibling's, for a geometry sibling. */
|
|
20
|
+
export declare function siblingCollectionId(siblingsById: Map<string, readonly LayerEntry[]>, layerId: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* The shapes of the geometry siblings `layerId` belongs to, in their order, or
|
|
23
|
+
* null where it is no sibling: the shapes the one layer they make holds.
|
|
24
|
+
*/
|
|
25
|
+
export declare function readGeometrySiblingShapes(project: Pick<QgsProject, 'layers' | 'layerTree'>, layerId: string): Array<NonNullable<FileDataSource['geometryTypeFilter']>> | null;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { GEOMETRY_TYPE_OPTION } from "./parseDataSource.js";
|
|
2
|
+
/**
|
|
3
|
+
* The project's layers that QGIS split out of one file by shape, which
|
|
4
|
+
* Groundwork shows as one layer: file layers whose sources are the same but
|
|
5
|
+
* for `|geometrytype=`, each naming a different shape. Keyed by each sibling's
|
|
6
|
+
* layer id, the value lists the whole set in the project's layer order (the
|
|
7
|
+
* layers panel, then layers it does not list, in file order), so its first
|
|
8
|
+
* entry is the layer the set takes its settings from.
|
|
9
|
+
*
|
|
10
|
+
* A set needs two siblings or more. Layers on the same file with no
|
|
11
|
+
* `geometrytype=`, or with any other difference in their source (another
|
|
12
|
+
* option, `subset=`, another spelling of the path), are not siblings, and
|
|
13
|
+
* neither are two naming the same shape: the set is then left as separate
|
|
14
|
+
* layers.
|
|
15
|
+
*/
|
|
16
|
+
export function findGeometrySiblings(project) {
|
|
17
|
+
const bySource = new Map();
|
|
18
|
+
for (const layer of orderLayersAsListed(project)) {
|
|
19
|
+
const ds = layer.dataSource;
|
|
20
|
+
if (ds.kind !== 'file' || ds.geometryTypeFilter === null)
|
|
21
|
+
continue;
|
|
22
|
+
const key = sourceWithoutGeometryType(ds.raw);
|
|
23
|
+
const set = bySource.get(key) ?? [];
|
|
24
|
+
set.push(layer);
|
|
25
|
+
bySource.set(key, set);
|
|
26
|
+
}
|
|
27
|
+
const siblingsById = new Map();
|
|
28
|
+
for (const set of bySource.values()) {
|
|
29
|
+
if (set.length < 2)
|
|
30
|
+
continue;
|
|
31
|
+
if (new Set(readSiblingShapes(set)).size !== set.length)
|
|
32
|
+
continue;
|
|
33
|
+
for (const layer of set)
|
|
34
|
+
siblingsById.set(layer.id, set);
|
|
35
|
+
}
|
|
36
|
+
return siblingsById;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A file source with its first `geometrytype=` option taken out, the one QGIS
|
|
40
|
+
* reads (`readGeometryTypeFilter` in `parseDataSource.ts`), the rest spelled as
|
|
41
|
+
* written.
|
|
42
|
+
*/
|
|
43
|
+
function sourceWithoutGeometryType(raw) {
|
|
44
|
+
const parts = raw.trim().split('|');
|
|
45
|
+
const index = parts.findIndex((part) => GEOMETRY_TYPE_OPTION.test(part.trim()));
|
|
46
|
+
return parts.filter((_part, partIndex) => partIndex !== index).join('|');
|
|
47
|
+
}
|
|
48
|
+
/** The shape each sibling keeps, in their order. */
|
|
49
|
+
export function readSiblingShapes(siblings) {
|
|
50
|
+
return siblings.flatMap((layer) => layer.dataSource.kind === 'file' && layer.dataSource.geometryTypeFilter ? [layer.dataSource.geometryTypeFilter] : []);
|
|
51
|
+
}
|
|
52
|
+
/** The id of the Collection a layer is in: the first sibling's, for a geometry sibling. */
|
|
53
|
+
export function siblingCollectionId(siblingsById, layerId) {
|
|
54
|
+
return siblingsById.get(layerId)?.[0].id ?? layerId;
|
|
55
|
+
}
|
|
56
|
+
/** The layers in the layers panel's order, then those it does not list, in the order the file holds them. */
|
|
57
|
+
function orderLayersAsListed(project) {
|
|
58
|
+
const byId = new Map(project.layers.map((layer) => [layer.id, layer]));
|
|
59
|
+
const ordered = new Set();
|
|
60
|
+
const walk = (group) => {
|
|
61
|
+
for (const child of group.children) {
|
|
62
|
+
if (child.kind === 'group')
|
|
63
|
+
walk(child);
|
|
64
|
+
else {
|
|
65
|
+
const layer = byId.get(child.layerId);
|
|
66
|
+
if (layer)
|
|
67
|
+
ordered.add(layer);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
walk(project.layerTree);
|
|
72
|
+
for (const layer of project.layers)
|
|
73
|
+
ordered.add(layer);
|
|
74
|
+
return [...ordered];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The shapes of the geometry siblings `layerId` belongs to, in their order, or
|
|
78
|
+
* null where it is no sibling: the shapes the one layer they make holds.
|
|
79
|
+
*/
|
|
80
|
+
export function readGeometrySiblingShapes(project, layerId) {
|
|
81
|
+
const siblings = findGeometrySiblings(project).get(layerId);
|
|
82
|
+
return siblings ? readSiblingShapes(siblings) : null;
|
|
83
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The project colour label Groundwork reads as the map's brand colour, compared ignoring case. */
|
|
2
|
+
export declare const BRAND_COLOUR_LABEL = "Brand";
|
|
3
|
+
/**
|
|
4
|
+
* The project colour labelled {@link BRAND_COLOUR_LABEL} (Project Properties >
|
|
5
|
+
* Colors), as QGIS saved it, or null where the project has none. QGIS saves
|
|
6
|
+
* the palette as two parallel lists, `<Palette><Colors>` and
|
|
7
|
+
* `<Palette><Labels>` (`QgsProject::setProjectColors`,
|
|
8
|
+
* `src/core/project/qgsproject.cpp`), each colour in
|
|
9
|
+
* `QgsColorUtils::colorToString` form, which starts `r,g,b,a,`
|
|
10
|
+
* (`src/core/qgscolorutils.cpp`, `qgis/QGIS@master`, read 2026-10-25). The
|
|
11
|
+
* first matching label wins. The app decodes the text: this package reads no
|
|
12
|
+
* colours of its own.
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseBrandColour(qgisRoot: Element): string | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { propertyList, readPropertyBlock } from "./projectProperties.js";
|
|
2
|
+
/** The project colour label Groundwork reads as the map's brand colour, compared ignoring case. */
|
|
3
|
+
export const BRAND_COLOUR_LABEL = 'Brand';
|
|
4
|
+
/**
|
|
5
|
+
* The project colour labelled {@link BRAND_COLOUR_LABEL} (Project Properties >
|
|
6
|
+
* Colors), as QGIS saved it, or null where the project has none. QGIS saves
|
|
7
|
+
* the palette as two parallel lists, `<Palette><Colors>` and
|
|
8
|
+
* `<Palette><Labels>` (`QgsProject::setProjectColors`,
|
|
9
|
+
* `src/core/project/qgsproject.cpp`), each colour in
|
|
10
|
+
* `QgsColorUtils::colorToString` form, which starts `r,g,b,a,`
|
|
11
|
+
* (`src/core/qgscolorutils.cpp`, `qgis/QGIS@master`, read 2026-10-25). The
|
|
12
|
+
* first matching label wins. The app decodes the text: this package reads no
|
|
13
|
+
* colours of its own.
|
|
14
|
+
*/
|
|
15
|
+
export function parseBrandColour(qgisRoot) {
|
|
16
|
+
const palette = readPropertyBlock(qgisRoot, 'Palette');
|
|
17
|
+
if (!palette)
|
|
18
|
+
return null;
|
|
19
|
+
const colours = propertyList(palette, 'Colors');
|
|
20
|
+
const labels = propertyList(palette, 'Labels');
|
|
21
|
+
const index = labels.findIndex((label) => label.trim().toLowerCase() === BRAND_COLOUR_LABEL.toLowerCase());
|
|
22
|
+
if (index < 0)
|
|
23
|
+
return null;
|
|
24
|
+
return colours[index]?.trim() || null;
|
|
25
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads each field's active data-defined **Editable** property, the button
|
|
3
|
+
* beside a field's Editable box in QGIS's Attributes Form, as one QGIS
|
|
4
|
+
* expression per field name.
|
|
5
|
+
*
|
|
6
|
+
* QGIS saves them under the layer's `<dataDefinedFieldProperties>`, one
|
|
7
|
+
* `<field name>` per field holding a property collection
|
|
8
|
+
* (`QgsEditFormConfig::writeXml`, `src/core/editform/qgseditformconfig.cpp`,
|
|
9
|
+
* and `QgsPropertyCollection::toVariant`, `src/core/qgspropertycollection.cpp`,
|
|
10
|
+
* `qgis/QGIS@master`, read 2026-10-25):
|
|
11
|
+
*
|
|
12
|
+
* <dataDefinedFieldProperties>
|
|
13
|
+
* <field name="installed">
|
|
14
|
+
* <Option type="Map">
|
|
15
|
+
* <Option type="QString" value="" name="name"/>
|
|
16
|
+
* <Option type="Map" name="properties">
|
|
17
|
+
* <Option type="Map" name="dataDefinedEditable">
|
|
18
|
+
* <Option type="bool" value="true" name="active"/>
|
|
19
|
+
* <Option type="QString" value=""last_inspected" IS NULL" name="expression"/>
|
|
20
|
+
* <Option type="int" value="3" name="type"/>
|
|
21
|
+
* </Option>
|
|
22
|
+
* </Option>
|
|
23
|
+
* <Option type="QString" value="collection" name="type"/>
|
|
24
|
+
* </Option>
|
|
25
|
+
* </field>
|
|
26
|
+
* </dataDefinedFieldProperties>
|
|
27
|
+
*
|
|
28
|
+
* `type` is `Qgis::PropertyType`: 1 static (`val`), 2 field (`field`), 3
|
|
29
|
+
* expression (`expression`) (`QgsProperty::toVariant`, `src/core/qgsproperty.cpp`).
|
|
30
|
+
* A field-type property becomes the field named in double quotes, and a static
|
|
31
|
+
* one `true` or `false`, read as Qt reads a string as a Boolean: empty, `0` and
|
|
32
|
+
* `false` in any case are false. A property that is not active, of an unknown
|
|
33
|
+
* type, or with no field or expression is left out, as `QgsProperty::loadVariant`
|
|
34
|
+
* deactivates an empty field or expression.
|
|
35
|
+
*
|
|
36
|
+
* Alias and Custom comment are not read.
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseDataDefinedEditable(maplayer: Element): Map<string, string>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads each field's active data-defined **Editable** property, the button
|
|
3
|
+
* beside a field's Editable box in QGIS's Attributes Form, as one QGIS
|
|
4
|
+
* expression per field name.
|
|
5
|
+
*
|
|
6
|
+
* QGIS saves them under the layer's `<dataDefinedFieldProperties>`, one
|
|
7
|
+
* `<field name>` per field holding a property collection
|
|
8
|
+
* (`QgsEditFormConfig::writeXml`, `src/core/editform/qgseditformconfig.cpp`,
|
|
9
|
+
* and `QgsPropertyCollection::toVariant`, `src/core/qgspropertycollection.cpp`,
|
|
10
|
+
* `qgis/QGIS@master`, read 2026-10-25):
|
|
11
|
+
*
|
|
12
|
+
* <dataDefinedFieldProperties>
|
|
13
|
+
* <field name="installed">
|
|
14
|
+
* <Option type="Map">
|
|
15
|
+
* <Option type="QString" value="" name="name"/>
|
|
16
|
+
* <Option type="Map" name="properties">
|
|
17
|
+
* <Option type="Map" name="dataDefinedEditable">
|
|
18
|
+
* <Option type="bool" value="true" name="active"/>
|
|
19
|
+
* <Option type="QString" value=""last_inspected" IS NULL" name="expression"/>
|
|
20
|
+
* <Option type="int" value="3" name="type"/>
|
|
21
|
+
* </Option>
|
|
22
|
+
* </Option>
|
|
23
|
+
* <Option type="QString" value="collection" name="type"/>
|
|
24
|
+
* </Option>
|
|
25
|
+
* </field>
|
|
26
|
+
* </dataDefinedFieldProperties>
|
|
27
|
+
*
|
|
28
|
+
* `type` is `Qgis::PropertyType`: 1 static (`val`), 2 field (`field`), 3
|
|
29
|
+
* expression (`expression`) (`QgsProperty::toVariant`, `src/core/qgsproperty.cpp`).
|
|
30
|
+
* A field-type property becomes the field named in double quotes, and a static
|
|
31
|
+
* one `true` or `false`, read as Qt reads a string as a Boolean: empty, `0` and
|
|
32
|
+
* `false` in any case are false. A property that is not active, of an unknown
|
|
33
|
+
* type, or with no field or expression is left out, as `QgsProperty::loadVariant`
|
|
34
|
+
* deactivates an empty field or expression.
|
|
35
|
+
*
|
|
36
|
+
* Alias and Custom comment are not read.
|
|
37
|
+
*/
|
|
38
|
+
export function parseDataDefinedEditable(maplayer) {
|
|
39
|
+
const result = new Map();
|
|
40
|
+
const block = Array.from(maplayer.children).find((child) => child.tagName === 'dataDefinedFieldProperties');
|
|
41
|
+
for (const field of Array.from(block?.children ?? [])) {
|
|
42
|
+
const name = field.getAttribute('name')?.trim();
|
|
43
|
+
if (field.tagName !== 'field' || !name || result.has(name))
|
|
44
|
+
continue;
|
|
45
|
+
const property = field.querySelector(':scope > Option[type="Map"] > Option[name="properties"] > Option[name="dataDefinedEditable"]');
|
|
46
|
+
const expression = property ? readProperty(property) : null;
|
|
47
|
+
if (expression)
|
|
48
|
+
result.set(name, expression);
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
function readProperty(property) {
|
|
53
|
+
const values = new Map();
|
|
54
|
+
for (const option of Array.from(property.children)) {
|
|
55
|
+
const key = option.getAttribute('name');
|
|
56
|
+
if (key && option.tagName === 'Option')
|
|
57
|
+
values.set(key, option.getAttribute('value') ?? '');
|
|
58
|
+
}
|
|
59
|
+
const active = values.get('active')?.trim().toLowerCase();
|
|
60
|
+
if (active !== 'true' && active !== '1')
|
|
61
|
+
return null;
|
|
62
|
+
switch (Number.parseInt(values.get('type') ?? '', 10)) {
|
|
63
|
+
case 1: {
|
|
64
|
+
const value = (values.get('val') ?? '').trim().toLowerCase();
|
|
65
|
+
return value === '' || value === '0' || value === 'false' ? 'false' : 'true';
|
|
66
|
+
}
|
|
67
|
+
case 2: {
|
|
68
|
+
const field = values.get('field')?.trim();
|
|
69
|
+
return field ? `"${field.replaceAll('"', '""')}"` : null;
|
|
70
|
+
}
|
|
71
|
+
case 3:
|
|
72
|
+
return values.get('expression')?.trim() || null;
|
|
73
|
+
default:
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|