ogcopenapis 1.0.2 → 1.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/README.md +34 -3
  3. package/lib/OgcOpenApiFeatureStore.d.ts +3 -1
  4. package/lib/OgcOpenApiFeatureStore.d.ts.map +1 -1
  5. package/lib/OgcOpenApiFeatureStore.js +22 -37
  6. package/lib/OgcOpenApiFeatureStore.js.map +1 -1
  7. package/lib/OgcOpenApiFetchTools.d.ts +9 -0
  8. package/lib/OgcOpenApiFetchTools.d.ts.map +1 -1
  9. package/lib/OgcOpenApiFetchTools.js +15 -0
  10. package/lib/OgcOpenApiFetchTools.js.map +1 -1
  11. package/lib/OgcOpenApiGetCapabilities.d.ts +16 -0
  12. package/lib/OgcOpenApiGetCapabilities.d.ts.map +1 -1
  13. package/lib/OgcOpenApiGetCapabilities.js +39 -3
  14. package/lib/OgcOpenApiGetCapabilities.js.map +1 -1
  15. package/lib/OgcOpenApiStyleTools.js +1 -1
  16. package/lib/OgcOpenApiStyleTools.js.map +1 -1
  17. package/lib/OgcOpenApiTileMatrixTools.d.ts +6 -0
  18. package/lib/OgcOpenApiTileMatrixTools.d.ts.map +1 -1
  19. package/lib/OgcOpenApiTileMatrixTools.js +13 -0
  20. package/lib/OgcOpenApiTileMatrixTools.js.map +1 -1
  21. package/lib/OgcOpenApiTilesModel.d.ts +2 -0
  22. package/lib/OgcOpenApiTilesModel.d.ts.map +1 -1
  23. package/lib/OgcOpenApiTilesModel.js +3 -2
  24. package/lib/OgcOpenApiTilesModel.js.map +1 -1
  25. package/lib/OgcOpenApiVectorTilesModel.d.ts +1 -0
  26. package/lib/OgcOpenApiVectorTilesModel.d.ts.map +1 -1
  27. package/lib/OgcOpenApiVectorTilesModel.js +1 -1
  28. package/lib/OgcOpenApiVectorTilesModel.js.map +1 -1
  29. package/package.json +1 -1
  30. package/src/OgcOpenApiFeatureStore.ts +21 -35
  31. package/src/OgcOpenApiFetchTools.ts +17 -0
  32. package/src/OgcOpenApiGetCapabilities.ts +47 -3
  33. package/src/OgcOpenApiStyleTools.ts +1 -1
  34. package/src/OgcOpenApiTileMatrixTools.ts +13 -0
  35. package/src/OgcOpenApiTilesModel.ts +7 -2
  36. package/src/OgcOpenApiVectorTilesModel.ts +4 -1
@@ -173,7 +173,7 @@ class OgcOpenApiStyleTools {
173
173
  if (link) return link.href;
174
174
  const self = collection.links.find(l => l.rel === "self");
175
175
  const collectionHref = self ? self.href : capabilities.baseUrl + "collections/" + collection.id;
176
- return OgcOpenApiFetchTools.cleanUrl(collectionHref) + "styles";
176
+ return OgcOpenApiFetchTools.appendPath(collectionHref, "styles");
177
177
  }
178
178
 
