Skip to content

Commit

Permalink
fix tests saba,bonaire,st_eustatius (still nr of tests failing)
Browse files Browse the repository at this point in the history
  • Loading branch information
arbakker committed Jun 19, 2024
1 parent a9c0341 commit cead7b5
Show file tree
Hide file tree
Showing 14 changed files with 203 additions and 61 deletions.
1 change: 0 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"name": "Python: Debug Tests",
"type": "debugpy",
"request": "launch",
"module": "pytest",
"args": ["${file}"],
"purpose": ["debug-test"],
"console": "integratedTerminal",
Expand Down
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,27 @@ echo 'extends: "spectral:oas"\n'> ruleset.yaml && spectral lint http://127.0.0.

### Install NSGI proj.db

Execute the following shell one-liner to install the NSGI
Execute the following shell commands to install the NSGI
`proj.time.dependent.transformations.db` as `proj.db` from the
[GeodetischeInfrastructuur/transformations](https://github.com/GeodetischeInfrastructuur/transformations/releases)
repo:

```sh
NSGI_PROJ_DB_VERSION=$(sed -rn 's/ARG NSGI_PROJ_DB_VERSION="(.*)"/\1/p' < Dockerfile)
proj_data_dir=$(python3 -c 'import pyproj;print(pyproj.datadir.get_data_dir());')
curl -sL -o "${proj_data_dir}/nl_nsgi_nlgeo2018.tif" https://cdn.proj.org/nl_nsgi_nlgeo2018.tif && \
curl -sL -o "${proj_data_dir}/nl_nsgi_rdcorr2018.tif" https://cdn.proj.org/nl_nsgi_rdcorr2018.tif && \
curl -sL -o "${proj_data_dir}/nl_nsgi_rdtrans2018.tif" https://cdn.proj.org/nl_nsgi_rdtrans2018.tif && \
curl -sL -H "Accept: application/octet-stream" $(curl -s "https://api.github.com/repos/GeodetischeInfrastructuur/transformations/releases/latest" | jq -r '.assets[] | select(.name=="proj.time.dependent.transformations.db").url') -o "${proj_data_dir}/proj.db"

# ( cmd ) -> subshell to execute commands in $proj_data_dir without changing workdir of current shell
(
cd "$proj_data_dir"
echo $NSGI_PROJ_DB_VERSION
curl -sL -o nl_nsgi_nlgeo2018.tif https://cdn.proj.org/nl_nsgi_nlgeo2018.tif && \
curl -sL -o nl_nsgi_rdcorr2018.tif https://cdn.proj.org/nl_nsgi_rdcorr2018.tif && \
curl -sL -o nl_nsgi_rdtrans2018.tif https://cdn.proj.org/nl_nsgi_rdtrans2018.tif && \
curl -sL -H "Accept: application/octet-stream" $(curl -s "https://api.github.com/repos/GeodetischeInfrastructuur/transformations/releases/tags/${NSGI_PROJ_DB_VERSION}" | jq -r '.assets[] | select(.name=="bq_nsgi_bongeo2004.tif").url') -o bq_nsgi_bongeo2004.tif && \
curl -sL -H "Accept: application/octet-stream" $(curl -s "https://api.github.com/repos/GeodetischeInfrastructuur/transformations/releases/tags/${NSGI_PROJ_DB_VERSION}" | jq -r '.assets[] | select(.name=="nllat2018.gtx").url') -o nllat2018.gtx && \
curl -sL -H "Accept: application/octet-stream" $(curl -s "https://api.github.com/repos/GeodetischeInfrastructuur/transformations/releases/tags/${NSGI_PROJ_DB_VERSION}" | jq -r '.assets[] | select(.name=="proj.time.dependent.transformations.db").url') -o proj.db
)

```

> :warning: For 'default' usage, like QGIS, use the proj.db. The coordinate
Expand Down
12 changes: 5 additions & 7 deletions src/coordinate_transformation_api/crs_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@ def check_axis(s_crs: CRS, t_crs: CRS) -> None:
def get_transformer(
source_crs: CRS, target_crs: CRS, epoch: float | None
) -> Transformer: # quit

check_axis(source_crs, target_crs)

if exclude_transformation(
Expand All @@ -299,6 +298,7 @@ def get_transformer(
raise TransformationNotPossibleError(
"{}:{}".format(*source_crs.to_authority()),
"{}:{}".format(*target_crs.to_authority()),
"Transformation Excluded",
)

# Get available transformer through TransformerGroup
Expand Down Expand Up @@ -351,7 +351,6 @@ def get_individual_crs_from_compound(compound_crs: CRS) -> tuple[CRS, CRS]:


def build_input_coord(coord: CoordinatesType, epoch: float | None) -> CoordinatesType:

# When 2D input is given with an epoch we need to add a height. So pyproj knows to
# that the epoch is an epoch and not the height, without this intervention the epoch
# would be place in the firth position of the tuple.
Expand Down Expand Up @@ -404,17 +403,17 @@ def my_round(val: float, precision: int | None) -> float | int:
and target_crs.is_compound
and not source_crs.is_geocentric
):

check_axis(source_crs, target_crs)

target_crs_horizontal, target_crs_vertical = get_individual_crs_from_compound(
target_crs
)

if source_crs is not None and source_crs.is_compound:
source_crs_horizontal, source_crs_vertical = (
get_individual_crs_from_compound(source_crs)
)
(
source_crs_horizontal,
source_crs_vertical,
) = get_individual_crs_from_compound(source_crs)
else:
source_crs_horizontal = source_crs
source_crs_vertical = source_crs
Expand All @@ -441,7 +440,6 @@ def my_round(val: float, precision: int | None) -> float | int:
v_transformer = get_transformer(source_crs, target_crs, epoch)

def transform_compound_crs(val: CoordinatesType) -> tuple[float, ...]:

input = tuple([*val, float(epoch)]) if epoch is not None else tuple([*val])

h = tuple(
Expand Down
1 change: 0 additions & 1 deletion src/coordinate_transformation_api/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,6 @@ def check_crs_is_known(crs_str: str, crs_list: list[AvailableCrs]) -> None:
def transform_coordinates(
coordinates: Any, source_crs: CRS, target_crs: CRS, epoch
) -> Any:

precision = get_precision(target_crs)
coordinate_list: CoordinatesType = list(
float(x) for x in coordinates.split(",")
Expand Down
58 changes: 52 additions & 6 deletions tests/data/bonaire_validation_data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ NSGI:Bonaire_DPnet_KADpeil,NSGI:Bonaire2004_GEOCENTRIC,(23000.0 18000.0 10.0 200
NSGI:Bonaire_DPnet_KADpeil,NSGI:Bonaire2004_GEOGRAPHIC_2D,(23000.0 18000.0 10.0 2000)
NSGI:Bonaire_DPnet_KADpeil,NSGI:Bonaire2004_GEOGRAPHIC_3D,(23000.0 18000.0 10.0 2000)
NSGI:Bonaire_DPnet_KADpeil,EPSG:32619,(23000.0 18000.0 10.0 2000)
NSGI:Bonaire_DPnet_KADpeil,EPSG:7789EPSG:7912,(23000.0 18000.0 10.0 2000)
NSGI:Bonaire_DPnet_KADpeil,EPSG:7789,(23000.0 18000.0 10.0 2000)
NSGI:Bonaire_DPnet_KADpeil,EPSG:7912,(23000.0 18000.0 10.0 2000)
NSGI:Bonaire_DPnet_KADpeil,EPSG:4979,(23000.0 18000.0 10.0 2000)
NSGI:Bonaire_DPnet_KADpeil,OGC:CRS84h,(23000.0 18000.0 10.0 2000)
NSGI:Bonaire_DPnet,NSGI:Bonaire_DPnet_KADpeil,(23000.0 18000.0 10.0 2000)
Expand All @@ -13,7 +14,8 @@ NSGI:Bonaire_DPnet,NSGI:Bonaire2004_GEOCENTRIC,(23000.0 18000.0 10.0 2000)
NSGI:Bonaire_DPnet,NSGI:Bonaire2004_GEOGRAPHIC_2D,(23000.0 18000.0 10.0 2000)
NSGI:Bonaire_DPnet,NSGI:Bonaire2004_GEOGRAPHIC_3D,(23000.0 18000.0 10.0 2000)
NSGI:Bonaire_DPnet,EPSG:32619,(23000.0 18000.0 10.0 2000)
NSGI:Bonaire_DPnet,EPSG:7789EPSG:7912,(23000.0 18000.0 10.0 2000)
NSGI:Bonaire_DPnet,EPSG:7789,(23000.0 18000.0 10.0 2000)
NSGI:Bonaire_DPnet,EPSG:7912,(23000.0 18000.0 10.0 2000)
NSGI:Bonaire_DPnet,EPSG:4979,(23000.0 18000.0 10.0 2000)
NSGI:Bonaire_DPnet,OGC:CRS84h,(23000.0 18000.0 10.0 2000)
NSGI:Bonaire2004_GEOCENTRIC,NSGI:Bonaire_DPnet_KADpeil,(2310487.4256387297 -5792376.868331335 1333594.0149470181 2000.0)
Expand All @@ -22,7 +24,8 @@ NSGI:Bonaire2004_GEOCENTRIC,NSGI:Bonaire2004_GEOCENTRIC,(2310487.4256387297 -579
NSGI:Bonaire2004_GEOCENTRIC,NSGI:Bonaire2004_GEOGRAPHIC_2D,(2310487.4256387297 -5792376.868331335 1333594.0149470181 2000.0)
NSGI:Bonaire2004_GEOCENTRIC,NSGI:Bonaire2004_GEOGRAPHIC_3D,(2310487.4256387297 -5792376.868331335 1333594.0149470181 2000.0)
NSGI:Bonaire2004_GEOCENTRIC,EPSG:32619,(2310487.4256387297 -5792376.868331335 1333594.0149470181 2000.0)
NSGI:Bonaire2004_GEOCENTRIC,EPSG:7789EPSG:7912,(2310487.4256387297 -5792376.868331335 1333594.0149470181 2000.0)
NSGI:Bonaire2004_GEOCENTRIC,EPSG:7789,(2310487.4256387297 -5792376.868331335 1333594.0149470181 2000.0)
NSGI:Bonaire2004_GEOCENTRIC,EPSG:7912,(2310487.4256387297 -5792376.868331335 1333594.0149470181 2000.0)
NSGI:Bonaire2004_GEOCENTRIC,EPSG:4979,(2310487.4256387297 -5792376.868331335 1333594.0149470181 2000.0)
NSGI:Bonaire2004_GEOCENTRIC,OGC:CRS84h,(2310487.4256387297 -5792376.868331335 1333594.0149470181 2000.0)
NSGI:Bonaire2004_GEOGRAPHIC_2D,NSGI:Bonaire_DPnet_KADpeil,(-68.25372592339036 12.149707219957842 -15.309041996486485 2000.0)
Expand All @@ -31,7 +34,8 @@ NSGI:Bonaire2004_GEOGRAPHIC_2D,NSGI:Bonaire2004_GEOCENTRIC,(-68.25372592339036 1
NSGI:Bonaire2004_GEOGRAPHIC_2D,NSGI:Bonaire2004_GEOGRAPHIC_2D,(-68.25372592339036 12.149707219957842 -15.309041996486485 2000.0)
NSGI:Bonaire2004_GEOGRAPHIC_2D,NSGI:Bonaire2004_GEOGRAPHIC_3D,(-68.25372592339036 12.149707219957842 -15.309041996486485 2000.0)
NSGI:Bonaire2004_GEOGRAPHIC_2D,EPSG:32619,(-68.25372592339036 12.149707219957842 -15.309041996486485 2000.0)
NSGI:Bonaire2004_GEOGRAPHIC_2D,EPSG:7789EPSG:7912,(-68.25372592339036 12.149707219957842 -15.309041996486485 2000.0)
NSGI:Bonaire2004_GEOGRAPHIC_2D,EPSG:7789,(-68.25372592339036 12.149707219957842 -15.309041996486485 2000.0)
NSGI:Bonaire2004_GEOGRAPHIC_2D,EPSG:7912,(-68.25372592339036 12.149707219957842 -15.309041996486485 2000.0)
NSGI:Bonaire2004_GEOGRAPHIC_2D,EPSG:4979,(-68.25372592339036 12.149707219957842 -15.309041996486485 2000.0)
NSGI:Bonaire2004_GEOGRAPHIC_2D,OGC:CRS84h,(-68.25372592339036 12.149707219957842 -15.309041996486485 2000.0)
NSGI:Bonaire2004_GEOGRAPHIC_3D,NSGI:Bonaire_DPnet_KADpeil,(-68.25372592339036 12.149707219957842 -14.943562592521495 2000.0)
Expand All @@ -40,7 +44,8 @@ NSGI:Bonaire2004_GEOGRAPHIC_3D,NSGI:Bonaire2004_GEOCENTRIC,(-68.25372592339036 1
NSGI:Bonaire2004_GEOGRAPHIC_3D,NSGI:Bonaire2004_GEOGRAPHIC_2D,(-68.25372592339036 12.149707219957842 -14.943562592521495 2000.0)
NSGI:Bonaire2004_GEOGRAPHIC_3D,NSGI:Bonaire2004_GEOGRAPHIC_3D,(-68.25372592339036 12.149707219957842 -14.943562592521495 2000.0)
NSGI:Bonaire2004_GEOGRAPHIC_3D,EPSG:32619,(-68.25372592339036 12.149707219957842 -14.943562592521495 2000.0)
NSGI:Bonaire2004_GEOGRAPHIC_3D,EPSG:7789EPSG:7912,(-68.25372592339036 12.149707219957842 -14.943562592521495 2000.0)
NSGI:Bonaire2004_GEOGRAPHIC_3D,EPSG:7789,(-68.25372592339036 12.149707219957842 -14.943562592521495 2000.0)
NSGI:Bonaire2004_GEOGRAPHIC_3D,EPSG:7912,(-68.25372592339036 12.149707219957842 -14.943562592521495 2000.0)
NSGI:Bonaire2004_GEOGRAPHIC_3D,EPSG:4979,(-68.25372592339036 12.149707219957842 -14.943562592521495 2000.0)
NSGI:Bonaire2004_GEOGRAPHIC_3D,OGC:CRS84h,(-68.25372592339036 12.149707219957842 -14.943562592521495 2000.0)
EPSG:32619,NSGI:Bonaire_DPnet_KADpeil,(581195.7179742614 1343219.3518943014 -15.309041996486485 2000.0)
Expand All @@ -49,6 +54,47 @@ EPSG:32619,NSGI:Bonaire2004_GEOCENTRIC,(581195.7179742614 1343219.3518943014 -15
EPSG:32619,NSGI:Bonaire2004_GEOGRAPHIC_2D,(581195.7179742614 1343219.3518943014 -15.309041996486485 2000.0)
EPSG:32619,NSGI:Bonaire2004_GEOGRAPHIC_3D,(581195.7179742614 1343219.3518943014 -15.309041996486485 2000.0)
EPSG:32619,EPSG:32619,(581195.7179742614 1343219.3518943014 -15.309041996486485 2000.0)
EPSG:32619,EPSG:7789EPSG:7912,(581195.7179742614 1343219.3518943014 -15.309041996486485 2000.0)
EPSG:32619,EPSG:7789,(581195.7179742614 1343219.3518943014 -15.309041996486485 2000.0)
EPSG:32619,EPSG:7912,(581195.7179742614 1343219.3518943014 -15.309041996486485 2000.0)
EPSG:32619,EPSG:4979,(581195.7179742614 1343219.3518943014 -15.309041996486485 2000.0)
EPSG:32619,OGC:CRS84h,(581195.7179742614 1343219.3518943014 -15.309041996486485 2000.0)
EPSG:7789,NSGI:Bonaire_DPnet_KADpeil,(inf inf inf inf)
EPSG:7789,NSGI:Bonaire_DPnet,(inf inf inf inf)
EPSG:7789,NSGI:Bonaire2004_GEOCENTRIC,(inf inf inf inf)
EPSG:7789,NSGI:Bonaire2004_GEOGRAPHIC_2D,(inf inf inf inf)
EPSG:7789,NSGI:Bonaire2004_GEOGRAPHIC_3D,(inf inf inf inf)
EPSG:7789,EPSG:32619,(inf inf inf inf)
EPSG:7789,EPSG:7789,(inf inf inf inf)
EPSG:7789,EPSG:7912,(inf inf inf inf)
EPSG:7789,EPSG:4979,(inf inf inf inf)
EPSG:7789,OGC:CRS84h,(inf inf inf inf)
EPSG:7912,NSGI:Bonaire_DPnet_KADpeil,(inf inf inf inf)
EPSG:7912,NSGI:Bonaire_DPnet,(inf inf inf inf)
EPSG:7912,NSGI:Bonaire2004_GEOCENTRIC,(inf inf inf inf)
EPSG:7912,NSGI:Bonaire2004_GEOGRAPHIC_2D,(inf inf inf inf)
EPSG:7912,NSGI:Bonaire2004_GEOGRAPHIC_3D,(inf inf inf inf)
EPSG:7912,EPSG:32619,(inf inf inf inf)
EPSG:7912,EPSG:7789,(inf inf inf inf)
EPSG:7912,EPSG:7912,(inf inf inf inf)
EPSG:7912,EPSG:4979,(inf inf inf inf)
EPSG:7912,OGC:CRS84h,(inf inf inf inf)
EPSG:4979,NSGI:Bonaire_DPnet_KADpeil,(-68.2537259371291 12.14970719200454 -40.252278505824506 2000.0)
EPSG:4979,NSGI:Bonaire_DPnet,(-68.2537259371291 12.14970719200454 -40.252278505824506 2000.0)
EPSG:4979,NSGI:Bonaire2004_GEOCENTRIC,(-68.2537259371291 12.14970719200454 -40.252278505824506 2000.0)
EPSG:4979,NSGI:Bonaire2004_GEOGRAPHIC_2D,(-68.2537259371291 12.14970719200454 -40.252278505824506 2000.0)
EPSG:4979,NSGI:Bonaire2004_GEOGRAPHIC_3D,(-68.2537259371291 12.14970719200454 -40.252278505824506 2000.0)
EPSG:4979,EPSG:32619,(-68.2537259371291 12.14970719200454 -40.252278505824506 2000.0)
EPSG:4979,EPSG:7789,(-68.2537259371291 12.14970719200454 -40.252278505824506 2000.0)
EPSG:4979,EPSG:7912,(-68.2537259371291 12.14970719200454 -40.252278505824506 2000.0)
EPSG:4979,EPSG:4979,(-68.2537259371291 12.14970719200454 -40.252278505824506 2000.0)
EPSG:4979,OGC:CRS84h,(-68.2537259371291 12.14970719200454 -40.252278505824506 2000.0)
OGC:CRS84h,NSGI:Bonaire_DPnet_KADpeil,(-68.2537259371291 12.149707191615798 -40.2522831344977 2000.0)
OGC:CRS84h,NSGI:Bonaire_DPnet,(-68.2537259371291 12.149707191615798 -40.2522831344977 2000.0)
OGC:CRS84h,NSGI:Bonaire2004_GEOCENTRIC,(-68.2537259371291 12.149707191615798 -40.2522831344977 2000.0)
OGC:CRS84h,NSGI:Bonaire2004_GEOGRAPHIC_2D,(-68.2537259371291 12.149707191615798 -40.2522831344977 2000.0)
OGC:CRS84h,NSGI:Bonaire2004_GEOGRAPHIC_3D,(-68.2537259371291 12.149707191615798 -40.2522831344977 2000.0)
OGC:CRS84h,EPSG:32619,(-68.2537259371291 12.149707191615798 -40.2522831344977 2000.0)
OGC:CRS84h,EPSG:7789,(-68.2537259371291 12.149707191615798 -40.2522831344977 2000.0)
OGC:CRS84h,EPSG:7912,(-68.2537259371291 12.149707191615798 -40.2522831344977 2000.0)
OGC:CRS84h,EPSG:4979,(-68.2537259371291 12.149707191615798 -40.2522831344977 2000.0)
OGC:CRS84h,OGC:CRS84h,(-68.2537259371291 12.149707191615798 -40.2522831344977 2000.0)
Loading

0 comments on commit cead7b5

Please sign in to comment.