for (final OWLRealInterval j : intersectWith) final OWLRealInterval k = i.intersection(j); if (k != null) revisedIntervals.add(k);
for (final OWLRealInterval j : intersectWith) final OWLRealInterval k = i.intersection(j); if (k != null) revisedIntervals.add(k);
final OWLRealInterval j = i.intersection(restriction); if (j != null)
final OWLRealInterval j = i.intersection(restriction); if (j != null)
/** * Verify that two continuous intervals overlapping just on an inclusive bound intersect to a point. */ @Test public void intersectionPointCon() { final OWLRealInterval a = interval(null, 2.1, false, true, LineType.CONTINUOUS); final OWLRealInterval b = interval(2.1, null, true, false, LineType.CONTINUOUS); final OWLRealInterval expected = new OWLRealInterval(BigDecimal.valueOf(2.1d)); assertEquals(expected, a.intersection(b)); assertEquals(expected, b.intersection(a)); assertTrue(a.intersection(b).isPoint()); assertTrue(b.intersection(a).isPoint()); assertTrue(a.intersection(b).contains(BigDecimal.valueOf(2.1d))); assertTrue(b.intersection(a).contains(BigDecimal.valueOf(2.1d))); assertEquals(IntervalRelations.OVERLAPS, a.compare(b)); assertEquals(IntervalRelations.OVERLAPPED_BY, b.compare(a)); }
/** * Verify that the overlap of two continuous intervals with exclusive bounds intersect correctly. */ @Test public void intersectionOverlapConCon1() { final OWLRealInterval a = interval(null, 0.51, false, false, LineType.CONTINUOUS); final OWLRealInterval b = interval(0.49, null, false, false, LineType.CONTINUOUS); final OWLRealInterval expected = interval(0.49, 0.51, false, false, LineType.CONTINUOUS); assertEquals(expected, a.intersection(b)); assertEquals(expected, b.intersection(a)); assertTrue(a.intersection(b).contains(BigDecimal.valueOf(0.50))); assertTrue(b.intersection(a).contains(BigDecimal.valueOf(0.50))); assertFalse(a.intersection(b).contains(BigDecimal.valueOf(0.49))); assertFalse(b.intersection(a).contains(BigDecimal.valueOf(0.49))); assertFalse(a.intersection(b).contains(BigDecimal.valueOf(0.51))); assertFalse(b.intersection(a).contains(BigDecimal.valueOf(0.51))); assertEquals(IntervalRelations.OVERLAPS, a.compare(b)); assertEquals(IntervalRelations.OVERLAPPED_BY, b.compare(a)); }
/** * Verify that the overlap of two continuous intervals with inclusive bounds intersect correctly. */ @Test public void intersectionOverlapConCon2() { final OWLRealInterval a = interval(null, 0.51, false, true, LineType.CONTINUOUS); final OWLRealInterval b = interval(0.49, null, true, false, LineType.CONTINUOUS); final OWLRealInterval expected = interval(0.49, 0.51, true, true, LineType.CONTINUOUS); assertEquals(expected, a.intersection(b)); assertEquals(expected, b.intersection(a)); assertTrue(a.intersection(b).contains(BigDecimal.valueOf(0.50))); assertTrue(b.intersection(a).contains(BigDecimal.valueOf(0.50))); assertTrue(a.intersection(b).contains(BigDecimal.valueOf(0.49))); assertTrue(b.intersection(a).contains(BigDecimal.valueOf(0.49))); assertTrue(a.intersection(b).contains(BigDecimal.valueOf(0.51))); assertTrue(b.intersection(a).contains(BigDecimal.valueOf(0.51))); assertEquals(IntervalRelations.OVERLAPS, a.compare(b)); assertEquals(IntervalRelations.OVERLAPPED_BY, b.compare(a)); }
/** * Verify that two integer intervals overlapping just on an inclusive bound intersect to a point. */ @Test public void intersectionPointOnly() { final OWLRealInterval a = interval(null, 2, false, true, LineType.INTEGER_ONLY); final OWLRealInterval b = interval(2, null, true, false, LineType.INTEGER_ONLY); final OWLRealInterval expected = new OWLRealInterval(Integer.valueOf(2)); assertEquals(expected, a.intersection(b)); assertEquals(expected, b.intersection(a)); assertTrue(a.intersection(b).isPoint()); assertTrue(b.intersection(a).isPoint()); assertTrue(a.intersection(b).contains(Integer.valueOf(2))); assertTrue(b.intersection(a).contains(Integer.valueOf(2))); assertEquals(IntervalRelations.OVERLAPS, a.compare(b)); assertEquals(IntervalRelations.OVERLAPPED_BY, b.compare(a)); }
/** * Verify that the intersection of a continuous interval with a continuous interval which it starts and which share an inclusive endpoint is correct. */ @Test public void intersectionStartsConCon1() { final OWLRealInterval a = interval(2.1, 3.1, true, true, LineType.CONTINUOUS); final OWLRealInterval b = interval(2.1, null, true, false, LineType.CONTINUOUS); assertEquals(a, a.intersection(b)); assertEquals(a, b.intersection(a)); assertEquals(IntervalRelations.STARTS, a.compare(b)); assertEquals(IntervalRelations.STARTED_BY, b.compare(a)); }
/** * Verify that if two continuous intervals meet (i.e., one's upper is the other's lower and the (in|ex)clusiveness differs), then they do not intersect. */ @Test public void intersectionMeetsCon() { final OWLRealInterval a = interval(null, 2.1, false, false, LineType.CONTINUOUS); final OWLRealInterval b = interval(2.1, null, true, false, LineType.CONTINUOUS); assertNull(a.intersection(b)); assertNull(b.intersection(a)); assertEquals(IntervalRelations.MEETS, a.compare(b)); assertEquals(IntervalRelations.MET_BY, b.compare(a)); }
/** * Verify that the intersection of a continuous interval with a continuous interval which it starts and which share an exclusive endpoint is correct. */ @Test public void intersectionStartsConCon2() { final OWLRealInterval a = interval(2.1, 3.1, false, true, LineType.CONTINUOUS); final OWLRealInterval b = interval(2.1, null, false, false, LineType.CONTINUOUS); assertEquals(a, a.intersection(b)); assertEquals(a, b.intersection(a)); assertEquals(IntervalRelations.STARTS, a.compare(b)); assertEquals(IntervalRelations.STARTED_BY, b.compare(a)); }
/** * Verify that the intersection of a continuous interval with a continuous interval which it starts but for which the endpoint type is different it correct * (i.e., it isn't a start relation). */ @Test public void intersectionStartsConCon3() { final OWLRealInterval a = interval(2.1, 3.1, false, true, LineType.CONTINUOUS); final OWLRealInterval b = interval(2.1, null, true, false, LineType.CONTINUOUS); assertEquals(a, a.intersection(b)); assertEquals(a, b.intersection(a)); assertEquals(IntervalRelations.DURING, a.compare(b)); assertEquals(IntervalRelations.CONTAINS, b.compare(a)); }
/** * Verify that if two no-integer intervals meet (i.e., one's upper is the other's lower and the (in|ex)clusiveness differs), then they do not intersect. */ @Test public void intersectionMeetsNoI() { final OWLRealInterval a = interval(null, 2.1, false, false, LineType.INTEGER_EXCLUDED); final OWLRealInterval b = interval(2.1, null, true, false, LineType.INTEGER_EXCLUDED); assertNull(a.intersection(b)); assertNull(b.intersection(a)); assertEquals(IntervalRelations.MEETS, a.compare(b)); assertEquals(IntervalRelations.MET_BY, b.compare(a)); }
/** * Verify that for all interval types, if no overlap exists between the bounds an empty intersection is identified */ @Test public void intersectionEmpty() { for (final LineType t : LineType.values()) { final OWLRealInterval a = interval(null, 0, false, true, t); final OWLRealInterval b = interval(1, null, true, false, t); assertNull(a.intersection(b)); assertNull(b.intersection(a)); assertEquals(IntervalRelations.PRECEDES, a.compare(b)); assertEquals(IntervalRelations.PRECEDED_BY, b.compare(a)); } }