@vectoriahq/quac 0.11.0 → 0.14.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/dist/generate/normalizedProject.d.ts +14 -0
- package/dist/generate/normalizedProject.js +17 -0
- package/dist/generate/serverLayerTree.d.ts +4 -3
- package/dist/generate/serverLayerTree.js +9 -7
- package/dist/generate/serverStacCatalogue.d.ts +25 -2
- package/dist/generate/serverStacCatalogue.js +56 -14
- package/dist/generate/stacCatalogue.d.ts +12 -0
- package/dist/generate/stacCatalogue.js +49 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -2
- package/dist/model/QgsProject.d.ts +6 -0
- package/dist/parse/parseLayers.js +26 -6
- package/package.json +1 -1
- package/src/schema/quac.schema.json +5 -0
|
@@ -53,6 +53,11 @@ export declare const QUAC_LEGEND_IMAGE_FIELD = "quac:legend_image";
|
|
|
53
53
|
* address, the same form as a column's `quac:icon`.
|
|
54
54
|
*/
|
|
55
55
|
export declare const QUAC_ICON_FIELD = "quac:icon";
|
|
56
|
+
/**
|
|
57
|
+
* The key a Collection takes for the message shown once a feature is added to
|
|
58
|
+
* it: text that may hold HTML markup.
|
|
59
|
+
*/
|
|
60
|
+
export declare const QUAC_ADDED_MESSAGE_FIELD = "quac:added_message";
|
|
56
61
|
/**
|
|
57
62
|
* The key a Collection takes for the area and distance units its source gives
|
|
58
63
|
* `$area`, `$length` and `$perimeter` in: `{ area_unit, distance_unit }`, each
|
|
@@ -208,6 +213,8 @@ export interface NormalizedLayer {
|
|
|
208
213
|
legendImage?: string | null;
|
|
209
214
|
/** Emitted as `quac:icon`: the `https://` address of the icon drawn beside the layer's name. */
|
|
210
215
|
icon?: string | null;
|
|
216
|
+
/** Emitted as `quac:added_message`: the message shown once a feature is added, as the source wrote it. */
|
|
217
|
+
addedMessage?: string | null;
|
|
211
218
|
/** Emitted as `quac:locks` where it locks an edit. */
|
|
212
219
|
locks?: LayerLocks;
|
|
213
220
|
/** Emitted as `quac:filters` where the source sets one up. */
|
|
@@ -344,6 +351,13 @@ export declare function readCollectionMeasurement(collection: StacCollection | n
|
|
|
344
351
|
export declare function readCollectionLegendImage(collection: StacCollection | null | undefined): string | null;
|
|
345
352
|
/** The icon drawn beside a Collection's name (`quac:icon`), or null where it names no `https://` address. */
|
|
346
353
|
export declare function readCollectionIcon(collection: StacCollection | null | undefined): string | null;
|
|
354
|
+
/**
|
|
355
|
+
* The message shown once a feature is added to a Collection
|
|
356
|
+
* (`quac:added_message`), as the source wrote it, or null where it names none.
|
|
357
|
+
* It may hold HTML markup, which the application shows only as far as it
|
|
358
|
+
* judges safe.
|
|
359
|
+
*/
|
|
360
|
+
export declare function readCollectionAddedMessage(collection: StacCollection | null | undefined): string | null;
|
|
347
361
|
/**
|
|
348
362
|
* Reads `quac:locks` back off a Collection: the edits it locks, each `true` or
|
|
349
363
|
* `{ expression }`. A member that is neither, or an expression that is blank,
|
|
@@ -57,6 +57,11 @@ export const QUAC_LEGEND_IMAGE_FIELD = 'quac:legend_image';
|
|
|
57
57
|
* address, the same form as a column's `quac:icon`.
|
|
58
58
|
*/
|
|
59
59
|
export const QUAC_ICON_FIELD = 'quac:icon';
|
|
60
|
+
/**
|
|
61
|
+
* The key a Collection takes for the message shown once a feature is added to
|
|
62
|
+
* it: text that may hold HTML markup.
|
|
63
|
+
*/
|
|
64
|
+
export const QUAC_ADDED_MESSAGE_FIELD = 'quac:added_message';
|
|
60
65
|
/**
|
|
61
66
|
* The key a Collection takes for the area and distance units its source gives
|
|
62
67
|
* `$area`, `$length` and `$perimeter` in: `{ area_unit, distance_unit }`, each
|
|
@@ -265,6 +270,8 @@ function buildCollection(layer, defaultProviders, folder) {
|
|
|
265
270
|
collection[QUAC_LEGEND_IMAGE_FIELD] = layer.legendImage;
|
|
266
271
|
if (layer.icon)
|
|
267
272
|
collection[QUAC_ICON_FIELD] = layer.icon;
|
|
273
|
+
if (layer.addedMessage)
|
|
274
|
+
collection[QUAC_ADDED_MESSAGE_FIELD] = layer.addedMessage;
|
|
268
275
|
if (layer.formOrder)
|
|
269
276
|
collection[QUAC_FORM_ORDER_FIELD] = layer.formOrder;
|
|
270
277
|
// Source-declaring vendor fields (`quac:wfs_*`), copied verbatim so a consumer reads the source structurally rather than by
|
|
@@ -509,6 +516,16 @@ export function readCollectionLegendImage(collection) {
|
|
|
509
516
|
export function readCollectionIcon(collection) {
|
|
510
517
|
return readHttpsAddress(collection?.[QUAC_ICON_FIELD]);
|
|
511
518
|
}
|
|
519
|
+
/**
|
|
520
|
+
* The message shown once a feature is added to a Collection
|
|
521
|
+
* (`quac:added_message`), as the source wrote it, or null where it names none.
|
|
522
|
+
* It may hold HTML markup, which the application shows only as far as it
|
|
523
|
+
* judges safe.
|
|
524
|
+
*/
|
|
525
|
+
export function readCollectionAddedMessage(collection) {
|
|
526
|
+
const message = collection?.[QUAC_ADDED_MESSAGE_FIELD];
|
|
527
|
+
return typeof message === 'string' && message.trim() !== '' ? message : null;
|
|
528
|
+
}
|
|
512
529
|
const LOCKED_EDITS = ['add', 'attributes', 'geometry', 'delete'];
|
|
513
530
|
/**
|
|
514
531
|
* Reads `quac:locks` back off a Collection: the edits it locks, each `true` or
|
|
@@ -35,9 +35,10 @@ export interface ServerLayerTreeLayer {
|
|
|
35
35
|
* what the QUAC plugin's reading spike returns in Python, so that the two
|
|
36
36
|
* languages are compared on the fixtures.
|
|
37
37
|
*
|
|
38
|
-
* A layer's names are `qgisServerNamesOf`'s, except that a layer
|
|
39
|
-
*
|
|
40
|
-
* the project does not
|
|
38
|
+
* A layer's names are `qgisServerNamesOf`'s, except that a layer the project
|
|
39
|
+
* leaves out of WMS (`wmsExcludedLayerIds`), such as one inside a group it
|
|
40
|
+
* leaves out, has no WMS name. A tree entry whose layer the project does not
|
|
41
|
+
* hold is left out.
|
|
41
42
|
*/
|
|
42
43
|
export declare function serverLayerTree(project: QgsProject): ServerLayerTree;
|
|
43
44
|
/** The ids of the layers the project publishes over WMS. */
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { qgisServerNamesOf } from "./stacCatalogue.js";
|
|
1
|
+
import { qgisServerNamesOf, wmsExcludedLayerIds } from "./stacCatalogue.js";
|
|
2
2
|
/**
|
|
3
3
|
* The layer tree QGIS Server reads from a project: each layer's WMS name and
|
|
4
4
|
* WFS type name, and the fields the project hides from each service. It is
|
|
5
5
|
* what the QUAC plugin's reading spike returns in Python, so that the two
|
|
6
6
|
* languages are compared on the fixtures.
|
|
7
7
|
*
|
|
8
|
-
* A layer's names are `qgisServerNamesOf`'s, except that a layer
|
|
9
|
-
*
|
|
10
|
-
* the project does not
|
|
8
|
+
* A layer's names are `qgisServerNamesOf`'s, except that a layer the project
|
|
9
|
+
* leaves out of WMS (`wmsExcludedLayerIds`), such as one inside a group it
|
|
10
|
+
* leaves out, has no WMS name. A tree entry whose layer the project does not
|
|
11
|
+
* hold is left out.
|
|
11
12
|
*/
|
|
12
13
|
export function serverLayerTree(project) {
|
|
13
14
|
const layersById = new Map(project.layers.map((layer) => [layer.id, layer]));
|
|
14
15
|
const restricted = new Set(project.wmsPublishing?.restrictedLayers ?? []);
|
|
16
|
+
const excluded = wmsExcludedLayerIds(project);
|
|
15
17
|
const context = { wmsPublishing: project.wmsPublishing ?? null, wfsTransactionLayers: project.wfsTransactionLayers ?? null };
|
|
16
18
|
const readGroup = (group, wmsPublished) => group.children.flatMap((node) => {
|
|
17
19
|
if (node.kind === 'group') {
|
|
@@ -19,17 +21,17 @@ export function serverLayerTree(project) {
|
|
|
19
21
|
return [{ kind: 'group', name: node.name, wmsPublished: published, children: readGroup(node, published) }];
|
|
20
22
|
}
|
|
21
23
|
const layer = layersById.get(node.layerId);
|
|
22
|
-
return layer ? [serverLayer(layer,
|
|
24
|
+
return layer ? [serverLayer(layer, !excluded.has(layer.id), context)] : [];
|
|
23
25
|
});
|
|
24
26
|
return { useLayerIds: project.wmsPublishing?.useLayerIds ?? false, children: readGroup(project.layerTree, true) };
|
|
25
27
|
}
|
|
26
|
-
function serverLayer(layer,
|
|
28
|
+
function serverLayer(layer, wmsPublished, context) {
|
|
27
29
|
const names = qgisServerNamesOf(layer, context);
|
|
28
30
|
return {
|
|
29
31
|
kind: 'layer',
|
|
30
32
|
id: layer.id,
|
|
31
33
|
name: layer.name,
|
|
32
|
-
wmsName:
|
|
34
|
+
wmsName: wmsPublished ? names.wmsName : null,
|
|
33
35
|
wfsTypeName: names.wfsTypeName,
|
|
34
36
|
hiddenFields: { wms: layer.serverHiddenFields?.wms ?? [], wfs: layer.serverHiddenFields?.wfs ?? [] }
|
|
35
37
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BoundingBox, QgsProject } from '../model/QgsProject.ts';
|
|
2
|
-
import type { StacCatalog } from '../model/Stac.ts';
|
|
2
|
+
import type { StacCatalog, StacCollection } from '../model/Stac.ts';
|
|
3
3
|
/**
|
|
4
4
|
* The catalogue a QGIS Server would serve for a project: the QUAC plugin's
|
|
5
5
|
* route, as a pure function of the project's text and the server's address, so
|
|
@@ -10,7 +10,8 @@ import type { StacCatalog } from '../model/Stac.ts';
|
|
|
10
10
|
* does:
|
|
11
11
|
*
|
|
12
12
|
* - A layer or group whose name the project leaves out of WMS
|
|
13
|
-
* (`WMSRestrictedLayers`) is left out, with every layer inside the group
|
|
13
|
+
* (`WMSRestrictedLayers`) is left out, with every layer inside the group, as
|
|
14
|
+
* `generateStacCatalogue` already leaves it out. A
|
|
14
15
|
* layer published for WFS but left out of WMS is left out too, because a
|
|
15
16
|
* server's Collection id is the WMS name (D1). A file the project splits into
|
|
16
17
|
* a layer per shape is left out: the project route writes it as one
|
|
@@ -82,3 +83,25 @@ export interface ServerCatalogueOptions {
|
|
|
82
83
|
* 2026-11-07). The list is the same for every layer.
|
|
83
84
|
*/
|
|
84
85
|
export declare function serverWmsCrsList(project: QgsProject): string[];
|
|
86
|
+
/**
|
|
87
|
+
* How `withoutHiddenFields` reads the other layers a Collection refers to: the
|
|
88
|
+
* fields a layer hides, by its project layer id, and the id a layer is served
|
|
89
|
+
* under, or null where it is not served.
|
|
90
|
+
*/
|
|
91
|
+
export interface HiddenFieldContext {
|
|
92
|
+
hiddenOf: (layerId: string) => ReadonlySet<string>;
|
|
93
|
+
servedId: (layerId: string) => string | null;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* A layer's Collection with every mention of the fields it hides from WMS or
|
|
97
|
+
* WFS dropped, as QGIS Server leaves them out of what it serves: its columns,
|
|
98
|
+
* its form order, its preset filters, its display field, a style's categorised
|
|
99
|
+
* field, a relation joined on a hidden field, and any expression that uses one.
|
|
100
|
+
* A lock whose expression uses one becomes `true`, and a field editable only
|
|
101
|
+
* while such an expression holds becomes read-only, so that hiding a field
|
|
102
|
+
* never unlocks an edit. A relation or Value Relation to a layer that is not
|
|
103
|
+
* served is dropped, and one to a served layer names it by its served id. For
|
|
104
|
+
* an application that serves a project's layers itself, as
|
|
105
|
+
* `generateServerStacCatalogue` does for QGIS Server.
|
|
106
|
+
*/
|
|
107
|
+
export declare function withoutHiddenFields(source: StacCollection, layerId: string, context: HiddenFieldContext): StacCollection;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { buildStacExtent, unionBboxes, withDataType } from "./normalizedProject.js";
|
|
2
2
|
import { serverLayerTree, wmsPublishedLayerIds } from "./serverLayerTree.js";
|
|
3
|
-
import { generateStacCatalogue } from "./stacCatalogue.js";
|
|
3
|
+
import { generateStacCatalogue, QUAC_CATEGORISED_FIELD } from "./stacCatalogue.js";
|
|
4
4
|
import { wfsGetFeatureAsset } from "./wfsStacCatalogue.js";
|
|
5
5
|
import { mapQtTypeToStacTableType } from "./wmsStacCatalogue.js";
|
|
6
6
|
import { declareQuacExtension, QUAC_SCHEMA_URL } from "../model/quacExtension.js";
|
|
@@ -17,7 +17,8 @@ import { chooseWmsCrs, WEB_MAP_LINKS_EXTENSION, WMS_REQUEST_PARAMETERS } from ".
|
|
|
17
17
|
* does:
|
|
18
18
|
*
|
|
19
19
|
* - A layer or group whose name the project leaves out of WMS
|
|
20
|
-
* (`WMSRestrictedLayers`) is left out, with every layer inside the group
|
|
20
|
+
* (`WMSRestrictedLayers`) is left out, with every layer inside the group, as
|
|
21
|
+
* `generateStacCatalogue` already leaves it out. A
|
|
21
22
|
* layer published for WFS but left out of WMS is left out too, because a
|
|
22
23
|
* server's Collection id is the WMS name (D1). A file the project splits into
|
|
23
24
|
* a layer per shape is left out: the project route writes it as one
|
|
@@ -60,7 +61,6 @@ export function generateServerStacCatalogue(project, options) {
|
|
|
60
61
|
const layerWgs84Extents = options.layerWgs84Extents ?? {};
|
|
61
62
|
const catalogue = generateStacCatalogue(project, [], { layerWgs84Extents: new Map(Object.entries(layerWgs84Extents)) });
|
|
62
63
|
const layersById = new Map(project.layers.map((layer) => [layer.id, layer]));
|
|
63
|
-
const restricted = new Set(project.wmsPublishing?.restrictedLayers ?? []);
|
|
64
64
|
const servedLayerIds = wmsPublishedLayerIds(serverLayerTree(project));
|
|
65
65
|
const wfsPublished = new Set(project.wfsTransactionLayers?.published ?? []);
|
|
66
66
|
const servedIds = new Map();
|
|
@@ -85,7 +85,7 @@ export function generateServerStacCatalogue(project, options) {
|
|
|
85
85
|
};
|
|
86
86
|
const serveCatalog = (node) => {
|
|
87
87
|
const collections = (node.collections ?? []).filter((collection) => servedIds.has(collection.id)).map((collection) => serveCollection(collection, context));
|
|
88
|
-
const catalogs = (node.catalogs ?? []).
|
|
88
|
+
const catalogs = (node.catalogs ?? []).map(serveCatalog);
|
|
89
89
|
const served = { ...node, links: [...node.links.filter((link) => link.rel !== 'child'), ...childLinks(catalogueFolder(node) ?? './', collections, catalogs)] };
|
|
90
90
|
delete served.collections;
|
|
91
91
|
delete served.catalogs;
|
|
@@ -185,8 +185,6 @@ function mentionsAny(expression, fields) {
|
|
|
185
185
|
const SOURCE_FIELDS = ['quac:wfs_endpoint', 'quac:wfs_type_name', 'quac:wfs_srs_name', 'quac:arcgis_layer_url', 'quac:arcgis_where', 'quac:max_zoom'];
|
|
186
186
|
function serveCollection(source, context) {
|
|
187
187
|
const layerId = source.id;
|
|
188
|
-
const layer = context.layersById.get(layerId);
|
|
189
|
-
const hidden = hiddenFieldsOf(layer);
|
|
190
188
|
const wmsName = context.servedIds.get(layerId);
|
|
191
189
|
const wfsTypeName = context.wfsPublished.has(layerId) ? source['quac:qgis_server_wfs_type_name'] : undefined;
|
|
192
190
|
const collection = { ...source, id: wmsName, links: [], assets: {} };
|
|
@@ -210,13 +208,36 @@ function serveCollection(source, context) {
|
|
|
210
208
|
collection.stac_extensions = extensions;
|
|
211
209
|
else
|
|
212
210
|
delete collection.stac_extensions;
|
|
211
|
+
const shown = withoutHiddenFields(collection, layerId, {
|
|
212
|
+
hiddenOf: (id) => hiddenFieldsOf(context.layersById.get(id)),
|
|
213
|
+
servedId: (id) => context.servedIds.get(id) ?? null
|
|
214
|
+
});
|
|
215
|
+
serveFieldTypes(shown, context.fieldTypes[layerId] ?? {});
|
|
216
|
+
return shown;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* A layer's Collection with every mention of the fields it hides from WMS or
|
|
220
|
+
* WFS dropped, as QGIS Server leaves them out of what it serves: its columns,
|
|
221
|
+
* its form order, its preset filters, its display field, a style's categorised
|
|
222
|
+
* field, a relation joined on a hidden field, and any expression that uses one.
|
|
223
|
+
* A lock whose expression uses one becomes `true`, and a field editable only
|
|
224
|
+
* while such an expression holds becomes read-only, so that hiding a field
|
|
225
|
+
* never unlocks an edit. A relation or Value Relation to a layer that is not
|
|
226
|
+
* served is dropped, and one to a served layer names it by its served id. For
|
|
227
|
+
* an application that serves a project's layers itself, as
|
|
228
|
+
* `generateServerStacCatalogue` does for QGIS Server.
|
|
229
|
+
*/
|
|
230
|
+
export function withoutHiddenFields(source, layerId, context) {
|
|
231
|
+
const collection = { ...source };
|
|
232
|
+
const hidden = new Set(context.hiddenOf(layerId));
|
|
213
233
|
if (hidden.has(String(collection['quac:display_field'])))
|
|
214
234
|
delete collection['quac:display_field'];
|
|
215
235
|
serveFormOrder(collection, hidden);
|
|
216
236
|
serveFilters(collection, hidden);
|
|
217
237
|
serveRelations(collection, hidden, context);
|
|
218
238
|
serveLocks(collection, hidden);
|
|
219
|
-
serveColumns(collection, hidden, context
|
|
239
|
+
serveColumns(collection, hidden, context);
|
|
240
|
+
serveStyleFields(collection, hidden);
|
|
220
241
|
return collection;
|
|
221
242
|
}
|
|
222
243
|
function serveFormOrder(collection, hidden) {
|
|
@@ -239,10 +260,10 @@ function serveRelations(collection, hidden, context) {
|
|
|
239
260
|
if (!Array.isArray(relations))
|
|
240
261
|
return;
|
|
241
262
|
const kept = relations.flatMap((relation) => {
|
|
242
|
-
const parentId = context.
|
|
263
|
+
const parentId = context.servedId(relation.parent_collection_id);
|
|
243
264
|
if (!parentId)
|
|
244
265
|
return [];
|
|
245
|
-
const parentHidden =
|
|
266
|
+
const parentHidden = context.hiddenOf(relation.parent_collection_id);
|
|
246
267
|
if (relation.fields.some((pair) => hidden.has(pair.child) || parentHidden.has(pair.parent)))
|
|
247
268
|
return [];
|
|
248
269
|
return [{ ...relation, parent_collection_id: parentId }];
|
|
@@ -262,19 +283,40 @@ function serveLocks(collection, hidden) {
|
|
|
262
283
|
}
|
|
263
284
|
collection['quac:locks'] = served;
|
|
264
285
|
}
|
|
265
|
-
function serveColumns(collection, hidden, context
|
|
286
|
+
function serveColumns(collection, hidden, context) {
|
|
266
287
|
const columns = collection['table:columns'];
|
|
267
288
|
if (!Array.isArray(columns))
|
|
268
289
|
return;
|
|
269
|
-
const fieldTypes = context.fieldTypes[layerId] ?? {};
|
|
270
290
|
const kept = columns
|
|
271
291
|
.filter((column) => !hidden.has(column.name))
|
|
272
|
-
.map((column) =>
|
|
292
|
+
.map((column) => serveColumn(column, hidden, context));
|
|
273
293
|
if (kept.length > 0)
|
|
274
294
|
collection['table:columns'] = kept;
|
|
275
295
|
else
|
|
276
296
|
delete collection['table:columns'];
|
|
277
297
|
}
|
|
298
|
+
/** Each column with the `type` QGIS Server reports for its field (`withFieldType`). */
|
|
299
|
+
function serveFieldTypes(collection, fieldTypes) {
|
|
300
|
+
const columns = collection['table:columns'];
|
|
301
|
+
if (Array.isArray(columns))
|
|
302
|
+
collection['table:columns'] = columns.map((column) => withFieldType(column, fieldTypes[column.name]));
|
|
303
|
+
}
|
|
304
|
+
/** A style asset's categorised field, dropped where the layer hides it. */
|
|
305
|
+
function serveStyleFields(collection, hidden) {
|
|
306
|
+
if (!collection.assets)
|
|
307
|
+
return;
|
|
308
|
+
const assets = {};
|
|
309
|
+
for (const [key, asset] of Object.entries(collection.assets)) {
|
|
310
|
+
if (hidden.has(String(asset[QUAC_CATEGORISED_FIELD]))) {
|
|
311
|
+
const served = { ...asset };
|
|
312
|
+
delete served[QUAC_CATEGORISED_FIELD];
|
|
313
|
+
assets[key] = served;
|
|
314
|
+
}
|
|
315
|
+
else
|
|
316
|
+
assets[key] = asset;
|
|
317
|
+
}
|
|
318
|
+
collection.assets = assets;
|
|
319
|
+
}
|
|
278
320
|
/** The column with the `type` QGIS Server reports for its field, and the `data_type` beside it, where QGIS Server reports one. */
|
|
279
321
|
function withFieldType(column, fieldType) {
|
|
280
322
|
const type = fieldType ? mapQtTypeToStacTableType(fieldType.type, fieldType.typeName) : undefined;
|
|
@@ -317,8 +359,8 @@ function serveColumn(source, hidden, context) {
|
|
|
317
359
|
}
|
|
318
360
|
const relation = column['quac:value_relation'];
|
|
319
361
|
if (relation) {
|
|
320
|
-
const lookupId = context.
|
|
321
|
-
const lookupHidden =
|
|
362
|
+
const lookupId = context.servedId(relation.collection);
|
|
363
|
+
const lookupHidden = context.hiddenOf(relation.collection);
|
|
322
364
|
const usesHidden = [relation.key, relation.value, relation.order_field].some((field) => field !== undefined && lookupHidden.has(field))
|
|
323
365
|
|| mentionsAny(relation.filter, lookupHidden)
|
|
324
366
|
|| mentionsAny(relation.filter, hidden);
|
|
@@ -29,6 +29,11 @@ export interface StacCompanionData {
|
|
|
29
29
|
* This is a thin wrapper: `qgsProjectToNormalized` resolves the QGS-specific
|
|
30
30
|
* wording, assets and columns into the shared `NormalizedProject`, and
|
|
31
31
|
* `generateStacFromNormalized` (see normalizedProject.ts) builds the catalogue.
|
|
32
|
+
*
|
|
33
|
+
* A layer or group the project leaves out of WMS (**Exclude layers**) is left
|
|
34
|
+
* out, as `generateServerStacCatalogue` leaves it out: the catalogue is built
|
|
35
|
+
* as if the project did not hold it, so a relation, Value Relation, filter or
|
|
36
|
+
* initial active layer naming it is dropped too (`wmsExcludedLayerIds`).
|
|
32
37
|
*/
|
|
33
38
|
export declare function generateStacCatalogue(project: QgsProject, companions?: StacCompanionData[], options?: {
|
|
34
39
|
selfHref?: string;
|
|
@@ -75,6 +80,13 @@ export declare function qgisServerNamesOf(layer: LayerEntry, context: {
|
|
|
75
80
|
wmsPublishing: WmsPublishing | null;
|
|
76
81
|
wfsTransactionLayers: WfsTransactionLayers | null;
|
|
77
82
|
}): QgisServerNames;
|
|
83
|
+
/**
|
|
84
|
+
* The layers a project leaves out of WMS under **Exclude layers**
|
|
85
|
+
* (`WMSRestrictedLayers`): each layer whose name it lists, wherever the layer
|
|
86
|
+
* sits, and every layer inside a group whose name it lists. Neither route's
|
|
87
|
+
* catalogue holds them.
|
|
88
|
+
*/
|
|
89
|
+
export declare function wmsExcludedLayerIds(project: QgsProject): Set<string>;
|
|
78
90
|
/** The title of the `via` link to the QGIS project a layer's Collection was written from. */
|
|
79
91
|
export declare const QGIS_PROJECT_LINK_TITLE = "QGIS project";
|
|
80
92
|
/**
|
|
@@ -30,6 +30,11 @@ import { declaredMediaTypeForFile, isLayerFileOfFormat, PROJECT_DATA_ROLES, QML_
|
|
|
30
30
|
* This is a thin wrapper: `qgsProjectToNormalized` resolves the QGS-specific
|
|
31
31
|
* wording, assets and columns into the shared `NormalizedProject`, and
|
|
32
32
|
* `generateStacFromNormalized` (see normalizedProject.ts) builds the catalogue.
|
|
33
|
+
*
|
|
34
|
+
* A layer or group the project leaves out of WMS (**Exclude layers**) is left
|
|
35
|
+
* out, as `generateServerStacCatalogue` leaves it out: the catalogue is built
|
|
36
|
+
* as if the project did not hold it, so a relation, Value Relation, filter or
|
|
37
|
+
* initial active layer naming it is dropped too (`wmsExcludedLayerIds`).
|
|
33
38
|
*/
|
|
34
39
|
export function generateStacCatalogue(project, companions = [], options = {}) {
|
|
35
40
|
// `selfHref` is the folder the project was published from, for a project
|
|
@@ -59,7 +64,7 @@ export function generateStacCatalogue(project, companions = [], options = {}) {
|
|
|
59
64
|
// reproject the canvas. `resolveLayerWgs84Extents` in the same file builds
|
|
60
65
|
// this map; a layer left out of it (or a caller that leaves the option off
|
|
61
66
|
// entirely) has no box of its own.
|
|
62
|
-
return withSelfLink(generateStacFromNormalized(qgsProjectToNormalized(project, companions, options.projectPath, options.projectPath ?? options.projectFileName, options.initialView ?? null, options.layerWgs84Extents)), options.selfHref);
|
|
67
|
+
return withSelfLink(generateStacFromNormalized(qgsProjectToNormalized(withoutWmsExcludedLayers(project), companions, options.projectPath, options.projectPath ?? options.projectFileName, options.initialView ?? null, options.layerWgs84Extents)), options.selfHref);
|
|
63
68
|
}
|
|
64
69
|
/**
|
|
65
70
|
* The key a style asset takes for the field its renderer classifies by, when
|
|
@@ -333,6 +338,48 @@ export function qgisServerNamesOf(layer, context) {
|
|
|
333
338
|
const wfsTypeName = wfsPublished ? ownName.replace(/ /g, '_').replace(/[:\u2014]/g, '-') : null;
|
|
334
339
|
return { wmsName: wmsName || null, wfsTypeName: wfsTypeName || null };
|
|
335
340
|
}
|
|
341
|
+
/**
|
|
342
|
+
* The layers a project leaves out of WMS under **Exclude layers**
|
|
343
|
+
* (`WMSRestrictedLayers`): each layer whose name it lists, wherever the layer
|
|
344
|
+
* sits, and every layer inside a group whose name it lists. Neither route's
|
|
345
|
+
* catalogue holds them.
|
|
346
|
+
*/
|
|
347
|
+
export function wmsExcludedLayerIds(project) {
|
|
348
|
+
const restricted = new Set(project.wmsPublishing?.restrictedLayers ?? []);
|
|
349
|
+
const excluded = new Set();
|
|
350
|
+
if (restricted.size === 0)
|
|
351
|
+
return excluded;
|
|
352
|
+
for (const layer of project.layers) {
|
|
353
|
+
if (restricted.has(layer.name))
|
|
354
|
+
excluded.add(layer.id);
|
|
355
|
+
}
|
|
356
|
+
const walk = (group, inExcludedGroup) => {
|
|
357
|
+
for (const node of group.children) {
|
|
358
|
+
if (node.kind === 'group')
|
|
359
|
+
walk(node, inExcludedGroup || restricted.has(node.name));
|
|
360
|
+
else if (inExcludedGroup)
|
|
361
|
+
excluded.add(node.layerId);
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
walk(project.layerTree, false);
|
|
365
|
+
return excluded;
|
|
366
|
+
}
|
|
367
|
+
/** The project less the layers and groups it leaves out of WMS (`wmsExcludedLayerIds`). */
|
|
368
|
+
function withoutWmsExcludedLayers(project) {
|
|
369
|
+
const excluded = wmsExcludedLayerIds(project);
|
|
370
|
+
if (excluded.size === 0)
|
|
371
|
+
return project;
|
|
372
|
+
const restricted = new Set(project.wmsPublishing?.restrictedLayers ?? []);
|
|
373
|
+
const prune = (group) => ({
|
|
374
|
+
...group,
|
|
375
|
+
children: group.children.flatMap((node) => {
|
|
376
|
+
if (node.kind === 'group')
|
|
377
|
+
return restricted.has(node.name) ? [] : [prune(node)];
|
|
378
|
+
return excluded.has(node.layerId) ? [] : [node];
|
|
379
|
+
})
|
|
380
|
+
});
|
|
381
|
+
return { ...project, layers: project.layers.filter((layer) => !excluded.has(layer.id)), layerTree: prune(project.layerTree) };
|
|
382
|
+
}
|
|
336
383
|
/** The shape a file layer's own `|geometrytype=` keeps, as the list `quac:geometry_filter` holds. */
|
|
337
384
|
function geometryFilterOf(layer) {
|
|
338
385
|
const shapes = readSiblingShapes([layer]);
|
|
@@ -377,6 +424,7 @@ function qgsLayerToNormalized(layer, context, geometryFilter = geometryFilterOf(
|
|
|
377
424
|
isPrivate: layer.isPrivate,
|
|
378
425
|
legendImage: layer.legendImage,
|
|
379
426
|
icon: layer.icon,
|
|
427
|
+
addedMessage: layer.addedMessage,
|
|
380
428
|
locks: combineLocks(layer.locks ?? {}, wfsTransactionLocks(layer.id, context.wfsTransactionLayers)),
|
|
381
429
|
filters: context.filtersByCollectionId.get(layer.id),
|
|
382
430
|
vendorFields: buildVendorFields(layer, context.measurement),
|
package/dist/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export { FILE_EXTENSION, FILE_SIZE_FIELD, TABLE_ROW_COUNT_FIELD, readCollectionR
|
|
|
34
34
|
export { PMTILES_MEDIA_TYPE, VISUAL_ROLE, readCollectionPmtiles } from './model/stacPmtiles.ts';
|
|
35
35
|
export type { StacPmtilesSource } from './model/stacPmtiles.ts';
|
|
36
36
|
export type { StacCompanionData } from './generate/stacCatalogue.ts';
|
|
37
|
-
export { QUAC_ACTIVE_COLLECTION_FIELD, QUAC_FILTERS_FIELD, QUAC_FORM_ORDER_FIELD, QUAC_LOCKS_FIELD, QUAC_MUTUALLY_EXCLUSIVE_FIELD, QUAC_PRIVATE_FIELD, readCatalogueActiveCollection, readCatalogueInitialView, readCollectionDisplayField, readCollectionEditable, readCollectionFieldAliases, readCollectionFieldComments, readCollectionFieldAttachments, readCollectionFieldEditRules, readCollectionFieldNames, readCollectionFieldTypes, readCollectionFieldValueRelations, readCollectionFieldValues, readCollectionFormLayout, readCollectionGeometryType, readCollectionIdentifiable, readCollectionMeasurement, readCollectionOpacity, readCollectionIcon, readCollectionLegendImage, readCollectionFilters, readCollectionLocks, readCollectionPrivate, readCollectionRelatedTo, readCollectionScaleRange, readCollectionVisibility, statedOpacity } from './generate/normalizedProject.ts';
|
|
37
|
+
export { QUAC_ACTIVE_COLLECTION_FIELD, QUAC_FILTERS_FIELD, QUAC_FORM_ORDER_FIELD, QUAC_LOCKS_FIELD, QUAC_MUTUALLY_EXCLUSIVE_FIELD, QUAC_PRIVATE_FIELD, readCatalogueActiveCollection, readCatalogueInitialView, readCollectionDisplayField, readCollectionEditable, readCollectionFieldAliases, readCollectionFieldComments, readCollectionFieldAttachments, readCollectionFieldEditRules, readCollectionFieldNames, readCollectionFieldTypes, readCollectionFieldValueRelations, readCollectionFieldValues, readCollectionFormLayout, readCollectionGeometryType, readCollectionIdentifiable, readCollectionMeasurement, readCollectionOpacity, readCollectionIcon, readCollectionAddedMessage, readCollectionLegendImage, readCollectionFilters, readCollectionLocks, readCollectionPrivate, readCollectionRelatedTo, readCollectionScaleRange, readCollectionVisibility, statedOpacity } from './generate/normalizedProject.ts';
|
|
38
38
|
export type { CollectionFilter, CollectionFormLayout, CollectionRelation, CollectionRelationField } from './generate/normalizedProject.ts';
|
|
39
39
|
export { generateStacCatalogueFromWfsCapabilities } from './generate/wfsStacCatalogue.ts';
|
|
40
40
|
export type { WfsStacCatalogueOptions } from './generate/wfsStacCatalogue.ts';
|
|
@@ -78,7 +78,8 @@ export { devLog } from './util/devLog.ts';
|
|
|
78
78
|
export { getFileNameFromPath, getLowerCaseExtension, getNormalisedFileBasename, getParentFolderPath } from './util/fileName.ts';
|
|
79
79
|
export { DEFAULT_WFS_VERSION, SPOKEN_WFS_VERSIONS, WFS_CAPABILITIES_VERSION, WFS_FALLBACK_VERSION } from './util/wfsVersions.ts';
|
|
80
80
|
export { QUAC_SCHEMA_URL, declareQuacExtension, isNewerQuacMajor, listQuacExtension, readQuacVersion } from './model/quacExtension.ts';
|
|
81
|
-
export { generateServerStacCatalogue } from './generate/serverStacCatalogue.ts';
|
|
81
|
+
export { generateServerStacCatalogue, withoutHiddenFields } from './generate/serverStacCatalogue.ts';
|
|
82
|
+
export type { HiddenFieldContext } from './generate/serverStacCatalogue.ts';
|
|
82
83
|
export { serverLayerTree } from './generate/serverLayerTree.ts';
|
|
83
84
|
export type { ServerLayerTree, ServerLayerTreeGroup, ServerLayerTreeLayer, ServerLayerTreeNode } from './generate/serverLayerTree.ts';
|
|
84
85
|
export { PROJ_CODE, PROJECTION_EXTENSION, readCollectionCrs } from './model/stacProjection.ts';
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ export { DATA_ROLE, findAssetByRole, readDataAsset } from "./model/stacAssetRole
|
|
|
23
23
|
export { THUMBNAIL_ROLE, readCollectionAttribution, readCollectionDeprecation, readCollectionSelfHref, readCollectionThumbnail } from "./model/stacCollectionNotes.js";
|
|
24
24
|
export { FILE_EXTENSION, FILE_SIZE_FIELD, TABLE_ROW_COUNT_FIELD, readCollectionRowCount, readDataAssetFileSize } from "./model/stacSizeAndCount.js";
|
|
25
25
|
export { PMTILES_MEDIA_TYPE, VISUAL_ROLE, readCollectionPmtiles } from "./model/stacPmtiles.js";
|
|
26
|
-
export { QUAC_ACTIVE_COLLECTION_FIELD, QUAC_FILTERS_FIELD, QUAC_FORM_ORDER_FIELD, QUAC_LOCKS_FIELD, QUAC_MUTUALLY_EXCLUSIVE_FIELD, QUAC_PRIVATE_FIELD, readCatalogueActiveCollection, readCatalogueInitialView, readCollectionDisplayField, readCollectionEditable, readCollectionFieldAliases, readCollectionFieldComments, readCollectionFieldAttachments, readCollectionFieldEditRules, readCollectionFieldNames, readCollectionFieldTypes, readCollectionFieldValueRelations, readCollectionFieldValues, readCollectionFormLayout, readCollectionGeometryType, readCollectionIdentifiable, readCollectionMeasurement, readCollectionOpacity, readCollectionIcon, readCollectionLegendImage, readCollectionFilters, readCollectionLocks, readCollectionPrivate, readCollectionRelatedTo, readCollectionScaleRange, readCollectionVisibility, statedOpacity } from "./generate/normalizedProject.js";
|
|
26
|
+
export { QUAC_ACTIVE_COLLECTION_FIELD, QUAC_FILTERS_FIELD, QUAC_FORM_ORDER_FIELD, QUAC_LOCKS_FIELD, QUAC_MUTUALLY_EXCLUSIVE_FIELD, QUAC_PRIVATE_FIELD, readCatalogueActiveCollection, readCatalogueInitialView, readCollectionDisplayField, readCollectionEditable, readCollectionFieldAliases, readCollectionFieldComments, readCollectionFieldAttachments, readCollectionFieldEditRules, readCollectionFieldNames, readCollectionFieldTypes, readCollectionFieldValueRelations, readCollectionFieldValues, readCollectionFormLayout, readCollectionGeometryType, readCollectionIdentifiable, readCollectionMeasurement, readCollectionOpacity, readCollectionIcon, readCollectionAddedMessage, readCollectionLegendImage, readCollectionFilters, readCollectionLocks, readCollectionPrivate, readCollectionRelatedTo, readCollectionScaleRange, readCollectionVisibility, statedOpacity } from "./generate/normalizedProject.js";
|
|
27
27
|
export { generateStacCatalogueFromWfsCapabilities } from "./generate/wfsStacCatalogue.js";
|
|
28
28
|
export { generateStacCatalogueFromFolder } from "./generate/folderStacCatalogue.js";
|
|
29
29
|
export { generateCollectionForDroppedFile, generateCollectionForLinkedFile } from "./generate/fileLayerCollection.js";
|
|
@@ -51,6 +51,6 @@ export { devLog } from "./util/devLog.js";
|
|
|
51
51
|
export { getFileNameFromPath, getLowerCaseExtension, getNormalisedFileBasename, getParentFolderPath } from "./util/fileName.js";
|
|
52
52
|
export { DEFAULT_WFS_VERSION, SPOKEN_WFS_VERSIONS, WFS_CAPABILITIES_VERSION, WFS_FALLBACK_VERSION } from "./util/wfsVersions.js";
|
|
53
53
|
export { QUAC_SCHEMA_URL, declareQuacExtension, isNewerQuacMajor, listQuacExtension, readQuacVersion } from "./model/quacExtension.js";
|
|
54
|
-
export { generateServerStacCatalogue } from "./generate/serverStacCatalogue.js";
|
|
54
|
+
export { generateServerStacCatalogue, withoutHiddenFields } from "./generate/serverStacCatalogue.js";
|
|
55
55
|
export { serverLayerTree } from "./generate/serverLayerTree.js";
|
|
56
56
|
export { PROJ_CODE, PROJECTION_EXTENSION, readCollectionCrs } from "./model/stacProjection.js";
|
|
@@ -289,6 +289,12 @@ export interface LayerEntry {
|
|
|
289
289
|
* or absent where it sets none.
|
|
290
290
|
*/
|
|
291
291
|
icon?: string | null;
|
|
292
|
+
/**
|
|
293
|
+
* The message shown once a feature is added to the layer, from its
|
|
294
|
+
* `quac_added_message` variable, as written. Null or absent where it sets
|
|
295
|
+
* none.
|
|
296
|
+
*/
|
|
297
|
+
addedMessage?: string | null;
|
|
292
298
|
/**
|
|
293
299
|
* The address of each field's icon, from the layer's `quac_icon_<field>`
|
|
294
300
|
* variables. Fields with none are absent.
|
|
@@ -117,6 +117,7 @@ function parseMapLayer(maplayer, notes) {
|
|
|
117
117
|
fieldAttachments,
|
|
118
118
|
fieldEditRules: parseFieldEditRules(maplayer, note),
|
|
119
119
|
icon: parseLayerIcon(maplayer),
|
|
120
|
+
addedMessage: parseAddedMessage(maplayer),
|
|
120
121
|
fieldIcons: parseFieldIcons(maplayer),
|
|
121
122
|
fieldControls: parseFieldControls(maplayer),
|
|
122
123
|
formLayout: parseFormLayout(maplayer),
|
|
@@ -991,19 +992,38 @@ function parseFieldIcons(maplayer) {
|
|
|
991
992
|
}
|
|
992
993
|
/** The name of the layer variable that sets the layer's own icon. */
|
|
993
994
|
const LAYER_ICON_VARIABLE = 'quac_icon';
|
|
995
|
+
/** The name of the layer variable that holds the message shown once a feature is added. */
|
|
996
|
+
const ADDED_MESSAGE_VARIABLE = 'quac_added_message';
|
|
994
997
|
/**
|
|
995
|
-
*
|
|
996
|
-
*
|
|
997
|
-
*
|
|
998
|
+
* The value of the layer variable of this name, held in the layer's
|
|
999
|
+
* `variableNames` and `variableValues` custom properties. Null where the layer
|
|
1000
|
+
* has no such variable.
|
|
998
1001
|
*/
|
|
999
|
-
function
|
|
1002
|
+
function readLayerVariable(maplayer, variable) {
|
|
1000
1003
|
const properties = directChild(maplayer, 'customproperties');
|
|
1001
1004
|
if (!properties)
|
|
1002
1005
|
return null;
|
|
1003
1006
|
const names = readCustomPropertyList(properties, 'variableNames');
|
|
1004
1007
|
const values = readCustomPropertyList(properties, 'variableValues');
|
|
1005
|
-
const index = names.indexOf(
|
|
1006
|
-
return index === -1 || index >= values.length ? null :
|
|
1008
|
+
const index = names.indexOf(variable);
|
|
1009
|
+
return index === -1 || index >= values.length ? null : values[index];
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Reads the icon the layer's `quac_icon` variable sets, as an address
|
|
1013
|
+
* (`resolveFieldIconAddress`). Null where the layer has no such variable or
|
|
1014
|
+
* its value names no icon.
|
|
1015
|
+
*/
|
|
1016
|
+
function parseLayerIcon(maplayer) {
|
|
1017
|
+
const value = readLayerVariable(maplayer, LAYER_ICON_VARIABLE);
|
|
1018
|
+
return value === null ? null : resolveFieldIconAddress(value);
|
|
1019
|
+
}
|
|
1020
|
+
/**
|
|
1021
|
+
* Reads the message the layer's `quac_added_message` variable holds, as
|
|
1022
|
+
* written. Null where the layer has no such variable or its value is blank.
|
|
1023
|
+
*/
|
|
1024
|
+
function parseAddedMessage(maplayer) {
|
|
1025
|
+
const value = readLayerVariable(maplayer, ADDED_MESSAGE_VARIABLE);
|
|
1026
|
+
return value === null || value.trim() === '' ? null : value;
|
|
1007
1027
|
}
|
|
1008
1028
|
/** The start of the name of a layer variable that chooses a field's control: `quac_control_condition`. */
|
|
1009
1029
|
const FIELD_CONTROL_VARIABLE_PREFIX = 'quac_control_';
|
package/package.json
CHANGED
|
@@ -253,6 +253,11 @@
|
|
|
253
253
|
"type": "string",
|
|
254
254
|
"pattern": "^https://"
|
|
255
255
|
},
|
|
256
|
+
"quac:added_message": {
|
|
257
|
+
"description": "The message shown once a feature is added to this Collection, which may hold HTML markup. Written from the layer variable named quac_added_message.",
|
|
258
|
+
"type": "string",
|
|
259
|
+
"minLength": 1
|
|
260
|
+
},
|
|
256
261
|
"quac:form_order": {
|
|
257
262
|
"description": "The names of the fields the source's form layout places, in its order. A column not listed is left out of the form. Written from a QGIS layer's Drag and Drop Designer form.",
|
|
258
263
|
"type": "array",
|