Author: desruisseaux Date: Thu May 9 11:05:37 2019 New Revision: 1858989 URL: http://svn.apache.org/viewvc?rev=1858989&view=rev Log: Add IP review for GeodeticCalculator. This enable work for SIS-385 and SIS-386: https://issues.apache.org/jira/browse/SIS-385 Added: sis/ip-review/GeodeticCalculator.xhtml sis/ip-review/rev/10796/GeodeticCalculator.xhtml sis/ip-review/rev/20874/GeodeticCalculator.xhtml sis/ip-review/rev/24925/GeodeticCalculator.xhtml Added: sis/ip-review/GeodeticCalculator.xhtml URL: http://svn.apache.org/viewvc/sis/ip-review/GeodeticCalculator.xhtml?rev=1858989&view=auto ============================================================================== --- sis/ip-review/GeodeticCalculator.xhtml (added) +++ sis/ip-review/GeodeticCalculator.xhtml Thu May 9 11:05:37 2019 @@ -0,0 +1,73 @@ + + + + + GeodeticCalculator history + + + +
+

GeodeticCalculator history

+

+ Click on the commit message for inspecting the diff and how the code has been rewritten. + In addition to those differences, the port to Apache SIS also needs to rewrite the code doing actual + geodesic computations in light of comments posted on + SIS-385 and + SIS-386. +

+

Command line:

+
svn log -r31996:1 http://svn.osgeo.org/geotools/trunk/modules/library/referencing/src/main/java/org/geotools/referencing/GeodeticCalculator.java
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Rev.DateAuthorMessage
307602008-06-18desruisseauxUpgrated from JSR-108 to JSR-275 (GEOT-1266). Some opportunist javadoc fixes and @Override annotations in the process.
306412008-06-12acusterCopyright headers: lib/referencing, this time with feeling (and the el in Toolkit)
305212008-06-05acusterCopyright: Update referencing headers
302582008-05-08acusterReshuffle the top level repo: drop uDig, move up trunk, tags, and branches.
302572008-05-08acusterMove trunk/gt/ directory contents up to trunk/ and drop gt
289222008-01-24acusterBump the (at)since version to 2.5 since WKTParser was cut from 2.4
287512008-01-14desruisseauxAttempt to make the GeodeticCalculator slightly more resistant to antipodal case (at least for orthodromic distance).
285402007-12-29acusterHide buttons which are not yet used
280812007-11-27desruisseauxJava 5 constructs: replaced some StringBuffer by StringBuilder in order to avoid unecessary synchronisation; rely on auto-boxing in order to give a chance to the JVM to reuse its cached values.
275752007-10-22desruisseauxConverted Java source files from ISO-LATIN-1 encoding to UTF-8 (GEOT-1516).
249252007-03-27jgarnettchange to org.opengis.geometry
224522006-10-28desruisseauxMoved some methods from CRSUtilities to CRS (GEOT-547).
223272006-10-23desruisseauxGEOT-982: regroup 'module', 'plugin', 'ext' and 'unsupported' in a common directory.
223152006-10-22desruisseauxReorganisation of directory tree structure (GEOT-982) phase 1: moved 'src' to 'src/main/java'.
221132006-10-13desruisseauxJavadoc fixes (include the replacement of {@linkPlain} tag by {@linkplain} - case matter).
217802006-10-03desruisseauxRemoved methods from the referencing module that were deprecated in Geotools 2.3. This imply the replacement of 'CRS.transform' by 'CRS.findMathTransform' in the whole Geotools code base.
215642006-09-23desruisseauxProvide a BufferedCoordinateOperationFactory as a replacement of BufferedDefaultCoordinateOperationFactory. The new implementation work as a wrapper around an arbitrary CoordinateOperationFactory instead of extending DefaultCoordinateOperationFactory. This is especially important since the actual backing factory doesn't need to be DefaultCoordinateOperationFactory, but can also be a AuthorityBackedFactory. The new implementation is automatically registered for FactoryFinder use, so users doesn't need to create instance of it explicitly.
208742006-08-07jgarnettip review
199592006-06-14desruisseauxCRS.decode(String code, boolean longitudeFirst) now work. Also fixed GEOT-856.
197692006-06-02desruisseauxJavadoc fix: replaced 'degrees' by 'decimal degrees' when relevant (GEOT-855)
187762006-03-22desruisseauxCRS.getEnvelope(...) returns an envelope in terms of the specified CRS instead of WGS84 (GEOT-825). AbstractFactory.hints type downgrated from 'Hints' to Map, in order to accept null values as specified in Factory.getImplementationHints() contract. PostgreSQL dependency upgrated.
176722006-01-19desruisseauxAdded @source tag.
176602006-01-18desruisseauxFixed SVN attributes, including the addition of URL attribute.
174322005-12-29desruisseauxMaven 2 fixes for test executions (GEOT-691)
162052005-10-11desruisseauxCleaned javadoc warning. More work done on Maven 2 configuration (GEOT-691)
161722005-10-10desruisseauxMoved a JTS dependency from the CRS class to the JTS class (GEOT-716)
161452005-10-07desruisseauxDependencies cleanup before 2.2.M1 release: move ParseWKT2GeoTiffMetadata and JTS classes (GEOT-716)
153502005-08-16desruisseauxMerged the 'split-main' branch to trunk (GEOT-662)
152802005-08-10desruisseauxMoved GCSUtilities / Moved 'shapeToGeometry' implementation code from 'GeodeticCalculator' to 'JTS' class
152562005-08-09desruisseauxExtraction of referencing module from main
152552005-08-09desruisseauxPrepare branch for splitting main
151502005-08-05desruisseauxAdded more localizations / Bug fix in image sample values table widget
149592005-07-28desruisseauxAdded orthodromic distance computation to OpenOffice formulas
149112005-07-26desruisseauxFixed GEOT-627, 630, 631, 632 and 634
148342005-07-20desruisseauxReorganized I18N resources
139252005-05-30desruisseauxAdded @since javadoc tag
138362005-05-26desruisseauxAdded 'Default' suffix to some CRS implementations: partial work
110012005-02-02desruisseauxFixed wrong encoding in main/src
107962005-01-28dzwiersimports cleaned
102562005-01-05desruisseauxExtracted a complicated 'assert' instruction into a method
101232004-12-31desruisseauxImproved Console implementation
+
+ + Added: sis/ip-review/rev/10796/GeodeticCalculator.xhtml URL: http://svn.apache.org/viewvc/sis/ip-review/rev/10796/GeodeticCalculator.xhtml?rev=1858989&view=auto ============================================================================== --- sis/ip-review/rev/10796/GeodeticCalculator.xhtml (added) +++ sis/ip-review/rev/10796/GeodeticCalculator.xhtml Thu May 9 11:05:37 2019 @@ -0,0 +1,234 @@ + + + + + GeodeticCalculator changes for revisions 10795:10796 + + + +
+

GeodeticCalculator changes for revisions 10795:10796

+

Changes in this commit seem to be the result of some "auto reformat" tool execution. +The Java - GeoAPI - GeoTools import ordering is altered, +imports used only in Javadoc are lost and the encoding of non-ASCII characters is broken. +This commit has been reverted, except for the removal of really unused imports which are keep removed.

+

Command line:

