Skip to content

Commit cbd4b5c

Browse files
authored
Don't crash when we have horizontal only (#170)
* Don't crash when we have horizontal only * rm test for components
1 parent b1ba6a4 commit cbd4b5c

4 files changed

Lines changed: 32 additions & 27 deletions

File tree

src/transformez/api.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -223,22 +223,24 @@ def build_components(
223223
vertical = None
224224
if source.vertical or target.vertical:
225225
if source.vertical is None or target.vertical is None:
226-
raise ValueError("Both source and target vertical references are required.")
227-
228-
vertical = build_shift_grid(
229-
region=region_obj,
230-
increment=increment,
231-
datum_in=src_srs,
232-
datum_out=dst_srs,
233-
cache_dir=cache_dir,
234-
**vertical_options,
235-
)
236-
237-
if source.horizontal is not None:
238-
vertical = vertical.reproject(
239-
source.horizontal,
240-
dst_region=region_obj,
226+
logger.debug(
227+
f"Both source and target vertical references are required. {source.vertical} -> {target.vertical}"
241228
)
229+
else:
230+
vertical = build_shift_grid(
231+
region=region_obj,
232+
increment=increment,
233+
datum_in=src_srs,
234+
datum_out=dst_srs,
235+
cache_dir=cache_dir,
236+
**vertical_options,
237+
)
238+
239+
if source.horizontal is not None:
240+
vertical = vertical.reproject(
241+
source.horizontal,
242+
dst_region=region_obj,
243+
)
242244

243245
return TransformationComponents(
244246
horizontal=horizontal,

src/transformez/engines/htdp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131

3232
InstallScope = Literal["user", "project"]
33-
DEFAULT_HTDP_VERSION = "3.6.0"
33+
DEFAULT_HTDP_VERSION = "3.5.0"
3434

3535

3636
class HTDPInstallError(RuntimeError):

src/transformez/reference/bindings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ class HtdpFrameBinding:
327327
reference_id="epsg:5869",
328328
engine="vdatum_grid",
329329
provider="vdatum",
330-
provider_datum="mhhm",
330+
provider_datum="mhhw",
331331
native_frame="EPSG:6319",
332332
default_model="g2018",
333333
global_proxy="global:hat",

tests/test_components.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,16 @@ def test_build_components_vertical_is_aligned_to_source_crs(monkeypatch):
103103
assert kwargs["dst_region"] is region
104104

105105

106-
def test_build_components_requires_both_vertical_references():
107-
with pytest.raises(
108-
ValueError,
109-
match="Both source and target vertical references are required",
110-
):
111-
build_components(
112-
"EPSG:4326+3855",
113-
"EPSG:4326",
114-
region=_region(),
115-
)
106+
# Removing this test for now; i don't think we should crash here when
107+
# we're building components to allow just the horizontal component
108+
# to be built and returned...
109+
# def test_build_components_requires_both_vertical_references():
110+
# with pytest.raises(
111+
# ValueError,
112+
# match="Both source and target vertical references are required",
113+
# ):
114+
# build_components(
115+
# "EPSG:4326+3855",
116+
# "EPSG:4326",
117+
# region=_region(),
118+
# )

0 commit comments

Comments
 (0)