Skip to content

Commit

Permalink
Remove dependncy on GPKG driver for GDAL
Browse files Browse the repository at this point in the history
Less dependencies is always good, this one was hardly being used.
  • Loading branch information
olsen232 committed Oct 2, 2022
1 parent 9ba0c19 commit f6e4ff4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
18 changes: 2 additions & 16 deletions kart/tabular/working_copy/gpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,24 +191,10 @@ def status(self, check_if_dirty=False, allow_unconnectable=False):
return result

def create_and_initialise(self):
# GDAL: Create GeoPackage
# GDAL: Add metadata/etc
gdal_driver = gdal.GetDriverByName("GPKG")
gdal_ds = gdal_driver.Create(str(self.full_path), 0, 0, 0, gdal.GDT_Unknown)
del gdal_ds

with self.session() as sess:
# Remove placeholder stuff GDAL creates
sess.execute(
"DELETE FROM gpkg_geometry_columns WHERE table_name='ogr_empty_table';"
)
sess.execute(
"DELETE FROM gpkg_contents WHERE table_name='ogr_empty_table';"
)
sess.execute("DROP TABLE IF EXISTS ogr_empty_table;")

# Create metadata tables
# Create standard GPKG tables:
GpkgTables().create_all(sess)
# Create Kart-specific tables:
self.kart_tables.create_all(sess)

def _create_table_for_dataset(self, sess, dataset):
Expand Down
11 changes: 7 additions & 4 deletions kart/tabular/working_copy/table_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@


class TinyInt(Integer):
__visit_name__ = "TINYINT"
def visit(self):
return "TINYINT"


class Double(Float):
__visit_name__ = "DOUBLE"
def visit(self):
return "DOUBLE"


class DateTime(Text):
__visit_name__ = "DATETIME"
def visit(self):
return "DATETIME"


STATE = "state"
Expand Down Expand Up @@ -183,7 +186,7 @@ def __init__(self):
Column(
"srs_id",
Integer,
ForeignKey("gpkg_spatial_ref_sys.srd_id", name="fk_gc_r_srs_id"),
ForeignKey("gpkg_spatial_ref_sys.srs_id", name="fk_gc_r_srs_id"),
),
)

Expand Down

0 comments on commit f6e4ff4

Please sign in to comment.