def test_copy_csv_with_z_to_db(self):
     print("\nINFO: Validating copy CSV points with Z to DB...")
     clean_table('test_ladm_col_3d', BOUNDARY_POINT_TABLE)
     self.qgis_utils.disable_automatic_fields(self.db_connection_3d, BOUNDARY_POINT_TABLE)
     self.upload_points_from_csv_with_elevation()
     self.validate_points_z_in_db()
     clean_table('test_ladm_col_3d', BOUNDARY_POINT_TABLE)
Ejemplo n.º 2
0
    def test_copy_csv_to_db(self):
        print("\nINFO: Validating copy CSV points to DB...")
        clean_table(SCHEMA_LADM_COL_EMPTY, self.names.LC_BOUNDARY_POINT_T)
        layer = self.app.core.get_layer(self.db_pg,
                                        self.names.LC_BOUNDARY_POINT_T, True)
        self.app.core.disable_automatic_fields(layer)

        csv_path = get_test_path('csv/puntos_fixed_ladm_v1_1.csv')
        txt_delimiter = ';'
        cbo_longitude = 'x'
        cbo_latitude = 'y'
        csv_layer = self.app.core.csv_to_layer(csv_path,
                                               txt_delimiter,
                                               cbo_longitude,
                                               cbo_latitude,
                                               "EPSG:9377",
                                               reproject=False)

        self.upload_points_from_csv(csv_layer, SCHEMA_LADM_COL_EMPTY)

        self.validate_points_in_db(SCHEMA_LADM_COL_EMPTY)
        test_layer = self.app.core.get_layer(self.db_pg,
                                             self.names.LC_BOUNDARY_POINT_T,
                                             load=True)
        delete_features(test_layer)
        self.assertEqual(test_layer.featureCount(), 0)
 def test_upload_points_from_csv_crs_wgs84(self):
     print("\nINFO: Copying CSV data with EPSG:4326...")
     clean_table('test_ladm_col', BOUNDARY_POINT_TABLE)
     self.qgis_utils.disable_automatic_fields(self.db_connection, BOUNDARY_POINT_TABLE)
     self.upload_points_from_csv_crs_wgs84()
     self.validate_points_in_db_from_wgs84()
     clean_table('test_ladm_col', BOUNDARY_POINT_TABLE)
 def test_copy_csv_overlapping_to_db(self):
     print('\nINFO: Validating copy csv overlapping to db')
     schema = 'test_ladm_col'
     clean_table(schema, 'puntolindero')
     self.upload_points_from_csv_overlapping(schema)
     self.validate_number_of_boundary_points_in_db(schema, 0)
     clean_table(schema, 'puntolindero')
