@Test public void testGetIntersectionTime_noIntersection() { final Polygon polygon = (Polygon) geometryFactory.parse("POLYGON((0 0, 0 2, 2 2, 2 0, 0 0))"); final S2Polyline polyline = (S2Polyline) wktReader.read("LINESTRING(0 -2,4 -2)"); final BcS2TimeAxis timeAxis = new BcS2TimeAxis( new BcS2LineString(polyline), new Date(100000000000L), new Date(100001000000L)); final TimeInterval timeInterval = timeAxis.getIntersectionTime(polygon); assertNull(timeInterval); }
@Test public void testGetIntersectionTime_StraightLineWithSquare_shifted() throws ParseException { final Polygon polygon = (Polygon) geometryFactory.parse("POLYGON((0 0, 0 4, 4 4, 4 0, 0 0))"); final S2Polyline polyline = (S2Polyline) wktReader.read("LINESTRING(-1 1,5 7)"); final BcS2TimeAxis timeAxis = new BcS2TimeAxis( new BcS2LineString(polyline), new Date(100000000000L), new Date(100001000000L)); final TimeInterval timeInterval = timeAxis.getIntersectionTime(polygon); assertNotNull(timeInterval); assertTimeIntervalEquals(100000167518L, 100000499493L, timeInterval); }
@Test public void testGetIntersectionTime_StraightLineWithSquare() { final Polygon polygon = (Polygon) geometryFactory.parse("POLYGON((0 0, 0 4, 4 4, 4 0, 0 0))"); final S2Polyline polyline = (S2Polyline) wktReader.read("LINESTRING(-2 0,4 6)"); final BcS2TimeAxis timeAxis = new BcS2TimeAxis( new BcS2LineString(polyline), new Date(100000000000L), new Date(100001000000L)); final TimeInterval timeInterval = timeAxis.getIntersectionTime(polygon); assertNotNull(timeInterval); assertTimeIntervalEquals(100000334421L, 100000666394L, timeInterval); }
@Test public void testGetIntersectionTime_StraightLineWithRectangle_line_inside() throws ParseException { final Polygon polygon = (Polygon) geometryFactory.parse("POLYGON((0 0, 0 2, 5 2, 5 0, 0 0))"); final S2Polyline polyline = (S2Polyline) wktReader.read("LINESTRING(1 1,4 1)"); final BcS2TimeAxis timeAxis = new BcS2TimeAxis( new BcS2LineString(polyline), new Date(100000000000L), new Date(100001000000L)); final TimeInterval timeInterval = timeAxis.getIntersectionTime(polygon); assertNotNull(timeInterval); assertTimeIntervalEquals(100000000000L, 100001000000L, timeInterval); }
@Test public void testGetIntersectionTime_SegmentedLineWithParallelogram() throws ParseException { final Polygon polygon = (Polygon) geometryFactory.parse("POLYGON((2 -2, 7 -2, 9 -5, 4 -5, 2 -2))"); final S2Polyline polyline = (S2Polyline) wktReader.read("LINESTRING(1 -6, 2 -4, 4 -3, 6 -3,8 -2)"); final BcS2TimeAxis timeAxis = new BcS2TimeAxis( new BcS2LineString(polyline), new Date(100000000000L), new Date(100001000000L)); final TimeInterval timeInterval = timeAxis.getIntersectionTime(polygon); assertNotNull(timeInterval); assertTimeIntervalEquals(100000384991L, 100000903592L, timeInterval); }