Skip to content

Commit d4d3d4d

Browse files
committed
Add get_columns hook
1 parent ba53089 commit d4d3d4d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

vecorel_cli/conversion/base.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class BaseConverter(LoggerMixin):
5151
variants: dict[str, Sources] = {}
5252
variant: Optional[str] = None
5353

54-
columns: dict[str, str|Sequence[str]] = {}
54+
columns: dict[str, str | Sequence[str]] = {}
5555
column_additions: dict[str, str] = {}
5656
column_filters: dict[str, Callable] = {}
5757
column_migrations: dict[str, Callable] = {}
@@ -83,6 +83,9 @@ def layer_filter(self, layer: str, uri: str) -> bool:
8383
def post_migrate(self, gdf: GeoDataFrame) -> GeoDataFrame:
8484
return gdf
8585

86+
def get_columns(self, gdf: GeoDataFrame) -> dict[str, str | Sequence[str]]:
87+
return self.columns.copy()
88+
8689
def get_cache(self, cache_folder=None, **kwargs) -> tuple[AbstractFileSystem, str]:
8790
if cache_folder is None:
8891
_kwargs = {}
@@ -338,7 +341,8 @@ def convert(
338341
self.info("Applying global migrations")
339342
gdf = self.migrate(gdf)
340343
assert isinstance(gdf, GeoDataFrame), "Migration function must return a GeoDataFrame"
341-
columns = self.columns.copy()
344+
345+
columns = self.get_columns(gdf)
342346

343347
# 2. Run filters to remove rows that shall not be in the final data
344348
gdf = self.filter_rows(gdf)

0 commit comments

Comments
 (0)