@@ -151,18 +151,42 @@ func init() {
151151 SchemeBuilder .Register (& WMS {}, & WMSList {})
152152}
153153
154- func (wms * WMS ) GetUniqueTiffBlobKeys () []string {
155- blobKeys := map [string ]bool {}
154+ func (layer * Layer ) getAllLayers () (layers []Layer ) {
155+ layers = append (layers , * layer )
156+ for _ , childLayer := range layer .Layers {
157+ layers = append (layers , childLayer .getAllLayers ()... )
158+ }
159+ return
160+ }
161+
162+ func (layer * Layer ) hasData () bool {
163+ switch {
164+ case layer .Data .Gpkg != nil :
165+ return true
166+ case layer .Data .Postgis != nil :
167+ return true
168+ case layer .Data .TIF != nil :
169+ return true
170+ default :
171+ return false
172+ }
173+ }
156174
157- if wms .Spec .Service .Layer .Data .TIF != nil && wms .Spec .Service .Layer .Data .TIF .BlobKey != "" {
158- blobKeys [wms .Spec .Service .Layer .Data .TIF .BlobKey ] = true
175+ func (wms * WMS ) GetAllLayersWithLegend () (layers []Layer ) {
176+ for _ , layer := range wms .Spec .Service .Layer .getAllLayers () {
177+ if layer .hasData () && layer .Style .Legend .BlobKey != "" {
178+ layers = append (layers , layer )
179+ }
159180 }
181+ return
182+ }
183+
184+ func (wms * WMS ) GetUniqueTiffBlobKeys () []string {
185+ blobKeys := map [string ]bool {}
160186
161- if len (wms .Spec .Service .Layer .Layers ) > 0 {
162- for _ , layer := range wms .Spec .Service .Layer .Layers {
163- if layer .Data .TIF != nil && layer .Data .TIF .BlobKey != "" {
164- blobKeys [layer .Data .TIF .BlobKey ] = true
165- }
187+ for _ , layer := range wms .Spec .Service .Layer .getAllLayers () {
188+ if layer .Data .TIF != nil && layer .Data .TIF .BlobKey != "" {
189+ blobKeys [layer .Data .TIF .BlobKey ] = true
166190 }
167191 }
168192 return slices .Collect (maps .Keys (blobKeys ))
0 commit comments