@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
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @vectoriahq/quac
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The JavaScript package for [QUAC](https://github.com/vectoriahq/quac), a profile of STAC 1.1.0 for describing the layers of a map: where each layer's data comes from, how its fields are filled in and checked, how it is drawn, and how its layers relate.
|
|
4
|
+
|
|
5
|
+
The package writes QUAC catalogues from QGIS projects and other sources, and reads them back. It makes no network request: it builds a catalogue from what an application has already fetched, such as a QGIS project's text or a QGIS Server GetProjectSettings response.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @vectoriahq/quac
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Example
|
|
14
|
+
|
|
15
|
+
Build a catalogue from a QGIS project file. The parsers use the standard `DOMParser`, which a browser provides; in Node, supply one, such as [linkedom](https://www.npmjs.com/package/linkedom)'s.
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import { readFile } from 'node:fs/promises'
|
|
19
|
+
import { DOMParser } from 'linkedom'
|
|
20
|
+
import { parseQgsXml, generateStacCatalogue } from '@vectoriahq/quac'
|
|
21
|
+
|
|
22
|
+
globalThis.DOMParser = DOMParser
|
|
23
|
+
|
|
24
|
+
const project = parseQgsXml(await readFile('project.qgs', 'utf8'))
|
|
25
|
+
const catalogue = generateStacCatalogue(project)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The JSON Schema that checks a catalogue's `quac:` fields is exported as `@vectoriahq/quac/schema`.
|
|
29
|
+
|
|
30
|
+
## Documentation
|
|
31
|
+
|
|
32
|
+
The [repository's README](https://github.com/vectoriahq/quac#readme) says where QUAC fits, and the [field reference](https://github.com/vectoriahq/quac/tree/main/packages/quac/spec) describes every field.
|
|
33
|
+
|
|
34
|
+
## Licence
|
|
35
|
+
|
|
36
|
+
Copyright 2026 Vectoria Pty Ltd. Apache License 2.0.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { NormalizedBbox } from './normalizedProject.ts';
|
|
2
|
+
import type { ArcgisLayerSet, ArcgisLayerSource, ArcgisNotShownReason } from '../model/arcgis.ts';
|
|
3
|
+
import type { StacAsset, StacCatalog, StacCollection } from '../model/Stac.ts';
|
|
4
|
+
/**
|
|
5
|
+
* Generates a STAC Catalog from an ArcGIS Online Web Map or Feature Service,
|
|
6
|
+
* already read down to its layers:
|
|
7
|
+
* the Web Map or item → top-level Catalog
|
|
8
|
+
* each layer → Collection
|
|
9
|
+
*
|
|
10
|
+
* A layer that can be shown carries its FeatureServer layer's address and the
|
|
11
|
+
* Web Map's filter on it, and declares its ArcGIS style as its default style
|
|
12
|
+
* where it has one. A layer that can't carries `quac:arcgis_not_shown` and no
|
|
13
|
+
* data asset, so it is still listed by name.
|
|
14
|
+
*
|
|
15
|
+
* Visibility, opacity, scale limits and a Web Map's saved view are written as
|
|
16
|
+
* the same shared fields a QGIS project's are. Only a Web Map declares
|
|
17
|
+
* visibility and opacity: a Feature Service item's layers have no author to
|
|
18
|
+
* set them.
|
|
19
|
+
*
|
|
20
|
+
* Pure function — no side effects, no I/O.
|
|
21
|
+
*/
|
|
22
|
+
export interface ArcgisStacCatalogueOptions {
|
|
23
|
+
/** Layer ids to emit, in the order given. Omit to emit every one. */
|
|
24
|
+
layerIds?: string[];
|
|
25
|
+
/**
|
|
26
|
+
* Each layer's extent already in WGS84, keyed by layer id. This package
|
|
27
|
+
* holds no reprojection, so a caller converts the service's extents and
|
|
28
|
+
* passes them; a layer left out has no box of its own.
|
|
29
|
+
*/
|
|
30
|
+
layerWgs84Extents?: Map<string, NormalizedBbox>;
|
|
31
|
+
/** The box the Web Map was saved showing, already in WGS84, for the same reason. */
|
|
32
|
+
initialView?: NormalizedBbox | null;
|
|
33
|
+
}
|
|
34
|
+
export declare function generateStacCatalogueFromArcgisLayers(layerSet: ArcgisLayerSet, options?: ArcgisStacCatalogueOptions): StacCatalog;
|
|
35
|
+
/** The Web Map or Feature Service item the Catalog was generated from; null for a FeatureServer that reports none. */
|
|
36
|
+
export declare function readArcgisCatalogueItemId(catalogue: StacCatalog): string | null;
|
|
37
|
+
/** Where a Collection's features are read from, or null for one that can't be shown. */
|
|
38
|
+
export declare function resolveArcgisCollectionSource(collection: StacCollection): ArcgisLayerSource | null;
|
|
39
|
+
/** Why a Collection's layer can't be shown, or null for one that can. */
|
|
40
|
+
export declare function readArcgisNotShownReason(collection: StacCollection): ArcgisNotShownReason | null;
|
|
41
|
+
/**
|
|
42
|
+
* A FeatureServer layer's data asset: its query for every feature the filter
|
|
43
|
+
* keeps, as GeoJSON in WGS84. A QGIS project's ArcGIS layer is published with
|
|
44
|
+
* the same asset.
|
|
45
|
+
*/
|
|
46
|
+
export declare function arcgisQueryAsset(source: ArcgisLayerSource, title: string, updated?: string | null): StacAsset;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { generateStacFromNormalized, slugify, unionBboxes } from "./normalizedProject.js";
|
|
2
|
+
import { DEFAULT_STYLE_ROLE, styleAssetKey } from "../model/stacStyles.js";
|
|
3
|
+
import { GEOJSON_MEDIA_TYPE } from "../util/catalogueFileFormats.js";
|
|
4
|
+
/** The name the layer's ArcGIS style is listed under. */
|
|
5
|
+
const ARCGIS_STYLE_NAME = 'default';
|
|
6
|
+
const NOT_SHOWN_REASONS = [
|
|
7
|
+
'not-queryable',
|
|
8
|
+
'not-a-feature-layer',
|
|
9
|
+
'layer-unavailable'
|
|
10
|
+
];
|
|
11
|
+
export function generateStacCatalogueFromArcgisLayers(layerSet, options = {}) {
|
|
12
|
+
return generateStacFromNormalized(arcgisLayersToNormalized(layerSet, options));
|
|
13
|
+
}
|
|
14
|
+
/** The Web Map or Feature Service item the Catalog was generated from; null for a FeatureServer that reports none. */
|
|
15
|
+
export function readArcgisCatalogueItemId(catalogue) {
|
|
16
|
+
const itemId = catalogue['quac:arcgis_item_id'];
|
|
17
|
+
return typeof itemId === 'string' && itemId ? itemId : null;
|
|
18
|
+
}
|
|
19
|
+
/** Where a Collection's features are read from, or null for one that can't be shown. */
|
|
20
|
+
export function resolveArcgisCollectionSource(collection) {
|
|
21
|
+
const layerUrl = collection['quac:arcgis_layer_url'];
|
|
22
|
+
if (typeof layerUrl !== 'string' || !layerUrl)
|
|
23
|
+
return null;
|
|
24
|
+
const where = collection['quac:arcgis_where'];
|
|
25
|
+
return { layerUrl, where: typeof where === 'string' && where ? where : null };
|
|
26
|
+
}
|
|
27
|
+
/** Why a Collection's layer can't be shown, or null for one that can. */
|
|
28
|
+
export function readArcgisNotShownReason(collection) {
|
|
29
|
+
const reason = collection['quac:arcgis_not_shown'];
|
|
30
|
+
return NOT_SHOWN_REASONS.find((candidate) => candidate === reason) ?? null;
|
|
31
|
+
}
|
|
32
|
+
function arcgisLayersToNormalized(layerSet, options) {
|
|
33
|
+
const selected = selectLayers(layerSet.layers, options.layerIds);
|
|
34
|
+
const hasAuthor = layerSet.itemType === 'Web Map';
|
|
35
|
+
const nodes = selected.map((layer) => arcgisLayerToNormalized(layer, options.layerWgs84Extents?.get(layer.id) ?? null, hasAuthor));
|
|
36
|
+
return {
|
|
37
|
+
id: slugify(layerSet.title) || 'arcgis',
|
|
38
|
+
title: layerSet.title,
|
|
39
|
+
description: layerSet.summary ?? `STAC catalogue generated from the ArcGIS Online ${layerSet.itemType} "${layerSet.title}".`,
|
|
40
|
+
bbox: unionBboxes(nodes.map((node) => node.bbox)),
|
|
41
|
+
initialView: options.initialView ?? null,
|
|
42
|
+
vendorFields: layerSet.itemId ? { 'quac:arcgis_item_id': layerSet.itemId } : {},
|
|
43
|
+
nodes
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** Resolves the requested ids against the layer set, preserving the caller's order. */
|
|
47
|
+
function selectLayers(layers, layerIds) {
|
|
48
|
+
if (!layerIds)
|
|
49
|
+
return layers;
|
|
50
|
+
const byId = new Map(layers.map((layer) => [layer.id, layer]));
|
|
51
|
+
return layerIds
|
|
52
|
+
.map((id) => byId.get(id))
|
|
53
|
+
.filter((layer) => Boolean(layer));
|
|
54
|
+
}
|
|
55
|
+
function arcgisLayerToNormalized(layer, bbox, hasAuthor) {
|
|
56
|
+
const vendorFields = {};
|
|
57
|
+
let assets = {};
|
|
58
|
+
if (layer.status === 'not-shown') {
|
|
59
|
+
vendorFields['quac:arcgis_not_shown'] = layer.reason;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
vendorFields['quac:arcgis_layer_url'] = layer.source.layerUrl;
|
|
63
|
+
if (layer.source.where)
|
|
64
|
+
vendorFields['quac:arcgis_where'] = layer.source.where;
|
|
65
|
+
assets = { data: arcgisQueryAsset(layer.source, layer.title, layer.dataUpdated ?? null) };
|
|
66
|
+
if (layer.styleHref) {
|
|
67
|
+
assets[styleAssetKey(assets, ARCGIS_STYLE_NAME)] = {
|
|
68
|
+
href: layer.styleHref,
|
|
69
|
+
type: 'application/json',
|
|
70
|
+
title: ARCGIS_STYLE_NAME,
|
|
71
|
+
roles: ['style', DEFAULT_STYLE_ROLE]
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
kind: 'layer',
|
|
77
|
+
// The Web Map's own layer id: one Web Map can list the same service layer
|
|
78
|
+
// twice, so the layer's address would not tell the two apart.
|
|
79
|
+
id: layer.id,
|
|
80
|
+
title: layer.title,
|
|
81
|
+
description: (layer.status === 'shown' ? layer.description : null) ?? `Layer "${layer.title}" of an ArcGIS Online map.`,
|
|
82
|
+
bbox,
|
|
83
|
+
geometryType: layer.status === 'shown' ? mapGeometryType(layer.geometryType) : null,
|
|
84
|
+
wkbTypes: layer.status === 'shown' ? mapWkbTypes(layer.geometryType) : [],
|
|
85
|
+
tableColumns: layer.status === 'shown' && layer.metadata ? layer.metadata.fields.map(fieldToColumn) : [],
|
|
86
|
+
assets,
|
|
87
|
+
...(layer.status === 'shown' && layer.keywords?.length ? { keywords: layer.keywords } : {}),
|
|
88
|
+
...(layer.status === 'shown' && layer.credit ? { providers: [{ name: layer.credit, roles: ['licensor'] }] } : {}),
|
|
89
|
+
...(layer.status === 'shown' && layer.license ? { license: layer.license } : {}),
|
|
90
|
+
...(layer.status === 'shown' && layer.created ? { created: layer.created } : {}),
|
|
91
|
+
...(layer.status === 'shown' && layer.updated ? { updated: layer.updated } : {}),
|
|
92
|
+
links: describeLayerLinks(layer),
|
|
93
|
+
displayField: layer.status === 'shown' ? layer.metadata?.displayField ?? null : null,
|
|
94
|
+
visibilityChecked: hasAuthor ? layer.visible : null,
|
|
95
|
+
editable: null,
|
|
96
|
+
scaleRange: layer.minScale === null && layer.maxScale === null
|
|
97
|
+
? null
|
|
98
|
+
: { minScale: layer.minScale, maxScale: layer.maxScale },
|
|
99
|
+
opacity: hasAuthor ? layer.opacity : null,
|
|
100
|
+
vendorFields
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/** The layer's item page on ArcGIS Online, then its FeatureServer layer's own page, where it has each. */
|
|
104
|
+
function describeLayerLinks(layer) {
|
|
105
|
+
const links = [];
|
|
106
|
+
if (layer.itemId) {
|
|
107
|
+
links.push({ rel: 'about', href: `https://www.arcgis.com/home/item.html?id=${layer.itemId}`, type: 'text/html', title: 'ArcGIS Online page' });
|
|
108
|
+
}
|
|
109
|
+
if (layer.status === 'shown') {
|
|
110
|
+
links.push({ rel: 'via', href: layer.source.layerUrl, type: 'text/html', title: 'Service description (technical)' });
|
|
111
|
+
}
|
|
112
|
+
return links;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* ArcGIS geometry types mapped to the geometry type names a QGIS project
|
|
116
|
+
* writes. A multipoint layer is a point layer, as QGIS counts it. A type
|
|
117
|
+
* absent here has no geometry type.
|
|
118
|
+
*/
|
|
119
|
+
const ESRI_GEOMETRY_TYPES = {
|
|
120
|
+
esriGeometryPoint: 'Point',
|
|
121
|
+
esriGeometryMultipoint: 'Point',
|
|
122
|
+
esriGeometryPolyline: 'Line',
|
|
123
|
+
esriGeometryPolygon: 'Polygon'
|
|
124
|
+
};
|
|
125
|
+
function mapGeometryType(esriType) {
|
|
126
|
+
return esriType && Object.hasOwn(ESRI_GEOMETRY_TYPES, esriType) ? ESRI_GEOMETRY_TYPES[esriType] : null;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* ArcGIS geometry types mapped to the one WKB type every feature of the layer
|
|
130
|
+
* takes. A polyline or polygon layer has none: a feature with one part reads
|
|
131
|
+
* as a LineString or Polygon and one with several as a MultiLineString or
|
|
132
|
+
* MultiPolygon.
|
|
133
|
+
*/
|
|
134
|
+
const ESRI_WKB_TYPES = {
|
|
135
|
+
esriGeometryPoint: 'Point',
|
|
136
|
+
esriGeometryMultipoint: 'MultiPoint'
|
|
137
|
+
};
|
|
138
|
+
function mapWkbTypes(esriType) {
|
|
139
|
+
return esriType && Object.hasOwn(ESRI_WKB_TYPES, esriType) ? [ESRI_WKB_TYPES[esriType]] : [];
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* ArcGIS field types mapped to column types. A narrower type maps to the
|
|
143
|
+
* column type that holds every value it can. A type absent here has no column
|
|
144
|
+
* type.
|
|
145
|
+
*/
|
|
146
|
+
const ESRI_COLUMN_TYPES = {
|
|
147
|
+
esriFieldTypeSmallInteger: 'int',
|
|
148
|
+
esriFieldTypeInteger: 'int',
|
|
149
|
+
esriFieldTypeBigInteger: 'long',
|
|
150
|
+
esriFieldTypeOID: 'long',
|
|
151
|
+
esriFieldTypeSingle: 'double',
|
|
152
|
+
esriFieldTypeDouble: 'double',
|
|
153
|
+
esriFieldTypeString: 'string',
|
|
154
|
+
esriFieldTypeGUID: 'string',
|
|
155
|
+
esriFieldTypeGlobalID: 'string',
|
|
156
|
+
esriFieldTypeDate: 'timestamp',
|
|
157
|
+
esriFieldTypeDateOnly: 'date',
|
|
158
|
+
esriFieldTypeTimeOnly: 'time',
|
|
159
|
+
esriFieldTypeTimestampOffset: 'timestamp'
|
|
160
|
+
};
|
|
161
|
+
function fieldToColumn(field) {
|
|
162
|
+
const column = { name: field.name };
|
|
163
|
+
if (field.alias)
|
|
164
|
+
column.title = field.alias;
|
|
165
|
+
if (field.type && Object.hasOwn(ESRI_COLUMN_TYPES, field.type))
|
|
166
|
+
column.type = ESRI_COLUMN_TYPES[field.type];
|
|
167
|
+
if (field.codedValues)
|
|
168
|
+
column.values = field.codedValues.map(({ code, name }) => ({ value: code, label: name }));
|
|
169
|
+
// A range on a date field is in epoch milliseconds, which is no number a form could limit.
|
|
170
|
+
if (field.range && (column.type === 'int' || column.type === 'long' || column.type === 'double')) {
|
|
171
|
+
column['quac:range'] = { min: field.range.min, max: field.range.max };
|
|
172
|
+
}
|
|
173
|
+
return column;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* A FeatureServer layer's data asset: its query for every feature the filter
|
|
177
|
+
* keeps, as GeoJSON in WGS84. A QGIS project's ArcGIS layer is published with
|
|
178
|
+
* the same asset.
|
|
179
|
+
*/
|
|
180
|
+
export function arcgisQueryAsset(source, title, updated = null) {
|
|
181
|
+
const params = new URLSearchParams({ where: source.where ?? '1=1', outFields: '*', outSR: '4326', f: 'geojson' });
|
|
182
|
+
return {
|
|
183
|
+
href: `${source.layerUrl}/query?${params.toString()}`,
|
|
184
|
+
type: GEOJSON_MEDIA_TYPE,
|
|
185
|
+
title: `ArcGIS feature service query: ${title}`,
|
|
186
|
+
roles: ['data'],
|
|
187
|
+
...(updated ? { updated } : {})
|
|
188
|
+
};
|
|
189
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { StacCatalog, StacCollection } from '../model/Stac.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Converts a STAC document fetched from somewhere else to the Groundwork
|
|
4
|
+
* profile (`packages/quac/spec/README.md`), so the rest of the app reads one shape
|
|
5
|
+
* whatever the source.
|
|
6
|
+
*
|
|
7
|
+
* Everything the source declared is kept — this fills gaps, it never
|
|
8
|
+
* overwrites. Three gaps get filled:
|
|
9
|
+
*
|
|
10
|
+
* - a root that is a single Collection is wrapped in a Catalog, so the
|
|
11
|
+
* result is always a Catalog of Collections
|
|
12
|
+
* - a Collection extent missing the required `temporal` gets the open
|
|
13
|
+
* interval `[[null, null]]`
|
|
14
|
+
* - a WFS-backed Collection with no `quac:wfs_*` fields gets them read out of its
|
|
15
|
+
* GetFeature asset href
|
|
16
|
+
*
|
|
17
|
+
* That last one is the fallback the profile allows: an external catalogue
|
|
18
|
+
* cannot be expected to have our vendor fields, so its `data` asset href is
|
|
19
|
+
* sniffed instead. Catalogues Groundwork generates have the fields, and the
|
|
20
|
+
* sniff never runs on them.
|
|
21
|
+
*
|
|
22
|
+
* Children linked as separate documents (`rel: "child"`) are not followed
|
|
23
|
+
* here — this function only sees what's already inlined. `StacEndpointAdapter`
|
|
24
|
+
* is what walks those links and inlines the fetched documents before calling
|
|
25
|
+
* this function.
|
|
26
|
+
*/
|
|
27
|
+
export declare function normalizeExternalStacCatalogue(root: StacCatalog | StacCollection): StacCatalog;
|
|
28
|
+
/**
|
|
29
|
+
* Reads the endpoint and feature type a Collection is backed by: the `quac:wfs_*`
|
|
30
|
+
* fields when it declares them, otherwise whatever its GetFeature asset href
|
|
31
|
+
* gives up. Returns null for a Collection that is not WFS-backed.
|
|
32
|
+
*
|
|
33
|
+
* The asset comes from `readDataAsset`, the same reader
|
|
34
|
+
* `classifyStacCollectionFormat` uses. The two have to agree: the classifier is
|
|
35
|
+
* what lists a Collection in the Add Layer picker, and this is what the add
|
|
36
|
+
* then resolves, so a Collection either of them could find alone would be
|
|
37
|
+
* offered and then refused with "Could not resolve the WFS endpoint or type
|
|
38
|
+
* name".
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveWfsCollectionSource(collection: StacCollection): {
|
|
41
|
+
endpoint: string;
|
|
42
|
+
typeName: string;
|
|
43
|
+
} | null;
|
|
44
|
+
/**
|
|
45
|
+
* Pulls the bare endpoint URL (no query) and the type name out of a WFS
|
|
46
|
+
* GetFeature URL. Returns null when the URL has no recognisable type-name
|
|
47
|
+
* parameter — WFS 1.x spells it `typeName`, 2.x `typeNames`, and servers vary
|
|
48
|
+
* on case.
|
|
49
|
+
*/
|
|
50
|
+
export declare function parseWfsGetFeatureUrl(href: string): {
|
|
51
|
+
endpoint: string;
|
|
52
|
+
typeName: string;
|
|
53
|
+
} | null;
|