Skip to content

Commit

Permalink
feat(tiles): support collection-level OGC API tiles (geodata tiles).
Browse files Browse the repository at this point in the history
  • Loading branch information
rkettelerij committed Aug 22, 2024
1 parent d7e4514 commit 58edead
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 35 deletions.
8 changes: 6 additions & 2 deletions assets/i18n/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ ConformanceText: The conformance describes which OGC standards this API implemen
Collections: Collections
CollectionsText: This API offers one or more collections that divide the dataset in various object types, which can be called separately through for instance <i>features</i> or <i>tiles</i>.
Tiles: Tiles
TilesTextHTML: This entire dataset is available as vector tiles in multiple projections. One or more <a href="styles" aria-label="Go to styles">styles</a> are also available.
TilesTextPlain: This entire dataset is available as vector tiles in multiple projections. One or more styles are also available.
TilesTextHTML: This entire dataset is available as vector tiles in multiple projections.
TilesTextPlain: This entire dataset is available as vector tiles in multiple projections.
WithStylesHTML: One or more <a href="styles" aria-label="Go to styles">styles</a> are also available.
WithStylesPlain: One or more styles are also available.
Styles: Styles
StylesText: One or more official styles as specified by the supplier. Styles are made available in the Mapbox format.
TileMatrixSets: Tile Matrix Sets
Expand Down Expand Up @@ -97,6 +99,8 @@ GoTo: Go to the
ViewIn: View in the
Browse: Browse through the
FeaturesExplanation: GeoJSON is an open and widely accepted format for feature data and the first choice for many (web) applications. However, it formally only supports the WGS84 projection. JSON-FG is an extension of GeoJSON and does offer official support for other projections. Since JSON-FG is a recent development, from a compatibility point of view GeoJSON is also offered in other projections for the time being.
CollectionTilesHTML: This collection is available as vector tiles in one or multiple projections.
CollectionTilesPlain: This collection is available as vector tiles in one or multiple projections.

# Features page
Geometry: geometry
Expand Down
8 changes: 6 additions & 2 deletions assets/i18n/nl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ ConformanceText: De conformance beschrijft welke OGC standaarden deze API implem
Collections: Collections
CollectionsText: Deze API biedt één of meerdere collecties waarmee onderscheid gemaakt wordt in verschillende object typen, die bijvoorbeeld als <i>features</i> of <i>tiles</i> separaat aangeroepen kunnen worden.
Tiles: Tiles
TilesTextHTML: Deze dataset wordt beschikbaar gesteld als vector tiles in meerdere projecties. Ook worden er &eacute;&eacute;n of meerdere <a href="styles" aria-label="Ga naar styles">styles</a> beschikbaar gesteld.
TilesTextPlain: Deze dataset wordt beschikbaar gesteld als vector tiles in meerdere projecties. Ook worden er één of meerdere styles beschikbaar gesteld.
TilesTextHTML: Deze dataset wordt beschikbaar gesteld als vector tiles in &eacute;&eacute;n of meerdere projecties.
TilesTextPlain: Deze dataset wordt beschikbaar gesteld als vector tiles in één of meerdere projecties.
WithStylesHTML: Ook worden er <a href="styles" aria-label="Ga naar styles">styles</a> beschikbaar gesteld.
WithStylesPlain: Ook worden er styles beschikbaar gesteld.
Styles: Styles
StylesText: Betreft één of meerdere officiële styles van/door de aanbieder gespecificeerd. Styles worden beschikbaar gesteld in het Mapbox formaat.
TileMatrixSets: Tile Matrix Sets
Expand Down Expand Up @@ -99,6 +101,8 @@ GoTo: Ga naar de
ViewIn: Bekijk in de
Browse: Blader door de
FeaturesExplanation: GeoJSON is een open en breed geaccepteerd formaat voor feature data en voor veel (web)toepassingen de eerste keus. Formeel ondersteunt het echter alleen de WGS84 projectie. JSON-FG is een uitbreiding op GeoJSON en biedt officiële ondersteuning voor andere projecties. Aangezien JSON-FG een recente ontwikkeling is wordt er vanuit compatibiliteit oogpunt vooralsnog ook GeoJSON in andere projecties aangeboden.
CollectionTilesHTML: Deze collectie wordt beschikbaar gesteld als vector tiles in &eacute;&eacute;n of meerdere projecties.
CollectionTilesPlain: Deze collectie wordt beschikbaar gesteld als vector tiles in één of meerdere projecties.