Ejemplo n.º 5
0
    def setUpClass(self):
        print("\nINFO: Setting up copy layer With different Geometries to DB validation...")
        self.qgis_utils = QGISUtils()

        # resore schemas
        restore_schema(SCHEMA_DISTINCT_GEOMS)
        restore_schema(SCHEMA_LADM_COL)
        restore_schema(SCHEMA_LADM_COL_3D)

        self.db_distinct_geoms = get_dbconn(SCHEMA_DISTINCT_GEOMS)
        result = self.db_distinct_geoms.test_connection()
        print('Test_connection for: '.format(SCHEMA_DISTINCT_GEOMS), result)
        if not result[1]:
            print('The test connection with  {} db is not working'.format(SCHEMA_DISTINCT_GEOMS))
            return

        self.db_connection = get_dbconn(SCHEMA_LADM_COL)
        result = self.db_connection.test_connection()
        print('Test_connection for: '.format(SCHEMA_LADM_COL), result)
        if not result[1]:
            print('The test connection with  {} db is not working'.format(SCHEMA_LADM_COL))
            return

        self.db_connection_3d = get_dbconn(SCHEMA_LADM_COL_3D)
        result = self.db_connection_3d.test_connection()
        print('Test_connection for: '.format(SCHEMA_LADM_COL_3D), result)
        if not result[1]:
            print('The test connection with {} db is not working'.format(SCHEMA_LADM_COL_3D))
            return

        self.gpkg_path = get_test_copy_path('geopackage/points_z_m_zm.gpkg')

        clean_table(SCHEMA_LADM_COL, BOUNDARY_POINT_TABLE)
        clean_table(SCHEMA_LADM_COL_3D, BOUNDARY_POINT_TABLE)
 def test_copy_csv_to_db(self):
     print("\nINFO: Validating copy CSV points to DB...")
     schema = 'test_ladm_col'
     clean_table('test_ladm_col', BOUNDARY_POINT_TABLE)
     self.qgis_utils.disable_automatic_fields(self.db_connection,
                                              BOUNDARY_POINT_TABLE)
     self.upload_points_from_csv(schema)
     self.validate_points_in_db(schema)
     clean_table(schema, BOUNDARY_POINT_TABLE)
    def test_valid_import_geom_3d_to_db_gpkg(self):
        print('\nINFO: Validating ETL-Model from [ Point, PointZ, PointM, PointZM ] to PointZ geometries...')

        test_layer_3d = self.qgis_utils.get_layer(self.db_connection_3d, BOUNDARY_POINT_TABLE, load=True)

        # Point To PointZ
        print("Validating Point to PointZ")
        uri = self.gpkg_path + '|layername={layername}'.format(layername='points')
        point_layer = QgsVectorLayer(uri, 'points', 'ogr')
        print("Is Valid layer :", point_layer.isValid())
        run_etl_model(point_layer, out_layer=test_layer_3d)
        print("Info: Validating geometry Point...")
        self.assertEqual(QgsWkbTypes.PointGeometry, test_layer_3d.type())
        self.assertEqual(QgsWkbTypes.Point, point_layer.wkbType())
        self.assertEqual(QgsWkbTypes.PointZ, test_layer_3d.wkbType())
        self.assertEqual(test_layer_3d.featureCount(), 51)
        test_layer_3d.startEditing()
        clean_table('test_ladm_col_3d', BOUNDARY_POINT_TABLE)
        test_layer_3d.dataProvider().truncate()

        # PointZ To PointZ
        print("Validating PointZ to PointZ")
        uri = self.gpkg_path + '|layername={layername}'.format(layername='points_Z')
        point_layer = QgsVectorLayer(uri, 'points', 'ogr')
        run_etl_model(point_layer, out_layer=test_layer_3d)
        print("Info: Validating geometry PointZ...", test_layer_3d.wkbType())
        self.assertEqual(QgsWkbTypes.PointGeometry, test_layer_3d.type())
        self.assertIn(point_layer.wkbType(), [QgsWkbTypes.PointZ, QgsWkbTypes.Point25D])
        self.assertEqual(QgsWkbTypes.PointZ, test_layer_3d.wkbType())
        self.assertEqual(test_layer_3d.featureCount(), 51)
        clean_table('test_ladm_col_3d', BOUNDARY_POINT_TABLE)
        test_layer_3d.dataProvider().truncate()

        # PointM To PointZ
        print("Validating PointM To PointZ")
        uri = self.gpkg_path + '|layername={layername}'.format(layername='points_M')
        point_layer = QgsVectorLayer(uri, 'points', 'ogr')
        run_etl_model(point_layer, out_layer=test_layer_3d)
        print("Info: Validating geometry PointZ...", test_layer_3d.wkbType())
        self.assertEqual(QgsWkbTypes.PointGeometry, test_layer_3d.type())
        self.assertEqual(QgsWkbTypes.PointM, point_layer.wkbType())
        self.assertEqual(QgsWkbTypes.PointZ, test_layer_3d.wkbType())
        self.assertEqual(test_layer_3d.featureCount(), 51)
        clean_table('test_ladm_col_3d', BOUNDARY_POINT_TABLE)
        test_layer_3d.dataProvider().truncate()

        # PointZM To PointZ
        print("Validating PointZM To PointZ")
        uri = self.gpkg_path + '|layername={layername}'.format(layername='points_ZM')
        point_layer = QgsVectorLayer(uri, 'points', 'ogr')
        run_etl_model(point_layer, out_layer=test_layer_3d)
        print("Info: Validating geometry PointZ...", test_layer_3d.wkbType())
        self.assertEqual(QgsWkbTypes.PointGeometry, test_layer_3d.type())
        self.assertEqual(QgsWkbTypes.PointZM, point_layer.wkbType())
        self.assertEqual(QgsWkbTypes.PointZ, test_layer_3d.wkbType())
        self.assertEqual(test_layer_3d.featureCount(), 51)
        clean_table('test_ladm_col_3d', BOUNDARY_POINT_TABLE)
        test_layer_3d.dataProvider().truncate()
Ejemplo n.º 8
0
    def test_copy_csv_overlapping_to_db(self):
        print('\nINFO: Validating copy csv overlapping to db')
        clean_table(SCHEMA_LADM_COL_EMPTY, self.names.OP_BOUNDARY_POINT_T)
        csv_path = get_test_path('csv/puntos_overlapping_v269.csv')
        txt_delimiter = ';'
        cbo_longitude = 'x'
        cbo_latitude = 'y'
        csv_layer = self.qgis_utils.csv_to_layer(csv_path, txt_delimiter,
                                                 cbo_longitude, cbo_latitude,
                                                 DEFAULT_EPSG)
        self.upload_points_from_csv_overlapping(csv_layer,
                                                SCHEMA_LADM_COL_EMPTY)
        self.validate_number_of_boundary_points_in_db(SCHEMA_LADM_COL_EMPTY, 0)

        test_layer = self.qgis_utils.get_layer(self.db_pg,
                                               self.names.OP_BOUNDARY_POINT_T,
                                               load=True)
        delete_features(test_layer)
        self.assertEqual(test_layer.featureCount(), 0)
Ejemplo n.º 9
0
    def test_copy_csv_to_db(self):
        print("\nINFO: Validating copy CSV points to DB...")
        clean_table(SCHEMA_LADM_COL_EMPTY, self.names.OP_BOUNDARY_POINT_T)
        self.qgis_utils.disable_automatic_fields(
            self.db_pg, self.names.OP_BOUNDARY_POINT_T)

        csv_path = get_test_path('csv/puntos_fixed_v296.csv')
        txt_delimiter = ';'
        cbo_longitude = 'x'
        cbo_latitude = 'y'
        csv_layer = self.qgis_utils.csv_to_layer(csv_path, txt_delimiter,
                                                 cbo_longitude, cbo_latitude,
                                                 DEFAULT_EPSG)
        self.upload_points_from_csv(csv_layer, SCHEMA_LADM_COL_EMPTY)

        self.validate_points_in_db(SCHEMA_LADM_COL_EMPTY)
        test_layer = self.qgis_utils.get_layer(self.db_pg,
                                               self.names.OP_BOUNDARY_POINT_T,
                                               load=True)
        delete_features(test_layer)
        self.assertEqual(test_layer.featureCount(), 0)
 def test_copy_csv_overlapping_to_db(self):
     clean_table('test_ladm_col', 'puntolindero')
     self.upload_points_from_csv_overlapping()
     self.validate_points_overlapping_in_db()
     clean_table('test_ladm_col', 'puntolindero')