Skip to content

Commit e4bd14b

Browse files
Merge pull request #94 from PDOK/jd/fixes
Fixes for v2 diffs
2 parents 2f70aca + d2819b1 commit e4bd14b

23 files changed

+136
-118
lines changed

api/v2beta1/shared_conversion.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,16 @@ func ConvertResources(src corev1.ResourceRequirements) corev1.PodSpec {
8686
targetResources := src
8787

8888
if src.Requests != nil {
89-
targetResources.Requests[corev1.ResourceEphemeralStorage] = src.Requests["ephemeralStorage"]
90-
delete(targetResources.Requests, "ephemeralStorage")
89+
if val, ok := src.Requests["ephemeralStorage"]; ok {
90+
targetResources.Requests[corev1.ResourceEphemeralStorage] = val
91+
delete(targetResources.Requests, "ephemeralStorage")
92+
}
9193
}
9294
if src.Limits != nil {
93-
targetResources.Limits[corev1.ResourceEphemeralStorage] = src.Limits["ephemeralStorage"]
94-
delete(targetResources.Limits, "ephemeralStorage")
95+
if val, ok := src.Limits["ephemeralStorage"]; ok {
96+
targetResources.Limits[corev1.ResourceEphemeralStorage] = val
97+
delete(targetResources.Limits, "ephemeralStorage")
98+
}
9599
}
96100

97101
return corev1.PodSpec{

api/v3/shared_validation.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func ValidateEphemeralStorage(podSpecPatch v1.PodSpec, allErrs *field.ErrorList)
125125
}
126126
}
127127

