Skip to content

Commit

Permalink
Revert renaming of param field to chainage
Browse files Browse the repository at this point in the history
  • Loading branch information
plimkilde committed Jan 6, 2025
1 parent 875a444 commit 5606eb7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions rivertopo/snapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

ogr.UseExceptions()

SnapResult = namedtuple('SnapResult', ['feature', 'segment', 'chainage', 'offset'])
SnapResult = namedtuple('SnapResult', ['feature', 'segment', 'param', 'offset'])

def snap_points(points, feature_id, linestring):
"""
Expand Down Expand Up @@ -57,7 +57,7 @@ def snap_points(points, feature_id, linestring):
snap_results.append(SnapResult(
feature=feature_id,
segment=closest_segment_index,
chainage=linestring_vector_projparams[closest_segment_index],
param=linestring_vector_projparams[closest_segment_index],
offset=offset,
))

Expand Down
8 changes: 4 additions & 4 deletions tests/test_snapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ def test_snap_points():
])

expected_results = [
SnapResult(feature=42, segment=0, chainage=0.28, offset=-0.2),
SnapResult(feature=42, segment=1, chainage=0.25, offset=-0.5),
SnapResult(feature=42, segment=1, chainage=0.75, offset=0.5),
SnapResult(feature=42, segment=0, param=0.28, offset=-0.2),
SnapResult(feature=42, segment=1, param=0.25, offset=-0.5),
SnapResult(feature=42, segment=1, param=0.75, offset=0.5),
]

snap_results = snap_points(points, feature_id, linestring)

assert [actual.feature for actual in snap_results] == [expected.feature for expected in expected_results]
assert [actual.segment for actual in snap_results] == [expected.segment for expected in expected_results]
assert np.allclose([actual.chainage for actual in snap_results], [expected.chainage for expected in expected_results])
assert np.allclose([actual.param for actual in snap_results], [expected.param for expected in expected_results])
assert np.allclose([actual.offset for actual in snap_results], [expected.offset for expected in expected_results])

0 comments on commit 5606eb7

Please sign in to comment.