Skip to content

Commit 3540122

Browse files
Merge pull request #397 from PDOK/collection-page-adjustments
Collection page adjustments for search collection
2 parents 35af06d + e0bc629 commit 3540122

File tree

16 files changed

+233
-112
lines changed

16 files changed

+233
-112
lines changed

assets/css/gokoala.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
.card-header a:hover {
3434
color: var(--secondary-color);
3535
}
36+
.collapse-chevron {
37+
transition: transform 0.2s ease-in-out;
38+
}
39+
a[data-bs-toggle="collapse"]:not([aria-expanded="false"]) .collapse-chevron {
40+
transform: rotate(-180deg);
41+
}
3642

3743
hgroup {
3844
margin-bottom: 0.5rem;

assets/i18n/en.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ CollectionsHeader: Collections
7676
SearchHelpText: Search query must be at least two characters long.
7777
NoCollectionSelectedText: A minimum of one collection must be selected.
7878

79+
7980
# Tile/TileMatrixSet page
8081
NetherlandsRDNewQuadAbstract: |-
8182
The tiles can be requested via the URL template below, where
@@ -126,8 +127,11 @@ BrowseSchemaAttributesSuffix: of the attributes for more details
126127
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.
127128
CollectionTilesHTML: This collection is available as vector tiles in one or multiple projections.
128129
CollectionTilesPlain: This collection is available as vector tiles in one or multiple projections.
129-
DisplayNameTemplate: Display template
130130
OGCCollections: Related OGC API feature collections
131+
DisplayNameExample: Display example
132+
DisplayedAs: Displayed as
133+
CollectionFilter: Collection filter
134+
Details: Details
131135

132136
# Features page
133137
Geometry: geometry

assets/i18n/nl.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ CollectionsHeader: Collecties
7676
SearchHelpText: Zoekterm moet minimaal twee tekens lang zijn.
7777
NoCollectionSelectedText: Er moet minimaal één collectie geselecteerd zijn.
7878

79+
7980
# Tile/TileMatrixSet page
8081
NetherlandsRDNewQuadAbstract: |-
8182
De tiles zijn op te vragen via onderstaande URL-template. Daarbij is
@@ -126,9 +127,11 @@ BrowseSchemaAttributesSuffix: van de attributes voor meer details
126127
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.
127128
CollectionTilesHTML: Deze collectie wordt beschikbaar gesteld als vector tiles in één of meerdere projecties.
128129
CollectionTilesPlain: Deze collectie wordt beschikbaar gesteld als vector tiles in één of meerdere projecties.
129-
DisplayNameTemplate: Weergavesjabloon
130130
OGCCollections: Gerelateerde OGC API feature collecties
131-
131+
DisplayedAs: Weergegeven als
132+
DisplayNameExample: Voorbeeldweergave
133+
CollectionFilter: Collectiefilter
134+
Details: Details
132135
# Features page
133136
Geometry: geometrie
134137
Prev: Vorige

assets/js/bootstrap.min.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/ogcapi_features_search.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,24 @@ func (csfs FeaturesSearchCollections) ContainsID(id string) bool {
8181
return false
8282
}
8383

84+
func (csfs FeaturesSearchCollections) GetCollectionRefsByCollectionID(collectionID string) []RelatedOGCAPIFeaturesCollection {
85+
var collection FeaturesSearchCollection
86+
for _, coll := range csfs {
87+
if coll.ID == collectionID {
88+
collection = coll
89+
break
90+
}
91+
}
92+
if collection.CollectionRefs == nil {
93+
return make([]RelatedOGCAPIFeaturesCollection, 0)
94+
}
95+
96+
result := make([]RelatedOGCAPIFeaturesCollection, len(collection.CollectionRefs))
97+
copy(result, collection.CollectionRefs)
98+
99+
return result
100+
}
101+
84102
// +kubebuilder:object:generate=true
85103
//
86104
//nolint:recvcheck
@@ -97,11 +115,14 @@ type FeaturesSearchCollection struct {
97115
// +optional
98116
Links *CollectionLinks `yaml:"links,omitempty" json:"links,omitempty"`
99117

100-
// Fields that make up the display name and/or suggestions. These fields can be used as variables in the DisplayNameTemplate.
118+
// Fields that make up the display name and/or suggestions. These fields can be used as variables in the DisplayNameExample.
101119
Fields []string `yaml:"fields,omitempty" json:"fields,omitempty"`
102120

103121
// Template that indicates how a search record is displayed. Uses Go text/template syntax to reference fields.
104-
DisplayNameTemplate string `yaml:"displayNameTemplate,omitempty" json:"displayNameTemplate,omitempty"`
122+
DisplayNameExample string `yaml:"displayNameExample,omitempty" json:"displayNameExample,omitempty"`
123+
124+
// Filter that is applied to gather data from FeatureCollections.
125+
CollectionFilter string `yaml:"collectionFilter,omitempty" json:"collectionFilter,omitempty"`
105126

106127
// Version of the collection exposed through the API.
107128
// +kubebuilder:default=1

examples/config_search.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ ogcApi:
6161
- address_street
6262
- address_postal
6363
- address_place
64-
displayNameTemplate: "{{ .address_street | firstupper }} {{ .address_postal}} {{ .address_place }}"
64+
displayNameExample: "Lange Jansstraat 1, 3512 BA Utrecht"
65+
collectionFilter: "address_postal LIKE '1234%'"
6566
collectionRefs:
6667
- collection: addresses # reference the locally hosted feature collection
6768
geometryType: point
@@ -79,11 +80,15 @@ ogcApi:
7980
fields:
8081
- street
8182
- place
82-
displayNameTemplate: "{{ .street | firstupper }} {{ .place }}"
83+
displayNameExample: "Domplein 9, 3512 JC Utrecht"
84+
collectionFilter: "address_postal LIKE '1234%'"
8385
collectionRefs:
8486
- api: https://example.com/ogc/v1 # reference a remote hosted feature collection
8587
collection: buildings
8688
geometryType: polygon
89+
- api: https://example.com/ogc/v2 # reference a remote hosted feature collection
90+
collection: buildings2
91+
geometryType: polygon
8792
tableName: buildings
8893
metadata:
8994
title: Dutch Buildings

examples/config_search_etl.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ collections:
88
- address_street
99
- address_postal
1010
- address_place
11-
displayNameTemplate: "{{ .address_street | firstupper }} {{ .address_postal}} {{ .address_place }}"
11+
displayNameExample: "Lange Jansstraat 1, 3512 BA Utrecht"
1212
suggestTemplates:
1313
- "{{ .address_street | firstupper }} {{ .address_postal}} {{ .address_place }}" # equal to display name
1414
- "{{ .address_street | firstupper }} {{ .address_postal}}, {{ .address_place }}"
@@ -20,7 +20,7 @@ collections:
2020
fields:
2121
- street
2222
- place
23-
displayNameTemplate: "{{ .street | firstupper }} {{ .place }}"
23+
displayNameExample: "Lange Jansstraat Utrecht"
2424
suggestTemplates:
2525
- "{{ .street | firstupper }} {{ .place }}" # equal to display name
2626
- "{{ .street | firstupper }} - {{ .place }}"

internal/engine/templates/layout.go.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,6 @@
158158
</div>
159159
</footer>
160160

161+
<script src="js/bootstrap.min.js"></script>
161162
</body>
162163
</html>

internal/ogc/common/geospatial/main_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,17 @@ func TestNewCollections_Collections(t *testing.T) {
133133
statusCode: http.StatusOK,
134134
},
135135
},
136+
{
137+
name: "search config, single collectionRef renders direct link in card header",
138+
fields: fields{
139+
configFile: "internal/ogc/features_search/testdata/config_search.yaml",
140+
url: "http://localhost:8080/collections?f=html",
141+
},
142+
want: want{
143+
bodyContains: "href=\"https://example.com/ogc/v1/collections/addresses/items\"",
144+
statusCode: http.StatusOK,
145+
},
146+
},
136147
}
137148
for _, tt := range tests {
138149
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)