Ejemplo n.º 1
0
    def _merge_time(self, time, l, layer, wms, wms_layers):
        errors = set()
        wmslayer = layer.name if isinstance(layer, LayerV1) else layer.layer
        try:
            if wmslayer in wms_layers:
                wms_layer_obj = wms[wmslayer]

                if wms_layer_obj.timepositions:
                    extent = parse_extent(
                        wms_layer_obj.timepositions,
                        wms_layer_obj.defaulttimeposition
                    )
                    time.merge(l, extent, layer.time_mode)

                for child_layer in wms_layer_obj.layers:
                    if child_layer.timepositions:
                        extent = parse_extent(
                            child_layer.timepositions,
                            child_layer.defaulttimeposition
                        )
                        # The time mode comes from the layer group
                        time.merge(l, extent, layer.time_mode)

        except ValueError:  # pragma no cover
            errors.add(
                "Error while handling time for layer '%s': %s"
                % (layer.name, sys.exc_info()[1])
            )

        return errors
Ejemplo n.º 2
0
 def test_merge_interval(self):
     from c2cgeoportal.lib.wmstparsing import parse_extent, TimeExtentInterval
     e1 = parse_extent(["2000/2005/P1Y"])
     e2 = parse_extent(["2006/2010/P1Y"])
     self.assertTrue(isinstance(e1, TimeExtentInterval))
     self.assertTrue(isinstance(e2, TimeExtentInterval))
     e1.merge(e2)
     d = e1.to_dict()
     self.assertEqual(d, {
         "minValue": "2000-01-01T00:00:00Z",
         "maxValue": "2010-01-01T00:00:00Z",
         "resolution": "year",
         "interval": (1, 0, 0, 0)
     })
Ejemplo n.º 3
0
 def test_merge_interval(self):
     from c2cgeoportal.lib.wmstparsing import parse_extent, TimeExtentInterval
     e1 = parse_extent(["2000/2005/P1Y"])
     e2 = parse_extent(["2006/2010/P1Y"])
     self.assertTrue(isinstance(e1, TimeExtentInterval))
     self.assertTrue(isinstance(e2, TimeExtentInterval))
     e1.merge(e2)
     d = e1.to_dict()
     self.assertEqual(
         d, {
             "minValue": "2000-01-01T00:00:00Z",
             "maxValue": "2010-01-01T00:00:00Z",
             "resolution": "year",
             "interval": (1, 0, 0, 0)
         })
Ejemplo n.º 4
0
 def test_merge_values(self):
     from c2cgeoportal.lib.wmstparsing import parse_extent, TimeExtentValue
     e1 = parse_extent(["2000", "2005"])
     e2 = parse_extent(["2001", "2003"])
     self.assertTrue(isinstance(e1, TimeExtentValue))
     self.assertTrue(isinstance(e2, TimeExtentValue))
     e1.merge(e2)
     d = e1.to_dict()
     self.assertEqual(d, {
         "minValue": "2000-01-01T00:00:00Z",
         "maxValue": "2005-01-01T00:00:00Z",
         "resolution": "year",
         "values": [
             '2000-01-01T00:00:00Z',
             '2001-01-01T00:00:00Z',
             '2003-01-01T00:00:00Z',
             '2005-01-01T00:00:00Z'
         ]
     })
Ejemplo n.º 5
0
 def test_merge_values(self):
     from c2cgeoportal.lib.wmstparsing import parse_extent, TimeExtentValue
     e1 = parse_extent(["2000", "2005"], "2000/2005")
     e2 = parse_extent(["2001", "2003"], "2001/2003")
     self.assertTrue(isinstance(e1, TimeExtentValue))
     self.assertTrue(isinstance(e2, TimeExtentValue))
     e1.merge(e2)
     d = e1.to_dict()
     self.assertEqual(d, {
         "minValue": "2000-01-01T00:00:00Z",
         "maxValue": "2005-01-01T00:00:00Z",
         "resolution": "year",
         "values": [
             "2000-01-01T00:00:00Z",
             "2001-01-01T00:00:00Z",
             "2003-01-01T00:00:00Z",
             "2005-01-01T00:00:00Z"
         ],
         "minDefValue": "2000-01-01T00:00:00Z",
         "maxDefValue": "2005-01-01T00:00:00Z",
     })
