Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ FROM docker.io/golang:1.24 AS builder
ARG TARGETOS
ARG TARGETARCH

#COPY --from=repos ./smooth-operator /smooth-operator

WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
Expand Down
8 changes: 4 additions & 4 deletions api/v2beta1/wms_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@

import (
"errors"
sharedModel "github.com/pdok/smooth-operator/model"
"log"
"sigs.k8s.io/controller-runtime/pkg/conversion"
"strconv"
"strings"

pdoknlv3 "github.com/pdok/mapserver-operator/api/v3"
sharedModel "github.com/pdok/smooth-operator/model"
)

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

// ConvertTo converts this WMS (v2beta1) to the Hub version (v3).
func (src *WMS) ConvertTo(dstRaw conversion.Hub) error {
Expand All @@ -55,7 +55,7 @@
dst.Annotations = make(map[string]string)
}

dst.Annotations[SERVICE_METADATA_IDENTIFIER_ANNOTATION] = src.Spec.Service.MetadataIdentifier
dst.Annotations[ServiceMetatdataIdentifierAnnotation] = src.Spec.Service.MetadataIdentifier

// Set LifeCycle if defined
if src.Spec.Kubernetes.Lifecycle != nil && src.Spec.Kubernetes.Lifecycle.TTLInDays != nil {
Expand Down Expand Up @@ -179,7 +179,7 @@
// TODO unable to fill in MetadataIdentifier here until we know how to handle non inspire services
}

uuid, ok := src.Annotations[SERVICE_METADATA_IDENTIFIER_ANNOTATION]
uuid, ok := src.Annotations[ServiceMetatdataIdentifierAnnotation]
if service.MetadataIdentifier == "00000000-0000-0000-0000-000000000000" && ok {
service.MetadataIdentifier = uuid
}
Expand Down Expand Up @@ -421,7 +421,7 @@
return layer
}

