Skip to content

Commit

Permalink
Merge pull request #1010 from RobinTopper/fix-1009
Browse files Browse the repository at this point in the history
Fixes #1009: WKTWriter#writeMultiLineString produces invalid WKT string
  • Loading branch information
copierrj authored Oct 11, 2019
2 parents b40fdd9 + 65a6c14 commit 854e193
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,22 @@ public void test_MultiPolygon()
writer.toString() );

}

@Test
public void test_MultiLineString()
throws XMLParsingException, XMLStreamException, FactoryConfigurationError, IOException,
UnknownCRSException {

Set<WKTFlag> flag = new HashSet<WKTFlag>();
Writer writer = new StringWriter();
WKTWriter WKTwriter = new WKTWriter( flag, decimalFormatter );
Geometry geom = parseGeometry( "MultiLineString.gml" );
WKTwriter.writeGeometry( geom, writer );
// System.out.print( writer.toString() + "\n" );
assertEquals( "MULTILINESTRING ((7.1 50.7,10.0 53.5,13.4 52.5),(7.1 50.7,10.0 53.5,13.4 52.5))", writer.toString() );

}


// ############################## PARSING THE GEOMETRY-FILE
private Geometry parseGeometry( String fileName )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1191,11 +1191,10 @@ public void writeMultiLineString( MultiLineString geometry, Writer writer )
for ( int i = 0; i < geometry.size(); i++ ) {
writer.append( '(' );
writeLineStringWithoutPrefix( geometry.get( i ), writer );
writer.append( ')' );
if ( i < geometry.size() - 1 ) {
writer.append( ',' );

writer.append( ',' );
}
writer.append( ')' );
}

writer.append( ')' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public void simplifyMultiCurve() {
MultiCurve<?> multiCurve = fac.createMultiCurve( null, CRSUtils.EPSG_4326, memberCurves );
MultiLineString simplified = (MultiLineString) simplifier.simplify( multiCurve );
assertEquals(
"MULTILINESTRING ((0.000000 0.000000,1.000000 1.000000,5.000000 5.000000,10.000000 10.000000,)(0.000000 0.000000,1.000000 1.000000,5.000000 5.000000,10.000000 10.000000,12.317848 12.699677,14.612186 15.419362,16.882842 18.158850,19.129644 20.917935,21.352424 23.696410,23.551014 26.494065,25.725249 29.310690,27.874965 32.146073,30.000000 35.000000))",
"MULTILINESTRING ((0.000000 0.000000,1.000000 1.000000,5.000000 5.000000,10.000000 10.000000),(0.000000 0.000000,1.000000 1.000000,5.000000 5.000000,10.000000 10.000000,12.317848 12.699677,14.612186 15.419362,16.882842 18.158850,19.129644 20.917935,21.352424 23.696410,23.551014 26.494065,25.725249 29.310690,27.874965 32.146073,30.000000 35.000000))",
simplified.toString() );
}

Expand Down

0 comments on commit 854e193

Please sign in to comment.