Esempio n. 1
0
    def _getChildren(self, theme, layers, wms_layers, wms):
        children = []
        errors = []
        for item in sorted(theme.children, key=lambda item: item.order):
            if type(item) == LayerGroup:
                time = TimeInformation()
                gp, gp_errors, stop = self._group(item, layers, wms_layers, wms, time)
                errors += gp_errors
                if stop:
                    errors.append("Themes listing interrupted because of an error"
                                  " with theme \"%s\"" % theme.name)
                    return children, errors, True

                if gp is not None:
                    if time.has_time():
                        gp.update({"time": time.to_dict()})  # pragma nocover
                    children.append(gp)
            elif type(item) == Layer:
                if item in layers:
                    time = TimeInformation()
                    l, l_errors = self._layer(item, wms_layers, wms, time)
                    if time.has_time():
                        l.update({"time": time.to_dict()})  # pragma nocover
                    errors += l_errors
                    children.append(l)
        return children, errors, False
Esempio n. 2
0
    def _getChildren(self, theme, layers, wms_layers, wms):
        children = []
        errors = []
        for item in sorted(theme.children, key=lambda item: item.order):
            if type(item) == LayerGroup:
                time = TimeInformation()
                gp, gp_errors, stop = self._group(item, layers, wms_layers,
                                                  wms, time)
                errors += gp_errors
                if stop:
                    errors.append(
                        "Themes listing interrupted because of an error"
                        " with theme \"%s\"" % theme.name)
                    return children, errors, True

                if gp is not None:
                    if time.has_time():
                        gp.update({"time": time.to_dict()})  # pragma nocover
                    children.append(gp)
            elif type(item) == Layer:
                if item in layers:
                    time = TimeInformation()
                    l, l_errors = self._layer(item, wms_layers, wms, time)
                    if time.has_time():
                        l.update({"time": time.to_dict()})  # pragma nocover
                    errors += l_errors
                    children.append(l)
        return children, errors, False
Esempio n. 3
0
    def _get_children(self, theme, layers, wms, wms_layers, version, catalogue, min_levels):
        children = []
        errors = set()
        for item in theme.children:
            if type(item) == LayerGroup:
                time = TimeInformation()
                gp, gp_errors = self._group(
                    "%s/%s" % (theme.name, item.name),
                    item, layers, time=time, wms=wms, wms_layers=wms_layers,
                    version=version, catalogue=catalogue, min_levels=min_levels
                )
                errors |= gp_errors

                if gp is not None:
                    if time.has_time() and time.layer is None:
                        gp["time"] = time.to_dict()
                    children.append(gp)
            elif self._layer_included(item, version):
                if min_levels > 0:
                    errors.add("The Layer '%s' cannot be directly in the theme '%s' (0/%i)." % (
                        item.name, theme.name, min_levels
                    ))
                elif item.name in layers:
                    time = TimeInformation()
                    l, l_errors = self._layer(
                        item, time=time, wms=wms, wms_layers=wms_layers
                    )
                    errors |= l_errors
                    children.append(l)
        return children, errors
Esempio n. 4
0
 def test_merge_modes(self):
     from c2cgeoportal.lib.wmstparsing import TimeInformation
     ti = TimeInformation()
     self.assertFalse(ti.has_time())
     self.assertTrue(ti.to_dict() is None)
     ti.merge_mode('single')
     self.assertEqual(ti.mode, 'single')
     ti.merge_mode('single')
     self.assertEqual(ti.mode, 'single')
Esempio n. 5
0
 def test_merge_modes(self):
     from c2cgeoportal.lib.wmstparsing import TimeInformation
     ti = TimeInformation()
     self.assertFalse(ti.has_time())
     self.assertTrue(ti.to_dict() is None)
     ti.merge_mode("single")
     self.assertEqual(ti.mode, "single")
     ti.merge_mode("single")
     self.assertEqual(ti.mode, "single")