From a5c0298698285482f64b168e218491489a657a46 Mon Sep 17 00:00:00 2001 From: Richard Kettelerij Date: Wed, 28 Aug 2024 16:44:51 +0200 Subject: [PATCH] fix(tiles): few fixes around collection-level OGC API Tiles: - fix landing/conformance page to not include dataset tiles when only using collection-level tiles - made some fields optional in CRD, since we're inlining a struct in the generated YAML/JSON. --- config/config.go | 8 +++++++- internal/ogc/common/core/templates/conformance.go.html | 2 ++ internal/ogc/common/core/templates/conformance.go.json | 2 ++ internal/ogc/common/core/templates/landing-page.go.html | 2 +- internal/ogc/common/core/templates/landing-page.go.json | 2 +- internal/ogc/tiles/main.go | 6 ++++-- 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/config/config.go b/config/config.go index 2a05ddae..4f9fa229 100644 --- a/config/config.go +++ b/config/config.go @@ -940,13 +940,19 @@ type PropertyFilter struct { // +kubebuilder:object:generate=true type Tiles struct { - // Reference to the server (or object storage) hosting the tiles + // Reference to the server (or object storage) hosting the tiles. + // Note: Only marked as optional in CRD to support top-level OR collection-level tiles + // +optional TileServer URL `yaml:"tileServer" json:"tileServer" validate:"required"` // Could be 'vector' and/or 'raster' to indicate the types of tiles offered + // Note: Only marked as optional in CRD to support top-level OR collection-level tiles + // +optional Types []TilesType `yaml:"types" json:"types" validate:"required"` // Specifies in what projections (SRS/CRS) the tiles are offered + // Note: Only marked as optional in CRD to support top-level OR collection-level tiles + // +optional SupportedSrs []SupportedSrs `yaml:"supportedSrs" json:"supportedSrs" validate:"required,dive"` // Optional template to the vector tiles on the tileserver. Defaults to {tms}/{z}/{x}/{y}.pbf. diff --git a/internal/ogc/common/core/templates/conformance.go.html b/internal/ogc/common/core/templates/conformance.go.html index 7404b328..ac20f4ad 100644 --- a/internal/ogc/common/core/templates/conformance.go.html +++ b/internal/ogc/common/core/templates/conformance.go.html @@ -194,10 +194,12 @@

Tiles

http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/tilesets-list {{ i18n "Standard" }} + {{ if .Config.OgcAPI.Tiles.DatasetTiles }} http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/dataset-tilesets {{ i18n "Standard" }} + {{ end }} {{ if .Config.OgcAPI.Tiles.Collections }} http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/geodata-tilesets diff --git a/internal/ogc/common/core/templates/conformance.go.json b/internal/ogc/common/core/templates/conformance.go.json index 406cc88c..6d8b6265 100644 --- a/internal/ogc/common/core/templates/conformance.go.json +++ b/internal/ogc/common/core/templates/conformance.go.json @@ -53,7 +53,9 @@ ,"http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/core" ,"http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/tileset" ,"http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/tilesets-list" + {{ if .Config.OgcAPI.Tiles.DatasetTiles }} ,"http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/dataset-tilesets" + {{ end }} {{ if .Config.OgcAPI.Tiles.Collections }} ,"http://www.opengis.net/spec/ogcapi-tiles-1/1.0/conf/geodata-tilesets" {{ end }} diff --git a/internal/ogc/common/core/templates/landing-page.go.html b/internal/ogc/common/core/templates/landing-page.go.html index 483eb349..69d1d04a 100644 --- a/internal/ogc/common/core/templates/landing-page.go.html +++ b/internal/ogc/common/core/templates/landing-page.go.html @@ -111,7 +111,7 @@

{{ end }} - {{ if .Config.OgcAPI.Tiles }} + {{ if and .Config.OgcAPI.Tiles .Config.OgcAPI.Tiles.DatasetTiles }}

diff --git a/internal/ogc/common/core/templates/landing-page.go.json b/internal/ogc/common/core/templates/landing-page.go.json index 248f5fea..65800826 100644 --- a/internal/ogc/common/core/templates/landing-page.go.json +++ b/internal/ogc/common/core/templates/landing-page.go.json @@ -49,7 +49,7 @@ "href": "{{ .Config.BaseURL }}/styles" } {{ end }} - {{ if .Config.OgcAPI.Tiles }} + {{ if and .Config.OgcAPI.Tiles .Config.OgcAPI.Tiles.DatasetTiles }} , { "rel": "http://www.opengis.net/def/rel/ogc/1.0/tilesets-vector", diff --git a/internal/ogc/tiles/main.go b/internal/ogc/tiles/main.go index 3b4a9eb6..f4bc0c4b 100644 --- a/internal/ogc/tiles/main.go +++ b/internal/ogc/tiles/main.go @@ -217,9 +217,11 @@ func renderTileMatrixTemplates(e *engine.Engine) { func renderTilesTemplates(e *engine.Engine, collection *config.GeoSpatialCollection, data templateData) { var breadcrumbs []engine.Breadcrumb + path := tilesPath collectionID := "" if collection != nil { collectionID = collection.ID + path = g.CollectionsPath + "/" + collectionID + tilesPath breadcrumbs = collectionsBreadcrumb breadcrumbs = append(breadcrumbs, []engine.Breadcrumb{ @@ -236,7 +238,7 @@ func renderTilesTemplates(e *engine.Engine, collection *config.GeoSpatialCollect breadcrumbs = tilesBreadcrumbs } - e.RenderTemplatesWithParams(tilesPath, + e.RenderTemplatesWithParams(path, data, breadcrumbs, engine.NewTemplateKeyWithName(templatesDir+"tiles.go.json", collectionID), @@ -252,7 +254,7 @@ func renderTilesTemplates(e *engine.Engine, collection *config.GeoSpatialCollect }, }...) - path := tilesPath + "/" + projection + path = tilesPath + "/" + projection if collection != nil { path = g.CollectionsPath + "/" + collectionID + tilesPath + "/" + projection }