Skip to content

Commit 7c0707f

Browse files
Merge pull request #22 from PDOK/jd/running-wfs
Jd/running wfs
2 parents 8670c9e + 64c7ad7 commit 7c0707f

Some content is hidden

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

46 files changed

+751
-447
lines changed

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ FROM docker.io/golang:1.24 AS builder
33
ARG TARGETOS
44
ARG TARGETARCH
55

6+
#COPY --from=repos ./smooth-operator /smooth-operator
7+
68
WORKDIR /workspace
79
# Copy the Go Modules manifests
810
COPY go.mod go.mod

api/v2beta1/wms_conversion.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ package v2beta1
2626

2727
import (
2828
"errors"
29-
sharedModel "github.com/pdok/smooth-operator/model"
3029
"log"
3130
"sigs.k8s.io/controller-runtime/pkg/conversion"
3231
"strconv"
3332
"strings"
3433

3534
pdoknlv3 "github.com/pdok/mapserver-operator/api/v3"
35+
sharedModel "github.com/pdok/smooth-operator/model"
3636
)
3737

38-
const SERVICE_METADATA_IDENTIFIER_ANNOTATION = "pdok.nl/wms-service-metadata-uuid"
38+
const ServiceMetatdataIdentifierAnnotation = "pdok.nl/wms-service-metadata-uuid"
3939

