Skip to content

Commit 477fd8c

Browse files
authored
Merge pull request #374 from PDOK/fix-missing-fields-collections
fix: add version + displayNameTemplate to collections response
2 parents 83fc2be + 8aa15a8 commit 477fd8c

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

internal/ogc/common/geospatial/main_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,28 @@ func TestNewCollections_Collections(t *testing.T) {
111111
statusCode: http.StatusOK,
112112
},
113113
},
114+
{
115+
name: "search config, check references to related collections",
116+
fields: fields{
117+
configFile: "internal/ogc/features_search/testdata/config_search.yaml",
118+
url: "http://localhost:8080/collections?f=json",
119+
},
120+
want: want{
121+
bodyContains: "Related OGC API Features collection 'buildings' in HTML representation",
122+
statusCode: http.StatusOK,
123+
},
124+
},
125+
{
126+
name: "search config, check version",
127+
fields: fields{
128+
configFile: "internal/ogc/features_search/testdata/config_search.yaml",
129+
url: "http://localhost:8080/collections?f=json",
130+
},
131+
want: want{
132+
bodyContains: "\"version\": 1,",
133+
statusCode: http.StatusOK,
134+
},
135+
},
114136
}
115137
for _, tt := range tests {
116138
t.Run(tt.name, func(t *testing.T) {

internal/ogc/common/geospatial/templates/collections.go.json

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@
8383
,"storageCrs" : "http://www.opengis.net/def/crs/OGC/1.3/CRS84"
8484
{{ end }}
8585
{{ end }}
86+
{{ if and $cfg.OgcAPI.FeaturesSearch $cfg.OgcAPI.FeaturesSearch.Collections }}
87+
{{ if $cfg.OgcAPI.FeaturesSearch.Collections.ContainsID $coll.ID }}
88+
{{ range $idxSearch, $collSearch := $cfg.OgcAPI.FeaturesSearch.Collections }}
89+
{{ if eq $collSearch.ID $coll.ID }}
90+
,"version" : {{ $collSearch.Version }}
91+
,"displayNameTemplate" : {{ mustToRawJson $collSearch.DisplayNameTemplate }}
92+
{{ end }}
93+
{{ end }}
94+
{{ end }}
95+
{{ end }}
8696
,"links" : [
8797
{
8898
"rel" : "self",
@@ -153,20 +163,28 @@
153163
{{ if and $cfg.OgcAPI.FeaturesSearch $cfg.OgcAPI.FeaturesSearch.Collections }}
154164
{{ if $cfg.OgcAPI.FeaturesSearch.Collections.ContainsID $coll.ID }}
155165
{{ range $idxSearch, $collSearch := $cfg.OgcAPI.FeaturesSearch.Collections }}
156-
{{ if and (eq $collSearch.ID $coll.ID) ($collSearch.IsRemoteFeatureCollection $coll.ID) }}
166+
{{ if eq $collSearch.ID $coll.ID }}
157167
{{/* collection reference is only required for remotely hosted collections */}}
168+
{{ if $collSearch.IsRemoteFeatureCollection $coll.ID }}
158169
,
159170
{{ range $o, $collRef := $coll.CollectionRefs -}}
160171
{{ if $o }},{{ end }}
161172
{
162-
"rel": "canonical",
173+
"rel": "source", {{/* not an offical IANA link relation */}}
163174
"type": "text/html",
164-
"title": "{{ $collRef.CollectionID }}",
165-
"href": "{{ $collRef.APIBaseURL }}/collections/{{ $collRef.CollectionID }}"
175+
"title": "Related OGC API Features collection '{{ $collRef.CollectionID }}' in HTML representation",
176+
"href": "{{ $collRef.APIBaseURL }}/collections/{{ $collRef.CollectionID }}?f=html"
177+
},
178+
{
179+
"rel": "source", {{/* not an offical IANA link relation */}}
180+
"type": "application/json",
181+
"title": "Related OGC API Features collection '{{ $collRef.CollectionID }}' in JSON representation",
182+
"href": "{{ $collRef.APIBaseURL }}/collections/{{ $collRef.CollectionID }}?f=json"
166183
}
167184
{{- end }}
168185
{{- end }}
169186
{{- end }}
187+
{{- end }}
170188
{{end}}
171189
{{end}}
172190
{{ if and $cfg.OgcAPI.Features $cfg.OgcAPI.Features.Collections }}

0 commit comments

Comments
 (0)