diff --git a/mikecore/DfsFile.py b/mikecore/DfsFile.py index 8bb13b1..ba848f0 100644 --- a/mikecore/DfsFile.py +++ b/mikecore/DfsFile.py @@ -1649,7 +1649,11 @@ def GetItemSpatialAxis(itemPointer): ctypes.byref(y0), ctypes.byref(dx), ctypes.byref(dy)) - axis = DfsAxisEqD2(eumUnit(eumUnitInt.value), xCount.value, x0.value, dx.value, yCount.value, y0.value, dy.value) + try: + spatial_axis_unit = eumUnit(eumUnitInt.value) + except: + spatial_axis_unit = eumUnit.eumUmeter + axis = DfsAxisEqD2(spatial_axis_unit, xCount.value, x0.value, dx.value, yCount.value, y0.value, dy.value) return (axis) if axisType == SpaceAxisType.NeqD2: diff --git a/testdata/shoreline_profile.dfs2 b/testdata/shoreline_profile.dfs2 new file mode 100644 index 0000000..d70b8b5 Binary files /dev/null and b/testdata/shoreline_profile.dfs2 differ diff --git a/tests/test_shoreline.py b/tests/test_shoreline.py new file mode 100644 index 0000000..8d321c1 --- /dev/null +++ b/tests/test_shoreline.py @@ -0,0 +1,13 @@ +from mikecore.DfsFileFactory import DfsFileFactory + + +def test_read_shoreline_profile_dfs2(): + + + # this file has a problematic spatial axis unit + filename = "testdata/shoreline_profile.dfs2" + + dfs2File = DfsFileFactory.Dfs2FileOpen(filename) + + assert dfs2File.SpatialAxis.XCount == 300 + assert dfs2File.SpatialAxis.YCount == 120 \ No newline at end of file