@vectoriahq/quac 0.1.0 → 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/README.md +1 -1
- package/dist/generate/externalStacCatalogue.d.ts +4 -4
- package/dist/generate/externalStacCatalogue.js +9 -11
- package/dist/generate/folderStacCatalogue.js +1 -1
- package/dist/generate/normalizedProject.d.ts +5 -4
- package/dist/generate/normalizedProject.js +44 -92
- package/dist/generate/ogcFeaturesStacCatalogue.js +1 -1
- package/dist/generate/stacCatalogue.js +7 -2
- package/dist/generate/wmsStacCatalogue.js +2 -1
- package/dist/model/QgsProject.d.ts +11 -9
- package/dist/model/Stac.d.ts +8 -6
- package/dist/model/Stac.js +1 -1
- package/dist/model/featureFilter.d.ts +1 -1
- package/dist/model/fieldIconAddress.d.ts +1 -1
- package/dist/model/fieldIconAddress.js +1 -1
- package/dist/model/ogcFeatures.d.ts +3 -3
- package/dist/model/ogcFeatures.js +2 -2
- package/dist/model/quacExtension.d.ts +1 -1
- package/dist/model/quacExtension.js +1 -1
- package/dist/model/stacAssetRoles.d.ts +1 -1
- package/dist/model/stacAssetRoles.js +1 -1
- package/dist/model/stacHref.d.ts +1 -1
- package/dist/model/stacHref.js +1 -1
- package/dist/model/stacPmtiles.d.ts +1 -1
- package/dist/model/stacWms.d.ts +1 -1
- package/dist/model/stacWms.js +1 -1
- package/dist/model/wfs.d.ts +1 -1
- package/dist/parse/geometrySiblings.d.ts +1 -1
- package/dist/parse/geometrySiblings.js +1 -1
- package/dist/parse/parseBrandColour.d.ts +3 -3
- package/dist/parse/parseBrandColour.js +3 -3
- package/dist/parse/parseDataDefinedEditable.js +2 -2
- package/dist/parse/parseLayers.js +88 -85
- package/dist/parse/parseMeasurement.d.ts +2 -3
- package/dist/parse/parseMeasurement.js +3 -4
- package/dist/parse/qgisExpression.d.ts +4 -4
- package/dist/parse/qgisExpression.js +8 -8
- package/dist/parse/qtDateFormat.d.ts +3 -3
- package/dist/parse/qtDateFormat.js +3 -3
- package/dist/parse/qtRegex.d.ts +2 -2
- package/dist/parse/qtRegex.js +2 -2
- package/dist/sources/stacItems.d.ts +1 -1
- package/dist/sources/stacItems.js +2 -2
- package/dist/util/devLog.d.ts +1 -2
- package/dist/util/devLog.js +1 -2
- package/dist/util/nonBlankText.d.ts +2 -0
- package/dist/util/nonBlankText.js +4 -0
- package/dist/util/wfsVersions.js +1 -1
- package/package.json +10 -2
- package/src/schema/quac.schema.json +5 -1
|
@@ -4,7 +4,7 @@ import type { StacCatalog, StacCollection } from './Stac.ts';
|
|
|
4
4
|
* `stac_extensions` to say which QUAC it follows. Written from this one
|
|
5
5
|
* constant, so the address changes in one place when the schema moves.
|
|
6
6
|
*/
|
|
7
|
-
export declare const QUAC_SCHEMA_URL = "https://vectoriahq.github.io/quac/v0.
|
|
7
|
+
export declare const QUAC_SCHEMA_URL = "https://vectoriahq.github.io/quac/v0.2.0/schema.json";
|
|
8
8
|
/**
|
|
9
9
|
* The QUAC version a document declares, such as `0.1.0`, read from the QUAC
|
|
10
10
|
* schema address in its `stac_extensions`. Null where it lists none.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* `stac_extensions` to say which QUAC it follows. Written from this one
|
|
4
4
|
* constant, so the address changes in one place when the schema moves.
|
|
5
5
|
*/
|
|
6
|
-
export const QUAC_SCHEMA_URL = 'https://vectoriahq.github.io/quac/v0.
|
|
6
|
+
export const QUAC_SCHEMA_URL = 'https://vectoriahq.github.io/quac/v0.2.0/schema.json';
|
|
7
7
|
// A QUAC schema address is a folder named for its version, holding the
|
|
8
8
|
// schema file `QUAC_SCHEMA_URL` names. Only the path is matched, not the host.
|
|
9
9
|
const QUAC_SCHEMA_FILE = QUAC_SCHEMA_URL.slice(QUAC_SCHEMA_URL.lastIndexOf('/'));
|
|
@@ -4,7 +4,7 @@ import type { StacAsset, StacCollection } from './Stac.ts';
|
|
|
4
4
|
*
|
|
5
5
|
* Portolan addresses assets by role rather than by key
|
|
6
6
|
* (the Portolan convention): `data` is the primary file, `visual`
|
|
7
|
-
* a rendering derivative, `style` a visualisation style.
|
|
7
|
+
* a rendering derivative, `style` a visualisation style. This package's own
|
|
8
8
|
* generators write the primary file under the `data` key *and* the `data` role,
|
|
9
9
|
* so the key stands as the fallback for a document that declares no roles at
|
|
10
10
|
* all — which an external catalogue is free to do.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Portolan addresses assets by role rather than by key
|
|
5
5
|
* (the Portolan convention): `data` is the primary file, `visual`
|
|
6
|
-
* a rendering derivative, `style` a visualisation style.
|
|
6
|
+
* a rendering derivative, `style` a visualisation style. This package's own
|
|
7
7
|
* generators write the primary file under the `data` key *and* the `data` role,
|
|
8
8
|
* so the key stands as the fallback for a document that declares no roles at
|
|
9
9
|
* all — which an external catalogue is free to do.
|
package/dist/model/stacHref.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { StacCollection } from './Stac.ts';
|
|
|
4
4
|
*
|
|
5
5
|
* An href is a URI reference, not a file path, so the characters URIs reserve
|
|
6
6
|
* have to be escaped in it. `#` and `?` are the two that bite: both are legal
|
|
7
|
-
* in a
|
|
7
|
+
* in a cloud folder's file names, and both end the path when
|
|
8
8
|
* a reader takes an href apart. A folder holding `Building #3.geojson` written
|
|
9
9
|
* unescaped publishes `./Building #3.geojson`, which reads back as `Building `
|
|
10
10
|
* — a file no folder holds, so the layer is dropped.
|
package/dist/model/stacHref.js
CHANGED
|
@@ -4,7 +4,7 @@ import { readDataAsset } from "./stacAssetRoles.js";
|
|
|
4
4
|
*
|
|
5
5
|
* An href is a URI reference, not a file path, so the characters URIs reserve
|
|
6
6
|
* have to be escaped in it. `#` and `?` are the two that bite: both are legal
|
|
7
|
-
* in a
|
|
7
|
+
* in a cloud folder's file names, and both end the path when
|
|
8
8
|
* a reader takes an href apart. A folder holding `Building #3.geojson` written
|
|
9
9
|
* unescaped publishes `./Building #3.geojson`, which reads back as `Building `
|
|
10
10
|
* — a file no folder holds, so the layer is dropped.
|
|
@@ -20,7 +20,7 @@ export interface StacPmtilesSource {
|
|
|
20
20
|
/**
|
|
21
21
|
* Layer names inside the archive to draw, from the link's `pmtiles:layers`.
|
|
22
22
|
* Empty where the source declares none — web-map-links leaves the choice to
|
|
23
|
-
* the reader in that case,
|
|
23
|
+
* the reader in that case, which may draw every layer the archive has.
|
|
24
24
|
*/
|
|
25
25
|
layers: string[];
|
|
26
26
|
}
|
package/dist/model/stacWms.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { WmsDataSource } from './QgsProject.ts';
|
|
|
2
2
|
import type { StacCollection, StacLink } from './Stac.ts';
|
|
3
3
|
/**
|
|
4
4
|
* The CRS a QGIS Server layer is requested in: the map's own when the server
|
|
5
|
-
* offers it, so the server draws it without the
|
|
5
|
+
* offers it, so the server draws it without the reading application reprojecting the image.
|
|
6
6
|
*/
|
|
7
7
|
export declare const PREFERRED_WMS_CRS = "EPSG:3857";
|
|
8
8
|
/** The CRS a WMS link asks for from the CRSs its server offers: `PREFERRED_WMS_CRS` where it is offered or none is listed, else the first. */
|
package/dist/model/stacWms.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The CRS a QGIS Server layer is requested in: the map's own when the server
|
|
3
|
-
* offers it, so the server draws it without the
|
|
3
|
+
* offers it, so the server draws it without the reading application reprojecting the image.
|
|
4
4
|
*/
|
|
5
5
|
export const PREFERRED_WMS_CRS = 'EPSG:3857';
|
|
6
6
|
/** The CRS a WMS link asks for from the CRSs its server offers: `PREFERRED_WMS_CRS` where it is offered or none is listed, else the first. */
|
package/dist/model/wfs.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FeatureFilter } from './featureFilter.ts';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* The high-level WFS operation names this package models.
|
|
4
4
|
*/
|
|
5
5
|
export type WfsOperationName = 'GetCapabilities' | 'DescribeFeatureType' | 'GetFeature' | 'Transaction';
|
|
6
6
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { FileDataSource, LayerEntry, QgsProject } from '../model/QgsProject.ts';
|
|
2
2
|
/**
|
|
3
3
|
* The project's layers that QGIS split out of one file by shape, which
|
|
4
|
-
*
|
|
4
|
+
* the catalogue publishes as one layer: file layers whose sources are the same but
|
|
5
5
|
* for `|geometrytype=`, each naming a different shape. Keyed by each sibling's
|
|
6
6
|
* layer id, the value lists the whole set in the project's layer order (the
|
|
7
7
|
* layers panel, then layers it does not list, in file order), so its first
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GEOMETRY_TYPE_OPTION } from "./parseDataSource.js";
|
|
2
2
|
/**
|
|
3
3
|
* The project's layers that QGIS split out of one file by shape, which
|
|
4
|
-
*
|
|
4
|
+
* the catalogue publishes as one layer: file layers whose sources are the same but
|
|
5
5
|
* for `|geometrytype=`, each naming a different shape. Keyed by each sibling's
|
|
6
6
|
* layer id, the value lists the whole set in the project's layer order (the
|
|
7
7
|
* layers panel, then layers it does not list, in file order), so its first
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** The project colour label
|
|
1
|
+
/** The project colour label this package reads as the map's brand colour, compared ignoring case. */
|
|
2
2
|
export declare const BRAND_COLOUR_LABEL = "Brand";
|
|
3
3
|
/**
|
|
4
4
|
* The project colour labelled {@link BRAND_COLOUR_LABEL} (Project Properties >
|
|
@@ -8,7 +8,7 @@ export declare const BRAND_COLOUR_LABEL = "Brand";
|
|
|
8
8
|
* `src/core/project/qgsproject.cpp`), each colour in
|
|
9
9
|
* `QgsColorUtils::colorToString` form, which starts `r,g,b,a,`
|
|
10
10
|
* (`src/core/qgscolorutils.cpp`, `qgis/QGIS@master`, read 2026-10-25). The
|
|
11
|
-
* first matching label wins. The
|
|
12
|
-
* colours of its own.
|
|
11
|
+
* first matching label wins. The reading application decodes the text: this
|
|
12
|
+
* package reads no colours of its own.
|
|
13
13
|
*/
|
|
14
14
|
export declare function parseBrandColour(qgisRoot: Element): string | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { propertyList, readPropertyBlock } from "./projectProperties.js";
|
|
2
|
-
/** The project colour label
|
|
2
|
+
/** The project colour label this package reads as the map's brand colour, compared ignoring case. */
|
|
3
3
|
export const BRAND_COLOUR_LABEL = 'Brand';
|
|
4
4
|
/**
|
|
5
5
|
* The project colour labelled {@link BRAND_COLOUR_LABEL} (Project Properties >
|
|
@@ -9,8 +9,8 @@ export const BRAND_COLOUR_LABEL = 'Brand';
|
|
|
9
9
|
* `src/core/project/qgsproject.cpp`), each colour in
|
|
10
10
|
* `QgsColorUtils::colorToString` form, which starts `r,g,b,a,`
|
|
11
11
|
* (`src/core/qgscolorutils.cpp`, `qgis/QGIS@master`, read 2026-10-25). The
|
|
12
|
-
* first matching label wins. The
|
|
13
|
-
* colours of its own.
|
|
12
|
+
* first matching label wins. The reading application decodes the text: this
|
|
13
|
+
* package reads no colours of its own.
|
|
14
14
|
*/
|
|
15
15
|
export function parseBrandColour(qgisRoot) {
|
|
16
16
|
const palette = readPropertyBlock(qgisRoot, 'Palette');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isTrueValue } from "./customProperties.js";
|
|
1
2
|
/**
|
|
2
3
|
* Reads each field's active data-defined **Editable** property, the button
|
|
3
4
|
* beside a field's Editable box in QGIS's Attributes Form, as one QGIS
|
|
@@ -61,8 +62,7 @@ function readProperty(property) {
|
|
|
61
62
|
return null;
|
|
62
63
|
switch (Number.parseInt(values.get('type') ?? '', 10)) {
|
|
63
64
|
case 1: {
|
|
64
|
-
|
|
65
|
-
return value === '' || value === '0' || value === 'false' ? 'false' : 'true';
|
|
65
|
+
return isTrueValue((values.get('val') ?? '').trim()) ? 'true' : 'false';
|
|
66
66
|
}
|
|
67
67
|
case 2: {
|
|
68
68
|
const field = values.get('field')?.trim();
|
|
@@ -120,12 +120,8 @@ function parseMapLayer(maplayer) {
|
|
|
120
120
|
function serverHiddenFieldsOf(maplayer) {
|
|
121
121
|
const wms = new Set();
|
|
122
122
|
const wfs = new Set();
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
const name = field.getAttribute('name');
|
|
126
|
-
if (!name)
|
|
127
|
-
continue;
|
|
128
|
-
const flags = (field.getAttribute('configurationFlags') ?? '').split('|').map((flag) => flag.trim());
|
|
123
|
+
for (const [name, field] of layerFields(maplayer)) {
|
|
124
|
+
const flags = configurationFlagsOf(field);
|
|
129
125
|
if (flags.includes('HideFromWms'))
|
|
130
126
|
wms.add(name);
|
|
131
127
|
if (flags.includes('HideFromWfs'))
|
|
@@ -269,19 +265,9 @@ const VALUE_MAP_NULL_CODE = '{2839923C-8B7D-419E-B84B-CA2FE9B80EC7}';
|
|
|
269
265
|
*/
|
|
270
266
|
function parseFieldValueMaps(maplayer) {
|
|
271
267
|
const result = {};
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
// `<map-layer-style-manager>`'s embedded per-style documents, whose field
|
|
275
|
-
// configs can genuinely disagree with the layer's own (verified against
|
|
276
|
-
// `packages/quac/src/tests/fixtures/qgis/graffiti/graffiti.qgs`, whose Graffiti Reports
|
|
277
|
-
// layer has `incident_uid` as `UuidGenerator` in a saved style and
|
|
278
|
-
// `TextEdit` at the layer's own level).
|
|
279
|
-
const fieldConfig = directChild(maplayer, 'fieldConfiguration');
|
|
280
|
-
for (const field of fieldConfig?.querySelectorAll(':scope > field') ?? []) {
|
|
281
|
-
const name = field.getAttribute('name');
|
|
282
|
-
if (!name || result[name])
|
|
268
|
+
for (const [name, editWidget] of layerEditWidgets(maplayer)) {
|
|
269
|
+
if (result[name])
|
|
283
270
|
continue;
|
|
284
|
-
const editWidget = directChild(field, 'editWidget');
|
|
285
271
|
if (editWidget?.getAttribute('type') !== 'ValueMap')
|
|
286
272
|
continue;
|
|
287
273
|
const mapList = editWidget.querySelector(':scope > config > Option[type="Map"] > Option[type="List"][name="map"]');
|
|
@@ -334,41 +320,30 @@ function parseFieldValueMaps(maplayer) {
|
|
|
334
320
|
*/
|
|
335
321
|
function parseFieldValueRelations(maplayer) {
|
|
336
322
|
const result = {};
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
for (const field of fieldConfig?.querySelectorAll(':scope > field') ?? []) {
|
|
340
|
-
const name = field.getAttribute('name');
|
|
341
|
-
if (!name || result[name])
|
|
323
|
+
for (const [name, editWidget] of layerEditWidgets(maplayer)) {
|
|
324
|
+
if (result[name])
|
|
342
325
|
continue;
|
|
343
|
-
const editWidget = directChild(field, 'editWidget');
|
|
344
326
|
if (editWidget?.getAttribute('type') !== 'ValueRelation')
|
|
345
327
|
continue;
|
|
346
|
-
const options =
|
|
347
|
-
for (const option of editWidget.querySelectorAll(':scope > config > Option[type="Map"] > Option')) {
|
|
348
|
-
const key = option.getAttribute('name');
|
|
349
|
-
const value = option.getAttribute('value');
|
|
350
|
-
if (key && value !== null)
|
|
351
|
-
options.set(key, value);
|
|
352
|
-
}
|
|
353
|
-
const isOn = (key) => options.get(key) === 'true' || options.get(key) === '1';
|
|
328
|
+
const options = readOptionMap(editWidget);
|
|
354
329
|
const layerId = readTrimmedOption(options, 'Layer') ?? '';
|
|
355
330
|
const layerName = readTrimmedOption(options, 'LayerName') ?? '';
|
|
356
331
|
const keyField = readTrimmedOption(options, 'Key');
|
|
357
332
|
const valueField = readTrimmedOption(options, 'Value');
|
|
358
333
|
if ((!layerId && !layerName) || !keyField || !valueField)
|
|
359
334
|
continue;
|
|
360
|
-
const orderField =
|
|
335
|
+
const orderField = readFlag(options, 'OrderByField') ? readTrimmedOption(options, 'OrderByFieldName') : null;
|
|
361
336
|
result[name] = {
|
|
362
337
|
layerId,
|
|
363
338
|
layerName,
|
|
364
339
|
keyField,
|
|
365
340
|
valueField,
|
|
366
341
|
filterExpression: readTrimmedOption(options, 'FilterExpression') ?? '',
|
|
367
|
-
allowNull:
|
|
368
|
-
allowMulti:
|
|
369
|
-
orderBy:
|
|
370
|
-
orderField:
|
|
371
|
-
descending:
|
|
342
|
+
allowNull: readFlag(options, 'AllowNull'),
|
|
343
|
+
allowMulti: readFlag(options, 'AllowMulti'),
|
|
344
|
+
orderBy: readFlag(options, 'OrderByValue') ? 'value' : orderField ? 'field' : 'key',
|
|
345
|
+
orderField: readFlag(options, 'OrderByValue') ? null : orderField,
|
|
346
|
+
descending: readFlag(options, 'OrderByDescending')
|
|
372
347
|
};
|
|
373
348
|
}
|
|
374
349
|
return result;
|
|
@@ -393,7 +368,7 @@ const RELATIVE_STORAGE = ['absolute', 'project', 'default-root'];
|
|
|
393
368
|
*/
|
|
394
369
|
const SINGLE_FILE_STORAGE_MODES = new Set([0, 3]);
|
|
395
370
|
/**
|
|
396
|
-
* Reads every field's Attachment edit widget into what
|
|
371
|
+
* Reads every field's Attachment edit widget into what the catalogue records,
|
|
397
372
|
* keyed by field name. QGIS registers the widget as `ExternalResource`
|
|
398
373
|
* (`QgsEditorWidgetRegistry::initEditors`,
|
|
399
374
|
* `src/gui/editorwidgets/core/qgseditorwidgetregistry.cpp`, `qgis/QGIS@master`,
|
|
@@ -412,7 +387,7 @@ const SINGLE_FILE_STORAGE_MODES = new Set([0, 3]);
|
|
|
412
387
|
* </editWidget>
|
|
413
388
|
*
|
|
414
389
|
* The widget writes more keys than these four; the rest are left behind
|
|
415
|
-
*
|
|
390
|
+
* and the catalogue does not carry them. A value-less `<Option type="invalid">`,
|
|
416
391
|
* which QGIS writes for an unset key, is skipped rather than read as blank.
|
|
417
392
|
* A widget whose `StorageMode` picks a directory or several files is not an
|
|
418
393
|
* attachment here.
|
|
@@ -421,23 +396,12 @@ const SINGLE_FILE_STORAGE_MODES = new Set([0, 3]);
|
|
|
421
396
|
*/
|
|
422
397
|
function parseFieldAttachments(maplayer) {
|
|
423
398
|
const result = {};
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
const fieldConfig = directChild(maplayer, 'fieldConfiguration');
|
|
427
|
-
for (const field of fieldConfig?.querySelectorAll(':scope > field') ?? []) {
|
|
428
|
-
const name = field.getAttribute('name');
|
|
429
|
-
if (!name || result[name])
|
|
399
|
+
for (const [name, editWidget] of layerEditWidgets(maplayer)) {
|
|
400
|
+
if (result[name])
|
|
430
401
|
continue;
|
|
431
|
-
const editWidget = directChild(field, 'editWidget');
|
|
432
402
|
if (editWidget?.getAttribute('type') !== 'ExternalResource')
|
|
433
403
|
continue;
|
|
434
|
-
const options =
|
|
435
|
-
for (const option of editWidget.querySelectorAll(':scope > config > Option[type="Map"] > Option')) {
|
|
436
|
-
const key = option.getAttribute('name');
|
|
437
|
-
const value = option.getAttribute('value');
|
|
438
|
-
if (key && value !== null)
|
|
439
|
-
options.set(key, value);
|
|
440
|
-
}
|
|
404
|
+
const options = readOptionMap(editWidget);
|
|
441
405
|
const storageMode = options.get('StorageMode');
|
|
442
406
|
if (storageMode !== undefined && !SINGLE_FILE_STORAGE_MODES.has(Number(storageMode)))
|
|
443
407
|
continue;
|
|
@@ -456,7 +420,7 @@ function parseFieldAttachments(maplayer) {
|
|
|
456
420
|
*/
|
|
457
421
|
const NOW_EXPRESSIONS = new Set(['now()', '$now', 'to_date(now())', 'to_datetime(now())']);
|
|
458
422
|
/**
|
|
459
|
-
* Reads the Attributes Form settings
|
|
423
|
+
* Reads the Attributes Form settings the catalogue records for every field, keyed
|
|
460
424
|
* by field name. QGIS writes them as blocks of the layer's own, shown here as
|
|
461
425
|
* `packages/quac/src/tests/fixtures/qgis/graffiti/graffiti.qgs` writes them:
|
|
462
426
|
*
|
|
@@ -484,10 +448,9 @@ const NOW_EXPRESSIONS = new Set(['now()', '$now', 'to_date(now())', 'to_datetime
|
|
|
484
448
|
*
|
|
485
449
|
* A default is kept as a `defaultValue` where `parseDefaultExpression` reads it,
|
|
486
450
|
* as a `defaultExpression` where only `readQgisExpression` does, and otherwise
|
|
487
|
-
* left out
|
|
488
|
-
*
|
|
489
|
-
*
|
|
490
|
-
* returned map.
|
|
451
|
+
* left out. A constraint expression follows the same rule. A field the
|
|
452
|
+
* `<editable>` block does not list is editable. A field with none of these
|
|
453
|
+
* settings is absent from the returned map.
|
|
491
454
|
*/
|
|
492
455
|
function parseFieldEditRules(maplayer) {
|
|
493
456
|
const result = {};
|
|
@@ -518,17 +481,21 @@ function parseFieldEditRules(maplayer) {
|
|
|
518
481
|
// first, so the widget's identifier stands only where there is none. The
|
|
519
482
|
// widget's shortening to a string field's declared length is not followed:
|
|
520
483
|
// a `.qgs` file does not carry a WFS field's length.
|
|
521
|
-
const fieldConfig = directChild(maplayer, 'fieldConfiguration');
|
|
522
484
|
const seenWidgets = new Set();
|
|
523
485
|
const allowNullOff = new Set();
|
|
524
|
-
for (const field of
|
|
525
|
-
|
|
526
|
-
if (!name || seenWidgets.has(name))
|
|
486
|
+
for (const [name, field] of layerFields(maplayer)) {
|
|
487
|
+
if (seenWidgets.has(name))
|
|
527
488
|
continue;
|
|
528
489
|
seenWidgets.add(name);
|
|
529
490
|
const widgetType = directChild(field, 'editWidget')?.getAttribute('type');
|
|
530
491
|
if (widgetType === 'Hidden')
|
|
531
492
|
ruleFor(name).hidden = true;
|
|
493
|
+
// The Fields tab's Not searchable, which QGIS's search of the active
|
|
494
|
+
// layer's features skips (`QgsActiveLayerFeaturesLocatorFilter`,
|
|
495
|
+
// `src/app/locator/qgsactivelayerfeatureslocatorfilter.cpp`,
|
|
496
|
+
// `qgis/QGIS@master`, read 2026-11-11).
|
|
497
|
+
if (configurationFlagsOf(field).includes('NotSearchable'))
|
|
498
|
+
ruleFor(name).notSearchable = true;
|
|
532
499
|
// The widget has no settings of its own (`QgsColorWidgetFactory::configWidget`,
|
|
533
500
|
// `src/gui/editorwidgets/qgscolorwidgetfactory.cpp`, `qgis/QGIS@master`,
|
|
534
501
|
// read 2026-10-25).
|
|
@@ -549,7 +516,7 @@ function parseFieldEditRules(maplayer) {
|
|
|
549
516
|
// (`QgsVectorLayer::readSymbology`, `src/core/vector/qgsvectorlayer.cpp`, and
|
|
550
517
|
// `QgsFieldConstraints`, `src/core/qgsfieldconstraints.h`, `qgis/QGIS@master`,
|
|
551
518
|
// read 2026-10-23). An expression is kept only where `readQgisExpression`
|
|
552
|
-
// reads it
|
|
519
|
+
// reads it.
|
|
553
520
|
const constraintExpressions = new Map();
|
|
554
521
|
for (const node of directChild(maplayer, 'constraintExpressions')?.querySelectorAll(':scope > constraint') ?? []) {
|
|
555
522
|
const name = node.getAttribute('field');
|
|
@@ -619,17 +586,7 @@ function parseFieldEditRules(maplayer) {
|
|
|
619
586
|
* `allow_null` both default to true; a field with either off goes in `allowNullOff`.
|
|
620
587
|
*/
|
|
621
588
|
function readWidgetOptions(field, name, widgetType, ruleFor, allowNullOff) {
|
|
622
|
-
const options =
|
|
623
|
-
for (const option of directChild(field, 'editWidget')?.querySelectorAll(':scope > config > Option[type="Map"] > Option') ?? []) {
|
|
624
|
-
const key = option.getAttribute('name');
|
|
625
|
-
const value = option.getAttribute('value');
|
|
626
|
-
if (key && value !== null)
|
|
627
|
-
options.set(key, value);
|
|
628
|
-
}
|
|
629
|
-
const flag = (key, fallback) => {
|
|
630
|
-
const value = options.get(key);
|
|
631
|
-
return value === undefined ? fallback : value === 'true' || value === '1';
|
|
632
|
-
};
|
|
589
|
+
const options = readOptionMap(directChild(field, 'editWidget'));
|
|
633
590
|
const number = (key) => {
|
|
634
591
|
const text = options.get(key)?.trim();
|
|
635
592
|
if (!text)
|
|
@@ -643,7 +600,7 @@ function readWidgetOptions(field, name, widgetType, ruleFor, allowNullOff) {
|
|
|
643
600
|
checkedValue: readTrimmedOption(options, 'CheckedState'),
|
|
644
601
|
uncheckedValue: readTrimmedOption(options, 'UncheckedState'),
|
|
645
602
|
showStoredValue: options.get('TextDisplayMethod') === '1',
|
|
646
|
-
allowNull:
|
|
603
|
+
allowNull: readFlag(options, 'AllowNullState', false)
|
|
647
604
|
};
|
|
648
605
|
return;
|
|
649
606
|
case 'Range': {
|
|
@@ -665,18 +622,18 @@ function readWidgetOptions(field, name, widgetType, ruleFor, allowNullOff) {
|
|
|
665
622
|
range.suffix = suffix;
|
|
666
623
|
if (Object.keys(range).length > 0)
|
|
667
624
|
ruleFor(name).range = range;
|
|
668
|
-
if (!
|
|
625
|
+
if (!readFlag(options, 'AllowNull', true))
|
|
669
626
|
allowNullOff.add(name);
|
|
670
627
|
return;
|
|
671
628
|
}
|
|
672
629
|
case 'DateTime': {
|
|
673
|
-
// A date or date-time field ignores `field_format`, which
|
|
674
|
-
// cannot tell here. ISO 8601 and the default for a date are what
|
|
675
|
-
//
|
|
630
|
+
// A date or date-time field ignores `field_format`, which this parser
|
|
631
|
+
// cannot tell here. ISO 8601 and the default for a date are what an
|
|
632
|
+
// application already reads, so they write nothing.
|
|
676
633
|
const format = options.get('field_format')?.trim();
|
|
677
|
-
if (format && format !== 'yyyy-MM-dd' && !
|
|
634
|
+
if (format && format !== 'yyyy-MM-dd' && !readFlag(options, 'field_iso_format', false))
|
|
678
635
|
ruleFor(name).dateFormat = format;
|
|
679
|
-
if (!
|
|
636
|
+
if (!readFlag(options, 'allow_null', true))
|
|
680
637
|
allowNullOff.add(name);
|
|
681
638
|
}
|
|
682
639
|
}
|
|
@@ -697,8 +654,8 @@ function constraintStrength(strength) {
|
|
|
697
654
|
* and reads the older block first so the newer one wins
|
|
698
655
|
* (`QgsEditFormConfig::readXml`, `src/core/editform/qgseditformconfig.cpp`,
|
|
699
656
|
* `qgis/QGIS@master`, read 2026-10-23). `AllowedDefaultOff` reads as not
|
|
700
|
-
* reused: it is off until someone ticks it in QGIS's own form, which
|
|
701
|
-
*
|
|
657
|
+
* reused: it is off until someone ticks it in QGIS's own form, which a
|
|
658
|
+
* reading application's form may have no tick for.
|
|
702
659
|
*/
|
|
703
660
|
function parseReuseLastValue(maplayer) {
|
|
704
661
|
const reuse = new Map();
|
|
@@ -716,7 +673,7 @@ function parseReuseLastValue(maplayer) {
|
|
|
716
673
|
return reuse;
|
|
717
674
|
}
|
|
718
675
|
/**
|
|
719
|
-
* Reads a default-value expression
|
|
676
|
+
* Reads a default-value expression an application can fill: one of
|
|
720
677
|
* `NOW_EXPRESSIONS`, `uuid()` or `$uuid` with an optional format, or a lone
|
|
721
678
|
* literal. Anything else, such as a field reference, a variable or a
|
|
722
679
|
* calculation, is null.
|
|
@@ -1103,6 +1060,52 @@ function parseOpacity(maplayer) {
|
|
|
1103
1060
|
const value = Number(text);
|
|
1104
1061
|
return Number.isFinite(value) ? Math.max(0, Math.min(1, value)) : 1;
|
|
1105
1062
|
}
|
|
1063
|
+
/**
|
|
1064
|
+
* The layer's own `<fieldConfiguration>` fields that have a name, as
|
|
1065
|
+
* `[name, <field>]`, in document order. A saved alternate style embeds its
|
|
1066
|
+
* own `<fieldConfiguration>`, which can disagree with the layer's own, so only
|
|
1067
|
+
* the direct child of `<maplayer>` is read (see docs/gotchas.md).
|
|
1068
|
+
*/
|
|
1069
|
+
function* layerFields(maplayer) {
|
|
1070
|
+
for (const field of directChild(maplayer, 'fieldConfiguration')?.querySelectorAll(':scope > field') ?? []) {
|
|
1071
|
+
const name = field.getAttribute('name');
|
|
1072
|
+
if (name)
|
|
1073
|
+
yield [name, field];
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* A `<fieldConfiguration><field>`'s `configurationFlags`: the Fields tab's
|
|
1078
|
+
* Configuration column, saved as `Qgis::FieldConfigurationFlag` names joined
|
|
1079
|
+
* by `|`, such as `NotSearchable|HideFromWms`, and `NoFlag` where none is set.
|
|
1080
|
+
*/
|
|
1081
|
+
function configurationFlagsOf(field) {
|
|
1082
|
+
return (field.getAttribute('configurationFlags') ?? '').split('|').map((flag) => flag.trim());
|
|
1083
|
+
}
|
|
1084
|
+
/** The named fields' `<editWidget>`, as `[name, <editWidget>]`; null where a field has none. */
|
|
1085
|
+
function* layerEditWidgets(maplayer) {
|
|
1086
|
+
for (const [name, field] of layerFields(maplayer))
|
|
1087
|
+
yield [name, directChild(field, 'editWidget')];
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* A flat widget config as key and value: the widget's `<Option type="Map">`
|
|
1091
|
+
* members that have a name and a `value`. An `<Option type="invalid">` that
|
|
1092
|
+
* QGIS writes for an unset key has no `value` and is left out.
|
|
1093
|
+
*/
|
|
1094
|
+
function readOptionMap(editWidget) {
|
|
1095
|
+
const options = new Map();
|
|
1096
|
+
for (const option of editWidget?.querySelectorAll(':scope > config > Option[type="Map"] > Option') ?? []) {
|
|
1097
|
+
const key = option.getAttribute('name');
|
|
1098
|
+
const value = option.getAttribute('value');
|
|
1099
|
+
if (key && value !== null)
|
|
1100
|
+
options.set(key, value);
|
|
1101
|
+
}
|
|
1102
|
+
return options;
|
|
1103
|
+
}
|
|
1104
|
+
/** A Boolean widget option: `true` or `1` is on, any other value off, and an absent key `fallback`. */
|
|
1105
|
+
function readFlag(options, key, fallback = false) {
|
|
1106
|
+
const value = options.get(key);
|
|
1107
|
+
return value === undefined ? fallback : value === 'true' || value === '1';
|
|
1108
|
+
}
|
|
1106
1109
|
function directChild(parent, tag) {
|
|
1107
1110
|
for (const child of Array.from(parent.children)) {
|
|
1108
1111
|
if (child.tagName === tag)
|
|
@@ -2,7 +2,7 @@ import type { ProjectMeasurement } from '../model/QgsProject.ts';
|
|
|
2
2
|
/** QGIS's own defaults for a project that saves no units (`QgsProject::clear`, `src/core/project/qgsproject.cpp`). */
|
|
3
3
|
export declare const DEFAULT_MEASUREMENT: ProjectMeasurement;
|
|
4
4
|
/**
|
|
5
|
-
* The factors that turn
|
|
5
|
+
* The factors that turn metres and square metres into
|
|
6
6
|
* the project's units, or null for a unit it does not convert. An expression
|
|
7
7
|
* that measures in a unit with no factor is unreadable.
|
|
8
8
|
*/
|
|
@@ -15,7 +15,6 @@ export declare function measureFactorsOf(measurement: ProjectMeasurement | null
|
|
|
15
15
|
* The project's area and distance units from `<properties><Measurement>`, as
|
|
16
16
|
* QGIS writes them (`QgsProject::writeProject`, `src/core/project/qgsproject.cpp`).
|
|
17
17
|
* Null where the project saves neither, which QGIS reads as square metres and
|
|
18
|
-
* metres. The project's ellipsoid (`<Measure><Ellipsoid>`) is not read
|
|
19
|
-
* Groundwork measures on WGS 84 whatever the project says.
|
|
18
|
+
* metres. The project's ellipsoid (`<Measure><Ellipsoid>`) is not read.
|
|
20
19
|
*/
|
|
21
20
|
export declare function parseProjectMeasurement(qgisRoot: Element): ProjectMeasurement | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { propertyText, readPropertyBlock } from "./projectProperties.js";
|
|
2
2
|
/**
|
|
3
3
|
* How many of a unit make up one square metre, for the area units QGIS saves
|
|
4
|
-
* as `<Measurement><AreaUnits>` that
|
|
4
|
+
* as `<Measurement><AreaUnits>` that this package converts. The saved names are
|
|
5
5
|
* `QgsUnitTypes::encodeUnit( Qgis::AreaUnit )` (`src/core/qgsunittypes.cpp`,
|
|
6
6
|
* `qgis/QGIS@master`, read 2026-10-25). `deg2` is saved too and is left out: a
|
|
7
7
|
* square degree is no fixed area.
|
|
@@ -21,7 +21,7 @@ const AREA_UNITS_PER_SQUARE_METRE = {
|
|
|
21
21
|
};
|
|
22
22
|
/**
|
|
23
23
|
* How many of a unit make up one metre, for the distance units QGIS saves as
|
|
24
|
-
* `<Measurement><DistanceUnits>` that
|
|
24
|
+
* `<Measurement><DistanceUnits>` that this package converts. The saved names are
|
|
25
25
|
* `QgsUnitTypes::encodeUnit( Qgis::DistanceUnit )`, same file. `degrees` and
|
|
26
26
|
* the survey chains are left out.
|
|
27
27
|
*/
|
|
@@ -49,8 +49,7 @@ export function measureFactorsOf(measurement) {
|
|
|
49
49
|
* The project's area and distance units from `<properties><Measurement>`, as
|
|
50
50
|
* QGIS writes them (`QgsProject::writeProject`, `src/core/project/qgsproject.cpp`).
|
|
51
51
|
* Null where the project saves neither, which QGIS reads as square metres and
|
|
52
|
-
* metres. The project's ellipsoid (`<Measure><Ellipsoid>`) is not read
|
|
53
|
-
* Groundwork measures on WGS 84 whatever the project says.
|
|
52
|
+
* metres. The project's ellipsoid (`<Measure><Ellipsoid>`) is not read.
|
|
54
53
|
*/
|
|
55
54
|
export function parseProjectMeasurement(qgisRoot) {
|
|
56
55
|
const block = readPropertyBlock(qgisRoot, 'Measurement');
|
|
@@ -54,7 +54,7 @@ export type ExpressionNode = {
|
|
|
54
54
|
}>;
|
|
55
55
|
otherwise: ExpressionNode | null;
|
|
56
56
|
};
|
|
57
|
-
/** The `aggregate` kinds
|
|
57
|
+
/** The `aggregate` kinds this reader takes, which the caller works out (`QgsAggregateCalculator::aggregates`). */
|
|
58
58
|
export declare const LOOKUP_AGGREGATES: readonly ["count", "min", "max", "concatenate"];
|
|
59
59
|
/**
|
|
60
60
|
* One read of another layer of the project: the features of `layer`, named by
|
|
@@ -78,7 +78,7 @@ export interface LayerLookup {
|
|
|
78
78
|
*/
|
|
79
79
|
export declare const LAYER_LOOKUP = "layer_lookup";
|
|
80
80
|
/**
|
|
81
|
-
* The values QGIS gives a feature from its geometry that
|
|
81
|
+
* The values QGIS gives a feature from its geometry that this reader takes, and
|
|
82
82
|
* the unit each is in: an area or a distance. They are written with no
|
|
83
83
|
* brackets (`$area`).
|
|
84
84
|
*/
|
|
@@ -149,7 +149,7 @@ export declare function readQgisExpression(expression: string, options?: {
|
|
|
149
149
|
/**
|
|
150
150
|
* A QGIS rule's condition as a GeoStyler filter: the condition's GeoStyler
|
|
151
151
|
* function inside a `custom` function named `QGIS_CONDITION`, which
|
|
152
|
-
* `geostyler-openlayers-parser` hands to the evaluator
|
|
152
|
+
* `geostyler-openlayers-parser` hands to the evaluator the application gives it.
|
|
153
153
|
* Null for a condition `readQgisExpression` cannot read. `measure` is the
|
|
154
154
|
* project's units, which `$area` and `$length` need.
|
|
155
155
|
*/
|
|
@@ -172,7 +172,7 @@ export declare function readLayerLookups(node: ExpressionNode): LayerLookup[];
|
|
|
172
172
|
* no feature (`expressionFormAttributes`,
|
|
173
173
|
* `src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp`,
|
|
174
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.
|
|
175
|
+
* gives a blank name and the filter is not used. This reader takes a text
|
|
176
176
|
* literal as the one constant argument. An empty list is an expression that
|
|
177
177
|
* reads no form value.
|
|
178
178
|
*/
|
|
@@ -88,7 +88,7 @@ const LOOKUPS = ['overlay_within', 'overlay_intersects', 'aggregate'];
|
|
|
88
88
|
* through, which stand nowhere else.
|
|
89
89
|
*/
|
|
90
90
|
const PARENT_GEOMETRY_CALLS = ['intersects', 'geometry', '$geometry', '@parent'];
|
|
91
|
-
/** The `aggregate` kinds
|
|
91
|
+
/** The `aggregate` kinds this reader takes, which the caller works out (`QgsAggregateCalculator::aggregates`). */
|
|
92
92
|
export const LOOKUP_AGGREGATES = ['count', 'min', 'max', 'concatenate'];
|
|
93
93
|
/**
|
|
94
94
|
* The `fnName` of the GeoStyler `custom` function that stands for a
|
|
@@ -98,10 +98,10 @@ export const LOOKUP_AGGREGATES = ['count', 'min', 'max', 'concatenate'];
|
|
|
98
98
|
export const LAYER_LOOKUP = 'layer_lookup';
|
|
99
99
|
/** The functions that take a date as their first argument, where `now()` may stand. */
|
|
100
100
|
const DATE_TAKERS = ['format_date', 'year', 'month', 'day', 'week', 'day_of_week', 'hour', 'minute', 'second'];
|
|
101
|
-
/** The aggregates
|
|
101
|
+
/** The aggregates this reader reads, which scan the records of a layer. */
|
|
102
102
|
const AGGREGATES = ['maximum', 'minimum'];
|
|
103
103
|
/**
|
|
104
|
-
* The values QGIS gives a feature from its geometry that
|
|
104
|
+
* The values QGIS gives a feature from its geometry that this reader takes, and
|
|
105
105
|
* the unit each is in: an area or a distance. They are written with no
|
|
106
106
|
* brackets (`$area`).
|
|
107
107
|
*/
|
|
@@ -239,7 +239,7 @@ function findRegexpPredicates(node) {
|
|
|
239
239
|
const own = node.kind === 'predicate' && node.op === 'regexp' ? [node] : [];
|
|
240
240
|
return [...own, ...childNodes(node).flatMap(findRegexpPredicates)];
|
|
241
241
|
}
|
|
242
|
-
/** A `format_date` call whose pattern and language are written-in text, and whose pattern
|
|
242
|
+
/** A `format_date` call whose pattern and language are written-in text, and whose pattern this package formats. */
|
|
243
243
|
function isReadableFormatDate(call) {
|
|
244
244
|
const [, pattern, language] = call.args;
|
|
245
245
|
return pattern?.kind === 'text' && isFormattableQtDatePattern(pattern.value) && (language === undefined || language.kind === 'text');
|
|
@@ -247,7 +247,7 @@ function isReadableFormatDate(call) {
|
|
|
247
247
|
/**
|
|
248
248
|
* A QGIS rule's condition as a GeoStyler filter: the condition's GeoStyler
|
|
249
249
|
* function inside a `custom` function named `QGIS_CONDITION`, which
|
|
250
|
-
* `geostyler-openlayers-parser` hands to the evaluator
|
|
250
|
+
* `geostyler-openlayers-parser` hands to the evaluator the application gives it.
|
|
251
251
|
* Null for a condition `readQgisExpression` cannot read. `measure` is the
|
|
252
252
|
* project's units, which `$area` and `$length` need.
|
|
253
253
|
*/
|
|
@@ -604,7 +604,7 @@ function readCase(tokens, index) {
|
|
|
604
604
|
}
|
|
605
605
|
return isWord(tokens[next], 'end') ? { node: { kind: 'case', whens, otherwise }, next: next + 1 } : null;
|
|
606
606
|
}
|
|
607
|
-
/** The fewest and most arguments a label function takes, or null for a function
|
|
607
|
+
/** The fewest and most arguments a label function takes, or null for a function this reader does not read. */
|
|
608
608
|
function argumentRangeOf(name) {
|
|
609
609
|
if (name === 'concat')
|
|
610
610
|
return [1, Infinity];
|
|
@@ -639,7 +639,7 @@ function findAddedIntervals(node) {
|
|
|
639
639
|
return [...own, ...childNodes(node).flatMap(findAddedIntervals)];
|
|
640
640
|
}
|
|
641
641
|
/**
|
|
642
|
-
* Whether an expression's reads of other layers are ones
|
|
642
|
+
* Whether an expression's reads of other layers are ones the caller can answer.
|
|
643
643
|
* With `allowed` false, it holds none. Otherwise each `overlay_within` or
|
|
644
644
|
* `overlay_intersects` gives an expression and is the array that
|
|
645
645
|
* `array_first` or a whole-number `[index]` reads; each `aggregate` is a
|
|
@@ -746,7 +746,7 @@ function findCalls(node, ...names) {
|
|
|
746
746
|
* no feature (`expressionFormAttributes`,
|
|
747
747
|
* `src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp`,
|
|
748
748
|
* `qgis/QGIS@master`, read 2026-10-24), so an argument that reads a field
|
|
749
|
-
* gives a blank name and the filter is not used.
|
|
749
|
+
* gives a blank name and the filter is not used. This reader takes a text
|
|
750
750
|
* literal as the one constant argument. An empty list is an expression that
|
|
751
751
|
* reads no form value.
|
|
752
752
|
*/
|