Skip to content

Commit

Permalink
rename _precision -> _digits reflecting accuracy of the constant (#123)
Browse files Browse the repository at this point in the history
Co-authored-by: Jochem-L <[email protected]>
  • Loading branch information
WouterVisscher and Jochem-L authored Feb 8, 2024
1 parent 4dfd9bf commit 62c5c9b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/coordinate_transformation_api/constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DEFAULT_PRECISION = 4
HEIGHT_PRECISION = (
DEFAULT_DIGITS_FOR_ROUNDING = 4
HEIGHT_DIGITS_FOR_ROUNDING = (
4 # height will always be in metres, therefor fixed precision of 4 decimals
)
DENSIFY_CRS_2D = "EPSG:9067"
Expand Down
14 changes: 7 additions & 7 deletions src/coordinate_transformation_api/crs_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

from coordinate_transformation_api import assets
from coordinate_transformation_api.constants import (
DEFAULT_PRECISION,
HEIGHT_PRECISION,
DEFAULT_DIGITS_FOR_ROUNDING,
HEIGHT_DIGITS_FOR_ROUNDING,
THREE_DIMENSIONAL,
TWO_DIMENSIONAL,
)
Expand All @@ -41,8 +41,8 @@
def get_precision(target_crs_crs: MyCrs) -> int:
unit = target_crs_crs.get_x_unit_crs()
if unit == "degree":
return DEFAULT_PRECISION + 5
return DEFAULT_PRECISION
return DEFAULT_DIGITS_FOR_ROUNDING + 5
return DEFAULT_DIGITS_FOR_ROUNDING


def get_shapely_objects(
Expand Down Expand Up @@ -376,13 +376,13 @@ def transform_compound_crs(val: CoordinatesType) -> tuple[float, ...]:

h = tuple(
[
float(my_round(x, DEFAULT_PRECISION))
float(my_round(x, DEFAULT_DIGITS_FOR_ROUNDING))
for x in h_transformer.transform(*input)
]
)
v = tuple(
[
float(my_round(x, HEIGHT_PRECISION))
float(my_round(x, HEIGHT_DIGITS_FOR_ROUNDING))
for x in v_transformer.transform(*input)
]
)
Expand Down Expand Up @@ -433,7 +433,7 @@ def transform_crs(val: CoordinatesType) -> tuple[float, ...]:
)

if len(output) >= THREE_DIMENSIONAL:
height = my_round(output[2:3][0], HEIGHT_PRECISION)
height = my_round(output[2:3][0], HEIGHT_DIGITS_FOR_ROUNDING)
return output[0:2] + tuple(
[height],
)
Expand Down

0 comments on commit 62c5c9b

Please sign in to comment.