179
179
  private static withJsonFormat(href: string) {
@@ -74,6 +74,19 @@ class OgcOpenApiTileMatrixTools {
74
74
  return {level, x: tileCol, y};
75
75
  }
76
76
 
77
+ /**
78
+ * The tiles of the dataset limited to some of its collections (OGC API Tiles, collections selection):
79
+ * collections=a,b. A comma inside an id is encoded, the commas between ids are not. A collections parameter
80
+ * that the URL already has is replaced. Without collections, the URL is returned as is.
81
+ */
82
+ public static setCollections(url: string, collections?: string[]): string {
83
+ if (!collections || collections.length === 0) return url;
84
+ const [base, query] = url.split(/\?(.*)/s);
85
+ const kept = query ? query.split("&").filter(p => p !== "" && decodeURIComponent(p.split("=")[0]) !== "collections") : [];
86
+ kept.push("collections=" + collections.map(c => encodeURIComponent(c)).join(","));
87
+ return base + "?" + kept.join("&");
88
+ }
89
+
77
90
  public static appendQueryParameters(url: string, parameters: { [key: string]: string | number | boolean | undefined }): string {
78
91
  const query = Object.keys(parameters)
79
92
  .filter(k => parameters[k] !== undefined && parameters[k] !== null)
@@ -19,6 +19,9 @@ export interface OgcOpenApiTilesModelOptions {
19
19
  requestHeaders?: { [p: string]: string };
20
20
  transparent?: boolean;
21
21
  bgcolor?: string;
22
+ // For a tileset of the dataset: only these collections in each tile. The server must support collections
23
+ // selection, see OgcOpenApiGetCapabilities.supportsCollectionSelection
24
+ collections?: string[];
22
25
 
23
26
  proxify?: ProxifyFunction
24
27
  }
@@ -43,6 +46,7 @@ export class OgcOpenApiTilesModel extends WMTSTileSetModel {
43
46
  private transparent: boolean;
44
47
  private bgcolor: string | undefined;
45
48
  private proxy: ProxifyFunction;
49
+ private collections: string[] | undefined;
46
50
  private tileMatrixSetLimits: TileMatrixLimits[] | undefined;
47
51
  // Not tileMatrices: WMTSTileSetModel keeps the tile matrix ids in that property
48
52
  private ogcTileMatrices: { id: string, matrixHeight: number }[];
@@ -109,6 +113,7 @@ export class OgcOpenApiTilesModel extends WMTSTileSetModel {
109
113
  this.tileMatrixSetLimits = options.tileMatrixSetLimits;
110
114
  this.transparent = typeof options.transparent !== "undefined" ? options.transparent : true;
111
115
  this.bgcolor = options.bgcolor;
116
+ this.collections = options.collections;
112
117
 
113
118
  this.proxy = options.proxify;
114
119
 
@@ -127,10 +132,10 @@ export class OgcOpenApiTilesModel extends WMTSTileSetModel {
127
132
  OgcOpenApiTileMatrixTools.resolveTileTemplate(this.ogcTemplate, this.tileGrid, tile) :
128
133
  super.getTileURL(baseURL, tile);
129
134
  if (targetUrl === null) return null;
130
- let tileUrl = OgcOpenApiTileMatrixTools.appendQueryParameters(targetUrl, {
135
+ let tileUrl = OgcOpenApiTileMatrixTools.setCollections(OgcOpenApiTileMatrixTools.appendQueryParameters(targetUrl, {
131
136
  transparent: this.transparent,
132
137
  bgcolor: this.transparent ? undefined : this.bgcolor
133
- });
138
+ }), this.collections);
134
139
  if (typeof this.proxy === "function") {
135
140
  const proxyfied = this.proxy(tileUrl, {});
136
141
  tileUrl = proxyfied.url;
@@ -19,6 +19,9 @@ export interface OgcOpenApiVectorTilesModelOptions {
19
19
  tileMatrixSetLimits?: TileMatrixLimits[];
20
20
  // The data extent, defaults to the extent of the tile matrix set
21
21
  bounds?: Bounds;
22
+ // For a tileset of the dataset: only these collections in each tile. The server must support collections
23
+ // selection, see OgcOpenApiGetCapabilities.supportsCollectionSelection
24
+ collections?: string[];
22
25
  styleUrl?: string;
23
26
 
24
27
  proxify?: ProxifyFunction
@@ -51,7 +54,7 @@ export class OgcOpenApiVectorTilesModel extends MapboxVectorTileSetModel {
51
54
  requestHeaders: options.requestHeaders ? options.requestHeaders : {},
52
55
  });
53
56
  this.tileGrid = tileGrid;
54
- this.tileTemplate = options.baseURL;
57
+ this.tileTemplate = OgcOpenApiTileMatrixTools.setCollections(options.baseURL, options.collections);
55
58
  this.serverOptions = OgcOpenApiFetchTools.createFetchOptions({originalUrl: options.baseURL, proxify: options.proxify});
56
59
  this.tileMatrixSetLimits = options.tileMatrixSetLimits;
57
60
  }