Skip to content

Commit

Permalink
Simplify code for PointLocation.isOnSegment
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-jts committed Apr 23, 2024
1 parent 11fae13 commit d4b654a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/algorithm/PointLocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,12 @@ PointLocation::isOnLine(const geom::CoordinateXY& p, const geom::CoordinateSeque
return false;
}

const geom::CoordinateXY* pp = &(pt->getAt<geom::CoordinateXY>(0));
for(std::size_t i = 1; i < ptsize; ++i) {
const geom::CoordinateXY& p1 = pt->getAt<geom::CoordinateXY>(i);
if(isOnSegment(p, *pp, p1)) {
if(isOnSegment(p,
pt->getAt<geom::CoordinateXY>(i - 1),
pt->getAt<geom::CoordinateXY>(i))) {
return true;
}
pp = &p1;
}
return false;
}
Expand Down

0 comments on commit d4b654a

Please sign in to comment.