Skip to content

Commit

Permalink
Merge branch 'release/0.8.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
cnheider committed Sep 24, 2024
2 parents 71e447b + d9a87f0 commit d5e3422
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion jord/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

__project__ = "Jord"
__author__ = "Christian Heider Lindbjerg"
__version__ = "0.8.1"
__version__ = "0.8.2"
__doc__ = r"""
.. module:: jord
:platform: Unix, Windows
Expand Down
27 changes: 22 additions & 5 deletions jord/qgis_utilities/layer_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,28 @@ def solve_type(d: Any) -> str:
return "string"


def solve_type_configuration(d: Any) -> Optional[str]:
def solve_type_configuration(
d: Any,
k: Optional[str],
columns: Optional[List],
allocation_multiplier: Optional[int] = 2,
) -> Optional[str]:
if isinstance(d, str):
a = len(d)
if True:
a *= 2

if k and columns:
max_len = a

if isinstance(columns, List):
for cols in columns:
c = cols[k]
if isinstance(c, str):
max_len = max(max_len, len(c))

a = max_len

if allocation_multiplier:
a *= allocation_multiplier

a = max(a, 255)
return str(a)
Expand Down Expand Up @@ -199,7 +216,7 @@ def add_qgis_single_feature_layer(
if columns:
fields = {k: solve_type(v) for k, v in columns}
field_type_configuration = {
k: solve_type_configuration(v) for k, v in columns.items()
k: solve_type_configuration(v, k, columns) for k, v in columns.items()
}
else:
fields = None
Expand Down Expand Up @@ -449,7 +466,7 @@ def add_qgis_multi_feature_layer(
if sample_row:
fields = {k: solve_type(v) for k, v in sample_row.items()}
field_type_configuration = {
k: solve_type_configuration(v) for k, v in sample_row.items()
k: solve_type_configuration(v, k, columns) for k, v in sample_row.items()
}
num_cols = len(sample_row)

Expand Down

0 comments on commit d5e3422

Please sign in to comment.