Java Code Examples for org.locationtech.spatial4j.distance.DistanceUtils#EARTH_MEAN_RADIUS_MI
The following examples show how to use
org.locationtech.spatial4j.distance.DistanceUtils#EARTH_MEAN_RADIUS_MI .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeoUnits.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static final double toMiles(double distance, IRI units) { final double miles; if (GEOF.UOM_METRE.equals(units)) { miles = DistanceUtils.KM_TO_MILES * distance / 1000.0; } else if (GEOF.UOM_DEGREE.equals(units)) { miles = DistanceUtils.degrees2Dist(distance, DistanceUtils.EARTH_MEAN_RADIUS_MI); } else if (GEOF.UOM_RADIAN.equals(units)) { miles = DistanceUtils.radians2Dist(distance, DistanceUtils.EARTH_MEAN_RADIUS_MI); } else if (GEOF.UOM_UNITY.equals(units)) { miles = distance * Math.PI * DistanceUtils.EARTH_MEAN_RADIUS_MI; } else { throw new IllegalArgumentException("Unsupported units: " + units); } return miles; }
Example 2
Source File: GeoUnits.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static final double fromMiles(double miles, IRI units) { double dist; if (GEOF.UOM_METRE.equals(units)) { dist = DistanceUtils.MILES_TO_KM * miles * 1000.0; } else if (GEOF.UOM_DEGREE.equals(units)) { dist = DistanceUtils.dist2Degrees(miles, DistanceUtils.EARTH_MEAN_RADIUS_MI); } else if (GEOF.UOM_RADIAN.equals(units)) { dist = DistanceUtils.dist2Radians(miles, DistanceUtils.EARTH_MEAN_RADIUS_MI); } else if (GEOF.UOM_UNITY.equals(units)) { dist = miles / (Math.PI * DistanceUtils.EARTH_MEAN_RADIUS_MI); } else { throw new IllegalArgumentException("Unsupported units: " + units); } return dist; }