func mapV3LayerToV2Layers(v3Layer pdoknlv3.Layer, parent *pdoknlv3.Layer, serviceEPSG string) []WMSLayer {

Check failure on line 424 in api/v2beta1/wms_conversion.go

View workflow job for this annotation

GitHub Actions / Run on Ubuntu

calculated cyclomatic complexity for function mapV3LayerToV2Layers is 20, max is 15 (cyclop)

Check failure on line 424 in api/v2beta1/wms_conversion.go

View workflow job for this annotation

GitHub Actions / Run on Ubuntu

calculated cyclomatic complexity for function mapV3LayerToV2Layers is 20, max is 15 (cyclop)
var layers []WMSLayer

if parent == nil && *v3Layer.Name == "wms" {
Expand Down
1 change: 1 addition & 0 deletions api/v2beta1/wms_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

func TestV2ToV3(t *testing.T) {
//nolint:misspell
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"
var v2wms WMS
err := yaml.Unmarshal([]byte(input), &v2wms)
Expand Down
31 changes: 16 additions & 15 deletions api/v2beta1/wms_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,22 @@ type WMSSpec struct {

// WMSService is the struct for all service level fields
type WMSService struct {
Inspire bool `json:"inspire"`
Title string `json:"title"`
Abstract string `json:"abstract"`
AccessConstraints string `json:"accessConstraints"`
Keywords []string `json:"keywords"`
MetadataIdentifier string `json:"metadataIdentifier"`
Authority Authority `json:"authority"`
Layers []WMSLayer `json:"layers"`
DataEPSG string `json:"dataEPSG"`
Extent *string `json:"extent,omitempty"`
Maxsize *float64 `json:"maxSize,omitempty"`
Resolution *int `json:"resolution,omitempty"`
DefResolution *int `json:"defResolution,omitempty"`
StylingAssets *StylingAssets `json:"stylingAssets,omitempty"`
Mapfile *Mapfile `json:"mapfile,omitempty"`
Inspire bool `json:"inspire"`
Title string `json:"title"`
Abstract string `json:"abstract"`
AccessConstraints string `json:"accessConstraints"`
Keywords []string `json:"keywords"`
MetadataIdentifier string `json:"metadataIdentifier"`
Authority Authority `json:"authority"`
Layers []WMSLayer `json:"layers"`
//nolint:tagliatelle
DataEPSG string `json:"dataEPSG"`
Extent *string `json:"extent,omitempty"`
Maxsize *float64 `json:"maxSize,omitempty"`
Resolution *int `json:"resolution,omitempty"`
DefResolution *int `json:"defResolution,omitempty"`
StylingAssets *StylingAssets `json:"stylingAssets,omitempty"`
Mapfile *Mapfile `json:"mapfile,omitempty"`
}

// WMSLayer is the struct for all layer level fields
Expand Down
34 changes: 27 additions & 7 deletions api/v3/shared_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,33 @@ type WMSWFS interface {
// Sha1 hash of the objects name
ID() string
URLPath() string

GeoPackages() []*Gpkg
}

type Mapfile struct {
ConfigMapKeyRef corev1.ConfigMapKeySelector `json:"configMapKeyRef"`
}

type Options struct {
IncludeIngress bool `json:"includeIngress"`
AutomaticCasing bool `json:"automaticCasing"`
ValidateRequests *bool `json:"validateRequests,omitempty"`
RewriteGroupToDataLayers *bool `json:"rewriteGroupToDataLayers,omitempty"`
DisableWebserviceProxy *bool `json:"disableWebserviceProxy,omitempty"`
PrefetchData *bool `json:"prefetchData,omitempty"`
// +kubebuilder:default:=true
IncludeIngress bool `json:"includeIngress"`

// +kubebuilder:default:=true
AutomaticCasing bool `json:"automaticCasing"`

// +kubebuilder:default:=true
ValidateRequests *bool `json:"validateRequests,omitempty"`

// +kubebuilder:default:=false
RewriteGroupToDataLayers *bool `json:"rewriteGroupToDataLayers,omitempty"`

// +kubebuilder:default:=false
DisableWebserviceProxy *bool `json:"disableWebserviceProxy,omitempty"`

// +kubebuilder:default:=true
PrefetchData *bool `json:"prefetchData,omitempty"`

ValidateChildStyleNameEqual *bool `json:"validateChildStyleNameEqual,omitempty"`
}

Expand Down Expand Up @@ -108,7 +122,13 @@ func SetHost(url string) {
host = strings.TrimSuffix(url, "/")
}

func GetHost() string {
func GetHost(includeProtocol bool) string {
if includeProtocol {
return host
} else if strings.HasPrefix(host, "http") {
return strings.Split(host, "://")[1]
}

return host
}

Expand Down
14 changes: 14 additions & 0 deletions api/v3/wfs_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ type WFSSpec struct {
}

type WFSService struct {
// Geonovum subdomein
// +kubebuilder:validation:MinLength:=1
Prefix string `json:"prefix"`
URL string `json:"url"`
Inspire *Inspire `json:"inspire,omitempty"`
Expand Down Expand Up @@ -155,3 +157,15 @@ func (wfs *WFS) ID() string {
func (wfs *WFS) URLPath() string {
return wfs.Spec.Service.URL
}

func (wfs *WFS) GeoPackages() []*Gpkg {
gpkgs := make([]*Gpkg, 0)

for _, ft := range wfs.Spec.Service.FeatureTypes {
if ft.Data.Gpkg != nil {
gpkgs = append(gpkgs, ft.Data.Gpkg)
}
}

return gpkgs
}
72 changes: 47 additions & 25 deletions api/v3/wms_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,16 @@ type WMSService struct {
OwnerInfoRef string `json:"ownerInfoRef"`
Fees *string `json:"fees,omitempty"`
// +kubebuilder:default="https://creativecommons.org/publicdomain/zero/1.0/deed.nl"
AccessConstraints string `json:"accessConstraints"`
MaxSize *int32 `json:"maxSize,omitempty"`
Inspire *Inspire `json:"inspire,omitempty"`
DataEPSG string `json:"dataEPSG"`
Resolution *int32 `json:"resolution,omitempty"`
DefResolution *int32 `json:"defResolution,omitempty"`
StylingAssets *StylingAssets `json:"stylingAssets,omitempty"`
Mapfile *Mapfile `json:"mapfile,omitempty"`
Layer Layer `json:"layer"`
AccessConstraints string `json:"accessConstraints"`
MaxSize *int32 `json:"maxSize,omitempty"`
Inspire *Inspire `json:"inspire,omitempty"`
//nolint:tagliatelle
DataEPSG string `json:"dataEPSG"`
Resolution *int32 `json:"resolution,omitempty"`
DefResolution *int32 `json:"defResolution,omitempty"`
StylingAssets *StylingAssets `json:"stylingAssets,omitempty"`
Mapfile *Mapfile `json:"mapfile,omitempty"`
Layer Layer `json:"layer"`
}

type StylingAssets struct {
Expand Down Expand Up @@ -178,7 +179,7 @@ func (wmsService *WMSService) GetBoundingBox() WMSBoundingBox {

allLayers := wmsService.GetAllLayers()
for _, layer := range allLayers {
if layer.BoundingBoxes != nil && len(layer.BoundingBoxes) > 0 {
if len(layer.BoundingBoxes) > 0 {
for _, bbox := range wmsService.Layer.BoundingBoxes {
if boundingBox == nil {
boundingBox = &bbox
Expand All @@ -191,18 +192,17 @@ func (wmsService *WMSService) GetBoundingBox() WMSBoundingBox {

if boundingBox != nil {
return *boundingBox
} else {
return WMSBoundingBox{
CRS: "EPSG:28992",
BBox: shared_model.BBox{
MinX: "-25000",
MaxX: "280000",
MinY: "250000",
MaxY: "860000",
},
}
}

return WMSBoundingBox{
CRS: "EPSG:28992",
BBox: shared_model.BBox{
MinX: "-25000",
MaxX: "280000",
MinY: "250000",
MaxY: "860000",
},
}
}

type AnnotatedLayer struct {
Expand Down Expand Up @@ -281,11 +281,11 @@ func (layer *Layer) GetParent(candidateLayer *Layer) *Layer {
for _, childLayer := range *candidateLayer.Layers {
if childLayer.Name == layer.Name {
return candidateLayer
} else {
parent := layer.GetParent(&childLayer)
if parent != nil {
return parent
}
}

parent := layer.GetParent(&childLayer)
if parent != nil {
return parent
}
}
return nil
Expand Down Expand Up @@ -447,3 +447,25 @@ func (wms *WMS) ID() string {
func (wms *WMS) URLPath() string {
return wms.Spec.Service.URL
}

func (wms *WMS) GeoPackages() []*Gpkg {
gpkgs := make([]*Gpkg, 0)

if wms.Spec.Service.Layer.Layers != nil {
for _, layer := range *wms.Spec.Service.Layer.Layers {
if layer.Data != nil {
if layer.Data.Gpkg != nil {
gpkgs = append(gpkgs, layer.Data.Gpkg)
}
} else if layer.Layers != nil {
for _, childLayer := range *layer.Layers {
if childLayer.Data != nil && childLayer.Data.Gpkg != nil {
gpkgs = append(gpkgs, childLayer.Data.Gpkg)
}
}
}
}
}

return gpkgs
}
1 change: 1 addition & 0 deletions api/v3/wms_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
return warnings, nil
}

func validateWMS(wms *WMS, warnings *[]string, reasons *[]string) {

Check failure on line 57 in api/v3/wms_validation.go

View workflow job for this annotation

GitHub Actions / Run on Ubuntu

calculated cyclomatic complexity for function validateWMS is 53, max is 15 (cyclop)

Check failure on line 57 in api/v3/wms_validation.go

View workflow job for this annotation

GitHub Actions / Run on Ubuntu

calculated cyclomatic complexity for function validateWMS is 53, max is 15 (cyclop)
if strings.Contains(wms.GetName(), "wms") {
*warnings = append(*warnings, sharedValidation.FormatValidationWarning("name should not contain wms", wms.GroupVersionKind(), wms.GetName()))
}
Expand Down Expand Up @@ -106,6 +106,7 @@
*reasons = append(*reasons, "layer.boundingBoxes must contain a boundingBox for CRS '"+service.DataEPSG+"' when service.dataEPSG is not 'EPSG:28992'")
}

//nolint:nestif
if !*layer.Visible {
if layer.Title != nil {
*warnings = append(*warnings, sharedValidation.FormatValidationWarning("layer.title is not used when layer.visible=false", wms.GroupVersionKind(), wms.GetName()))
Expand Down
26 changes: 26 additions & 0 deletions api/v3/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading