sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 02/04: Delete deprecated DistanceUtils class (replaced by GeodeticCalculator) and remove LatLonPointRadius from public API.
Date Thu, 12 Sep 2019 14:53:43 GMT
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 3f0bf11e021a74d6df7db6f55711d599fab8374b
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Thu Sep 12 14:29:44 2019 +0200

    Delete deprecated DistanceUtils class (replaced by GeodeticCalculator) and remove LatLonPointRadius
from public API.
---
 .../org/apache/sis/distance/DistanceUtils.java     | 102 ---------------------
 .../apache/sis/index/tree}/LatLonPointRadius.java  |  61 ++----------
 .../java/org/apache/sis/index/tree/QuadTree.java   |   1 -
 3 files changed, 6 insertions(+), 158 deletions(-)

diff --git a/core/sis-referencing/src/main/java/org/apache/sis/distance/DistanceUtils.java
b/core/sis-referencing/src/main/java/org/apache/sis/distance/DistanceUtils.java
deleted file mode 100644
index 4037eeb..0000000
--- a/core/sis-referencing/src/main/java/org/apache/sis/distance/DistanceUtils.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sis.distance;
-
-import org.apache.sis.geometry.DirectPosition2D;
-
-/**
- * Class to calculate distances on earth surface. Actual calculation code very
- * similar to Apache SIS but refractor to allow use of custom classes.
- *
- * @deprecated Replaced by {@link org.apache.sis.referencing.GeodeticCalculator}.
- * See <a href="https://issues.apache.org/jira/browse/SIS-385">SIS-385</a>.
- */
-@Deprecated
-public final class DistanceUtils {
-  private DistanceUtils() {
-  }
-
-  public static final int EARTH_RADIUS = 6371; // in km
-  public static final double HALF_EARTH_CIRCUMFERENCE = 20037.58; // in km
-
-  /**
-   * Returns a coordinate on the great circle at the specified bearing.
-   *
-   * @param latitude
-   *          the latitude of center of circle
-   * @param longitude
-   *          the longitude of center of circle
-   * @param d
-   *          the distance from the center
-   * @param bearing
-   *          the great circle bearing
-   * @return a coordinate at the specified bearing
-   *
-   * @deprecated Replaced by {@link org.apache.sis.referencing.GeodeticCalculator#getEndPoint()}.
-   */
-  @Deprecated
-  public static DirectPosition2D getPointOnGreatCircle(double latitude, double longitude,
-      double d, double bearing) {
-    double angularDistance = d / EARTH_RADIUS;
-
-    double lon1 = Math.toRadians(longitude);
-    double lat1 = Math.toRadians(latitude);
-
-    double cosLat = Math.cos(lat1);
-    double sinLat = Math.sin(lat1);
-
-    double sinD = Math.sin(angularDistance);
-    double cosD = Math.cos(angularDistance);
-    double brng = Math.toRadians(bearing);
-
-    double lat2 = Math.asin((sinLat * cosD) + (cosLat * sinD * Math.cos(brng)));
-    double lon2 = lon1
-        + Math.atan2(Math.sin(brng) * sinD * cosLat, cosD - sinLat
-            * Math.sin(lat2));
-
-    return new DirectPosition2D(Math.toDegrees(lat2), Math.toDegrees(lon2));
-  }
-
-  /**
-   * Calculates haversine (great circle) distance between two lat/lon
-   * coordinates.
-   *
-   * @param latitude1
-   *          latitude of first coordinate
-   * @param longitude1
-   *          longitude of first coordinate
-   * @param latitude2
-   *          latitude of second coordinate
-   * @param longitude2
-   *          longitude of second coordinate
-   * @return great circle distance between specified lat/lon coordinates
-   *
-   * @deprecated Replaced by {@link org.apache.sis.referencing.GeodeticCalculator#getGeodesicDistance()}.
-   */
-  @Deprecated
-  public static double getHaversineDistance(double latitude1,
-      double longitude1, double latitude2, double longitude2) {
-    double longRadian1 = Math.toRadians(longitude1);
-    double latRadian1 = Math.toRadians(latitude1);
-    double longRadian2 = Math.toRadians(longitude2);
-    double latRadian2 = Math.toRadians(latitude2);
-    double angularDistance = Math.acos(Math.sin(latRadian1)
-        * Math.sin(latRadian2) + Math.cos(latRadian1) * Math.cos(latRadian2)
-        * Math.cos(longRadian1 - longRadian2));
-    return EARTH_RADIUS * angularDistance;
-  }
-}
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/distance/LatLonPointRadius.java
b/storage/sis-storage/src/main/java/org/apache/sis/index/tree/LatLonPointRadius.java
similarity index 69%
rename from core/sis-referencing/src/main/java/org/apache/sis/distance/LatLonPointRadius.java
rename to storage/sis-storage/src/main/java/org/apache/sis/index/tree/LatLonPointRadius.java
index a58d767..82a0429 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/distance/LatLonPointRadius.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/index/tree/LatLonPointRadius.java
@@ -15,18 +15,12 @@
  * limitations under the License.
  */
 
-package org.apache.sis.distance;
+package org.apache.sis.index.tree;
 
-//JDK imports
 import java.awt.geom.Area;
 import java.awt.geom.Path2D;
 import java.awt.geom.Rectangle2D;
-
-// GeoAPI import
 import org.opengis.geometry.DirectPosition;
-
-//SIS imports
-import org.apache.sis.geometry.DirectPosition2D;
 import org.apache.sis.measure.Longitude;
 import org.apache.sis.referencing.CommonCRS;
 import org.apache.sis.referencing.GeodeticCalculator;
@@ -34,11 +28,9 @@ import org.apache.sis.referencing.GeodeticCalculator;
 /**
  * Represents a 2D point associated with a radius to enable great circle
  * estimation on earth surface.
- *
- * @deprecated Replaced by {@link org.apache.sis.referencing.GeodeticCalculator#createGeodesicCircle2D(double)}.
  */
-@Deprecated
-public class LatLonPointRadius {
+final class LatLonPointRadius {
+  private static final double HALF_EARTH_CIRCUMFERENCE = 20037.58; // in km
 
   private final DirectPosition center;
   private final double radius;
@@ -51,61 +43,20 @@ public class LatLonPointRadius {
    * @param radius
    *          the radius of the search region
    */
-  public LatLonPointRadius(DirectPosition center, double radius) {
+  LatLonPointRadius(DirectPosition center, double radius) {
     this.center = center;
     this.radius = radius;
   }
 
   /**
-   * Gets the circular region approximation on the earth surface using haversine
-   * formula.
-   *
-   * @param numberOfPoints
-   *          the number of points used to estimate the circular region
-   * @return an array of DirectPosition2D representing the points that estimate the
-   *         circular region
-   */
-  public DirectPosition2D[] getCircularRegionApproximation(int numberOfPoints) {
-    if (radius >= DistanceUtils.HALF_EARTH_CIRCUMFERENCE) {
-      DirectPosition2D[] points = new DirectPosition2D[5];
-      points[0] = new DirectPosition2D(-180.0, -90.0);
-      points[1] = new DirectPosition2D(-180.0, 90.0);
-      points[2] = new DirectPosition2D(180.0, 90.0);
-      points[3] = new DirectPosition2D(180.0, -90.0);
-      points[4] = points[0];
-      return points;
-    }
-    // plus one to add closing point
-    DirectPosition2D[] points = new DirectPosition2D[numberOfPoints + 1];
-
-    double bearingIncrement = 0;
-    if (numberOfPoints > 0) { bearingIncrement = 360/numberOfPoints; }
-
-    final GeodeticCalculator calculator = GeodeticCalculator.create(CommonCRS.SPHERE.geographic());
-    calculator.setStartGeographicPoint(center.getOrdinate(1), center.getOrdinate(0));
-    calculator.setGeodesicDistance(radius);
-
-    for (int i = 0; i < numberOfPoints; i++)
-    {
-      calculator.setStartingAzimuth(i * bearingIncrement);
-      DirectPosition p = calculator.getEndPoint();
-      points[i] = new DirectPosition2D(p.getOrdinate(1), p.getOrdinate(0));
-    }
-
-    points[numberOfPoints] = points[0];
-
-    return points;
-  }
-
-  /**
    * Calculates the rectangular region enclosing the circular search region.
    *
    * @param numberOfPoints
    *          the number of points used to estimate the circular search region
    * @return Java Rectangle2D object that bounds the circlar search region
    */
-  public Rectangle2D getRectangularRegionApproximation(int numberOfPoints) {
-    if (radius >= DistanceUtils.HALF_EARTH_CIRCUMFERENCE) {
+  Rectangle2D getRectangularRegionApproximation(int numberOfPoints) {
+    if (radius >= HALF_EARTH_CIRCUMFERENCE) {
       return new Rectangle2D.Double(0.0, 0.0, 360.0, 180.0);
     }
     int numberOfCrossOvers = 0;
diff --git a/storage/sis-storage/src/main/java/org/apache/sis/index/tree/QuadTree.java b/storage/sis-storage/src/main/java/org/apache/sis/index/tree/QuadTree.java
index cfb8e4d..bda627c 100644
--- a/storage/sis-storage/src/main/java/org/apache/sis/index/tree/QuadTree.java
+++ b/storage/sis-storage/src/main/java/org/apache/sis/index/tree/QuadTree.java
@@ -22,7 +22,6 @@ import java.util.List;
 
 import org.apache.sis.geometry.DirectPosition2D;
 import org.apache.sis.geometry.Envelope2D;
-import org.apache.sis.distance.LatLonPointRadius;
 import org.apache.sis.referencing.CommonCRS;
 import org.apache.sis.referencing.GeodeticCalculator;
 


Mime
View raw message