| | 1561 | /** |
| | 1562 | * Create a new LatLon at a specified distance. Uses WGS84. |
| | 1563 | * This does not currently attempt to be hugely accurate. The actual location may be off |
| | 1564 | * depending upon the distance and the |
| | 1565 | * |
| | 1566 | * @param original The originating point |
| | 1567 | * @param angle The angle (from true north) in radians |
| | 1568 | * @param offset The distance to the new point in the current projection's units |
| | 1569 | * @return The location at the specified angle and distance from the originating point |
| | 1570 | * @since xxx |
| | 1571 | */ |
| | 1572 | public static ILatLon getLatLonFrom(final ILatLon original, final double angle, final double offset) { |
| | 1573 | final double meterOffset = ProjectionRegistry.getProjection().getMetersPerUnit() * offset; |
| | 1574 | final double deltaLongitudeDegree = (Math.PI * WGS84.a * Math.cos(Math.toRadians(original.lat()))) |
| | 1575 | / (180 * Math.sqrt(1 - WGS84.e2 * Math.pow(Math.sin(Math.toRadians(original.lat())), 2))); |
| | 1576 | final double deltaLatitudeDegree = (Math.PI * WGS84.a * (1 - WGS84.e2)) |
| | 1577 | / (180 * Math.pow(1 - WGS84.e2 * Math.pow(Math.sin(original.lat()), 2), 1.5)); |
| | 1578 | final double dx = meterOffset * Math.sin(angle); |
| | 1579 | final double dy = meterOffset * Math.cos(angle); |
| | 1580 | final double dLon = dx / deltaLongitudeDegree; |
| | 1581 | final double dLat = dy / deltaLatitudeDegree; |
| | 1582 | return new LatLon(original.lat() + dLat, original.lon() + dLon); |
| | 1583 | } |
| | 1584 | |