Skip to content

Commit

Permalink
fix issue with inner boundary with arcs continued by outer boundary w…
Browse files Browse the repository at this point in the history
…ith straights (claeis/ili2db#510)
  • Loading branch information
claeis committed Apr 17, 2023
1 parent 590fb07 commit 9360464
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions doc/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
-----------------------------
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/ch/interlis/iox_j/wkb/LineSegment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Coordinate> tail = coordinates.subList(pos, coordinates.size());
LineSegment result = new LineSegment(wkbType);

Expand Down
11 changes: 9 additions & 2 deletions src/main/java/ch/interlis/iox_j/wkb/RingCollector.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -106,7 +114,6 @@ private void extractInnerRing(Coordinate coordinate) {
}

extractedRing.get(extractedRing.size() - 1).add(coordinate);

rings.add(extractedRing);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ch/interlis/iox_j/wkb/Wkb2iox.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/ch/interlis/iox_j/wkb/Iox2wkbTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9360464

Please sign in to comment.