Opened 7 years ago

Closed 7 years ago

#832 closed defect (fixed)

LinearLocation::isValid and LinearLocation::normalize, faulty comparisons

Reported by: nila Owned by: geos-devel@…
Priority: major Milestone:
Component: Default Version: main
Severity: Unassigned Keywords:
Cc:

Description

componentIndex and segmentIndex are declared as

unsigned int

in geos/linearref/LinearLocation.h:46-47, thus the comparisons, eg.

componentIndex < 0

made at linearref/LinearLocation.cpp:92, 98, 235 and 239 are always false.

Change History (5)

comment:1 by strk, 7 years ago

Can you try to add a test under tests/unit/linearref exposing a bad consequence of that always-false comparison ? It would be great to have the need-for-fix clearly shown and the later fix secured.

comment:2 by nila, 7 years ago

I cannot see the always-false comparison would introduce any bad conseqence as such. The code is a pretty straightforward port from JTS with the exception of componentIndex and segmentIndex being unsigned here, while they are signed in JTS. In JTS the comparisons are needed, but here they are redundant. The LinearLocation::normalize can therefore be reduced by 11 lines and 2 lines in LinearLocation::isValid can be shortened (and 4 Clang warnings can be silenced).

comment:3 by strk, 7 years ago

Sounds like a plan, up for a pull request ?

comment:4 by nila, 7 years ago

Just sent a pull request.

comment:5 by Sandro Santilli <strk@…>, 7 years ago

Resolution: fixed
Status: newclosed

In 16183469/git:

Remove redundant code

Closes #832

Note: See TracTickets for help on using tickets.