diff --git a/doc/CHANGES.txt b/doc/CHANGES.txt index 2f54c375..10a87f59 100644 --- a/doc/CHANGES.txt +++ b/doc/CHANGES.txt @@ -6,6 +6,7 @@ ideas/open issues iox-ili 1.21.18 (SNAPSHOT) ----------------------------- - Iox2wkb/RingCollector: fix issues with duplicate coordinates (ili2db#510) +- Iox2wkb/RingCollector: fix issue with inner boundary with arcs continued by outer boundary with straights (ili2db#510) iox-ili 1.21.17 (2023-02-22) ----------------------------- diff --git a/src/main/java/ch/interlis/iox_j/wkb/LineSegment.java b/src/main/java/ch/interlis/iox_j/wkb/LineSegment.java index d2e27d8b..841dad51 100644 --- a/src/main/java/ch/interlis/iox_j/wkb/LineSegment.java +++ b/src/main/java/ch/interlis/iox_j/wkb/LineSegment.java @@ -66,7 +66,10 @@ public int size(){ public LineSegment splitTailAt(Coordinate coordinate){ int pos = coordinatesMap.get(coordinate); if (pos == coordinates.size() - 1) return null; - + if(pos!=0 && pos%2==0 && wkbType==WKBConstants.wkbCircularString) { + throw new IllegalArgumentException("A mid-point of an ARC can not start a ring "+coordinate.toString()); + } + List tail = coordinates.subList(pos, coordinates.size()); LineSegment result = new LineSegment(wkbType); diff --git a/src/main/java/ch/interlis/iox_j/wkb/RingCollector.java b/src/main/java/ch/interlis/iox_j/wkb/RingCollector.java index 4f0aea57..f0137c86 100644 --- a/src/main/java/ch/interlis/iox_j/wkb/RingCollector.java +++ b/src/main/java/ch/interlis/iox_j/wkb/RingCollector.java @@ -86,7 +86,15 @@ else if (repairSelfTouchingRing && getSegmentIdx(getCurrentRing(),coordinate)!=n } segment = getCurrentSegment(); - segment.add(coordinate); + // different/new segment required? + if (!segment.trySetWkbType(WkbType)) { + Coordinate lastCoord = segment.getLast(); + segment = new LineSegment(WkbType); + segment.add(lastCoord); + ring.add(segment); + }else { + segment.add(coordinate); + } } private void extractInnerRing(Coordinate coordinate) { @@ -106,7 +114,6 @@ private void extractInnerRing(Coordinate coordinate) { } extractedRing.get(extractedRing.size() - 1).add(coordinate); - rings.add(extractedRing); } diff --git a/src/main/java/ch/interlis/iox_j/wkb/Wkb2iox.java b/src/main/java/ch/interlis/iox_j/wkb/Wkb2iox.java index 5c29dc60..fb79991c 100644 --- a/src/main/java/ch/interlis/iox_j/wkb/Wkb2iox.java +++ b/src/main/java/ch/interlis/iox_j/wkb/Wkb2iox.java @@ -324,7 +324,7 @@ private IomObject readCompoundCurve() throws IOException }else{ IomObject arcPt=readPoint();coordi++; if(coordi>=coordc){ - throw new IllegalStateException("missing coord"); + throw new IllegalStateException("missing coord (arcPt "+arcPt.toString()+")"); } IomObject endPt=readPoint(); endPt.setobjecttag(Iom_jObject.ARC); diff --git a/src/test/java/ch/interlis/iox_j/wkb/Iox2wkbTest.java b/src/test/java/ch/interlis/iox_j/wkb/Iox2wkbTest.java index 854498b3..15542ddb 100644 --- a/src/test/java/ch/interlis/iox_j/wkb/Iox2wkbTest.java +++ b/src/test/java/ch/interlis/iox_j/wkb/Iox2wkbTest.java @@ -473,9 +473,9 @@ public void surfaceReapirTouchingRingMultipleInnerRingSegments() throws Exceptio // verify Wkb2iox test=new Wkb2iox(); - assertEquals("MULTISURFACE {surface SURFACE {boundary [BOUNDARY {polyline POLYLINE {sequence SEGMENTS {segment [COORD {C1 2645116.0, C2 1247903.0}, COORD {C1 2650896.0, C2 1245677.0}, COORD {C1 2650921.0, C2 1247915.0}, COORD {C1 2650921.0, C2 1247915.0}, COORD {C1 2650921.0, C2 1250572.0}, COORD {C1 2645116.0, C2 1247903.0}]}}}, BOUNDARY {polyline POLYLINE {sequence SEGMENTS {segment [COORD {C1 2650921.0, C2 1247915.0}, ARC {A1 2649853.0, A2 1247123.0, C1 2648651.0, C2 1247238.0}, COORD {C1 2648618.0, C2 1248913.0}, ARC {A1 2649677.0, A2 1248889.0, C1 2650921.0, C2 1247915.0}]}}}]}}",test.read(wkb).toString()); + assertEquals("MULTISURFACE {surface SURFACE {boundary [BOUNDARY {polyline POLYLINE {sequence SEGMENTS {segment [COORD {C1 2645116.0, C2 1247903.0}, COORD {C1 2650896.0, C2 1245677.0}, COORD {C1 2650921.0, C2 1247915.0}, COORD {C1 2650921.0, C2 1250572.0}, COORD {C1 2645116.0, C2 1247903.0}]}}}, BOUNDARY {polyline POLYLINE {sequence SEGMENTS {segment [COORD {C1 2650921.0, C2 1247915.0}, ARC {A1 2649853.0, A2 1247123.0, C1 2648651.0, C2 1247238.0}, COORD {C1 2648618.0, C2 1248913.0}, ARC {A1 2649677.0, A2 1248889.0, C1 2650921.0, C2 1247915.0}]}}}]}}",test.read(wkb).toString()); String wkbText=Iox2wkb.bytesToHex(wkb); - assertEquals("000000000A0000000200000000090000000100000000020000000641442E3E0000000041330A9F000000004144398800000000413301ED00000000414439948000000041330AAB00000000414439948000000041330AAB0000000041443994800000004133150C0000000041442E3E0000000041330A9F00000000000000000900000003000000000800000003414439948000000041330AAB000000004144377E8000000041330793000000004144352580000000413308060000000000000000020000000241443525800000004133080600000000414435150000000041330E9100000000000000000800000003414435150000000041330E9100000000414437268000000041330E7900000000414439948000000041330AAB00000000",wkbText); + assertEquals("000000000A0000000200000000090000000200000000020000000341442E3E0000000041330A9F000000004144398800000000413301ED00000000414439948000000041330AAB00000000000000000200000003414439948000000041330AAB0000000041443994800000004133150C0000000041442E3E0000000041330A9F00000000000000000900000003000000000800000003414439948000000041330AAB000000004144377E8000000041330793000000004144352580000000413308060000000000000000020000000241443525800000004133080600000000414435150000000041330E9100000000000000000800000003414435150000000041330E9100000000414437268000000041330E7900000000414439948000000041330AAB00000000",wkbText); } @Test