Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PrecisionReducer test for CoordinateSequence.add bug #962

Merged
merged 1 commit into from Sep 22, 2023

Conversation

dr-jts
Copy link
Contributor

@dr-jts dr-jts commented Sep 21, 2023

Issue #811 is caused by a bug in a CoordinateSequence::add method, which is called from SegmentNodeList.addEdgeCoordinates during snap-rounding noding. #963 fixes this issue.

This PR adds a unit test using the case in #811.

Demonstration of Bug

If the original code is used with the debug trace statements in SegmentNodeList.addEdgeCoordinates, the test:

bin/test_geos_unit geos::operation::overlayng::PrecisionReducer 15

produces:

addEdgeCoordinates: (127.117461568 34.562519572, 127.117461568 34.562519572)
updated coord list: (127.117461568 34.562519572)

addEdgeCoordinates: (127.117461568 34.562519572, 127.117483252 34.5624884690001, 127.117603304 34.562319127, 127.117607012 34.562312359)
updated coord list: (127.117461568 34.562519572, 127.117483252 34.5624884690001, 127.117603304 34.562319127, 127.117607012 34.562312359)

addEdgeCoordinates: (127.117607012 34.562312359, 127.117607152 34.562312309, 127.117607012 34.562312359, 127.117254733 34.5621607510001, 127.117746661 34.5620659730001, 127.117603496 34.5623196400001, 127.117484065 34.562488982, 127.117462315 34.562520066, 127.117461568 34.562519572)
updated coord list: (127.117461568 34.562519572, 127.117483252 34.5624884690001, 127.117603304 34.562319127, 127.117607012 34.562312359, 127.117607152 34.562312309, 127.117254733 34.5621607510001, 127.117746661 34.5620659730001, 127.117603496 34.5623196400001, 127.117484065 34.562488982, 127.117462315 34.562520066, 127.117461568 34.562519572)

addEdgeCoordinates: (127.117461568 34.562519572, 127.117245225 34.562385186, 127.117461568 34.562519572)
updated coord list: (127.117461568 34.562519572, 127.117483252 34.5624884690001, 127.117603304 34.562319127, 127.117607012 34.562312359, 127.117607152 34.562312309, 127.117254733 34.5621607510001, 127.117746661 34.5620659730001, 127.117603496 34.5623196400001, 127.117484065 34.562488982, 127.117462315 34.562520066, 127.117461568 34.562519572, 127.117245225 34.562385186)

geos::operation::overlayng::PrecisionReducer: [15=X]

---> group: geos::operation::overlayng::PrecisionReducer, test: test<15>
     problem: unexpected exception
     exception typeid: N4geos4util17TopologyExceptionE
     message: `TopologyException: Ring edge missing at 127.11745999999999 34.562519999999999`

Note that in the final call to addEdgeCoordinates the last coordinate 127.117461568 34.562519572 of the added coordinates is not present in the result coordinates.

Using the new code the trace is:

addEdgeCoordinates: (127.117461568 34.562519572, 127.117461568 34.562519572)
updated coord list: (127.117461568 34.562519572)

addEdgeCoordinates: (127.117461568 34.562519572, 127.117483252 34.5624884690001, 127.117603304 34.562319127, 127.117607012 34.562312359)
updated coord list: (127.117461568 34.562519572, 127.117483252 34.5624884690001, 127.117603304 34.562319127, 127.117607012 34.562312359)

addEdgeCoordinates: (127.117607012 34.562312359, 127.117607152 34.562312309, 127.117607012 34.562312359, 127.117254733 34.5621607510001, 127.117746661 34.5620659730001, 127.117603496 34.5623196400001, 127.117484065 34.562488982, 127.117462315 34.562520066, 127.117461568 34.562519572)
updated coord list: (127.117461568 34.562519572, 127.117483252 34.5624884690001, 127.117603304 34.562319127, 127.117607012 34.562312359, 127.117607152 34.562312309, 127.117607012 34.562312359, 127.117254733 34.5621607510001, 127.117746661 34.5620659730001, 127.117603496 34.5623196400001, 127.117484065 34.562488982, 127.117462315 34.562520066, 127.117461568 34.562519572)

addEdgeCoordinates: (127.117461568 34.562519572, 127.117245225 34.562385186, 127.117461568 34.562519572)
updated coord list: (127.117461568 34.562519572, 127.117483252 34.5624884690001, 127.117603304 34.562319127, 127.117607012 34.562312359, 127.117607152 34.562312309, 127.117607012 34.562312359, 127.117254733 34.5621607510001, 127.117746661 34.5620659730001, 127.117603496 34.5623196400001, 127.117484065 34.562488982, 127.117462315 34.562520066, 127.117461568 34.562519572, 127.117245225 34.562385186, 127.117461568 34.562519572)

geos::operation::overlayng::PrecisionReducer: .

tests summary: ok:1

Fixes #811.

@dr-jts dr-jts requested a review from dbaston September 21, 2023 18:31
@dr-jts dr-jts added the Bug label Sep 21, 2023
@dr-jts dr-jts marked this pull request as draft September 21, 2023 18:32
@dbaston
Copy link
Member

dbaston commented Sep 21, 2023

Are you planning to extract a CoordinateSequence test case, or should I do that?

@dr-jts
Copy link
Contributor Author

dr-jts commented Sep 21, 2023 via email

@dr-jts dr-jts changed the title Fix PrecisionReducer bug in CoordinateSequence.add Add PrecisionReducer test for CoordinateSequence.add bug Sep 22, 2023
@dr-jts dr-jts removed the request for review from dbaston September 22, 2023 02:22
@dr-jts dr-jts marked this pull request as ready for review September 22, 2023 02:22
@dr-jts dr-jts merged commit d51982c into libgeos:main Sep 22, 2023
27 checks passed
@dr-jts dr-jts deleted the fix-precisionreducer branch September 22, 2023 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: valid geometry fails with topology error in GEOSGeom_setPrecision
2 participants