GeoLine extends GeoObject { @Nonnull @Override public GeoPoint getCenter() { final double lat = (southWest.getLat() + northEast.getLat()) / 2.0; final double lon = (((northEast.getLon() >= southWest.getLon()) ? (northEast.getLon()) : ((northEast.getLon() + 360.0))) + southWest.getLon()) / 2.0; final double elevationMeters = (southWest.getElevationMetersOrNaN() + northEast.getElevationMetersOrNaN()) / 2.0; return new GeoPoint(lat, lon, elevationMeters); } GeoLine(
            @Nonnull final GeoPoint southWest,
            @Nonnull final GeoPoint northEast); @SuppressWarnings({"ConstantConditions", "UnusedDeclaration"}) @Deprecated private  GeoLine(); @Nonnull @Override GeoPoint getOrigin(); @Nonnull @Override GeoPoint getCenter(); @Nonnull GeoPoint getSouthWest(); @Nonnull GeoPoint getNorthEast(); @Nonnull GeoLine withSouthWest(@Nonnull final GeoPoint southWest); @Nonnull GeoLine withNorthEast(@Nonnull final GeoPoint northEast); @Nonnull @Override GeoLine translate(@Nonnull final GeoVector vector); @Nonnull @Override GeoLine moveTo(@Nonnull final GeoPoint origin); double getNorthing(); double getEasting(); double getLengthMeters(); boolean isWrappedOnLongSide(); @Nonnull static GeoLine getShortestLine(
            @Nonnull final GeoPoint from,
            @Nonnull final GeoPoint to); double getHeading(); @Override boolean canEqual(@Nonnull final Object obj); @Override boolean equals(@Nullable final Object obj); @Override int hashCode();  }
@Test public void testGetCenterWithElevation() { LOG.info("testGetCenterWithElevation"); GeoPoint x = new GeoPoint(0.0, 2.0); GeoPoint y = new GeoPoint(10.0, 4.0, 100.0); GeoPoint m = new GeoPoint(5.0, 3.0, 100.0); GeoLine line = new GeoLine(x, y); Assert.assertEquals(m, line.getCenter()); x = new GeoPoint(0.0, 2.0, 50.0); y = new GeoPoint(10.0, 4.0, 100.0); m = new GeoPoint(5.0, 3.0, 75.0); line = new GeoLine(x, y); Assert.assertEquals(m, line.getCenter()); x = new GeoPoint(0.0, 2.0, -50.0); y = new GeoPoint(10.0, 4.0, 50.0); m = new GeoPoint(5.0, 3.0, 0.0); line = new GeoLine(x, y); Assert.assertEquals(m, line.getCenter()); }
@Test public void testGetCenter() { LOG.info("testGetCenter"); final GeoPoint x1 = new GeoPoint(0.0, 2.0); final GeoPoint y1 = new GeoPoint(10.0, 4.0); final GeoPoint m1 = new GeoPoint(5.0, 3.0); final GeoLine line1 = new GeoLine(x1, y1); Assert.assertEquals(m1, line1.getCenter()); final GeoPoint x2 = new GeoPoint(-10.0, 170.0); final GeoPoint y2 = new GeoPoint(10.0, -175.0); final GeoPoint shortMid = new GeoPoint(0.0, -2.5); final GeoLine shortSide = new GeoLine(y2, x2); Assert.assertEquals(shortMid, shortSide.getCenter()); final GeoPoint longMid = new GeoPoint(0.0, 177.5); final GeoLine longSide = new GeoLine(x2, y2); Assert.assertEquals(longMid, longSide.getCenter()); { final GeoPoint p1 = new GeoPoint(0.0, 160.0); final GeoPoint p2 = new GeoPoint(0.0, 170.0); final GeoLine p1short = new GeoLine(p1, p2); final GeoLine p1long = new GeoLine(p2, p1); final double eastingShort = p1short.getEasting(); final double eastingLong = p1long.getEasting(); Assert.assertTrue(eastingShort >= 0.0); Assert.assertTrue(eastingLong >= 0.0); final GeoPoint midpShort = new GeoPoint(0.0, 165.0); final GeoPoint midpLong = new GeoPoint(0.0, -15.0); Assert.assertEquals(midpShort, p1short.getCenter()); Assert.assertEquals(midpLong, p1long.getCenter()); } { final GeoPoint p1 = new GeoPoint(0.0, -170.0); final GeoPoint p2 = new GeoPoint(0.0, -160.0); final GeoLine p1short = new GeoLine(p1, p2); final GeoLine p1long = new GeoLine(p2, p1); final double eastingShort = p1short.getEasting(); final double eastingLong = p1long.getEasting(); Assert.assertTrue(eastingShort >= 0.0); Assert.assertTrue(eastingLong >= 0.0); final GeoPoint midpShort = new GeoPoint(0.0, -165.0); final GeoPoint midpLong = new GeoPoint(0.0, 15.0); Assert.assertEquals(midpShort, p1short.getCenter()); Assert.assertEquals(midpLong, p1long.getCenter()); } }