# Features page
Geometry: geometrie
Expand Down
2 changes: 1 addition & 1 deletion internal/ogc/common/core/templates/landing-page.go.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ <h2 class="card-header h5">
</h2>
<div class="card-body">
<p>
{{ i18n "TilesTextHTML" }}
{{ i18n "TilesTextHTML" }} {{ if .Config.OgcAPI.Styles }}{{ i18n "WithStylesHTML" }}{{ end }}
{{ i18n "AvailableIn" }}
</p>
<small class="text-body-secondary">{{ i18n "ViewAs" }} <a href="tiles?f=json" target="_blank" aria-label="{{ i18n "Tiles" }} {{ i18n "As" }} JSON">JSON</a></small>
Expand Down
32 changes: 16 additions & 16 deletions internal/ogc/common/geospatial/templates/collection.go.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ <h2 class="card-header h5">
<div class="col-md-4 col-sm-12">
<div class="card h-100">
<h2 class="card-header h5">
<a href="#" aria-label="{{ i18n "To" }} Tiles">Tiles</a>
<a href="{{ .Config.BaseURL }}/collections/{{ .Params.ID }}/tiles" aria-label="{{ i18n "To" }} Tiles">Tiles</a>
</h2>
<div class="card-body">
<p>
TODO (placeholder)
{{ i18n "CollectionTilesHTML" }} {{ if .Config.OgcAPI.Styles }}{{ i18n "WithStylesHTML" }}{{ end }}
</p>
</div>
</div>
Expand All @@ -148,20 +148,20 @@ <h2 class="card-header h5">
</p>
<p>
<ul>
{{ range $formatKey, $formatName := $.AvailableFormatsFeatures }}
<li> <label for="select{{ $formatKey }}" class="visually-hidden">{{ i18n "To" }} Features in</label>
<select id="select{{ $formatKey }}">
<option value="https://www.opengis.net/def/crs/OGC/1.3/CRS84">WGS84</option>
{{ range $index, $srs := $.Config.OgcAPI.Features.ProjectionsForCollection $.Params.ID }}
{{ $crs := printf "http://www.opengis.net/def/crs/EPSG/0/%s" (trimPrefix "EPSG:" $srs) }}
<option value="{{ $crs }}">{{ $srs }}</option>
{{ end }}
</select>
{{ i18n "As" }}
<a href="{{ $.Config.BaseURL }}/collections/{{ $.Params.ID }}" onclick="gotoFeatures('{{ $formatKey }}', 'select{{ $formatKey }}'); return false;">{{ $formatName }}</a>.
</li>
{{ end }}
</ul>
{{ range $formatKey, $formatName := $.AvailableFormatsFeatures }}
<li> <label for="select{{ $formatKey }}" class="visually-hidden">{{ i18n "To" }} Features in</label>
<select id="select{{ $formatKey }}">
<option value="https://www.opengis.net/def/crs/OGC/1.3/CRS84">WGS84</option>
{{ range $index, $srs := $.Config.OgcAPI.Features.ProjectionsForCollection $.Params.ID }}
{{ $crs := printf "http://www.opengis.net/def/crs/EPSG/0/%s" (trimPrefix "EPSG:" $srs) }}
<option value="{{ $crs }}">{{ $srs }}</option>
{{ end }}
</select>
{{ i18n "As" }}
<a href="{{ $.Config.BaseURL }}/collections/{{ $.Params.ID }}" onclick="gotoFeatures('{{ $formatKey }}', 'select{{ $formatKey }}'); return false;">{{ $formatName }}</a>.
</li>
{{ end }}
</ul>
</p>
<div class="alert alert-primary" role="alert">
<small>{{ i18n "FeaturesExplanation" }}</small>
Expand Down
4 changes: 2 additions & 2 deletions internal/ogc/common/geospatial/templates/collection.go.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@
{{ if and .Config.OgcAPI.Tiles .Config.OgcAPI.Tiles.Collections }}
,
{
"rel" : "items",
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/tilesets-vector",
"type" : "application/json",
"title" : "The JSON representation of the {{ .Params.ID }} tiles served from this endpoint",
"href" : "{{ .Config.BaseURL }}/collections/{{ .Params.ID }}/tiles?f=json"
},
{
"rel" : "alternate",
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/tilesets-vector",
"type" : "text/html",
"title" : "The HTML representation of the {{ .Params.ID }} tiles served from this endpoint",
"href" : "{{ .Config.BaseURL }}/collections/{{ .Params.ID }}/tiles?f=html"
Expand Down
4 changes: 2 additions & 2 deletions internal/ogc/common/geospatial/templates/collections.go.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@
{{ if and $cfg.OgcAPI.Tiles $cfg.OgcAPI.Tiles.Collections }}
{{ if $cfg.OgcAPI.Tiles.Collections.ContainsID $coll.ID }}
,{
"rel" : "items",
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/tilesets-vector",
"type" : "application/json",
"title" : "The JSON representation of the {{ $coll.ID }} tiles served from this endpoint",
"href" : "{{ $baseUrl }}/collections/{{ $coll.ID }}/tiles?f=json"
},
{
"rel" : "items",
"rel" : "http://www.opengis.net/def/rel/ogc/1.0/tilesets-vector",
"type" : "text/html",
"title" : "The HTML representation of the {{ $coll.ID }} tiles served from this endpoint",
"href" : "{{ $baseUrl }}/collections/{{ $coll.ID }}/tiles?f=html"
Expand Down
16 changes: 8 additions & 8 deletions internal/ogc/tiles/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
)

var (
// When adding a new project also add corresponding templates
// When adding a new projection also add corresponding templates
allProjections = map[string]string{
"EPSG:28992": "NetherlandsRDNewQuad",
"EPSG:3035": "EuropeanETRS89_LAEAQuad",
Expand Down Expand Up @@ -190,16 +190,16 @@ func renderTileMatrixTemplates(e *engine.Engine) {
engine.NewTemplateKey(templatesDir+"tileMatrixSets.go.html"))

for _, projection := range allProjections {
tileMatrixSetsSrsBreadcrumbs := tileMatrixSetsBreadcrumbs
tileMatrixSetsSrsBreadcrumbs = append(tileMatrixSetsSrsBreadcrumbs, []engine.Breadcrumb{
breadcrumbs := tileMatrixSetsBreadcrumbs
breadcrumbs = append(breadcrumbs, []engine.Breadcrumb{
{
Name: projection,
Path: tileMatrixSetsLocalPath + projection,
},
}...)

e.RenderTemplates(tileMatrixSetsPath+"/"+projection,
tileMatrixSetsSrsBreadcrumbs,
breadcrumbs,
engine.NewTemplateKey(templatesDir+tileMatrixSetsLocalPath+projection+".go.json"),
engine.NewTemplateKey(templatesDir+tileMatrixSetsLocalPath+projection+".go.html"))
}
Expand All @@ -213,8 +213,8 @@ func renderTilesTemplates(e *engine.Engine, collectionID string, data templateDa
engine.NewTemplateKeyWithName(templatesDir+"tiles.go.html", collectionID))

for _, projection := range allProjections {
tilesSrsBreadcrumbs := tilesBreadcrumbs
tilesSrsBreadcrumbs = append(tilesSrsBreadcrumbs, []engine.Breadcrumb{
breadcrumbs := tilesBreadcrumbs
breadcrumbs = append(breadcrumbs, []engine.Breadcrumb{
{
Name: projection,
Path: tilesLocalPath + projection,
Expand All @@ -227,12 +227,12 @@ func renderTilesTemplates(e *engine.Engine, collectionID string, data templateDa
}
e.RenderTemplatesWithParamsAndValidate(path,
data,
tilesSrsBreadcrumbs,
breadcrumbs,
engine.NewTemplateKeyWithName(templatesDir+tilesLocalPath+projection+".go.json", collectionID),
engine.NewTemplateKeyWithName(templatesDir+tilesLocalPath+projection+".go.html", collectionID))
e.RenderTemplatesWithParamsAndValidate(path,
data,
tilesSrsBreadcrumbs,
breadcrumbs,
engine.NewTemplateKeyWithName(templatesDir+tilesLocalPath+projection+".go.tilejson", collectionID))
}
}
2 changes: 1 addition & 1 deletion internal/ogc/tiles/templates/tiles.go.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h1 class="title" id="title">{{ .Config.Title }} - {{ i18n "Tiles" }}</h1>
<div class="row py-3">
<div class="col-md-12">
<p>
{{ i18n "TilesTextHTML" }}
{{ i18n "TilesTextHTML" }} {{ if .Config.OgcAPI.Styles }}{{ i18n "WithStylesHTML" }}{{ end }}
</p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion internal/ogc/tiles/templates/tiles.go.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{ if .Config.OgcAPI.Tiles }}
{{ $baseUrlTiles := .Params.BaseURL }}
"title": "{{ .Config.Title }} - Tiles",
"description": "{{ i18n "TilesTextPlain" }}",
"description": "{{ i18n "TilesTextPlain" }} {{ if .Config.OgcAPI.Styles }}{{ i18n "WithStylesPlain" }}{{ end }}",
"links": [
{
"rel": "self",
Expand Down

0 comments on commit 58edead

Please sign in to comment.