/** * @param other * The other {@link Location} to test * @return True if this {@link Location} is east or on the same {@link Longitude} as the other * {@link Location}. */ public boolean isEastOfOrOnTheSameLatitudeAs(final Location other) { return this.getLongitude().isGreaterThanOrEqualTo(other.getLongitude()); }
@Test public void testAssertCompareAntiMeridian() { final Longitude oneEighty = Longitude.degrees(180); final Longitude minusOneEighty = Longitude.degrees(-180); final Longitude ninety = Longitude.degrees(90); Assert.assertTrue(oneEighty.isGreaterThan(minusOneEighty)); Assert.assertTrue(minusOneEighty.isLessThan(oneEighty)); Assert.assertFalse(minusOneEighty.isGreaterThanOrEqualTo(oneEighty)); Assert.assertTrue(oneEighty.isGreaterThanOrEqualTo(oneEighty)); Assert.assertTrue(oneEighty.isLessThanOrEqualTo(oneEighty)); Assert.assertTrue(oneEighty.isGreaterThan(ninety)); Assert.assertTrue(ninety.isLessThanOrEqualTo(oneEighty)); } }
/** * Test if this rectangle fully encloses a {@link Located} item * * @param item * The item to test * @return True if this rectangle contains a {@link Located} item */ public boolean fullyGeometricallyEncloses(final Located item) { final Rectangle bounds = item instanceof Rectangle ? (Rectangle) item : item.bounds(); return this.lowerLeft().getLatitude().isLessThanOrEqualTo(bounds.lowerLeft().getLatitude()) && this.lowerLeft().getLongitude() .isLessThanOrEqualTo(bounds.lowerLeft().getLongitude()) && this.upperRight().getLatitude() .isGreaterThanOrEqualTo(bounds.upperRight().getLatitude()) && this.upperRight().getLongitude() .isGreaterThanOrEqualTo(bounds.upperRight().getLongitude()); }