Skip to content

Commit

Permalink
fix type map bug and add test downloading streams
Browse files Browse the repository at this point in the history
  • Loading branch information
smnorris committed Sep 26, 2022
1 parent ac67fc1 commit ad58faf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion bcdata/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions tests/test_bc2pg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ad58faf

Please sign in to comment.