Skip to content

Commit

Permalink
Merge pull request #252 from PDOK/pdok-16665-collection-json-add-fields
Browse files Browse the repository at this point in the history
add some fields to collection json
  • Loading branch information
roelarents authored Nov 4, 2024
2 parents 28850ce + 70605d6 commit 3b33044
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cmd/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ func Test_newRouter(t *testing.T) {
apiCall: "http://localhost:8180/collections/NewYork?f=html",
wantBody: "internal/engine/testdata/expected_multiple_ogc_apis_single_collection.html",
},
{
name: "Serve JSON-LD in multiple OGC APIs for single collection in HTML",
configFile: "internal/engine/testdata/config_multiple_ogc_apis_single_collection.yaml",
apiCall: "http://localhost:8180/collections/NewYork?f=html",
wantBody: "internal/engine/testdata/expected_multiple_ogc_apis_single_collection_json_ld.html",
},
{
name: "Serve multiple Feature Tables from single GeoPackage",
configFile: "internal/ogc/features/testdata/config_features_bag_multiple_feature_tables.yaml",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
"id": "NewYork",
"title": "NewYork",
"description": "This is a description about the NewYork collection in Markdown. We offer both 3D Tiles and Features for this collection.",
"keywords": [
{
"keyword": "Keyword1"
},
{
"keyword": "Keyword2"
}
],
"collectionType": "3d-container",
"extent": {
"spatial": {
Expand Down Expand Up @@ -35,14 +43,22 @@
"rel": "self",
"type": "application/json",
"title": "This document as JSON",
"updated": "2023-05-10T12:00:00Z",
"href": "http://localhost:8180/collections/NewYork?f=json"
},
{
"rel": "alternate",
"type": "text/html",
"title": "This document as HTML",
"updated": "2023-05-10T12:00:00Z",
"href": "http://localhost:8180/collections/NewYork?f=html"
},
{
"rel": "preview",
"type": "image/png",
"title": "Thumbnail for NewYork",
"href": "http://localhost:8180/resources/3d.png"
},
{
"rel": "items",
"type": "application/json+3dtiles",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "Dataset",
"isPartOf": "http:\/\/localhost:8180?f=html",
"name": "New York - NewYork",
"description": "This is a description about the NewYork collection in Markdown. We offer both 3D Tiles and Features for this collection.",
"url": "http:\/\/localhost:8180/collections/NewYork?f=html","keywords": ["Keyword1","Keyword2"],"license": "https:\/\/creativecommons.org\/publicdomain\/zero\/1.0\/deed.nl",
"isAccessibleForFree": true
,"thumbnailUrl": "http:\/\/localhost:8180/resources/3d.png"
,"version": "2023-05-10"
}
</script>
6 changes: 5 additions & 1 deletion internal/ogc/common/geospatial/templates/collection.go.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
{{- end }}
"url": "{{ .Config.BaseURL }}/collections/{{ .Params.ID }}?f=html",
{{- if and .Params.Metadata .Params.Metadata.Keywords -}}
"keywords": ["{{ .Params.Metadata.Keywords | join ", " }}"],
"keywords": [
{{- range $i, $k := .Params.Metadata.Keywords -}}
{{- if $i -}},{{- end -}}"{{ $k }}"
{{- end -}}
],
{{- end -}}
"license": "{{ .Config.License.URL }}",
"isAccessibleForFree": true
Expand Down
22 changes: 22 additions & 0 deletions internal/ogc/common/geospatial/templates/collection.go.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
{{ if and .Params.Metadata .Params.Metadata.Description }}
"description" : "{{ unmarkdown .Params.Metadata.Description }}",
{{ end }}
{{- if and .Params.Metadata .Params.Metadata.Keywords }}
"keywords": [
{{- range $k, $keyword := .Params.Metadata.Keywords -}}
{{ if $k }},{{ end }}
{"keyword": {{ mustToRawJson $keyword }} }
{{- end -}}
],
{{- end }}
{{ if and .Config.OgcAPI.GeoVolumes .Config.OgcAPI.GeoVolumes.Collections }}
"collectionType" : "3d-container",
{{ end }}
Expand Down Expand Up @@ -48,14 +56,28 @@
"rel" : "self",
"type" : "application/json",
"title" : "This document as JSON",
{{- if and .Params.Metadata .Params.Metadata.LastUpdated }}
"updated" : "{{ dateInZone "2006-01-02T15:04:05Z07:00" (toDate "2006-01-02T15:04:05Z07:00" .Params.Metadata.LastUpdated) "UTC" }}",
{{- end }}
"href" : "{{ .Config.BaseURL }}/collections/{{ .Params.ID }}?f=json"
},
{
"rel" : "alternate",
"type" : "text/html",
"title" : "This document as HTML",
{{- if and .Params.Metadata .Params.Metadata.LastUpdated }}
"updated" : "{{ dateInZone "2006-01-02T15:04:05Z07:00" (toDate "2006-01-02T15:04:05Z07:00" .Params.Metadata.LastUpdated) "UTC" }}",
{{- end }}
"href" : "{{ .Config.BaseURL }}/collections/{{ .Params.ID }}?f=html"
}
{{ if and .Params.Metadata .Params.Metadata.Thumbnail }}
,{
"rel": "preview",
"type": "image/{{ .Params.Metadata.Thumbnail | ext | trimPrefix "." }}",
"title": "Thumbnail for {{ .Params.ID }}",
"href": "{{ .Config.BaseURL }}/resources/{{ .Params.Metadata.Thumbnail }}"
}
{{ end }}
{{ if and .Config.OgcAPI.GeoVolumes .Config.OgcAPI.GeoVolumes.Collections }}
{{ if and .Params.GeoVolumes .Params.GeoVolumes.Has3DTiles }}
,
Expand Down
22 changes: 22 additions & 0 deletions internal/ogc/common/geospatial/templates/collections.go.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@
{{ if and $coll.Metadata $coll.Metadata.Description }}
,"description" : "{{ unmarkdown $coll.Metadata.Description }}"
{{ end }}
{{- if and $coll.Metadata $coll.Metadata.Keywords }}
,"keywords": [
{{- range $k, $keyword := $coll.Metadata.Keywords -}}
{{ if $k }},{{ end }}
{ "keyword": {{ mustToRawJson $keyword }} }
{{- end }}
]
{{- end -}}
{{ if and $cfg.OgcAPI.GeoVolumes $cfg.OgcAPI.GeoVolumes.Collections }}
{{ if $cfg.OgcAPI.GeoVolumes.Collections.ContainsID $coll.ID }}
,"collectionType" : "3d-container"
Expand Down Expand Up @@ -77,14 +85,28 @@
"rel" : "self",
"type" : "application/json",
"title" : "Information about the {{ $coll.ID }} collection as JSON",
{{- if and $coll.Metadata $coll.Metadata.LastUpdated }}
"updated" : "{{ dateInZone "2006-01-02T15:04:05Z07:00" (toDate "2006-01-02T15:04:05Z07:00" $coll.Metadata.LastUpdated) "UTC" }}",
{{- end }}
"href" : "{{ $baseUrl }}/collections/{{ $coll.ID }}?f=json"
},
{
"rel" : "alternate",
"type" : "text/html",
"title" : "Information about the {{ $coll.ID }} collection as HTML",
{{- if and $coll.Metadata $coll.Metadata.LastUpdated }}
"updated" : "{{ dateInZone "2006-01-02T15:04:05Z07:00" (toDate "2006-01-02T15:04:05Z07:00" $coll.Metadata.LastUpdated) "UTC" }}",
{{- end }}
"href" : "{{ $baseUrl }}/collections/{{ $coll.ID }}?f=html"
}
{{ if and $coll.Metadata $coll.Metadata.Thumbnail }}
,{
"rel": "preview",
"type": "image/{{ $coll.Metadata.Thumbnail | ext | trimPrefix "." }}",
"title": "Thumbnail for {{ $coll.ID }}",
"href": "{{ $baseUrl }}/resources/{{ $coll.Metadata.Thumbnail }}"
}
{{ end }}
{{ if and $cfg.OgcAPI.GeoVolumes $cfg.OgcAPI.GeoVolumes.Collections }}
{{ if $cfg.OgcAPI.GeoVolumes.Collections.ContainsID $coll.ID }}
{{ if and $coll.GeoVolumes $coll.GeoVolumes.Has3DTiles }}
Expand Down

0 comments on commit 3b33044

Please sign in to comment.