Transformers are using meta flags inconsistently when operating on coords
anthonynorth opened this issue · comments
Transformers are using meta flags inconsistently when operating on coords.
Lines 152 to 164 in 67f7013
I think the bug is line 158, which tests for the m
dimension being in the output. This results in garbage output in m
dimension, when use_m = TRUE
and input dimensions are xy
. The below reprex shows what I mean.
If my understanding is correct, fix is a 1-liner.
wk::wk_transform(
wk::xy(1,1),
wk::wk_trans_set(wk::xy(1, 1), use_m = TRUE)
)
#> <wk_xym[1]>
#> [1] M (1 1 4.526213e-315)
wk::wk_transform(
wk::xy(1,1),
wk::wk_trans_set(wk::xy(1, 1), use_z = TRUE)
)
#> <wk_xyz[1]>
#> [1] Z (1 1 NaN)
wk::wk_transform(
wk::xy(1,1),
wk::wk_trans_set(wk::xy(1, 1), use_m = TRUE, use_z = TRUE)
)
#> <wk_xyzm[1]>
#> [1] ZM (1 1 NaN 2.359942e-312)
wk::wk_transform(
wk::xy(1, 1),
PROJ::proj_trans_create("OGC:CRS84", "EPSG:3857", use_m = TRUE)
)
#> <wk_xym[1]>
#> [1] M (111319.5 111325.1 2.359942e-312)
wk::wk_transform(
wk::xy(1, 1),
PROJ::proj_trans_create("OGC:CRS84", "EPSG:3857", use_z = TRUE)
)
#> <wk_xyz[1]>
#> [1] Z (111319.5 111325.1 NaN)
wk::wk_transform(
wk::xy(1, 1),
PROJ::proj_trans_create("OGC:CRS84", "EPSG:3857", use_z = TRUE, use_m = TRUE)
)
#> <wk_xyzm[1]>
#> [1] ZM (111319.5 111325.1 NaN 2.359942e-312)
Created on 2024-03-06 with reprex v2.0.2
Thank you for tracking this down!