+
svn diff --extensions "--unified --ignore-space-change --ignore-all-space --ignore-eol-style" -r10795:10796 http://svn.osgeo.org/geotools/trunk/modules/library/referencing/src/main/java/org/geotools/referencing/GeodeticCalculator.java
+ + + + + + + + + + + + + + + + + + + + + + +
Revision 10795Revision 10796
// J2SE dependencies
+import java.awt.Shape;
+import java.awt.geom.Line2D;
+import java.awt.geom.Point2D;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.PathIterator;
+import java.awt.geom.IllegalPathStateException;
+import java.util.ArrayList;
+import java.util.List;
+
+// JTS dependencies
+import com.vividsolutions.jts.geom.Geometry;
+import com.vividsolutions.jts.geom.Coordinate;
+import com.vividsolutions.jts.geom.LineString;
+import com.vividsolutions.jts.geom.LinearRing;
+import com.vividsolutions.jts.geom.MultiLineString;
+import com.vividsolutions.jts.geom.GeometryFactory;
+
+// OpenGIS dependencies
+import org.opengis.referencing.datum.Ellipsoid;
+
+// Geotools dependencies
+import org.geotools.measure.Latitude;
+import org.geotools.measure.Longitude;
+import org.geotools.measure.CoordinateFormat;
+import org.geotools.geometry.GeneralDirectPosition;
+import org.geotools.resources.cts.Resources;
+import org.geotools.resources.cts.ResourceKeys;
+import org.geotools.resources.geometry.ShapeUtilities;
+
+
+/**
+ * Performs geodetic calculations on an ellipsoid. This class encapsulate a generic ellipsoid
+ * and calculate the following properties:
// J2SE dependencies
+import java.awt.Shape;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.IllegalPathStateException;
+import java.awt.geom.Line2D;
+import java.awt.geom.PathIterator;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.geotools.geometry.GeneralDirectPosition;
+import org.geotools.measure.CoordinateFormat;
+import org.geotools.measure.Latitude;
+import org.geotools.measure.Longitude;
+import org.geotools.resources.cts.ResourceKeys;
+import org.geotools.resources.cts.Resources;
+import org.geotools.resources.geometry.ShapeUtilities;
+import org.opengis.referencing.datum.Ellipsoid;
+
+import com.vividsolutions.jts.geom.Coordinate;
+import com.vividsolutions.jts.geom.Geometry;
+import com.vividsolutions.jts.geom.GeometryFactory;
+import com.vividsolutions.jts.geom.LineString;
+import com.vividsolutions.jts.geom.LinearRing;
+import com.vividsolutions.jts.geom.MultiLineString;
+
+
+/**
+ * Performs geodetic calculations on an ellipsoid. This class encapsulate a generic ellipsoid
+ * and calculate the following properties:
 * the {@linkplain #getDestinationPoint() destination point} are discarted.
+ * They will need to be specified again.
+ *
+ * @param  longitude The longitude in degrees between -180 and +180°
+ * @param  latitude  The latitude  in degrees between  -90 and  +90°
+ * @throws IllegalArgumentException if the longitude or the latitude is out of bounds.
+ */
+public void setAnchorPoint(double longitude, double latitude) throws IllegalArgumentException {
 * the {@linkplain #getDestinationPoint() destination point} are discarted.
+ * They will need to be specified again.
+ *
+ * @param  longitude The longitude in degrees between -180 and +180�
+ * @param  latitude  The latitude  in degrees between  -90 and  +90�
+ * @throws IllegalArgumentException if the longitude or the latitude is out of bounds.
+ */
+public void setAnchorPoint(double longitude, double latitude) throws IllegalArgumentException {
 * effect of this call. They will be recomputed the next time {@link #getAzimuth()} or
+ * {@link #getOrthodromicDistance()} are invoked.
+ *
+ * @param  longitude The longitude in degrees between -180 and +180°
+ * @param  latitude  The latgitude in degrees between  -90 and  +90°
+ * @throws IllegalArgumentException if the longitude or the latitude is out of bounds.
+ */
+public void setDestinationPoint(double longitude, double latitude) throws IllegalArgumentException {
 * effect of this call. They will be recomputed the next time {@link #getAzimuth()} or
+ * {@link #getOrthodromicDistance()} are invoked.
+ *
+ * @param  longitude The longitude in degrees between -180 and +180�
+ * @param  latitude  The latgitude in degrees between  -90 and  +90�
+ * @throws IllegalArgumentException if the longitude or the latitude is out of bounds.
+ */
+public void setDestinationPoint(double longitude, double latitude) throws IllegalArgumentException {
* The destination point will be updated as a side effect of this call. It will be
+* recomputed the next time {@link #getDestinationPoint()} is invoked.
+*
+* @param  azimuth The azimuth in degrees from -180° to 180°.
+* @param  distance The orthodromic distance in the same units as the
+*         {@linkplain #getEllipsoid ellipsoid} axis.
+* @throws IllegalArgumentException if the azimuth or the distance is out of bounds.
* The destination point will be updated as a side effect of this call. It will be
+* recomputed the next time {@link #getDestinationPoint()} is invoked.
+*
+* @param  azimuth The azimuth in degrees from -180� to 180�.
+* @param  distance The orthodromic distance in the same units as the
+*         {@linkplain #getEllipsoid ellipsoid} axis.
+* @throws IllegalArgumentException if the azimuth or the distance is out of bounds.
 * has been invoked after. In this later case, the azimuth will be computed from the
+ * {@linkplain #getAnchorPoint anchor point} to the destination point.
+ *
+ * @return The azimuth, in degrees from -180° to +180°.
+ * @throws IllegalStateException if the destination point has not been set.
+ */
+public double getAzimuth() throws IllegalStateException {
 * has been invoked after. In this later case, the azimuth will be computed from the
+ * {@linkplain #getAnchorPoint anchor point} to the destination point.
+ *
+ * @return The azimuth, in degrees from -180� to +180�.
+ * @throws IllegalStateException if the destination point has not been set.
+ */
+public double getAzimuth() throws IllegalStateException {
 *         {@linkplain #getAnchorPoint anchor point} to the
+ *         {@linkplain #getDestinationPoint destination point}.
+ *
+ * @todo We should check for cases where the path cross the 90°N, 90°S, 90°E or 90°W boundaries.
+ */
+public Shape getGeodeticCurve(final int numberOfPoints) {
+    checkNumberOfPoints(numberOfPoints);
 *         {@linkplain #getAnchorPoint anchor point} to the
+ *         {@linkplain #getDestinationPoint destination point}.
+ *
+ * @todo We should check for cases where the path cross the 90�N, 90�S, 90�E or 90�W boundaries.
+ */
+public Shape getGeodeticCurve(final int numberOfPoints) {
+    checkNumberOfPoints(numberOfPoints);
** THE FOLLOWING IS CHECKED FOR COMPILER ERROR, BUT EXCLUDED FROM THE .class FILE.  **
+** THIS CODE IS WRONG: LOXODROMIC CURVES ARE STRAIGHT LINES IN MERCATOR PROJECTION, **
+** NOT IT PLAIN (longitude,latitude) SPACE. FURTHERMORE, THE "OUT OF BOUNDS" CHECK  **
+** IS UNFINISHED: WHEN THE PATH CROSS THE 180° LONGITUDE, A +360° ADDITION NEED TO  **
+** BE PERFORMED ON ONE OF THE SOURCE OR TARGET POINT  BEFORE TO COMPUTE THE LINEAR  **
+** INTERPOLATION (OTHERWISE, THE SLOPE VALUE IS WRONG). FORMULAS FOR COMPUTING MID- **
+** POINT ON A LOXODROMIC CURVE ARE AVAILABLE THERE:                                 **
** THE FOLLOWING IS CHECKED FOR COMPILER ERROR, BUT EXCLUDED FROM THE .class FILE.  **
+** THIS CODE IS WRONG: LOXODROMIC CURVES ARE STRAIGHT LINES IN MERCATOR PROJECTION, **
+** NOT IT PLAIN (longitude,latitude) SPACE. FURTHERMORE, THE "OUT OF BOUNDS" CHECK  **
+** IS UNFINISHED: WHEN THE PATH CROSS THE 180� LONGITUDE, A +360� ADDITION NEED TO  **
+** BE PERFORMED ON ONE OF THE SOURCE OR TARGET POINT  BEFORE TO COMPUTE THE LINEAR  **
+** INTERPOLATION (OTHERWISE, THE SLOPE VALUE IS WRONG). FORMULAS FOR COMPUTING MID- **
+** POINT ON A LOXODROMIC CURVE ARE AVAILABLE THERE:                                 **
if (Boolean.FALSE.equals(yDirect)) {
+    /*
+     * Crossing North or South pole is more complicated than what we do for now: If we
+     * follow the 0° longitude toward North, then we have to follow the 180° longitude
+     * from North to South pole and follow the 0° longitude again toward North up to
+     * the destination point.
+     */
+    throw new UnsupportedOperationException("Crossing pole is not yet implemented");
if (Boolean.FALSE.equals(yDirect)) {
+    /*
+     * Crossing North or South pole is more complicated than what we do for now: If we
+     * follow the 0� longitude toward North, then we have to follow the 180� longitude
+     * from North to South pole and follow the 0� longitude again toward North up to
+     * the destination point.
+     */
+    throw new UnsupportedOperationException("Crossing pole is not yet implemented");
}
+/*
+ * The azimuth is heading in the opposite direction of the path from P1 to P2. Computes
+ * the intersection points at the 90°N / 90°S boundaries, or the 180°E / 180°W boundaries.
+ * (xout,yout) is the point where the path goes out (initialized to the corner where the
+ * azimuth is heading); (xin,yin) is the point where the path come back in the opposite
+ * hemisphere.
}
+/*
+ * The azimuth is heading in the opposite direction of the path from P1 to P2. Computes
+ * the intersection points at the 90�N / 90�S boundaries, or the 180�E / 180�W boundaries.
+ * (xout,yout) is the point where the path goes out (initialized to the corner where the
+ * azimuth is heading); (xin,yin) is the point where the path come back in the opposite
+ * hemisphere.
 * The path is diagonal (neither horizontal or vertical). The following loop
+ * is executed exactly twice:  the first pass computes the "out" point,  and
+ * the second pass computes the "in" point.  Each pass computes actually two
+ * points: the intersection point against the 180°W or 180°E boundary, and
+ * the intersection point against the 90°N or 90°S boundary. Usually one of
+ * those points will be out of range and the other one is selected.
+ */
+boolean in = false;
+do {
+    final double meridX, meridY; // The point where the path cross the +/-180° meridian.
+    final double zonalX, zonalY; // The point where the path cross the +/- 90° parallel.
+    meridX = in ? xin : xout;    meridY = dy/dx * (meridX-x1) + y1;
+    zonalY = in ? yin : yout;    zonalX = dx/dy * (zonalY-y1) + x1;
+    if (Math.abs(meridY) < Math.abs(zonalX)*0.5) {
 * The path is diagonal (neither horizontal or vertical). The following loop
+ * is executed exactly twice:  the first pass computes the "out" point,  and
+ * the second pass computes the "in" point.  Each pass computes actually two
+ * points: the intersection point against the 180�W or 180�E boundary, and
+ * the intersection point against the 90�N or 90�S boundary. Usually one of
+ * those points will be out of range and the other one is selected.
+ */
+boolean in = false;
+do {
+    final double meridX, meridY; // The point where the path cross the +/-180� meridian.
+    final double zonalX, zonalY; // The point where the path cross the +/- 90� parallel.
+    meridX = in ? xin : xout;    meridY = dy/dx * (meridX-x1) + y1;
+    zonalY = in ? yin : yout;    zonalX = dx/dy * (zonalY-y1) + x1;
+    if (Math.abs(meridY) < Math.abs(zonalX)*0.5) {
+
+ + Added: sis/ip-review/rev/20874/GeodeticCalculator.xhtml URL: http://svn.apache.org/viewvc/sis/ip-review/rev/20874/GeodeticCalculator.xhtml?rev=1858989&view=auto ============================================================================== --- sis/ip-review/rev/20874/GeodeticCalculator.xhtml (added) +++ sis/ip-review/rev/20874/GeodeticCalculator.xhtml Thu May 9 11:05:37 2019 @@ -0,0 +1,63 @@ + + + + + GeodeticCalculator changes for revisions 20873:20874 + + + +
+

GeodeticCalculator changes for revisions 20873:20874

+

Changes in GeoTools header only. The removal of the "or (at your option) any later version" clause +must be keep in Geotk for every classes having contribution from a developer other than those who accepted re-licensing. +This header does not apply to Apache SIS, since the above-cited contributions are omitted.

+

Command line:

+
svn diff --extensions "--unified --ignore-space-change --ignore-all-space --ignore-eol-style" -r20873:20874 http://svn.osgeo.org/geotools/trunk/modules/library/referencing/src/main/java/org/geotools/referencing/GeodeticCalculator.java
+ + + + + + +
Revision 20873Revision 20874
/*
+ * Geotools 2 - OpenSource mapping toolkit
+ * (C) 2004, Geotools Project Managment Committee (PMC)
+ *
+ *    This library is free software; you can redistribute it and/or
+ *    modify it under the terms of the GNU Lesser General Public
+ *    License as published by the Free Software Foundation; either
+ *    version 2.1 of the License, or (at your option) any later version.
+ *
+ *    This library is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
/*
+ *    GeoTools - OpenSource mapping toolkit
+ *    http://geotools.org
+ *    (C) 2004-2006, GeoTools Project Managment Committee (PMC)
+ *
+ *    This library is free software; you can redistribute it and/or
+ *    modify it under the terms of the GNU Lesser General Public
+ *    License as published by the Free Software Foundation;
+ *    version 2.1 of the License.
+ *
+ *    This library is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *    Lesser General Public License for more details.
+ *
+ *    You should have received a copy of the GNU Lesser General Public
+ *    License along with this library; if not, write to the Free Software
+ *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+/*
+ * Portions of this file is adapted from Fortran code provided by NOAA.
+ * Programmed for CDC-6600 by LCDR L.Pfeifer NGS ROCKVILLE MD 18FEB75
+ * Modified for IBM SYSTEM 360 by John G.Gergen NGS ROCKVILLE MD 7507
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+*    Lesser General Public License for more details.
+*
+* Portions of this file is adapted from Fortran code provided by NOAA.
+* Programmed for CDC-6600 by LCDR L.Pfeifer NGS ROCKVILLE MD 18FEB75
+* Modified for IBM SYSTEM 360 by John G.Gergen NGS ROCKVILLE MD 7507
+
+ + Added: sis/ip-review/rev/24925/GeodeticCalculator.xhtml URL: http://svn.apache.org/viewvc/sis/ip-review/rev/24925/GeodeticCalculator.xhtml?rev=1858989&view=auto ============================================================================== --- sis/ip-review/rev/24925/GeodeticCalculator.xhtml (added) +++ sis/ip-review/rev/24925/GeodeticCalculator.xhtml Thu May 9 11:05:37 2019 @@ -0,0 +1,39 @@ + + + + + GeodeticCalculator changes for revisions 24924:24925 + + + +
+

GeodeticCalculator changes for revisions 24924:24925

+

This commit propagates the package names change which was done in GeoAPI. +There is no way such change could be done differently, +since not renaming the packages cause a compilation error.

+

Command line:

+
svn diff --extensions "--unified --ignore-space-change --ignore-all-space --ignore-eol-style" -r24924:24925 http://svn.osgeo.org/geotools/trunk/modules/library/referencing/src/main/java/org/geotools/referencing/GeodeticCalculator.java
+ + + + +
Revision 24924Revision 24925
import org.opengis.referencing.crs.CompoundCRS;
+import org.opengis.referencing.crs.GeographicCRS;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.spatialschema.geometry.geometry.Position;
+import org.opengis.spatialschema.geometry.DirectPosition;
+
+// Geotools dependencies
+import org.geotools.measure.Angle;
import org.opengis.referencing.crs.CompoundCRS;
+import org.opengis.referencing.crs.GeographicCRS;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.geometry.coordinate.Position;
+import org.opengis.geometry.DirectPosition;
+
+// Geotools dependencies
+import org.geotools.measure.Angle;
+
+ +