Java Code Examples for org.locationtech.spatial4j.distance.DistanceUtils#RADIANS_TO_DEGREES

The following examples show how to use org.locationtech.spatial4j.distance.DistanceUtils#RADIANS_TO_DEGREES . 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: Geo3dDistanceCalculator.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
public Point pointOnBearing(Point from, double distDEG, double bearingDEG, SpatialContext ctx, Point reuse) {
  Geo3dPointShape geoFrom = (Geo3dPointShape) from;
  GeoPoint point = (GeoPoint) geoFrom.shape;
  double dist = DistanceUtils.DEGREES_TO_RADIANS * distDEG;
  double bearing = DistanceUtils.DEGREES_TO_RADIANS * bearingDEG;
  GeoPoint newPoint = planetModel.surfacePointOnBearing(point, dist, bearing);
  double newLat = newPoint.getLatitude() * DistanceUtils.RADIANS_TO_DEGREES;
  double newLon = newPoint.getLongitude() * DistanceUtils.RADIANS_TO_DEGREES;
  if (reuse != null) {
    reuse.reset(newLon, newLat);
    return reuse;
  }
  else {
    return ctx.getShapeFactory().pointXY(newLon, newLat);
  }
}
 
Example 2
Source File: GeoUnits.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static final double toDegrees(double distance, IRI units) {
	final double degs;
	if (GEOF.UOM_METRE.equals(units)) {
		degs = DistanceUtils.dist2Degrees(distance / 1000.0, DistanceUtils.EARTH_MEAN_RADIUS_KM);
	} else if (GEOF.UOM_DEGREE.equals(units)) {
		degs = distance;
	} else if (GEOF.UOM_RADIAN.equals(units)) {
		degs = DistanceUtils.RADIANS_TO_DEGREES * distance;
	} else if (GEOF.UOM_UNITY.equals(units)) {
		degs = distance * 180.0;
	} else {
		throw new IllegalArgumentException("Unsupported units: " + units);
	}
	return degs;
}
 
Example 3
Source File: S2PrefixTree.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public double getDistanceForLevel(int level) {
    if (level == 0) {
        return 180;
    }
    return S2Projections.MAX_WIDTH.getValue(arity * (level - 1)) * DistanceUtils.RADIANS_TO_DEGREES;
}
 
Example 4
Source File: Geo3dRectangleShape.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * Set the bounds from the wrapped GeoBBox.
 */
private void setBoundsFromshape() {
  LatLonBounds bounds = new LatLonBounds();
  shape.getBounds(bounds);
  minX = bounds.checkNoLongitudeBound() ? -180.0 : bounds.getLeftLongitude() * DistanceUtils.RADIANS_TO_DEGREES;
  minY = bounds.checkNoBottomLatitudeBound() ? -90.0 : bounds.getMinLatitude() * DistanceUtils.RADIANS_TO_DEGREES;
  maxX = bounds.checkNoLongitudeBound() ? 180.0 : bounds.getRightLongitude() * DistanceUtils.RADIANS_TO_DEGREES;
  maxY = bounds.checkNoTopLatitudeBound() ? 90.0 : bounds.getMaxLatitude() * DistanceUtils.RADIANS_TO_DEGREES;
}
 
Example 5
Source File: Geo3dDistanceCalculator.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public double distance(Point from, Point to) {
  if (from instanceof Geo3dPointShape && to instanceof Geo3dPointShape) {
    GeoPointShape pointShape1 = ((Geo3dPointShape) from).shape;
    GeoPointShape pointShape2 = ((Geo3dPointShape) to).shape;
    return planetModel.surfaceDistance(pointShape1.getCenter(), pointShape2.getCenter()) * DistanceUtils.RADIANS_TO_DEGREES;
  }
  return distance(from, to.getX(), to.getY());
}
 
Example 6
Source File: Geo3dDistanceCalculator.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public double distance(Point from, double toX, double toY) {
  GeoPoint fromGeoPoint;
  if (from instanceof Geo3dPointShape) {
    fromGeoPoint = (((Geo3dPointShape) from).shape).getCenter();
  } else {
    fromGeoPoint = new GeoPoint(planetModel,
        from.getY() * DistanceUtils.DEGREES_TO_RADIANS,
        from.getX() * DistanceUtils.DEGREES_TO_RADIANS);
  }
  GeoPoint toGeoPoint = new GeoPoint(planetModel,
      toY * DistanceUtils.DEGREES_TO_RADIANS,
      toX * DistanceUtils.DEGREES_TO_RADIANS);
  return planetModel.surfaceDistance(fromGeoPoint, toGeoPoint) * DistanceUtils.RADIANS_TO_DEGREES;
}
 
Example 7
Source File: Geo3dPointShape.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public double getX() {
  return shape.getCenter().getLongitude() * DistanceUtils.RADIANS_TO_DEGREES;
}
 
Example 8
Source File: Geo3dPointShape.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public double getY() {
  return shape.getCenter().getLatitude() * DistanceUtils.RADIANS_TO_DEGREES;
}
 
Example 9
Source File: Geo3dCircleShape.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public double getRadius() {
  return shape.getRadius() * DistanceUtils.RADIANS_TO_DEGREES;
}
 
Example 10
Source File: ValueSourceParser.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public double func(int doc, FunctionValues vals) throws IOException {
  return vals.doubleVal(doc) * DistanceUtils.RADIANS_TO_DEGREES;
}