#87 closed defect (worksforme)
Strange result of isValid() for LinearRing
Reported by: | mloskot | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | Core | Version: | main |
Severity: | Significant | Keywords: | imported, phpbugtracker |
Cc: |
Description (last modified by )
I'm getting strange result of isValid() call for non-empty, simple and closed LinearRing.
Here is a code of one of my tests for LinearRing:
// 1. Create non-empty sequence of coordiantes CoordinateArraySequence* pseq = new CoordinateArraySequence(); ensure( "sequence is null pointer.", pseq != 0 ); // 2. Add 4 points to get closed ring pseq->add(Coordinate(0, 0, 0)); pseq->add(Coordinate(5, 5, 5)); pseq->add(Coordinate(10, 10, 10)); pseq->add(Coordinate(0, 0, 0)); // <--- 1 ensure_equals( pseq->size(), 4 ); // 3. Create non-empty linearring instance geos::geom::LinearRing ring(pseq, &factory_); // 4. Simple tests ensure( !ring.isEmpty() ); ensure( ring.isClosed() ); ensure( ring.isRing() ); ensure( ring.isSimple() ); // 5. THIS TEST FAILS ensure( ring.isValid() ); // <--- 2
From my point of view, the code above seems to be valid. I add 4 points with first point repeated 1 at the end to get closed ring. Next, I create LinearRing instance and all tests pass besides isValid() in line 2.
I debugged step by step and what I revealed - and what seems to be quite strange for me - it that checkValid() operation called in IsValidOp::isValid() returns validError.
The error id is eRingSelfIntersection and the messge is "Ring Self-intersection".
In my opinion, the problem is in checkValid() function which validates LinearRing object incorrectly. I suppose that checkValid() recognizes first and last point of LinearRing as self-intersection.
I did a test with not adding the last repeated point in line 1 but then LinearRing ctor throws exception because isClosed() returns false.
Summary: The IsValidOp::checkValid(const Geometry *g) function needs to be checked for LinearRing geometries.
Change History (6)
comment:2 by , 18 years ago
Resolution: | none → not a bug |
---|
Steve, you're right. My mistake. I'm closing this bug with "Not a bug" resolution. I'm going to use this example to test isValid() for self-intersecting LinearRing :-)
comment:3 by , 16 years ago
Description: | modified (diff) |
---|---|
Milestone: | imported |
Reporter: | changed from | to
Resolution: | not a bug |
Status: | closed → reopened |
comment:4 by , 16 years ago
Resolution: | → worksforme |
---|---|
Status: | reopened → closed |
Version: | 3.0.0 → svn-trunk |
comment:5 by , 16 years ago
Milestone: | → 3.0.0 |
---|---|
Priority: | 3 → major |