public void testMultiLineString4_reallyBigDistance_floating() throws Exception { new BufferValidator( 1E10, "MULTILINESTRING (( 635074.5418406526 6184832.4888257105, 635074.5681951842 6184832.571842485, 635074.6472587794 6184832.575795664 ), ( 635074.6657069515 6184832.53889932, 635074.6933792098 6184832.451929366, 635074.5642420045 6184832.474330718 ))") .setBufferHolesExpected(false) .setEmptyBufferExpected(false) .test(); }
public BufferValidator setEmptyBufferExpected(final boolean emptyBufferExpected) { return addTest(new Test("Empty Buffer Test", 1) { public void test() throws Exception { Assert.assertTrue( supplement( "Expected buffer " + (emptyBufferExpected ? "" : "not ") + "to be empty"), emptyBufferExpected == getBuffer().isEmpty()); } }); }
public void test1() throws Exception { new BufferValidator( 0, "POINT (100 100)") .setEmptyBufferExpected(true) .test(); } public void test2() throws Exception {
public void test10() throws Exception { new BufferValidator( 10, "POLYGON ((100 300, 300 300, 300 100, 100 100, 100 300), (220 220, 180 220, 180 180, 220 180, 220 220))") .test(); } public void test11() throws Exception {
private String supplement(String message) throws ParseException { String newMessage = "\n" + message + "\n"; newMessage += "Original: " + wktWriter.writeFormatted(getOriginal()) + "\n"; newMessage += "Buffer Distance: " + bufferDistance + "\n"; newMessage += "Buffer: " + wktWriter.writeFormatted(getBuffer()) + "\n"; return newMessage.substring(0, newMessage.length() - 1); }
public BufferValidator(double bufferDistance, String wkt, boolean addContainsTest) throws ParseException { // SRID = 888 is to test that SRID is preserved in computed buffers setFactory(new PrecisionModel(), 888); this.bufferDistance = bufferDistance; this.wkt = wkt; if (addContainsTest) addContainsTest(); //addBufferResultValidatorTest(); }
public void test() throws Exception { try { Collection tests = nameToTestMap.values(); for (Iterator i = tests.iterator(); i.hasNext(); ) { Test test = (Test) i.next(); test.test(); } } catch (Exception e) { throw new Exception( supplement(e.toString()) + StringUtil.getStackTrace(e)); } } private String supplement(String message) throws ParseException {
public void test11() throws Exception { new BufferValidator( 5, "POLYGON ((260 400, 220 300, 80 300, 180 220, 40 200, 180 160, 60 20, 200 80, 280 20, 260 140, 440 20, 340 180, 520 160, 280 220, 460 340, 300 300, 260 400), (260 320, 240 260, 220 220, 160 180, 220 160, 200 100, 260 160, 300 140, 320 180, 260 200, 260 320))") .test(); } public void test12() throws Exception {
public void test1a() throws Exception { new BufferValidator( -1, "POINT (100 100)") .setEmptyBufferExpected(true) .test(); } public void test2a() throws Exception {
private Geometry getBuffer() throws ParseException { if (buffer == null) { buffer = getOriginal().buffer(bufferDistance, QUADRANT_SEGMENTS_1); if (getBuffer().getClass() == GeometryCollection.class && getBuffer().isEmpty()) { try { //#contains doesn't work with GeometryCollections [Jon Aquino // 10/29/2003] buffer = wktReader.read("POINT EMPTY"); } catch (ParseException e) { org.locationtech.jts.util.Assert.shouldNeverReachHere(); } } } return buffer; }
public void testMultiLineString_separateBuffers_floating() throws Exception { new BufferValidator( 0.01, "MULTILINESTRING (( 635074.5418406526 6184832.4888257105, 635074.5681951842 6184832.571842485, 635074.6472587794 6184832.575795664 ), ( 635074.6657069515 6184832.53889932, 635074.6933792098 6184832.451929366, 635074.5642420045 6184832.474330718 ))") .setBufferHolesExpected(false) .setEmptyBufferExpected(false) .test(); } public void testMultiLineString2_buffersTouchToMakeHole_floating() throws Exception {
public void test24() throws Exception { new BufferValidator( 160, "POLYGON ((20 60, 20 20, 240 20, 40 21, 240 22, 40 22, 240 23, 240 60, 20 60))") .test(); } public void test25() throws Exception {
public void test2a() throws Exception { new BufferValidator( -1, "LINESTRING (10 10, 100 100)") .setEmptyBufferExpected(true) .test(); }
private void addBufferResultValidatorTest() { addTest(new Test("BufferResultValidator Test") { public void test() throws Exception { if (getOriginal().getClass() == GeometryCollection.class) { return; } Assert.assertTrue( supplement("BufferResultValidator failure"), BufferResultValidator.isValid(getOriginal(), bufferDistance, getBuffer())); } }); }
public void testMultiLineString2_buffersTouchToMakeHole_floating() throws Exception { new BufferValidator( 0.037, "MULTILINESTRING (( 635074.5418406526 6184832.4888257105, 635074.5681951842 6184832.571842485, 635074.6472587794 6184832.575795664 ), ( 635074.6657069515 6184832.53889932, 635074.6933792098 6184832.451929366, 635074.5642420045 6184832.474330718 ))") .setBufferHolesExpected(true) .setEmptyBufferExpected(false) .test(); } public void testMultiLineString3_holeVanishes_floating() throws Exception {
public void test27() throws Exception { new BufferValidator( -30, "POLYGON ((2330 1950, 2320 1950, 2310 1940, 2220 1880, 2260 1870, 2270 1870, 2290 1870, 2300 1860, 2320 1860, 2340 1850, 2360 1840, 2370 1830, 2380 1820, 2370 1840, 2360 1850, 2360 1860, 2350 1870, 2350 1880, 2340 1890, 2340 1910, 2340 1920, 2330 1930, 2330 1950 ))") .test(); } public void test28() throws Exception {
public void test2() throws Exception { new BufferValidator( 0, "LINESTRING (10 10, 100 100)") .setEmptyBufferExpected(true) .test(); } public void test1a() throws Exception {
public BufferValidator setExpectedArea(final double expectedArea) { return addTest(new Test("Area Test") { public void test() throws Exception { double tolerance = Math.abs( getBuffer().getArea() - getOriginal() .buffer( bufferDistance, QUADRANT_SEGMENTS_1 - QUADRANT_SEGMENTS_2) .getArea()); Assert.assertEquals( getName(), expectedArea, getBuffer().getArea(), tolerance); } }); }
public void testMultiLineString3_holeVanishes_floating() throws Exception { new BufferValidator( 0.16, "MULTILINESTRING (( 635074.5418406526 6184832.4888257105, 635074.5681951842 6184832.571842485, 635074.6472587794 6184832.575795664 ), ( 635074.6657069515 6184832.53889932, 635074.6933792098 6184832.451929366, 635074.5642420045 6184832.474330718 ))") .setBufferHolesExpected(false) .setEmptyBufferExpected(false) .test(); } public void testMultiLineString4_reallyBigDistance_floating() throws Exception {
public void test30() throws Exception { new BufferValidator( 260, "POLYGON ((4400 -930, 4400 -670, 4750 -670, 4710 -710, 4690 -720, 4680 -730, 4670 -740, 4630 -780, 4590 -810, 4580 -820, 4540 -840, 4530 -850, 4520 -860, 4500 -860, 4490 -870, 4480 -880, 4440 -900, 4430 -910, 4410 -920, 4400 -930 ))") .test(); } public void test31() throws Exception {