Exemple #1
0
 @Nonnull
 private GeoRectangle calcBoundingBox(final double c) {
   final double lowerLeftLat = center.getLat() - (Geo.metersToDegreesLat(radiusMeters) * c);
   final double lowerLeftLon =
       center.getLon() - (Geo.metersToDegreesLonAtLat(radiusMeters, center.getLat()) * c);
   final double upperRightLat = center.getLat() + (Geo.metersToDegreesLat(radiusMeters) * c);
   final double upperRightLon =
       center.getLon() + Geo.metersToDegreesLonAtLat(radiusMeters, center.getLat() * c);
   return new GeoRectangle(
       new GeoPoint(lowerLeftLat, lowerLeftLon), new GeoPoint(upperRightLat, upperRightLon));
 }
Exemple #2
0
 /**
  * Create a circle geo area with 2 points: one is the center, the other a point on the circle.
  *
  * @param center Center.
  * @param point Point in circle.
  */
 public GeoCircle(@Nonnull final GeoPoint center, @Nonnull final GeoPoint point) {
   super();
   assert center != null;
   assert point != null;
   final double lat = Math.abs(center.getLat() - point.getLat());
   final double lon = Math.abs(center.getLon() - point.getLon());
   final double w = Geo.degreesLatToMeters(lat);
   final double h = Geo.degreesLonToMetersAtLat(lon, (center.getLat() + point.getLat()) / 2.0);
   final double radius = Math.sqrt((w * w) + (h * h));
   this.center = center;
   this.radiusMeters = radius;
 }