Ejemplo n.º 6
0
    def _merge_time(self, time, layer, wms_layers, wms):
        errors = []
        try:
            if layer.name in wms_layers:
                wms_layer_obj = wms[layer.name]

                if wms_layer_obj.timepositions:
                    extent = parse_extent(wms_layer_obj.timepositions)
                    time.merge_extent(extent)
                    time.merge_mode(layer.timeMode)

                for child_layer in wms_layer_obj.layers:
                    if child_layer.timepositions:
                        extent = parse_extent(child_layer.timepositions)
                        time.merge_extent(extent)
                        # The time mode comes from the layer group
                        time.merge_mode(layer.timeMode)
        except:  # pragma no cover
            errors.append("Error while handling time for layer '%s' : '%s'"
                          % (layer.name, sys.exc_info()[1]))

        return errors
Ejemplo n.º 7
0
    def _merge_time(self, time, layer, wms_layers, wms):
        errors = []
        try:
            if layer.name in wms_layers:
                wms_layer_obj = wms[layer.name]

                if wms_layer_obj.timepositions:
                    extent = parse_extent(wms_layer_obj.timepositions)
                    time.merge_extent(extent)
                    time.merge_mode(layer.timeMode)

                for child_layer in wms_layer_obj.layers:
                    if child_layer.timepositions:
                        extent = parse_extent(child_layer.timepositions)
                        time.merge_extent(extent)
                        # The time mode comes from the layer group
                        time.merge_mode(layer.timeMode)
        except:  # pragma no cover
            errors.append("Error while handling time for layer '%s' : '%s'" %
                          (layer.name, sys.exc_info()[1]))

        return errors
Ejemplo n.º 8
0
 def test_merge_different_intervals(self):
     from c2cgeoportal.lib.wmstparsing import parse_extent
     e1 = parse_extent(["2000/2005/P1Y"])
     e2 = parse_extent(["2006/2010/P1M"])
     self.assertRaises(ValueError, e1.merge, e2)
Ejemplo n.º 9
0
 def test_merge_value_interval(self):
     from c2cgeoportal.lib.wmstparsing import parse_extent
     tev = parse_extent(["2000", "2001"])
     tei = parse_extent(["2000/2010/P1Y"])
     self.assertRaises(ValueError, tev.merge, tei)
     self.assertRaises(ValueError, tei.merge, tev)
Ejemplo n.º 10
0
 def test_parse_interval(self):
     from c2cgeoportal.lib.wmstparsing import parse_extent, TimeExtentInterval
     extent = parse_extent(["2000/2005/P1Y"])
     self.assertTrue(isinstance(extent, TimeExtentInterval))
Ejemplo n.º 11
0
 def test_parse_values(self):
     from c2cgeoportal.lib.wmstparsing import parse_extent, TimeExtentValue
     extent = parse_extent(["2005", "2006"])
     self.assertTrue(isinstance(extent, TimeExtentValue))
Ejemplo n.º 12
0
 def test_merge_different_intervals(self):
     from c2cgeoportal.lib.wmstparsing import parse_extent
     e1 = parse_extent(["2000/2005/P1Y"], "2002")
     e2 = parse_extent(["2006/2010/P1M"], "2002")
     self.assertRaises(ValueError, e1.merge, e2)
Ejemplo n.º 13
0
 def test_merge_value_interval(self):
     from c2cgeoportal.lib.wmstparsing import parse_extent
     tev = parse_extent(["2000", "2001"], "2000")
     tei = parse_extent(["2000/2010/P1Y"], "2002")
     self.assertRaises(ValueError, tev.merge, tei)
     self.assertRaises(ValueError, tei.merge, tev)
Ejemplo n.º 14
0
 def test_parse_interval(self):
     from c2cgeoportal.lib.wmstparsing import parse_extent, TimeExtentInterval
     extent = parse_extent(["2000/2005/P1Y"], "2002")
     self.assertTrue(isinstance(extent, TimeExtentInterval))
Ejemplo n.º 15
0
 def test_parse_values(self):
     from c2cgeoportal.lib.wmstparsing import parse_extent, TimeExtentValue
     extent = parse_extent(["2005", "2006"], "2005")
     self.assertTrue(isinstance(extent, TimeExtentValue))