Opened 7 years ago
Closed 7 years ago
#832 closed defect (fixed)
LinearLocation::isValid and LinearLocation::normalize, faulty comparisons
Reported by: | nila | Owned by: | |
---|---|---|---|
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 , 7 years ago
comment:2 by , 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).
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.