Coverage for gws-app/gws/base/layer/group.py: 85%
53 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-05 13:35 +0200
1"""Group layer."""
3import gws
4import gws.config
5import gws.lib.bounds
6import gws.lib.extent
7import gws.gis.source
9from . import core, tree
12@gws.ext.config.layer('group')
13class Config(core.Config):
14 """Layer that groups other layers."""
16 layers: list[gws.ext.config.layer]
17 """Layers in this group."""
20@gws.ext.props.layer('group')
21class Props(core.Props):
22 layers: list[gws.ext.props.layer]
25@gws.ext.object.layer('group')
26class Object(core.Object):
27 """Group layer.
29 Holds the child layers from the ``layers`` configuration and derives its
30 extent, resolutions, legend and render capabilities from them.
31 """
33 isGroup = True
35 def configure(self):
36 self.configure_layer()
38 self.canRenderBox = any(la.canRenderBox for la in self.layers)
39 self.canRenderTile = any(la.canRenderTile for la in self.layers)
40 self.canRenderSvg = any(la.canRenderSvg for la in self.layers)
42 def configure_group(self):
43 p = self.cfg('layers')
44 if p:
45 tree.create_group_layers(self, p)
46 return True
48 def configure_extent(self):
49 if super().configure_extent():
50 return True
51 self.wgsExtent = gws.lib.extent.union(*(la.wgsExtent for la in self.layers))
52 return True
54 def configure_zoom_bounds(self):
55 if super().configure_zoom_bounds():
56 return True
57 self.zoomBounds = gws.lib.bounds.union([(la.zoomBounds or la.bounds) for la in self.layers])
58 return True
60 def configure_resolutions(self):
61 if super().configure_resolutions():
62 return True
63 res = set()
64 for la in self.layers:
65 res.update(la.resolutions)
66 self.resolutions = sorted(res)
67 return True
69 def configure_legend(self):
70 if super().configure_legend():
71 return True
72 layers_uids = [la.uid for la in self.layers if la.legend]
73 if layers_uids:
74 self.legend = self.create_child(gws.ext.object.legend, type='combined', layerUids=layers_uids)
75 return True
77 def post_configure(self):
78 self.isSearchable = any(la.isSearchable for la in self.layers)
80 ##
82 def props(self, user):
83 return gws.u.merge(super().props(user), type='group')