Пример #1
0
    def test_absolute_time_stvds_1(self):
        """Test the registration of maps with absolute time in a
        space time raster dataset
        """
        tgis.register_maps_in_space_time_dataset(
            type="vector",
            name=self.stvds_abs.get_name(),
            maps="register_map_1,register_map_2",
            start="2001-01-01",
            increment="1 day",
            interval=True,
        )

        map = tgis.VectorDataset("register_map_1@" + tgis.get_current_mapset())
        map.select()
        start, end = map.get_absolute_time()
        self.assertEqual(start, datetime.datetime(2001, 1, 1))
        self.assertEqual(end, datetime.datetime(2001, 1, 2))

        map = tgis.VectorDataset("register_map_2@" + tgis.get_current_mapset())
        map.select()
        start, end = map.get_absolute_time()
        self.assertEqual(start, datetime.datetime(2001, 1, 2))
        self.assertEqual(end, datetime.datetime(2001, 1, 3))

        self.stvds_abs.select()
        start, end = self.stvds_abs.get_absolute_time()
        self.assertEqual(start, datetime.datetime(2001, 1, 1))
        self.assertEqual(end, datetime.datetime(2001, 1, 3))
Пример #2
0
    def test_absolute_time_2(self):
        """Register vector maps in the temporal database and in addition
        in a stvds using the object method deleting empty maps

        :return:
        """
        tgis.register_maps_in_space_time_dataset(
            type="vector",
            name=None,
            maps="register_map_1,register_map_2,register_map_empty",
            start="2001-01-01",
            increment="1 day",
            interval=True,
        )

        map_1 = tgis.VectorDataset("register_map_1@" +
                                   tgis.get_current_mapset())
        map_1.select()
        start, end = map_1.get_absolute_time()
        self.assertEqual(start, datetime.datetime(2001, 1, 1))
        self.assertEqual(end, datetime.datetime(2001, 1, 2))

        map_2 = tgis.VectorDataset("register_map_2@" +
                                   tgis.get_current_mapset())
        map_2.select()
        start, end = map_2.get_absolute_time()
        self.assertEqual(start, datetime.datetime(2001, 1, 2))
        self.assertEqual(end, datetime.datetime(2001, 1, 3))

        map_3 = tgis.VectorDataset("register_map_empty@" +
                                   tgis.get_current_mapset())
        map_3.select()
        start, end = map_3.get_absolute_time()
        self.assertEqual(start, datetime.datetime(2001, 1, 3))
        self.assertEqual(end, datetime.datetime(2001, 1, 4))

        map_list = [map_1, map_2, map_3]

        tgis.register_map_object_list(
            type="vector",
            map_list=map_list,
            output_stds=self.stvds_abs,
            delete_empty=True,
        )
        self.stvds_abs.select()
        start, end = self.stvds_abs.get_absolute_time()
        self.assertEqual(start, datetime.datetime(2001, 1, 1))
        self.assertEqual(end, datetime.datetime(2001, 1, 3))

        map_3 = tgis.VectorDataset("register_map_empty@" +
                                   tgis.get_current_mapset())
        self.assertEqual(map_3.map_exists(), False)
Пример #3
0
    def test_absolute_time_stvds_3(self):
        """Test the registration of maps with absolute time in a
        space time raster dataset. The timestamps are set via method arguments and with the
        c-interface. The timestamps of the method arguments should overwrite the
        time stamps set via the C-interface.
        """

        ciface = tgis.get_tgis_c_library_interface()
        ciface.write_vector_timestamp(
            "register_map_1", tgis.get_current_mapset(), "1 Jan 2001/2 Jan 2001"
        )

        tgis.register_maps_in_space_time_dataset(
            type="vector",
            name=self.stvds_abs.get_name(),
            maps="register_map_1",
            start="2001-02-01",
            increment="1 day",
            interval=True,
        )

        map = tgis.VectorDataset("register_map_1@" + tgis.get_current_mapset())
        map.select()
        start, end = map.get_absolute_time()
        self.assertEqual(start, datetime.datetime(2001, 2, 1))
        self.assertEqual(end, datetime.datetime(2001, 2, 2))

        self.stvds_abs.select()
        start, end = self.stvds_abs.get_absolute_time()
        self.assertEqual(start, datetime.datetime(2001, 2, 1))
        self.assertEqual(end, datetime.datetime(2001, 2, 2))
