diff --git a/CHANGES.txt b/CHANGES.txt index 5692689..daf9e7b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,6 +1,10 @@ Changes ======= +0.7.3 (2022-09-26) +------------------ +- bc2pg - fully handle geometries with Z values (#114) and add a test to check + 0.7.2 (2022-09-26) ------------------ - bc2pg - handle geometries with Z values (#114) diff --git a/bcdata/database.py b/bcdata/database.py index 47cf243..d381f74 100644 --- a/bcdata/database.py +++ b/bcdata/database.py @@ -147,7 +147,7 @@ def define_table( # make everything multipart # (some datasets have mixed singlepart/multipart geometries) - if geom_type in ["POINT", "LINESTRING", "POLYGON"]: + if geom_type[:5] != "MULTI": geom_type = "MULTI" + geom_type columns.append(Column("geom", Geometry(geom_type, srid=3005))) meta = MetaData(bind=self.engine) diff --git a/tests/test_bc2pg.py b/tests/test_bc2pg.py index 61c5d6c..c7558df 100644 --- a/tests/test_bc2pg.py +++ b/tests/test_bc2pg.py @@ -10,6 +10,7 @@ VICTORIA_QUERY = "Victoria Harbour (Camel Point) Heliport" ASSESSMENTS_TABLE = "whse_fish.pscis_assessment_svw" TENURES_TABLE = "whse_tantalis.ta_crown_tenures_svw" +STREAMS_TABLE = "whse_basemapping.fwa_stream_networks_sp" def test_bc2pg(): @@ -40,6 +41,18 @@ def test_bc2pg_schema(): DB_CONNECTION.execute("drop schema testschema cascade") +def test_bc2pg_z(): + bcdata.bc2pg(STREAMS_TABLE, DB_URL, query="WATERSHED_GROUP_CODE='VICT'") + assert STREAMS_TABLE in DB_CONNECTION.tables + r = DB_CONNECTION.query( + """ + SELECT ST_NDims(geom) from whse_basemapping.fwa_stream_networks_sp limit 1 + """ + ) + assert r[0][0] == 3 + DB_CONNECTION.execute("drop table " + STREAMS_TABLE) + + def test_bc2pg_primary_key(): bcdata.bc2pg(ASSESSMENTS_TABLE, DB_URL, primary_key="stream_crossing_id", count=100) assert ASSESSMENTS_TABLE in DB_CONNECTION.tables