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
43 changes: 26 additions & 17 deletions internal/controller/mapfilegenerator/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
const (
defaultMaxFeatures = 1000
geopackagePath = "/srv/data/gpkg"
defaultExtent = "-25000 250000 280000 860000"
)

var mapserverDebugLevel = 0
Expand Down Expand Up @@ -68,25 +69,21 @@ func MapWFSToMapfileGeneratorInput(wfs *pdoknlv3.WFS, ownerInfo *smoothoperatorv
DebugLevel: mapserverDebugLevel,
},
MaxFeatures: smoothoperatorutils.PointerVal(wfs.Spec.Service.CountDefault, strconv.Itoa(defaultMaxFeatures)),
Layers: getWFSLayers(wfs.Spec.Service.FeatureTypes),
Layers: getWFSLayers(wfs.Spec.Service),
}

return input, nil
}

func getWFSLayers(featureTypes []pdoknlv3.FeatureType) (layers []WFSLayer) {
for _, featureType := range featureTypes {
bbox := pdoknlv3.FeatureBbox{}
if featureType.Bbox != nil {
bbox = *featureType.Bbox
}
func getWFSLayers(service pdoknlv3.WFSService) (layers []WFSLayer) {
for _, featureType := range service.FeatureTypes {
layer := WFSLayer{
BaseLayer: BaseLayer{
Name: featureType.Name,
Title: mapperutils.EscapeQuotes(featureType.Title),
Abstract: mapperutils.EscapeQuotes(featureType.Abstract),
Keywords: strings.Join(featureType.Keywords, ","),
Extent: bbox.DefaultCRS.ToExtent(),
Extent: getWFSExtent(featureType, service),
MetadataID: featureType.DatasetMetadataURL.CSW.MetadataIdentifier,
Columns: getColumns(featureType.Data),
TableName: featureType.Data.GetTableName(),
Expand All @@ -104,6 +101,26 @@ func getWFSLayers(featureTypes []pdoknlv3.FeatureType) (layers []WFSLayer) {
return
}

func getWFSExtent(featureType pdoknlv3.FeatureType, service pdoknlv3.WFSService) string {
if featureType.Bbox != nil {
return featureType.Bbox.DefaultCRS.ToExtent()
}
if service.Bbox != nil {
return service.Bbox.DefaultCRS.ToExtent()
}
return defaultExtent
}

func getWMSExtent(serviceLayer pdoknlv3.Layer, serviceExtent string) string {
if len(serviceLayer.BoundingBoxes) > 0 {
return serviceLayer.BoundingBoxes[0].ToExtent()
}
if serviceExtent != "" {
return serviceExtent
}
return defaultExtent
}

func getColumns(data pdoknlv3.Data) []Column {
columns := []Column{{Name: "fuuid"}}
if data.GetColumns() != nil {
Expand Down Expand Up @@ -220,15 +237,7 @@ func MapWMSToMapfileGeneratorInput(wms *pdoknlv3.WMS, _ *smoothoperatorv1.OwnerI
return result, nil
}

// TODO fix linting (cyclop)
//
//nolint:cyclop
func getWMSLayer(serviceLayer pdoknlv3.Layer, serviceExtent string, wms *pdoknlv3.WMS) WMSLayer {
layerExtent := serviceExtent
if len(serviceLayer.BoundingBoxes) > 0 {
layerExtent = serviceLayer.BoundingBoxes[0].ToExtent()
}

groupName := ""
parent := serviceLayer.GetParent(&wms.Spec.Service.Layer)
// If the layer falls directly under the toplayer, the groupname is omitted
Expand Down Expand Up @@ -257,7 +266,7 @@ func getWMSLayer(serviceLayer pdoknlv3.Layer, serviceExtent string, wms *pdoknlv
Title: smoothoperatorutils.PointerVal(serviceLayer.Title, ""),
Abstract: smoothoperatorutils.PointerVal(serviceLayer.Abstract, ""),
Keywords: strings.Join(serviceLayer.Keywords, ","),
Extent: layerExtent,
Extent: getWMSExtent(serviceLayer, serviceExtent),
MetadataID: metadataID,
Columns: columns,
GeometryType: nil,
Expand Down
1 change: 0 additions & 1 deletion internal/controller/shared_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,6 @@ func mutateConfigMapMapfileGenerator[R Reconciler, O pdoknlv3.WMSWFS](r R, obj O
if err != nil {
return err
}
// mapfileGeneratorConfig := "TODO" // TODO Implement mapfilegenerator.GetConfig for WMS
configMap.Data = map[string]string{mapfileGeneratorInput: mapfileGeneratorConfig}
}
configMap.Immutable = smoothoperatorutils.Pointer(true)
Expand Down
Loading