WKTReader2 extends WKTReader { public Geometry read(String wellKnownText) throws ParseException { StringReader reader = new StringReader(wellKnownText); try { return read(reader); } finally { reader.close(); } } WKTReader2();  WKTReader2(double tolerance);  WKTReader2(GeometryFactory geometryFactory); Geometry read(String wellKnownText); Geometry read(Reader reader);  }
@Test public void compoundCurve() throws Exception { String WKT = "COMPOUNDCURVE((153.72942375 -27.21757040, 152.29285719 -29.23940482, 154.74034096 -30.51635287),CIRCULARSTRING(154.74034096 -30.51635287, 154.74034096 -30.51635287, 152.39926953 -32.16574411, 155.11278414 -34.08116619, 151.86720784 -35.62414508))"; WKTReader reader = new WKTReader2(); Geometry geometry = reader.read(WKT); assertNotNull(geometry); WKT = "COMPOUNDCURVE((153.72942375 -27.21757040, 152.29285719 -29.23940482, 154.74034096 -30.51635287))"; geometry = reader.read(WKT); assertNotNull(geometry); WKT = "COMPOUNDCURVE(CIRCULARSTRING(154.74034096 -30.51635287, 154.74034096 -30.51635287, 152.39926953 -32.16574411, 155.11278414 -34.08116619, 151.86720784 -35.62414508))"; geometry = reader.read(WKT); assertNotNull(geometry); WKT = "COMPOUNDCURVE EMPTY"; geometry = reader.read(WKT); assertNotNull(geometry); assertTrue( geometry.isEmpty() ); }
@Test public void curvePolygon() throws Exception { WKTReader reader = new WKTReader2(); String WKT; Polygon polygon; Geometry geometry; WKT = "CURVEPOLYGON(CIRCULARSTRING(143.62025166838282 -30.037497356076827, 142.92857147299705 -32.75101196874403, 143.62025166838282 -30.037497356076827))"; geometry = reader.read(WKT); assertNotNull("read curvepolygon", geometry); assertTrue( geometry instanceof Polygon ); polygon = (Polygon) geometry; assertTrue(polygon.getExteriorRing() instanceof CircularRing); assertTrue( "ring", polygon.getExteriorRing().isClosed() ); assertEquals("segmented ring", 51, polygon.getExteriorRing().getNumPoints()); assertEquals( "no holes", 0, polygon.getNumInteriorRing() ); WKT = "CURVEPOLYGON((144.84399355252685 -31.26123924022086, 144.20551952601693 -32.27215644886158, 145.55230712890625 -33.49203872680664, 147.97080993652344 -32.03618621826172, 146.38697244992585 -31.47406391572417, 144.84399355252685 -31.26123924022086))"; polygon = (Polygon) reader.read( WKT ); assertTrue( "ring", polygon.getExteriorRing().isClosed() ); assertEquals( "no holes", 0, polygon.getNumInteriorRing() ); WKT = "CURVEPOLYGON("+ "CIRCULARSTRING(143.62025166838282 -30.037497356076827, 142.92857147299705 -32.75101196874403, 145.96132309891922 -34.985671061528784, 149.57565307617188 -33.41153335571289, 149.41972407584802 -29.824672680573517, 146.1209416055467 -30.19711586270431, 143.62025166838282 -30.037497356076827),"+ "(144.84399355252685 -31.26123924022086, 144.20551952601693 -32.27215644886158, 145.55230712890625 -33.49203872680664, 147.97080993652344 -32.03618621826172, 146.38697244992585 -31.47406391572417, 144.84399355252685 -31.26123924022086))"; polygon = (Polygon) reader.read( WKT ); assertTrue( "ring", polygon.getExteriorRing().isClosed() ); assertTrue(polygon.getExteriorRing() instanceof CircularRing); assertEquals("one holes", 1, polygon.getNumInteriorRing()); assertFalse(polygon.getInteriorRingN(0) instanceof CircularRing); WKT = "CURVEPOLYGON(COMPOUNDCURVE(CIRCULARSTRING(0 0,2 0, 2 1, 2 3, 4 3),(4 3, 4 5, 1 4, 0 0)), CIRCULARSTRING(1.7 1, 1.4 0.4, 1.6 0.4, 1.6 0.5, 1.7 1) )"; polygon = (Polygon) reader.read(WKT); assertTrue("ring", polygon.getExteriorRing().isClosed()); assertTrue(polygon.getExteriorRing() instanceof CompoundRing); assertEquals("one holes", 1, polygon.getNumInteriorRing()); assertTrue(polygon.getInteriorRingN(0) instanceof CircularRing); }
@Test public void testCaseInsensitive() throws Exception { WKTReader reader = new WKTReader2(); assertNotNull( reader.read("POINT(1 2)") ); assertNotNull( reader.read("Point(1 2)") ); assertNotNull( reader.read("LINESTRING(0 2, 2 0, 8 6)") ); assertNotNull( reader.read("LineString(0 2, 2 0, 8 6)") ); }