Skip to content

Commit 1134cdb

Browse files
Merge pull request #57 from PDOK/jd/capabilities-generator
Improved capabilities generator
2 parents 1bcc22b + d1bf092 commit 1134cdb

File tree

31 files changed

+1581
-616
lines changed

31 files changed

+1581
-616
lines changed

api/v2beta1/wfs_conversion.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,17 @@ func (src *WFS) ToV3(dst *pdoknlv3.WFS) error {
7777
Fees: nil,
7878
AccessConstraints: src.Spec.Service.AccessConstraints,
7979
DefaultCrs: src.Spec.Service.DataEPSG,
80-
OtherCrs: []string{},
81-
CountDefault: src.Spec.Service.Maxfeatures,
82-
FeatureTypes: make([]pdoknlv3.FeatureType, 0),
80+
OtherCrs: []string{
81+
"EPSG::25831",
82+
"EPSG::25832",
83+
"EPSG::3034",
84+
"EPSG::3035",
85+
"EPSG::3857",
86+
"EPSG::4258",
87+
"EPSG::4326",
88+
},
89+
CountDefault: src.Spec.Service.Maxfeatures,
90+
FeatureTypes: make([]pdoknlv3.FeatureType, 0),
8391
}
8492

8593
if src.Spec.Service.Mapfile != nil {

api/v3/shared_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ type TIF struct {
215215
// This option can be used to control the resampling kernel used sampling raster images, optional
216216
// +kubebuilder:validation:MinLength:=1
217217
// +kubebuilder:validation:Pattern=`(NEAREST|AVERAGE|BILINEAR)`
218+
// +kubebuilder:default=NEAREST
218219
Resample *string `json:"resample,omitempty"`
219220

220221
// Sets the color index to treat as transparent for raster layers, optional, hex or rgb
@@ -259,6 +260,12 @@ func GetBaseURLPath[T WMSWFS](o T) string {
259260
return strings.TrimPrefix(parsed.Path, "/")
260261
}
261262

263+
func GetBaseURLPathWithoutTypeAndVersion[T WMSWFS](o T) string {
264+
serviceURL := o.URLPath()
265+
parsed, _ := url.Parse(serviceURL)
266+
return strings.TrimPrefix(parsed.Path, "/")
267+
}
268+
262269
func (d *Data) GetColumns() *[]Column {
263270
switch {
264271
case d.Gpkg != nil:

api/v3/wms_types.go

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -376,30 +376,41 @@ func (wmsService *WMSService) GetAnnotatedLayers() []AnnotatedLayer {
376376
}
377377

378378
func (wmsService *WMSService) GetAllLayers() (layers []Layer) {
379-
return wmsService.Layer.GetAllLayers()
379+
return wmsService.Layer.FlattenLayers()
380380
}
381381

382-
func (layer *Layer) GetAllLayers() (layers []Layer) {
383-
layers = append(layers, *layer)
382+
// FlattenLayers - flattens the layer and its sublayers into one array
383+
func (layer *Layer) FlattenLayers() []Layer {
384+
layers := []Layer{*layer}
384385
for _, childLayer := range layer.Layers {
385-
layers = append(layers, childLayer.GetAllLayers()...)
386+
layers = append(layers, childLayer.FlattenLayers()...)
386387
}
387-
return
388+
return layers
389+
}
390+
391+
// GetAllSublayers - get all sublayers of a layer, the result does not include the layer itself
392+
func (layer *Layer) GetAllSublayers() []Layer {
393+
layers := layer.Layers
394+
for _, childLayer := range layer.Layers {
395+
layers = append(layers, childLayer.GetAllSublayers()...)
396+
}
397+
return layers
388398
}
389399

390-
func (layer *Layer) GetParent(candidateLayer *Layer) *Layer {
391-
if candidateLayer.Layers == nil {
400+
func (wmsService *WMSService) GetParentLayer(layer Layer) *Layer {
401+
if wmsService.Layer.Layers == nil {
392402
return nil
393403
}
394404

395-
for _, childLayer := range candidateLayer.Layers {
396-
if childLayer.Name == layer.Name {
397-
return candidateLayer
405+
for _, middleLayer := range wmsService.Layer.Layers {
406+
if middleLayer.Name == layer.Name {
407+
return &wmsService.Layer
398408
}
399409

400-
parent := layer.GetParent(&childLayer)
401-
if parent != nil {
402-
return parent
410+
for _, bottomLayer := range middleLayer.Layers {
411+
if bottomLayer.Name == layer.Name {
412+
return &middleLayer
413+
}
403414
}
404415
}
405416
return nil
@@ -489,7 +500,7 @@ func (layer *Layer) setInheritedBoundingBoxes() {
489500
}
490501

491502
func (wms *WMS) GetAllLayersWithLegend() (layers []Layer) {
492-
for _, layer := range wms.Spec.Service.Layer.GetAllLayers() {
503+
for _, layer := range wms.Spec.Service.GetAllLayers() {
493504
if !layer.hasData() || len(layer.Styles) == 0 {
494505
continue
495506
}
@@ -505,7 +516,7 @@ func (wms *WMS) GetAllLayersWithLegend() (layers []Layer) {
505516

506517
func (wms *WMS) GetUniqueTiffBlobKeys() []string {
507518
blobKeys := map[string]bool{}
508-
for _, layer := range wms.Spec.Service.Layer.GetAllLayers() {
519+
for _, layer := range wms.Spec.Service.GetAllLayers() {
509520
if layer.hasTIFData() {
510521
blobKeys[layer.Data.TIF.BlobKey] = true
511522
}
@@ -536,7 +547,7 @@ func (wms *WMS) GetAuthority() *Authority {
536547
}
537548

538549
func (wms *WMS) HasPostgisData() bool {
539-
for _, layer := range wms.Spec.Service.Layer.GetAllLayers() {
550+
for _, layer := range wms.Spec.Service.GetAllLayers() {
540551
if layer.Data != nil && layer.Data.Postgis != nil {
541552
return true
542553
}

api/v3/wms_types_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func TestLayer_GetParent(t *testing.T) {
134134
topLayer := Layer{Name: controller.Pointer("toplayer"), Layers: []Layer{childLayer1}}
135135

136136
type args struct {
137-
candidateLayer *Layer
137+
service WMSService
138138
}
139139
tests := []struct {
140140
name string
@@ -145,19 +145,19 @@ func TestLayer_GetParent(t *testing.T) {
145145
{
146146
name: "Test GetParent on layer with parent",
147147
layer: childLayer2,
148-
args: args{candidateLayer: &topLayer},
148+
args: args{service: WMSService{Layer: topLayer}},
149149
want: &childLayer1,
150150
},
151151
{
152152
name: "Test GetParent on layer without parent",
153153
layer: topLayer,
154-
args: args{candidateLayer: &topLayer},
154+
args: args{service: WMSService{Layer: topLayer}},
155155
want: nil,
156156
},
157157
}
158158
for _, tt := range tests {
159159
t.Run(tt.name, func(t *testing.T) {
160-
if got := tt.layer.GetParent(tt.args.candidateLayer); !reflect.DeepEqual(got, tt.want) {
160+
if got := tt.args.service.GetParentLayer(tt.layer); !reflect.DeepEqual(got, tt.want) {
161161
t.Errorf("GetParent() = %v, want %v", got, tt.want)
162162
}
163163
})

api/v3/wms_validation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func ValidateWMS(wms *WMS, warnings *[]string, allErrs *field.ErrorList) {
9090
var names []string
9191
hasVisibleLayer := false
9292
wms.Spec.Service.Layer.setInheritedBoundingBoxes()
93-
for _, layer := range wms.Spec.Service.Layer.GetAllLayers() {
93+
for _, layer := range wms.Spec.Service.GetAllLayers() {
9494
path = path.Child("layers")
9595
var layerErrs field.ErrorList
9696

cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const (
5555
defaultMultitoolImage = "acrpdokprodman.azurecr.io/pdok/docker-multitool:0.9.4"
5656
defaultMapfileGeneratorImage = "acrpdokprodman.azurecr.io/pdok/mapfile-generator:1.9.5"
5757
defaultMapserverImage = "acrpdokprodman.azurecr.io/mirror/docker.io/pdok/mapserver:8.4.0-4-nl"
58-
defaultCapabilitiesGeneratorImage = "acrpdokprodman.azurecr.io/mirror/docker.io/pdok/ogc-capabilities-generator:1.0.0-beta7"
58+
defaultCapabilitiesGeneratorImage = "acrpdokprodman.azurecr.io/mirror/docker.io/pdok/ogc-capabilities-generator:1.0.0-beta8"
5959
defaultFeatureinfoGeneratorImage = "acrpdokprodman.azurecr.io/mirror/docker.io/pdok/featureinfo-generator:1.4.0-beta1"
6060
defaultOgcWebserviceProxyImage = "acrpdokprodman.azurecr.io/pdok/ogc-webservice-proxy:0.1.8"
6161
defaultApacheExporterImage = "acrpdokprodman.azurecr.io/mirror/docker.io/lusotycoon/apache-exporter:v0.7.0"

config/crd/bases/pdok.nl_wfs.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,7 @@ spec:
13371337
pattern: (#[0-9A-F]{6}([0-9A-F]{2})?)|([0-9]{1,3}\s[0-9]{1,3}\s[0-9]{1,3})
13381338
type: string
13391339
resample:
1340+
default: NEAREST
13401341
description: This option can be used to control
13411342
the resampling kernel used sampling raster images,
13421343
optional

config/crd/bases/pdok.nl_wms.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,6 +1329,7 @@ spec:
13291329
pattern: (#[0-9A-F]{6}([0-9A-F]{2})?)|([0-9]{1,3}\s[0-9]{1,3}\s[0-9]{1,3})
13301330
type: string
13311331
resample:
1332+
default: NEAREST
13321333
description: This option can be used to control the resampling kernel used sampling raster images, optional
13331334
minLength: 1
13341335
pattern: (NEAREST|AVERAGE|BILINEAR)
@@ -1537,6 +1538,7 @@ spec:
15371538
pattern: (#[0-9A-F]{6}([0-9A-F]{2})?)|([0-9]{1,3}\s[0-9]{1,3}\s[0-9]{1,3})
15381539
type: string
15391540
resample:
1541+
default: NEAREST
15401542
description: This option can be used to control the resampling kernel used sampling raster images, optional
15411543
minLength: 1
15421544
pattern: (NEAREST|AVERAGE|BILINEAR)
@@ -1745,6 +1747,7 @@ spec:
17451747
pattern: (#[0-9A-F]{6}([0-9A-F]{2})?)|([0-9]{1,3}\s[0-9]{1,3}\s[0-9]{1,3})
17461748
type: string
17471749
resample:
1750+
default: NEAREST
17481751
description: This option can be used to control the resampling kernel used sampling raster images, optional
17491752
minLength: 1
17501753
pattern: (NEAREST|AVERAGE|BILINEAR)

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ require (
1111
github.com/onsi/ginkgo/v2 v2.22.2
1212
github.com/onsi/gomega v1.36.2
1313
github.com/pdok/featureinfo-generator v1.4.0-beta1
14-
github.com/pdok/ogc-capabilities-generator v1.0.0-beta7
15-
github.com/pdok/ogc-specifications v1.0.0-beta7
14+
github.com/pdok/ogc-capabilities-generator v1.0.0-beta8
15+
github.com/pdok/ogc-specifications v1.0.0-beta9
1616
github.com/pdok/smooth-operator v0.1.1
1717
github.com/peterbourgon/ff v1.7.1
1818
github.com/stretchr/testify v1.10.0

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaR
151151
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
152152
github.com/pdok/featureinfo-generator v1.4.0-beta1 h1:ZZO5OtK7yW5ozXFrl1OaxKl0MK3XF5YGFh2692JZVN8=
153153
github.com/pdok/featureinfo-generator v1.4.0-beta1/go.mod h1:02Ryu7ZRkeha8SCfS6VYWCdKYZh0llskrfFgp6xRCjk=
154-
github.com/pdok/ogc-capabilities-generator v1.0.0-beta7 h1:w0dP2RQX0KEEovrq57NCM1w+Hlizg9mQlgdRBEqKX2g=
155-
github.com/pdok/ogc-capabilities-generator v1.0.0-beta7/go.mod h1:slk89sAgmWU5NCIKwGyciQWnm0RHmwhJYQ431E2CwSk=
156-
github.com/pdok/ogc-specifications v1.0.0-beta7 h1:AFSO8iCYbD1MrjOS2q+PGp2PmSqAH+O7cuA7JeePCXE=
157-
github.com/pdok/ogc-specifications v1.0.0-beta7/go.mod h1:YDngwkwrWOfc5MYnEYseiv97K1Y9bZXlVzwi/8EaIl8=
154+
github.com/pdok/ogc-capabilities-generator v1.0.0-beta8 h1:8UAv64fArp8wjpwuRIzjjpr5aGLtEhBS7vbi0l5gMao=
155+
github.com/pdok/ogc-capabilities-generator v1.0.0-beta8/go.mod h1:2yUZlJikf5gGH6S33FszUiI9+j85gpIINfAFsCF/eNk=
156+
github.com/pdok/ogc-specifications v1.0.0-beta9 h1:VrdggKg4d2tSway/deztAfZTviXKX0AftfUuZTXx5j8=
157+
github.com/pdok/ogc-specifications v1.0.0-beta9/go.mod h1:YDngwkwrWOfc5MYnEYseiv97K1Y9bZXlVzwi/8EaIl8=
158158
github.com/pdok/smooth-operator v0.1.1 h1:rmsup4HmzJsxt4ZT9GWfj498dKLRfDhyuILeEkjju/A=
159159
github.com/pdok/smooth-operator v0.1.1/go.mod h1:przwM7mBGmNPqabyhImKVZ15WL4zbqLqH4ExbuWKhWE=
160160
github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t2kKREewys=

0 commit comments

Comments
 (0)