Skip to content

Commit

Permalink
pass property if multigeom in geopackage to GpkgLayerUri member inste…
Browse files Browse the repository at this point in the history
…ad to pass to every function
  • Loading branch information
signedav committed Oct 30, 2024
1 parent cdd3176 commit c64340b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
5 changes: 3 additions & 2 deletions modelbaker/db_factory/gpkg_layer_uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ class GpkgLayerUri(LayerUri):
def __init__(self, uri: str) -> None:
LayerUri.__init__(self, uri)
self.provider = "ogr"
self.gpkg_multigeom = False

def get_data_source_uri(self, record: dict, multigeom: bool) -> str:
def get_data_source_uri(self, record: dict) -> str:
data_source_uri = "{uri}|layername={table}".format(
uri=self.uri, table=record["tablename"]
)
if multigeom:
if self.gpkg_multigeom:
data_source_uri = "{} ({})".format(
data_source_uri, record["geometry_column"]
)
Expand Down
2 changes: 1 addition & 1 deletion modelbaker/db_factory/layer_uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, uri: str) -> None:
self.provider = None

@abstractmethod
def get_data_source_uri(self, record: dict, multigeom: bool) -> str:
def get_data_source_uri(self, record: dict) -> str:
"""Provides layer uri based on database uri and specific information of the data source.
:param str record: Dictionary containing specific information of the data source.
Expand Down
2 changes: 1 addition & 1 deletion modelbaker/db_factory/mssql_layer_uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, uri: str) -> None:
LayerUri.__init__(self, uri)
self.provider = "mssql"

def get_data_source_uri(self, record: dict, multigeom: bool) -> str:
def get_data_source_uri(self, record: dict) -> str:
if record["geometry_column"]:
data_source_uri = '{uri} key={primary_key} estimatedmetadata=true srid={srid} type={type} table="{schema}"."{table}" ({geometry_column}) sql='.format(
uri=self._get_layer_uri_common(),
Expand Down
2 changes: 1 addition & 1 deletion modelbaker/db_factory/pg_layer_uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, uri: str) -> None:
self.pg_estimated_metadata = False
self.provider = "postgres"

def get_data_source_uri(self, record: dict, multigeom: bool) -> str:
def get_data_source_uri(self, record: dict) -> str:
if record["geometry_column"]:
str_pg_estimated_metadata = (
"true" if self.pg_estimated_metadata else "false"
Expand Down
13 changes: 6 additions & 7 deletions modelbaker/generator/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,14 @@ def layers(self, filter_layer_list: list = []) -> list[Layer]:
if coord_decimals:
coordinate_precision = 1 / (10**coord_decimals)

layer_uri.gpkg_multigeom = bool(
table_appearance_count[record["tablename"]] > 1
and "geometry_column" in record
)

layer = Layer(
layer_uri.provider,
layer_uri.get_data_source_uri(
record,
bool(
table_appearance_count[record["tablename"]] > 1
and "geometry_column" in record
),
),
layer_uri.get_data_source_uri(record),
record.get("tablename"),
record.get("srid"),
record.get("extent"),
Expand Down

0 comments on commit c64340b

Please sign in to comment.