GeoLine extends GeoObject { public double getHeading() { double lat1 = Math.toRadians(southWest.getLat()); double lon1 = Math.toRadians(southWest.getLon()); double lat2 = Math.toRadians(northEast.getLat()); double lon2 = Math.toRadians(northEast.getLon()); double dLon = lon2 - lon1; double y = Math.sin(dLon) * Math.cos(lat2); double x = (Math.cos(lat1) * Math.sin(lat2)) - (Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon)); double bearing = Math.atan2(y, x); bearing = Geo.mapToLon(Math.toDegrees(bearing)); return bearing; } 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 testGetheading() { LOG.info("testgetHeading"); Assert.assertEquals(0.0, new GeoLine(new GeoPoint(0.0, 0.0), new GeoPoint(0.0, 0.0)).getHeading(), 1.0); Assert.assertEquals(0.0, new GeoLine(new GeoPoint(0.0, 0.0), new GeoPoint(1.0, 0.0)).getHeading(), 1.0); Assert.assertEquals(90.0, new GeoLine(new GeoPoint(0.0, 0.0), new GeoPoint(0.0, 1.0)).getHeading(), 1.0); Assert.assertEquals(90.0, new GeoLine(new GeoPoint(1.0, 1.0), new GeoPoint(1.0, 2.0)).getHeading(), 1.0); Assert.assertEquals(90.0, new GeoLine(new GeoPoint(10.0, 10.0), new GeoPoint(10.0, 11.0)).getHeading(), 1.0); Assert.assertEquals(-90.0, new GeoLine(new GeoPoint(10.0, 10.0), new GeoPoint(10.0, 9.0)).getHeading(), 1.0); }