Skip to content

Commit

Permalink
added a MultiLineString test case
Browse files Browse the repository at this point in the history
  • Loading branch information
halset committed Aug 16, 2022
1 parent 0ead697 commit 927de1f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/test/java/no/ecc/vectortile/VectorTileEncoderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryCollection;
import org.locationtech.jts.geom.GeometryFactory;
import org.locationtech.jts.geom.LineString;
import org.locationtech.jts.geom.LinearRing;
import org.locationtech.jts.geom.MultiLineString;
import org.locationtech.jts.geom.MultiPolygon;
import org.locationtech.jts.geom.Point;
import org.locationtech.jts.geom.Polygon;
Expand Down Expand Up @@ -537,6 +539,30 @@ public void testMultiPolygon() throws IOException {
MultiPolygon mp2 = (MultiPolygon) features.get(0).getGeometry();
assertEquals(mp.getNumGeometries(), mp2.getNumGeometries());
}

public void testMultiLineString() throws IOException {

// create MultiLineString with 3 LineStrings. The last one is very short.
LineString[] lineStrings = new LineString[3];
lineStrings[0] = gf.createLineString(new Coordinate[] {new Coordinate(3, 6), new Coordinate(4, 7)});
lineStrings[1] = gf.createLineString(new Coordinate[] {new Coordinate(13, 16), new Coordinate(14, 17)});
lineStrings[2] = gf.createLineString(new Coordinate[] {new Coordinate(23, 26), new Coordinate(23.0000000001, 26.0000000001)});
MultiLineString multiLineString = gf.createMultiLineString(lineStrings);

Map<String, String> attributes = Collections.singletonMap("key1", "value1");

VectorTileEncoder vtm = new VectorTileEncoder(256);
vtm.addFeature("mp", attributes, multiLineString);

byte[] encoded = vtm.encode();
assertTrue(encoded.length > 0);

VectorTileDecoder decoder = new VectorTileDecoder();
List<Feature> features = decoder.decode(encoded).asList();
assertEquals(1, features.size());
MultiLineString multiLineString2 = (MultiLineString) features.get(0).getGeometry();
assertEquals(2, multiLineString2.getNumGeometries());
}

public void testGeometryCollection() throws IOException {
Geometry[] geometries = new Geometry[2];
Expand Down

0 comments on commit 927de1f

Please sign in to comment.