Java Code Examples for org.locationtech.spatial4j.distance.DistanceUtils#degrees2Dist()
The following examples show how to use
org.locationtech.spatial4j.distance.DistanceUtils#degrees2Dist() .
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: FunctionArguments.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Convert degrees to another unit * * @param degs degrees * @param units UoM IRI of the unit to convert to * @return converted value as a double * @throws ValueExprEvaluationException */ public static double convertFromDegrees(double degs, IRI units) throws ValueExprEvaluationException { double v; if (GEOF.UOM_DEGREE.equals(units)) { v = degs; } else if (GEOF.UOM_RADIAN.equals(units)) { v = DistanceUtils.toRadians(degs); } else if (GEOF.UOM_UNITY.equals(units)) { v = degs / 180.0; } else if (GEOF.UOM_METRE.equals(units)) { v = DistanceUtils.degrees2Dist(degs, DistanceUtils.EARTH_MEAN_RADIUS_KM) * 1000.0; } else { throw new ValueExprEvaluationException("Invalid unit of measurement: " + units); } return v; }
Example 2
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 3
Source File: GeoUnits.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static final double toKilometres(double distance, IRI units) { final double kms; if (GEOF.UOM_METRE.equals(units)) { kms = distance / 1000.0; } else if (GEOF.UOM_DEGREE.equals(units)) { kms = DistanceUtils.degrees2Dist(distance, DistanceUtils.EARTH_MEAN_RADIUS_KM); } else if (GEOF.UOM_RADIAN.equals(units)) { kms = DistanceUtils.radians2Dist(distance, DistanceUtils.EARTH_MEAN_RADIUS_KM); } else if (GEOF.UOM_UNITY.equals(units)) { kms = distance * Math.PI * DistanceUtils.EARTH_MEAN_RADIUS_KM; } else { throw new IllegalArgumentException("Unsupported units: " + units); } return kms; }
Example 4
Source File: GeoUnits.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static final double fromDegrees(double degs, IRI units) { double dist; if (GEOF.UOM_METRE.equals(units)) { dist = DistanceUtils.degrees2Dist(degs, DistanceUtils.EARTH_MEAN_RADIUS_KM) * 1000.0; } else if (GEOF.UOM_DEGREE.equals(units)) { dist = degs; } else if (GEOF.UOM_RADIAN.equals(units)) { dist = DistanceUtils.DEGREES_TO_RADIANS * degs; } else if (GEOF.UOM_UNITY.equals(units)) { dist = degs / 180.0; } else { throw new IllegalArgumentException("Unsupported units: " + units); } return dist; }