4040
// ConvertTo converts this WMS (v2beta1) to the Hub version (v3).
4141
func (src *WMS) ConvertTo(dstRaw conversion.Hub) error {
@@ -55,7 +55,7 @@ func V3HubFromV2(src *WMS, target *pdoknlv3.WMS) {
5555
dst.Annotations = make(map[string]string)
5656
}
5757

58-
dst.Annotations[SERVICE_METADATA_IDENTIFIER_ANNOTATION] = src.Spec.Service.MetadataIdentifier
58+
dst.Annotations[ServiceMetatdataIdentifierAnnotation] = src.Spec.Service.MetadataIdentifier
5959

6060
// Set LifeCycle if defined
6161
if src.Spec.Kubernetes.Lifecycle != nil && src.Spec.Kubernetes.Lifecycle.TTLInDays != nil {
@@ -179,7 +179,7 @@ func (dst *WMS) ConvertFrom(srcRaw conversion.Hub) error {
179179
// TODO unable to fill in MetadataIdentifier here until we know how to handle non inspire services
180180
}
181181

182-
uuid, ok := src.Annotations[SERVICE_METADATA_IDENTIFIER_ANNOTATION]
182+
uuid, ok := src.Annotations[ServiceMetatdataIdentifierAnnotation]
183183
if service.MetadataIdentifier == "00000000-0000-0000-0000-000000000000" && ok {
184184
service.MetadataIdentifier = uuid
185185
}

api/v2beta1/wms_conversion_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
)
99

1010
func TestV2ToV3(t *testing.T) {
11+
//nolint:misspell
1112
input := "apiVersion: pdok.nl/v2beta1\nkind: WMS\nmetadata:\n name: rws-nwbwegen-v1-0\n labels:\n dataset-owner: rws\n dataset: nwbwegen\n service-version: v1_0\n service-type: wms\n annotations:\n lifecycle-phase: prod\n service-bundle-id: b39c152b-393b-52f5-a50c-e1ffe904b6fb\nspec:\n general:\n datasetOwner: rws\n dataset: nwbwegen\n serviceVersion: v1_0\n kubernetes:\n healthCheck:\n boundingbox: 135134.89,457152.55,135416.03,457187.82\n resources:\n limits:\n ephemeralStorage: 1535Mi\n memory: 4G\n requests:\n cpu: 2000m\n ephemeralStorage: 1535Mi\n memory: 4G\n options:\n automaticCasing: true\n disableWebserviceProxy: false\n includeIngress: true\n validateRequests: true\n service:\n title: NWB - Wegen WMS\n abstract:\n Dit is de web map service van het Nationaal Wegen Bestand (NWB) - wegen.\n Deze dataset bevat alleen de wegvakken en hectometerpunten. Het Nationaal Wegen\n Bestand - Wegen is een digitaal geografisch bestand van alle wegen in Nederland.\n Opgenomen zijn alle wegen die worden beheerd door wegbeheerders als het Rijk,\n provincies, gemeenten en waterschappen, echter alleen voor zover deze zijn voorzien\n van een straatnaam of nummer.\n authority:\n name: rws\n url: https://www.rijkswaterstaat.nl\n dataEPSG: EPSG:28992\n extent: -59188.44333693248 304984.64144318487 308126.88473339565 858328.516489961\n inspire: true\n keywords:\n - Vervoersnetwerken\n - Menselijke gezondheid en veiligheid\n - Geluidsbelasting hoofdwegen (Richtlijn Omgevingslawaai)\n - Nationaal\n - Voertuigen\n - Verkeer\n - Wegvakken\n - Hectometerpunten\n - HVD\n - Mobiliteit\n stylingAssets:\n configMapRefs:\n - name: includes\n keys:\n - nwb_wegen_hectopunten.symbol\n - hectopunten.style\n - wegvakken.style\n blobKeys:\n - resources/fonts/liberation-sans.ttf\n layers:\n - abstract:\n Deze laag bevat de wegvakken uit het Nationaal Wegen bestand (NWB)\n en geeft gedetailleerde informatie per wegvak zoals straatnaam, wegnummer,\n routenummer, wegbeheerder, huisnummers, enz. weer.\n data:\n gpkg:\n columns:\n - objectid\n - wvk_id\n - wvk_begdat\n - jte_id_beg\n - jte_id_end\n - wegbehsrt\n - wegnummer\n - wegdeelltr\n - hecto_lttr\n - bst_code\n - rpe_code\n - admrichtng\n - rijrichtng\n - stt_naam\n - stt_bron\n - wpsnaam\n - gme_id\n - gme_naam\n - hnrstrlnks\n - hnrstrrhts\n - e_hnr_lnks\n - e_hnr_rhts\n - l_hnr_lnks\n - l_hnr_rhts\n - begafstand\n - endafstand\n - beginkm\n - eindkm\n - pos_tv_wol\n - wegbehcode\n - wegbehnaam\n - distrcode\n - distrnaam\n - dienstcode\n - dienstnaam\n - wegtype\n - wgtype_oms\n - routeltr\n - routenr\n - routeltr2\n - routenr2\n - routeltr3\n - routenr3\n - routeltr4\n - routenr4\n - wegnr_aw\n - wegnr_hmp\n - geobron_id\n - geobron_nm\n - bronjaar\n - openlr\n - bag_orl\n - frc\n - fow\n - alt_naam\n - alt_nr\n - rel_hoogte\n - st_lengthshape\n geometryType: MultiLineString\n blobKey: geopackages/rws/nwbwegen/410a6d1e-e767-41b4-ba8d-9e1e955dd013/1/nwb_wegen.gpkg\n table: wegvakken\n datasetMetadataIdentifier: a9b7026e-0a81-4813-93bd-ba49e6f28502\n keywords:\n - Vervoersnetwerken\n - Menselijke gezondheid en veiligheid\n - Geluidsbelasting hoofdwegen (Richtlijn Omgevingslawaai)\n - Nationaal\n - Voertuigen\n - Verkeer\n - Wegvakken\n maxScale: 50000.0\n minScale: 1.0\n name: wegvakken\n sourceMetadataIdentifier: 8f0497f0-dbd7-4bee-b85a-5fdec484a7ff\n styles:\n - name: wegvakken\n title: NWB - Wegvakken\n visualization: wegvakken.style\n title: Wegvakken\n visible: true\n - abstract:\n Deze laag bevat de hectopunten uit het Nationaal Wegen Bestand (NWB)\n en geeft gedetailleerde informatie per hectopunt zoals hectometrering, afstand,\n zijde en hectoletter weer.\n data:\n gpkg:\n columns:\n - objectid\n - hectomtrng\n - afstand\n - wvk_id\n - wvk_begdat\n - zijde\n - hecto_lttr\n geometryType: MultiPoint\n blobKey: geopackages/rws/nwbwegen/410a6d1e-e767-41b4-ba8d-9e1e955dd013/1/nwb_wegen.gpkg\n table: hectopunten\n datasetMetadataIdentifier: a9b7026e-0a81-4813-93bd-ba49e6f28502\n keywords:\n - Vervoersnetwerken\n - Menselijke gezondheid en veiligheid\n - Geluidsbelasting hoofdwegen (Richtlijn Omgevingslawaai)\n - Nationaal\n - Voertuigen\n - Verkeer\n - Hectometerpunten\n maxScale: 50000.0\n minScale: 1.0\n name: hectopunten\n sourceMetadataIdentifier: 8f0497f0-dbd7-4bee-b85a-5fdec484a7ff\n styles:\n - name: hectopunten\n title: NWB - Hectopunten\n visualization: hectopunten.style\n title: Hectopunten\n visible: true\n metadataIdentifier: f2437a92-ddd3-4777-a1bc-fdf4b4a7fcb8\n"
1213
var v2wms WMS
1314
err := yaml.Unmarshal([]byte(input), &v2wms)

api/v2beta1/wms_types.go

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,22 @@ type WMSSpec struct {
5454

5555
// WMSService is the struct for all service level fields
5656
type WMSService struct {
57-
Inspire bool `json:"inspire"`
58-
Title string `json:"title"`
59-
Abstract string `json:"abstract"`
60-
AccessConstraints string `json:"accessConstraints"`
61-
Keywords []string `json:"keywords"`
62-
MetadataIdentifier string `json:"metadataIdentifier"`
63-
Authority Authority `json:"authority"`
64-
Layers []WMSLayer `json:"layers"`
65-
DataEPSG string `json:"dataEPSG"`
66-
Extent *string `json:"extent,omitempty"`
67-
Maxsize *float64 `json:"maxSize,omitempty"`
68-
Resolution *int `json:"resolution,omitempty"`
69-
DefResolution *int `json:"defResolution,omitempty"`
70-
StylingAssets *StylingAssets `json:"stylingAssets,omitempty"`
71-
Mapfile *Mapfile `json:"mapfile,omitempty"`
57+
Inspire bool `json:"inspire"`
58+
Title string `json:"title"`
59+
Abstract string `json:"abstract"`
60+
AccessConstraints string `json:"accessConstraints"`
61+
Keywords []string `json:"keywords"`
62+
MetadataIdentifier string `json:"metadataIdentifier"`
63+
Authority Authority `json:"authority"`
64+
Layers []WMSLayer `json:"layers"`
65+
//nolint:tagliatelle
66+
DataEPSG string `json:"dataEPSG"`
67+
Extent *string `json:"extent,omitempty"`
68+
Maxsize *float64 `json:"maxSize,omitempty"`
69+
Resolution *int `json:"resolution,omitempty"`
70+
DefResolution *int `json:"defResolution,omitempty"`
71+
StylingAssets *StylingAssets `json:"stylingAssets,omitempty"`
72+
Mapfile *Mapfile `json:"mapfile,omitempty"`
7273
}
7374

7475
// WMSLayer is the struct for all layer level fields

api/v3/shared_types.go

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,33 @@ type WMSWFS interface {
3636
// Sha1 hash of the objects name
3737
ID() string
3838
URLPath() string
39+
40+
GeoPackages() []*Gpkg
3941
}
4042

4143
type Mapfile struct {
4244
ConfigMapKeyRef corev1.ConfigMapKeySelector `json:"configMapKeyRef"`
4345
}
4446

4547
type Options struct {
46-
IncludeIngress bool `json:"includeIngress"`
47-
AutomaticCasing bool `json:"automaticCasing"`
48-
ValidateRequests *bool `json:"validateRequests,omitempty"`
49-
RewriteGroupToDataLayers *bool `json:"rewriteGroupToDataLayers,omitempty"`
50-
DisableWebserviceProxy *bool `json:"disableWebserviceProxy,omitempty"`
51-
PrefetchData *bool `json:"prefetchData,omitempty"`
48+
// +kubebuilder:default:=true
49+
IncludeIngress bool `json:"includeIngress"`
50+
51+
// +kubebuilder:default:=true
52+
AutomaticCasing bool `json:"automaticCasing"`
53+
54+
// +kubebuilder:default:=true
55+
ValidateRequests *bool `json:"validateRequests,omitempty"`
56+
57+
// +kubebuilder:default:=false
58+
RewriteGroupToDataLayers *bool `json:"rewriteGroupToDataLayers,omitempty"`
59+
60+
// +kubebuilder:default:=false
61+
DisableWebserviceProxy *bool `json:"disableWebserviceProxy,omitempty"`
62+
63+
// +kubebuilder:default:=true
64+
PrefetchData *bool `json:"prefetchData,omitempty"`
65+
5266
ValidateChildStyleNameEqual *bool `json:"validateChildStyleNameEqual,omitempty"`
5367
}
5468

@@ -108,7 +122,13 @@ func SetHost(url string) {
108122
host = strings.TrimSuffix(url, "/")
109123
}
110124

111-
func GetHost() string {
125+
func GetHost(includeProtocol bool) string {
126+
if includeProtocol {
127+
return host
128+
} else if strings.HasPrefix(host, "http") {
129+
return strings.Split(host, "://")[1]
130+
}
131+
112132
return host
113133
}
114134

api/v3/wfs_types.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ type WFSSpec struct {
7878
}
7979

8080
type WFSService struct {
81+
// Geonovum subdomein
82+
// +kubebuilder:validation:MinLength:=1
8183
Prefix string `json:"prefix"`
8284
URL string `json:"url"`
8385
Inspire *Inspire `json:"inspire,omitempty"`
@@ -155,3 +157,15 @@ func (wfs *WFS) ID() string {
155157
func (wfs *WFS) URLPath() string {
156158
return wfs.Spec.Service.URL
157159
}
160+
161+
func (wfs *WFS) GeoPackages() []*Gpkg {
162+
gpkgs := make([]*Gpkg, 0)
163+
164+
for _, ft := range wfs.Spec.Service.FeatureTypes {
165+
if ft.Data.Gpkg != nil {
166+
gpkgs = append(gpkgs, ft.Data.Gpkg)
167+
}
168+
}
169+
170+
return gpkgs
171+
}

api/v3/wms_types.go

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,16 @@ type WMSService struct {
6565
OwnerInfoRef string `json:"ownerInfoRef"`
6666
Fees *string `json:"fees,omitempty"`
6767
// +kubebuilder:default="https://creativecommons.org/publicdomain/zero/1.0/deed.nl"
68-
AccessConstraints string `json:"accessConstraints"`
69-
MaxSize *int32 `json:"maxSize,omitempty"`
70-
Inspire *Inspire `json:"inspire,omitempty"`
71-
DataEPSG string `json:"dataEPSG"`
72-
Resolution *int32 `json:"resolution,omitempty"`
73-
DefResolution *int32 `json:"defResolution,omitempty"`
74-
StylingAssets *StylingAssets `json:"stylingAssets,omitempty"`
75-
Mapfile *Mapfile `json:"mapfile,omitempty"`
76-
Layer Layer `json:"layer"`
68+
AccessConstraints string `json:"accessConstraints"`
69+
MaxSize *int32 `json:"maxSize,omitempty"`
70+
Inspire *Inspire `json:"inspire,omitempty"`
71+
//nolint:tagliatelle
72+
DataEPSG string `json:"dataEPSG"`
73+
Resolution *int32 `json:"resolution,omitempty"`
74+
DefResolution *int32 `json:"defResolution,omitempty"`
75+
StylingAssets *StylingAssets `json:"stylingAssets,omitempty"`
76+
Mapfile *Mapfile `json:"mapfile,omitempty"`
77+
Layer Layer `json:"layer"`
7778
}
7879

7980
type StylingAssets struct {
@@ -178,7 +179,7 @@ func (wmsService *WMSService) GetBoundingBox() WMSBoundingBox {
178179

179180
allLayers := wmsService.GetAllLayers()
180181
for _, layer := range allLayers {
181-
if layer.BoundingBoxes != nil && len(layer.BoundingBoxes) > 0 {
182+
if len(layer.BoundingBoxes) > 0 {
182183
for _, bbox := range wmsService.Layer.BoundingBoxes {
183184
if boundingBox == nil {
184185
boundingBox = &bbox
@@ -191,18 +192,17 @@ func (wmsService *WMSService) GetBoundingBox() WMSBoundingBox {
191192

192193
if boundingBox != nil {
193194
return *boundingBox
194-
} else {
195-
return WMSBoundingBox{
196-
CRS: "EPSG:28992",
197-
BBox: shared_model.BBox{
198-
MinX: "-25000",
199-
MaxX: "280000",
200-
MinY: "250000",
201-
MaxY: "860000",
202-
},
203-
}
204195
}
205196

197+
return WMSBoundingBox{
198+
CRS: "EPSG:28992",
199+
BBox: shared_model.BBox{
200+
MinX: "-25000",
201+
MaxX: "280000",
202+
MinY: "250000",
203+
MaxY: "860000",
204+
},
205+
}
206206
}
207207

208208
type AnnotatedLayer struct {
@@ -281,11 +281,11 @@ func (layer *Layer) GetParent(candidateLayer *Layer) *Layer {
281281
for _, childLayer := range *candidateLayer.Layers {
282282
if childLayer.Name == layer.Name {
283283
return candidateLayer
284-
} else {
285-
parent := layer.GetParent(&childLayer)
286-
if parent != nil {
287-
return parent
288-
}
284+
}
285+
286+
parent := layer.GetParent(&childLayer)
287+
if parent != nil {
288+
return parent
289289
}
290290
}
291291
return nil
@@ -447,3 +447,25 @@ func (wms *WMS) ID() string {
447447
func (wms *WMS) URLPath() string {
448448
return wms.Spec.Service.URL
449449
}
450+
451+
func (wms *WMS) GeoPackages() []*Gpkg {
452+
gpkgs := make([]*Gpkg, 0)
453+
454+
if wms.Spec.Service.Layer.Layers != nil {
455+
for _, layer := range *wms.Spec.Service.Layer.Layers {
456+
if layer.Data != nil {
457+
if layer.Data.Gpkg != nil {
458+
gpkgs = append(gpkgs, layer.Data.Gpkg)
459+
}
460+
} else if layer.Layers != nil {
461+
for _, childLayer := range *layer.Layers {
462+
if childLayer.Data != nil && childLayer.Data.Gpkg != nil {
463+
gpkgs = append(gpkgs, childLayer.Data.Gpkg)
464+
}
465+
}
466+
}
467+
}
468+
}
469+
470+
return gpkgs
471+
}

api/v3/wms_validation.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ func validateWMS(wms *WMS, warnings *[]string, reasons *[]string) {
106106
*reasons = append(*reasons, "layer.boundingBoxes must contain a boundingBox for CRS '"+service.DataEPSG+"' when service.dataEPSG is not 'EPSG:28992'")
107107
}
108108

109+
//nolint:nestif
109110
if !*layer.Visible {
110111
if layer.Title != nil {
111112
*warnings = append(*warnings, sharedValidation.FormatValidationWarning("layer.title is not used when layer.visible=false", wms.GroupVersionKind(), wms.GetName()))

api/v3/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)