Пример #4
0
    def test_absolute_time_stvds_2(self):
        """Test the registration of maps with absolute time in a
        space time raster dataset.
        The timestamps are set using the C-Interface beforehand, so that the register function needs
        to read the timetsamp from the map metadata.
        """

        ciface = tgis.get_tgis_c_library_interface()
        ciface.write_vector_timestamp(
            "register_map_1", tgis.get_current_mapset(), "1 Jan 2001/2 Jan 2001"
        )
        ciface.write_vector_timestamp(
            "register_map_2", tgis.get_current_mapset(), "2 Jan 2001/3 Jan 2001"
        )

        tgis.register_maps_in_space_time_dataset(
            type="vector",
            name=self.stvds_abs.get_name(),
            maps="register_map_1,register_map_2",
        )

        map = tgis.VectorDataset("register_map_1@" + tgis.get_current_mapset())
        map.select()
        start, end = map.get_absolute_time()
        self.assertEqual(start, datetime.datetime(2001, 1, 1))
        self.assertEqual(end, datetime.datetime(2001, 1, 2))

        map = tgis.VectorDataset("register_map_2@" + tgis.get_current_mapset())
        map.select()
        start, end = map.get_absolute_time()
        self.assertEqual(start, datetime.datetime(2001, 1, 2))
        self.assertEqual(end, datetime.datetime(2001, 1, 3))

        self.stvds_abs.select()
        start, end = self.stvds_abs.get_absolute_time()
        self.assertEqual(start, datetime.datetime(2001, 1, 1))
        self.assertEqual(end, datetime.datetime(2001, 1, 3))
Пример #5
0
    def test_absolute_time_2(self):
        """Test the registration of maps with absolute time
        using register_maps_in_space_time_dataset() and register_map_object_list() with empty map deletion
        """
        tgis.register_maps_in_space_time_dataset(
            type="raster",
            name=None,
            maps="register_map_1,register_map_2,register_map_null",
            start="2001-01-01 10:30:01",
            increment="8 hours",
            interval=False,
        )

        map_1 = tgis.RasterDataset("register_map_1@" +
                                   tgis.get_current_mapset())
        map_1.select()
        start, end = map_1.get_absolute_time()
        self.assertEqual(start, datetime.datetime(2001, 1, 1, 10, 30, 1))

        map_2 = tgis.RasterDataset("register_map_2@" +
                                   tgis.get_current_mapset())
        map_2.select()
        start, end = map_2.get_absolute_time()
        self.assertEqual(start, datetime.datetime(2001, 1, 1, 18, 30, 1))

        map_3 = tgis.RasterDataset("register_map_null@" +
                                   tgis.get_current_mapset())
        map_3.select()
        start, end = map_3.get_absolute_time()
        self.assertEqual(start, datetime.datetime(2001, 1, 2, 2, 30, 1))

        map_list = [map_1, map_2, map_3]

        tgis.register_map_object_list(
            type="raster",
            map_list=map_list,
            output_stds=self.strds_abs,
            delete_empty=True,
        )
        self.strds_abs.select()
        start, end = self.strds_abs.get_absolute_time()
        self.assertEqual(start, datetime.datetime(2001, 1, 1, 10, 30, 1))
        self.assertEqual(end, datetime.datetime(2001, 1, 1, 18, 30, 1))

        map_3 = tgis.VectorDataset("register_map_null@" +
                                   tgis.get_current_mapset())
        self.assertEqual(map_3.map_exists(), False)