Skip to content

Commit 5ee4597

Browse files
committed
Remove duplicate IsGroupLayer() func
1 parent 3b33217 commit 5ee4597

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

api/v3/wms_types.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func (layer *Layer) hasTIFData() bool {
214214

215215
func (layer *Layer) GetLayerType(service *WMSService) (layerType string) {
216216
switch {
217-
case layer.hasData() && layer.Layers == nil:
217+
case layer.IsDataLayer():
218218
return DataLayer
219219
case layer.Name == service.Layer.Name:
220220
return TopLayer
@@ -223,12 +223,12 @@ func (layer *Layer) GetLayerType(service *WMSService) (layerType string) {
223223
}
224224
}
225225

226-
func (layer *Layer) IsDataLayer(service *WMSService) bool {
227-
return layer.GetLayerType(service) == DataLayer
226+
func (layer *Layer) IsDataLayer() bool {
227+
return layer.hasData() && (layer.Layers == nil || len(*layer.Layers) == 0)
228228
}
229229

230-
func (layer *Layer) IsGroupLayer(service *WMSService) bool {
231-
return layer.GetLayerType(service) == GroupLayer
230+
func (layer *Layer) IsGroupLayer() bool {
231+
return layer.Layers != nil && len(*layer.Layers) > 0
232232
}
233233

234234
func (layer *Layer) hasBoundingBoxForCRS(crs string) bool {
@@ -259,10 +259,6 @@ func (layer *Layer) setInheritedBoundingBoxes() {
259259
*layer.Layers = updatedLayers
260260
}
261261

262-
func (layer *Layer) IsGroupLayer() bool {
263-
return layer.Layers != nil && len(*layer.Layers) > 0
264-
}
265-
266262
func (wms *WMS) GetAllLayersWithLegend() (layers []Layer) {
267263
for _, layer := range wms.Spec.Service.Layer.GetAllLayers() {
268264
if !layer.hasData() || len(layer.Styles) == 0 {

api/v3/wms_validation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func validateWMS(wms *WMS, warnings *[]string, reasons *[]string) {
163163
}
164164
}
165165

166-
if layer.IsDataLayer(&wms.Spec.Service) {
166+
if layer.IsDataLayer() {
167167
for _, style := range layer.Styles {
168168
if wms.Spec.Service.Mapfile == nil && style.Visualization == nil {
169169
layerReasons = append(layerReasons, fmt.Sprintf("invalid style: '%s': style.visualization must be set on a dataLayer", style.Name))

internal/controller/featureinfogenerator/mapper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func MapWMSToFeatureinfoGeneratorInput(wms *pdoknlv3.WMS) (*featureinfo.Scheme,
1818
}
1919

2020
for _, layer := range wms.Spec.Service.Layer.GetAllLayers() {
21-
if !layer.IsDataLayer(&wms.Spec.Service) {
21+
if !layer.IsDataLayer() {
2222
continue
2323
}
2424
l := featureinfo.Layer{
@@ -27,7 +27,7 @@ func MapWMSToFeatureinfoGeneratorInput(wms *pdoknlv3.WMS) (*featureinfo.Scheme,
2727
}
2828

2929
parentLayer := layer.GetParent(&wms.Spec.Service.Layer)
30-
if parentLayer != nil && parentLayer.IsGroupLayer(&wms.Spec.Service) {
30+
if parentLayer != nil && parentLayer.IsGroupLayer() {
3131
l.GroupName = parentLayer.Name
3232
}
3333

0 commit comments

Comments
 (0)