128-
func ValidateInspire[O WMSWFS](obj O, allErrs *field.ErrorList) {
128+
func ValidateInspire[O WMSWFS](obj O, allErrs *field.ErrorList, allWarnings *[]string) {
129129
if obj.Inspire() == nil {
130130
return
131131
}
@@ -134,11 +134,11 @@ func ValidateInspire[O WMSWFS](obj O, allErrs *field.ErrorList) {
134134
spatialID := obj.Inspire().SpatialDatasetIdentifier
135135

136136
if slices.Contains(datasetIDs, spatialID) {
137-
*allErrs = append(*allErrs, field.Invalid(
137+
*allWarnings = append(*allWarnings, field.Invalid(
138138
field.NewPath("spec").Child("service").Child("inspire").Child("spatialDatasetIdentifier"),
139139
spatialID,
140-
"spatialDatasetIdentifier cannot also be used as an datasetMetadataUrl.csw.metadataIdentifier",
141-
))
140+
"spatialDatasetIdentifier should not also be used as an datasetMetadataUrl.csw.metadataIdentifier",
141+
).Error())
142142
}
143143

144144
if serviceID := obj.Inspire().ServiceMetadataURL.CSW; serviceID != nil {

api/v3/wfs_validation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func ValidateWFS(wfs *WFS, warnings *[]string, allErrs *field.ErrorList) {
6262
}
6363
}
6464

65-
ValidateInspire(wfs, allErrs)
65+
ValidateInspire(wfs, allErrs, warnings)
6666

6767
if wfs.Spec.HorizontalPodAutoscalerPatch != nil {
6868
ValidateHorizontalPodAutoscalerPatch(*wfs.Spec.HorizontalPodAutoscalerPatch, allErrs)

api/v3/wms_validation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func ValidateWMS(wms *WMS, warnings *[]string, allErrs *field.ErrorList) {
5353
}
5454
}
5555

56-
ValidateInspire(wms, allErrs)
56+
ValidateInspire(wms, allErrs, warnings)
5757
if wms.HorizontalPodAutoscalerPatch() != nil {
5858
ValidateHorizontalPodAutoscalerPatch(*wms.HorizontalPodAutoscalerPatch(), allErrs)
5959
}

internal/controller/blobdownload/blob_download.go

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,25 @@ func GetBlobDownloadInitContainer[O pdoknlv3.WMSWFS](obj O, images types.Images,
4141
blobkeys = append(blobkeys, gpkg.BlobKey)
4242
}
4343
}
44+
45+
envVars := []corev1.EnvVar{
46+
{
47+
Name: "GEOPACKAGE_TARGET_PATH",
48+
Value: "/srv/data/gpkg",
49+
},
50+
}
51+
if len(blobkeys) > 0 {
52+
envVars = append(envVars, corev1.EnvVar{
53+
Name: "GEOPACKAGE_DOWNLOAD_LIST",
54+
Value: strings.Join(blobkeys, ";"),
55+
})
56+
}
57+
4458
initContainer := corev1.Container{
4559
Name: constants.BlobDownloadName,
4660
Image: images.MultitoolImage,
4761
ImagePullPolicy: corev1.PullIfNotPresent,
48-
Env: []corev1.EnvVar{
49-
{
50-
Name: "GEOPACKAGE_TARGET_PATH",
51-
Value: "/srv/data/gpkg",
52-
},
53-
{
54-
Name: "GEOPACKAGE_DOWNLOAD_LIST",
55-
Value: strings.Join(blobkeys, ";"),
56-
},
57-
},
62+
Env: envVars,
5863
EnvFrom: []corev1.EnvFromSource{
5964
utils.NewEnvFromSource(utils.EnvFromSourceTypeConfigMap, blobsConfigName),
6065
utils.NewEnvFromSource(utils.EnvFromSourceTypeSecret, blobsSecretName),
@@ -198,7 +203,7 @@ func downloadLegends(sb *strings.Builder, wms *pdoknlv3.WMS) error {
198203
if err != nil {
199204
return err
200205
}
201-
writeLine(sb, "Copied legend %s to %s/%s/%s.png;", fileName, legendPath, *layer.Name, style.Name)
206+
writeLine(sb, "echo 'Copied legend %s to %s/%s/%s.png';", fileName, legendPath, *layer.Name, style.Name)
202207
}
203208
}
204209
writeLine(sb, "chown -R 999:999 %s", legendPath)

internal/controller/blobdownload/blob_download_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ echo 'generated fonts.list:';
3535
cat /srv/data/config/fonts/fonts.list;
3636
mkdir -p /var/www/legend/wms-gpkg-layer-1-name;
3737
rclone copyto blobs:/resources-bucket/key/gpkg-layer-1-legend.png /var/www/legend/wms-gpkg-layer-1-name/wms-gpkg-style-1-name.png || exit 1;
38-
Copied legend gpkg-layer-1-legend.png to /var/www/legend/wms-gpkg-layer-1-name/wms-gpkg-style-1-name.png;
38+
echo 'Copied legend gpkg-layer-1-legend.png to /var/www/legend/wms-gpkg-layer-1-name/wms-gpkg-style-1-name.png';
3939
mkdir -p /var/www/legend/wms-gpkg-layer-2-name;
4040
rclone copyto blobs:/resources-bucket/key/gpkg-layer-2-legend.png /var/www/legend/wms-gpkg-layer-2-name/wms-gpkg-style-2-name.png || exit 1;
41-
Copied legend gpkg-layer-2-legend.png to /var/www/legend/wms-gpkg-layer-2-name/wms-gpkg-style-2-name.png;
41+
echo 'Copied legend gpkg-layer-2-legend.png to /var/www/legend/wms-gpkg-layer-2-name/wms-gpkg-style-2-name.png';
4242
chown -R 999:999 /var/www/legend
4343
`
4444

@@ -58,10 +58,10 @@ echo 'generated fonts.list:';
5858
cat /srv/data/config/fonts/fonts.list;
5959
mkdir -p /var/www/legend/wms-tif-layer-1-name;
6060
rclone copyto blobs:/resources-bucket/key/tif-layer-1-legend.png /var/www/legend/wms-tif-layer-1-name/wms-tif-style-1-name.png || exit 1;
61-
Copied legend tif-layer-1-legend.png to /var/www/legend/wms-tif-layer-1-name/wms-tif-style-1-name.png;
61+
echo 'Copied legend tif-layer-1-legend.png to /var/www/legend/wms-tif-layer-1-name/wms-tif-style-1-name.png';
6262
mkdir -p /var/www/legend/wms-tif-layer-2-name;
6363
rclone copyto blobs:/resources-bucket/key/tif-layer-2-legend.png /var/www/legend/wms-tif-layer-2-name/wms-tif-style-2-name.png || exit 1;
64-
Copied legend tif-layer-2-legend.png to /var/www/legend/wms-tif-layer-2-name/wms-tif-style-2-name.png;
64+
echo 'Copied legend tif-layer-2-legend.png to /var/www/legend/wms-tif-layer-2-name/wms-tif-style-2-name.png';
6565
chown -R 999:999 /var/www/legend
6666
`
6767
)

internal/controller/capabilitiesgenerator/mapper.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,11 @@ func createCRSFromEpsgString(epsgString string) (*wfs200.CRS, error) {
194194
return nil, fmt.Errorf("could not determine EPSG code from EPSG string %s", epsgCodeString)
195195
}
196196

197+
epsgUrn := "urn:ogc:def:crs:EPSG:"
198+
197199
return &wfs200.CRS{
198-
Code: epsgCode,
200+
Namespace: epsgUrn,
201+
Code: epsgCode,
199202
}, nil
200203
}
201204

@@ -503,11 +506,13 @@ func mapLayer(layer pdoknlv3.Layer, canonicalURL string, authorityURL *wms130.Au
503506

504507
// Map sublayers
505508
for _, sublayer := range layer.Layers {
506-
mapped, err := mapLayer(sublayer, canonicalURL, authorityURL, identifier, append(parentStyleNames, layerStyleNames...), bboxes)
507-
if err != nil {
508-
return nil, err
509+
if sublayer.Visible {
510+
mapped, err := mapLayer(sublayer, canonicalURL, authorityURL, identifier, append(parentStyleNames, layerStyleNames...), bboxes)
511+
if err != nil {
512+
return nil, err
513+
}
514+
l.Layer = append(l.Layer, mapped)
509515
}
510-
l.Layer = append(l.Layer, mapped)
511516
}
512517

513518
return &l, nil

internal/controller/mapfilegenerator/mapper.go

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,20 @@ func MapWFSToMapfileGeneratorInput(wfs *pdoknlv3.WFS, ownerInfo *smoothoperatorv
4343

4444
input := WFSInput{
4545
BaseServiceInput: BaseServiceInput{
46-
Title: mapperutils.EscapeQuotes(wfs.Spec.Service.Title),
47-
Abstract: mapperutils.EscapeQuotes(wfs.Spec.Service.Abstract),
48-
Keywords: strings.Join(wfs.Spec.Service.KeywordsIncludingInspireKeyword(), ","),
49-
OnlineResource: wfs.URL().Scheme + "://" + wfs.URL().Host,
50-
Path: wfs.URL().Path,
51-
MetadataID: metadataID,
52-
Extent: extent,
53-
NamespacePrefix: wfs.Spec.Service.Prefix,
54-
NamespaceURI: mapperutils.GetNamespaceURI(wfs.Spec.Service.Prefix, ownerInfo),
55-
AutomaticCasing: wfs.Options().AutomaticCasing,
56-
DataEPSG: wfs.Spec.Service.DefaultCrs,
57-
EPSGList: append([]string{wfs.Spec.Service.DefaultCrs}, wfs.Spec.Service.OtherCrs...),
58-
DebugLevel: mapserverDebugLevel,
46+
Title: mapperutils.EscapeQuotes(wfs.Spec.Service.Title),
47+
Abstract: mapperutils.EscapeQuotes(wfs.Spec.Service.Abstract),
48+
Keywords: strings.Join(wfs.Spec.Service.KeywordsIncludingInspireKeyword(), ","),
49+
OnlineResource: wfs.URL().Scheme + "://" + wfs.URL().Host,
50+
Path: wfs.URL().Path,
51+
MetadataID: metadataID,
52+
Extent: extent,
53+
NamespacePrefix: wfs.Spec.Service.Prefix,
54+
NamespaceURI: mapperutils.GetNamespaceURI(wfs.Spec.Service.Prefix, ownerInfo),
55+
AutomaticCasing: wfs.Options().AutomaticCasing,
56+
DataEPSG: wfs.Spec.Service.DefaultCrs,
57+
EPSGList: append([]string{wfs.Spec.Service.DefaultCrs}, wfs.Spec.Service.OtherCrs...),
58+
DebugLevel: mapserverDebugLevel,
59+
AccessConstraints: wfs.Spec.Service.AccessConstraints.String(),
5960
},
6061
MaxFeatures: strconv.Itoa(smoothoperatorutils.PointerVal(wfs.Spec.Service.CountDefault, defaultMaxFeatures)),
6162
Layers: getWFSLayers(wfs.Spec.Service),
@@ -169,29 +170,29 @@ func MapWMSToMapfileGeneratorInput(wms *pdoknlv3.WMS, ownerInfo *smoothoperatorv
169170

170171
result := WMSInput{
171172
BaseServiceInput: BaseServiceInput{
172-
Title: service.Title,
173-
Abstract: service.Abstract,
174-
Keywords: strings.Join(wms.Spec.Service.KeywordsIncludingInspireKeyword(), ","),
175-
Extent: extent,
176-
NamespacePrefix: wms.Spec.Service.Prefix,
177-
NamespaceURI: mapperutils.GetNamespaceURI(wms.Spec.Service.Prefix, ownerInfo),
178-
OnlineResource: wms.URL().Scheme + "://" + wms.URL().Host,
179-
Path: wms.URL().Path,
180-
MetadataID: metadataID,
181-
DatasetOwner: &datasetOwner,
182-
AuthorityURL: &authorityURL,
183-
AutomaticCasing: wms.Options().AutomaticCasing,
184-
DataEPSG: service.DataEPSG,
173+
Title: service.Title,
174+
Abstract: service.Abstract,
175+
Keywords: strings.Join(wms.Spec.Service.KeywordsIncludingInspireKeyword(), ","),
176+
Extent: extent,
177+
NamespacePrefix: wms.Spec.Service.Prefix,
178+
NamespaceURI: mapperutils.GetNamespaceURI(wms.Spec.Service.Prefix, ownerInfo),
179+
OnlineResource: wms.URL().Scheme + "://" + wms.URL().Host,
180+
Path: wms.URL().Path,
181+
MetadataID: metadataID,
182+
DatasetOwner: &datasetOwner,
183+
AuthorityURL: &authorityURL,
184+
AutomaticCasing: wms.Options().AutomaticCasing,
185+
DataEPSG: service.DataEPSG,
186+
AccessConstraints: service.AccessConstraints.String(),
185187
},
186-
AccessConstraints: service.AccessConstraints.String(),
187-
Layers: []WMSLayer{},
188-
GroupLayers: []GroupLayer{},
189-
Symbols: getSymbols(wms),
190-
Fonts: fonts,
191-
OutputFormatJpg: "jpg",
192-
OutputFormatPng: "png",
193-
Templates: constants.HTMLTemplatesPath,
194-
MaxSize: maxSize,
188+
Layers: []WMSLayer{},
189+
GroupLayers: []GroupLayer{},
190+
Symbols: getSymbols(wms),
191+
Fonts: fonts,
192+
OutputFormatJpg: "jpg",
193+
OutputFormatPng: "png",
194+
Templates: constants.HTMLTemplatesPath,
195+
MaxSize: maxSize,
195196
}
196197

197198
if wms.Spec.Service.Layer.Name != nil {
@@ -288,10 +289,9 @@ func getWMSLayer(serviceLayer pdoknlv3.Layer, serviceExtent string, wms *pdoknlv
288289
MaxScale: serviceLayer.MaxScaleDenominator,
289290
LabelNoClip: serviceLayer.LabelNoClip,
290291
},
291-
GroupName: groupName,
292-
Styles: []Style{},
293-
Offsite: "",
294-
GetFeatureInfoIncludesClass: false,
292+
GroupName: groupName,
293+
Styles: []Style{},
294+
Offsite: "",
295295
}
296296

297297
for _, style := range serviceLayer.Styles {

internal/controller/mapfilegenerator/test_data/expected/wfs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"service_onlineresource": "https://service.pdok.nl",
1010
"service_path": "/datasetOwner/dataset/theme/wfs/v1_0",
1111
"service_metadata_id": "metameta-meta-meta-meta-metametameta",
12+
"service_accessconstraints": "http://creativecommons.org/publicdomain/zero/1.0/deed.nl",
1213
"automatic_casing": true,
1314
"data_epsg": "EPSG:28992",
1415
"service_debug_level": 0,

internal/controller/mapfilegenerator/types.go

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,22 @@ import (
1010

1111
//nolint:tagliatelle
1212
type BaseServiceInput struct {
13-
Title string `json:"service_title"`
14-
Abstract string `json:"service_abstract"`
15-
Keywords string `json:"service_keywords"`
16-
Extent string `json:"service_extent"`
17-
NamespacePrefix string `json:"service_namespace_prefix"`
18-
NamespaceURI string `json:"service_namespace_uri"`
19-
OnlineResource string `json:"service_onlineresource"`
20-
Path string `json:"service_path"`
21-
MetadataID string `json:"service_metadata_id"`
22-
DatasetOwner *string `json:"dataset_owner,omitempty"`
23-
AuthorityURL *string `json:"authority_url,omitempty"`
24-
AutomaticCasing bool `json:"automatic_casing"`
25-
DataEPSG string `json:"data_epsg"`
26-
EPSGList []string `json:"epsg_list"`
27-
DebugLevel int `json:"service_debug_level,omitempty"`
13+
Title string `json:"service_title"`
14+
Abstract string `json:"service_abstract"`
15+
Keywords string `json:"service_keywords"`
16+
Extent string `json:"service_extent"`
17+
NamespacePrefix string `json:"service_namespace_prefix"`
18+
NamespaceURI string `json:"service_namespace_uri"`
19+
OnlineResource string `json:"service_onlineresource"`
20+
Path string `json:"service_path"`
21+
MetadataID string `json:"service_metadata_id"`
22+
DatasetOwner *string `json:"dataset_owner,omitempty"`
23+
AuthorityURL *string `json:"authority_url,omitempty"`
24+
AutomaticCasing bool `json:"automatic_casing"`
25+
DataEPSG string `json:"data_epsg"`
26+
EPSGList []string `json:"epsg_list"`
27+
DebugLevel int `json:"service_debug_level,omitempty"`
28+
AccessConstraints string `json:"service_accessconstraints"`
2829
}
2930

3031
//nolint:tagliatelle
@@ -37,18 +38,17 @@ type WFSInput struct {
3738
//nolint:tagliatelle
3839
type WMSInput struct {
3940
BaseServiceInput
40-
AccessConstraints string `json:"service_accessconstraints"`
41-
Layers []WMSLayer `json:"layers"`
42-
GroupLayers []GroupLayer `json:"group_layers"`
43-
Symbols []string `json:"symbols"`
44-
Fonts *string `json:"fonts,omitempty"`
45-
Templates string `json:"templates,omitempty"`
46-
OutputFormatJpg string `json:"outputformat_jpg"`
47-
OutputFormatPng string `json:"outputformat_png8"`
48-
MaxSize string `json:"maxSize"`
49-
TopLevelName string `json:"top_level_name,omitempty"`
50-
Resolution string `json:"resolution,omitempty"`
51-
DefResolution string `json:"defresolution,omitempty"`
41+
Layers []WMSLayer `json:"layers"`
42+
GroupLayers []GroupLayer `json:"group_layers"`
43+
Symbols []string `json:"symbols"`
44+
Fonts *string `json:"fonts,omitempty"`
45+
Templates string `json:"templates,omitempty"`
46+
OutputFormatJpg string `json:"outputformat_jpg"`
47+
OutputFormatPng string `json:"outputformat_png8"`
48+
MaxSize string `json:"maxSize"`
49+
TopLevelName string `json:"top_level_name,omitempty"`
50+
Resolution string `json:"resolution,omitempty"`
51+
DefResolution string `json:"defresolution,omitempty"`
5252
}
5353

5454
//nolint:tagliatelle
@@ -90,7 +90,7 @@ type WMSLayer struct {
9090
GroupName string `json:"group_name,omitempty"`
9191
Styles []Style `json:"styles"`
9292
Offsite string `json:"offsite,omitempty"`
93-
GetFeatureInfoIncludesClass bool `json:"get_feature_info_includes_class,omitempty"`
93+
GetFeatureInfoIncludesClass *bool `json:"get_feature_info_includes_class,omitempty"`
9494
}
9595

9696
type Column struct {
@@ -125,6 +125,7 @@ func SetDataFields[O pdoknlv3.WMSWFS](obj O, wmsLayer *WMSLayer, data pdoknlv3.D
125125
}
126126
wmsLayer.BaseLayer.Resample = &tif.Resample
127127
wmsLayer.Offsite = smoothoperatorutils.PointerVal(tif.Offsite, "")
128+
wmsLayer.GetFeatureInfoIncludesClass = &tif.GetFeatureInfoIncludesClass
128129
case data.Postgis != nil:
129130
postgis := data.Postgis
130131
wmsLayer.Postgis = smoothoperatorutils.Pointer(true)

0 commit comments

Comments
 (0)