Skip to content

Commit bd2c9b7

Browse files
authored
Merge pull request #87 from PDOK/wr/losse-eindjes
Wr/losse eindjes
2 parents 9669e68 + efc0f90 commit bd2c9b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+578
-293
lines changed

api/v2beta1/wms_conversion.go

Lines changed: 104 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,11 @@ func (v2Service WMSService) MapLayersToV3() pdoknlv3.Layer {
353353

354354
if ok {
355355
topLayer = &notGroupedLayers[0]
356+
var bbox *pdoknlv3.WMSBoundingBox
357+
if len(topLayer.BoundingBoxes) > 0 {
358+
bbox = &topLayer.BoundingBoxes[0]
359+
}
360+
topLayer.BoundingBoxes = getDefaultWMSLayerBoundingBoxes(bbox)
356361
}
357362
}
358363

@@ -362,10 +367,10 @@ func (v2Service WMSService) MapLayersToV3() pdoknlv3.Layer {
362367
// it needs to be created with defaults from the service
363368
// and in this case the middleLayers are all layers without a group
364369
if topLayer == nil {
365-
boundingBoxes := make([]pdoknlv3.WMSBoundingBox, 0)
370+
var bbox *pdoknlv3.WMSBoundingBox
366371
if v2Service.Extent != nil {
367372
bboxStringList := strings.Split(*v2Service.Extent, " ")
368-
bbox := pdoknlv3.WMSBoundingBox{
373+
bbox = &pdoknlv3.WMSBoundingBox{
369374
CRS: v2Service.DataEPSG,
370375
BBox: smoothoperatormodel.BBox{
371376
MinX: bboxStringList[0],
@@ -374,15 +379,14 @@ func (v2Service WMSService) MapLayersToV3() pdoknlv3.Layer {
374379
MaxY: bboxStringList[3],
375380
},
376381
}
377-
boundingBoxes = append(boundingBoxes, bbox)
378382
}
379383

380384
topLayer = &pdoknlv3.Layer{
381385
Title: &v2Service.Title,
382386
Abstract: &v2Service.Abstract,
383387
Keywords: v2Service.Keywords,
384388
Layers: []pdoknlv3.Layer{},
385-
BoundingBoxes: boundingBoxes,
389+
BoundingBoxes: getDefaultWMSLayerBoundingBoxes(bbox),
386390
Visible: true,
387391
}
388392

@@ -410,6 +414,102 @@ func (v2Service WMSService) MapLayersToV3() pdoknlv3.Layer {
410414
return *topLayer
411415
}
412416

417+
func getDefaultWMSLayerBoundingBoxes(defaultBbox *pdoknlv3.WMSBoundingBox) []pdoknlv3.WMSBoundingBox {
418+
defaultBboxes := []pdoknlv3.WMSBoundingBox{
419+
{
420+
CRS: "EPSG:28992",
421+
BBox: smoothoperatormodel.BBox{
422+
MinX: "-25000",
423+
MinY: "250000",
424+
MaxX: "280000",
425+
MaxY: "860000",
426+
},
427+
},
428+
{
429+
CRS: "EPSG:25831",
430+
BBox: smoothoperatormodel.BBox{
431+
MinX: "-470271",
432+
MinY: "5.56231e+06",
433+
MaxX: "795163",
434+
MaxY: "6.18197e+06",
435+
},
436+
},
437+
{
438+
CRS: "EPSG:25832",
439+
BBox: smoothoperatormodel.BBox{
440+
MinX: "62461.6",
441+
MinY: "5.56555e+06",
442+
MaxX: "397827",
443+
MaxY: "6.19042e+06",
444+
},
445+
},
446+
{
447+
CRS: "EPSG:3034",
448+
BBox: smoothoperatormodel.BBox{
449+
MinX: "2.61336e+06",
450+
MinY: "3.509e+06",
451+
MaxX: "3.22007e+06",
452+
MaxY: "3.84003e+06",
453+
},
454+
},
455+
{
456+
CRS: "EPSG:3035",
457+
BBox: smoothoperatormodel.BBox{
458+
MinX: "3.01676e+06",
459+
MinY: "3.81264e+06",
460+
MaxX: "3.64485e+06",
461+
MaxY: "4.15586e+06",
462+
},
463+
},
464+
{
465+
CRS: "EPSG:3857",
466+
BBox: smoothoperatormodel.BBox{
467+
MinX: "281318",
468+
MinY: "6.48322e+06",
469+
MaxX: "820873",
470+
MaxY: "7.50311e+06",
471+
},
472+
},
473+
{
474+
CRS: "EPSG:4258",
475+
BBox: smoothoperatormodel.BBox{
476+
MinX: "50.2129",
477+
MinY: "2.52713",
478+
MaxX: "55.7212",
479+
MaxY: "7.37403",
480+
},
481+
},
482+
{
483+
CRS: "EPSG:4326",
484+
BBox: smoothoperatormodel.BBox{
485+
MinX: "50.2129",
486+
MinY: "2.52713",
487+
MaxX: "55.7212",
488+
MaxY: "7.37403",
489+
},
490+
},
491+
{
492+
CRS: "CRS:84",
493+
BBox: smoothoperatormodel.BBox{
494+
MinX: "2.52713",
495+
MinY: "50.2129",
496+
MaxX: "7.37403",
497+
MaxY: "55.7212",
498+
},
499+
},
500+
}
501+
bboxes := []pdoknlv3.WMSBoundingBox{}
502+
if defaultBbox != nil {
503+
bboxes = []pdoknlv3.WMSBoundingBox{*defaultBbox}
504+
}
505+
for _, bbox := range defaultBboxes {
506+
if defaultBbox == nil || bbox.CRS != defaultBbox.CRS {
507+
bboxes = append(bboxes, bbox)
508+
}
509+
}
510+
return bboxes
511+
}
512+
413513
func (v2Layer WMSLayer) MapToV3(v2Service WMSService) pdoknlv3.Layer {
414514
layer := pdoknlv3.Layer{
415515
Name: &v2Layer.Name,

api/v2beta1/wms_conversion_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestWMSService_MapLayersToV3(t *testing.T) {
3939
want: pdoknlv3.Layer{
4040
Title: ptr.To(""),
4141
Abstract: ptr.To(""),
42-
BoundingBoxes: []pdoknlv3.WMSBoundingBox{},
42+
BoundingBoxes: getDefaultWMSLayerBoundingBoxes(nil),
4343
Visible: true,
4444
Layers: []pdoknlv3.Layer{{
4545
Name: ptr.To("layer"),
@@ -58,7 +58,7 @@ func TestWMSService_MapLayersToV3(t *testing.T) {
5858
want: pdoknlv3.Layer{
5959
Title: ptr.To(""),
6060
Abstract: ptr.To(""),
61-
BoundingBoxes: []pdoknlv3.WMSBoundingBox{},
61+
BoundingBoxes: getDefaultWMSLayerBoundingBoxes(nil),
6262
Visible: true,
6363
Layers: []pdoknlv3.Layer{{
6464
Name: ptr.To("group-layer"),
@@ -87,7 +87,7 @@ func TestWMSService_MapLayersToV3(t *testing.T) {
8787
want: pdoknlv3.Layer{
8888
Title: ptr.To(""),
8989
Abstract: ptr.To(""),
90-
BoundingBoxes: []pdoknlv3.WMSBoundingBox{},
90+
BoundingBoxes: getDefaultWMSLayerBoundingBoxes(nil),
9191
Visible: true,
9292
Layers: []pdoknlv3.Layer{
9393
{
@@ -131,7 +131,7 @@ func TestWMSService_MapLayersToV3(t *testing.T) {
131131
want: pdoknlv3.Layer{
132132
Title: ptr.To(""),
133133
Abstract: ptr.To(""),
134-
BoundingBoxes: []pdoknlv3.WMSBoundingBox{},
134+
BoundingBoxes: getDefaultWMSLayerBoundingBoxes(nil),
135135
Visible: true,
136136
Layers: []pdoknlv3.Layer{
137137
{
@@ -166,7 +166,7 @@ func TestWMSService_MapLayersToV3(t *testing.T) {
166166
}},
167167
want: pdoknlv3.Layer{
168168
Name: ptr.To("top-layer"),
169-
BoundingBoxes: []pdoknlv3.WMSBoundingBox{},
169+
BoundingBoxes: getDefaultWMSLayerBoundingBoxes(nil),
170170
Visible: true,
171171
Styles: []pdoknlv3.Style{},
172172
Layers: []pdoknlv3.Layer{{
@@ -195,7 +195,7 @@ func TestWMSService_MapLayersToV3(t *testing.T) {
195195
}},
196196
want: pdoknlv3.Layer{
197197
Name: ptr.To("top-layer"),
198-
BoundingBoxes: []pdoknlv3.WMSBoundingBox{},
198+
BoundingBoxes: getDefaultWMSLayerBoundingBoxes(nil),
199199
Visible: true,
200200
Styles: []pdoknlv3.Style{},
201201
Layers: []pdoknlv3.Layer{

api/v3/wfs_validation.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ func ValidateWFS(wfs *WFS, warnings *[]string, allErrs *field.ErrorList) {
5050
)
5151
}
5252

53+
crsses := []string{}
54+
for i, crs := range service.OtherCrs {
55+
if slices.Contains(crsses, crs) {
56+
*allErrs = append(*allErrs, field.Duplicate(
57+
path.Child("otherCrs").Index(i),
58+
crs,
59+
))
60+
} else {
61+
crsses = append(crsses, crs)
62+
}
63+
}
64+
5365
ValidateInspire(wfs, allErrs)
5466

5567
if wfs.Spec.HorizontalPodAutoscalerPatch != nil {

api/v3/wms_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ type Layer struct {
249249
}
250250

251251
type WMSBoundingBox struct {
252+
// +kubebuilder:validation:Pattern:="^(EPSG:(28992|25831|25832|3034|3035|3857|4258|4326)|CRS:84)$"
252253
CRS string `json:"crs"`
253254
BBox smoothoperatormodel.BBox `json:"bbox"`
254255
}

api/v3/wms_validation.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@ func validateLayer(layer AnnotatedLayer, path *field.Path, groupStyles []string,
122122
validateNotVisibleLayer(layer, path, wms, warnings, allErrs)
123123
}
124124

125+
crsses := []string{}
126+
for i, bbox := range layer.BoundingBoxes {
127+
if slices.Contains(crsses, bbox.CRS) {
128+
*allErrs = append(*allErrs, field.Duplicate(
129+
path.Child("boundingBoxes").Index(i).Child("crs"),
130+
bbox.CRS,
131+
))
132+
} else {
133+
crsses = append(crsses, bbox.CRS)
134+
}
135+
}
136+
125137
styleNames := []string{}
126138
for i, style := range layer.Styles {
127139
stylePath := path.Child("styles").Index(i)

config/crd/bases/pdok.nl_wms.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,6 +1323,7 @@ spec:
13231323
- miny
13241324
type: object
13251325
crs:
1326+
pattern: ^(EPSG:(28992|25831|25832|3034|3035|3857|4258|4326)|CRS:84)$
13261327
type: string
13271328
required:
13281329
- bbox
@@ -1421,6 +1422,7 @@ spec:
14211422
- miny
14221423
type: object
14231424
crs:
1425+
pattern: ^(EPSG:(28992|25831|25832|3034|3035|3857|4258|4326)|CRS:84)$
14241426
type: string
14251427
required:
14261428
- bbox
@@ -1625,6 +1627,7 @@ spec:
16251627
- miny
16261628
type: object
16271629
crs:
1630+
pattern: ^(EPSG:(28992|25831|25832|3034|3035|3857|4258|4326)|CRS:84)$
16281631
type: string
16291632
required:
16301633
- bbox
@@ -1999,6 +2002,7 @@ spec:
19992002
- title
20002003
- abstract
20012004
- keywords
2005+
- boundingBoxes
20022006
- layers
20032007
type: object
20042008
x-kubernetes-validations:

config/crd/update_openapi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func updateLayersV3(version *v1.CustomResourceDefinitionVersion) {
9393

9494
// Level 1
9595
layerSpecLevel1 := layer.DeepCopy()
96-
layerSpecLevel1.Required = append(layerSpecLevel1.Required, "title", "abstract", "keywords", "layers")
96+
layerSpecLevel1.Required = append(layerSpecLevel1.Required, "title", "abstract", "keywords", "boundingBoxes", "layers")
9797
layerSpecLevel1.XValidations = []v1.ValidationRule{
9898
{Rule: "self.visible", Message: "TopLayer must be visible", FieldPath: ".visible"},
9999
{Rule: "!has(self.name) || has(self.styles)", Message: "If TopLayer has a name, it must have styles", FieldPath: ".styles"},

0 commit comments

Comments
 (0)