Skip to content

Commit 0e54f64

Browse files
author
Charles Karney
committed
Merge from devel for version 1.52
2 parents 4d3774c + 8988839 commit 0e54f64

File tree

8 files changed

+48
-23
lines changed

8 files changed

+48
-23
lines changed

java/direct/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<groupId>net.sf.geographiclib.example</groupId>
1010
<artifactId>Direct</artifactId>
1111
<name>Direct</name>
12-
<version>1.51-SNAPSHOT</version>
12+
<version>1.52-SNAPSHOT</version>
1313

1414
<packaging>jar</packaging>
1515

@@ -28,7 +28,7 @@
2828
<dependency>
2929
<groupId>net.sf.geographiclib</groupId>
3030
<artifactId>GeographicLib-Java</artifactId>
31-
<version>1.51</version>
31+
<version>1.52</version>
3232
</dependency>
3333
</dependencies>
3434

java/inverse/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<groupId>net.sf.geographiclib.example</groupId>
1010
<artifactId>Inverse</artifactId>
1111
<name>Inverse</name>
12-
<version>1.51-SNAPSHOT</version>
12+
<version>1.52-SNAPSHOT</version>
1313

1414
<packaging>jar</packaging>
1515

@@ -28,7 +28,7 @@
2828
<dependency>
2929
<groupId>net.sf.geographiclib</groupId>
3030
<artifactId>GeographicLib-Java</artifactId>
31-
<version>1.51</version>
31+
<version>1.52</version>
3232
</dependency>
3333
</dependencies>
3434

java/planimeter/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<groupId>net.sf.geographiclib.example</groupId>
1010
<artifactId>Planimeter</artifactId>
1111
<name>Planimeter</name>
12-
<version>1.51-SNAPSHOT</version>
12+
<version>1.52-SNAPSHOT</version>
1313

1414
<packaging>jar</packaging>
1515

@@ -28,7 +28,7 @@
2828
<dependency>
2929
<groupId>net.sf.geographiclib</groupId>
3030
<artifactId>GeographicLib-Java</artifactId>
31-
<version>1.51</version>
31+
<version>1.52</version>
3232
</dependency>
3333
</dependencies>
3434

java/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<groupId>net.sf.geographiclib</groupId>
1010
<artifactId>GeographicLib-Java</artifactId>
11-
<version>1.51</version>
11+
<version>1.52</version>
1212

1313
<packaging>jar</packaging>
1414

java/src/main/java/net/sf/geographiclib/GeoMath.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ public static double atan2d(double y, double x) {
243243
case 1: ang = (y >= 0 ? 180 : -180) - ang; break;
244244
case 2: ang = 90 - ang; break;
245245
case 3: ang = -90 + ang; break;
246+
default: break;
246247
}
247248
return ang;
248249
}

java/src/main/java/net/sf/geographiclib/Geodesic.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Implementation of the net.sf.geographiclib.Geodesic class
33
*
4-
* Copyright (c) Charles Karney (2013-2020) <charles@karney.com> and licensed
4+
* Copyright (c) Charles Karney (2013-2021) <charles@karney.com> and licensed
55
* under the MIT/X11 License. For more information, see
66
* https://geographiclib.sourceforge.io/
77
**********************************************************************/
@@ -759,7 +759,9 @@ private InverseData InverseInt(double lat1, double lon1,
759759
// not a shortest path.
760760
if (sig12 < 1 || m12x >= 0) {
761761
// Need at least 2, to handle 90 0 90 180
762-
if (sig12 < 3 * tiny_)
762+
if (sig12 < 3 * tiny_ ||
763+
// Prevent negative s12 or m12 for short lines
764+
(sig12 < tol0_ && (s12x < 0 || m12x < 0)))
763765
sig12 = m12x = s12x = 0;
764766
m12x *= _b;
765767
s12x *= _b;
@@ -842,7 +844,6 @@ private InverseData InverseInt(double lat1, double lon1,
842844
ssig2 = w.ssig2; csig2 = w.csig2;
843845
eps = w.eps; domg12 = w.domg12;
844846
dV = w.dlam12;
845-
// 2 * tol0 is approximately 1 ulp for a number in [0, pi].
846847
// Reversed test to allow escape with NaNs
847848
if (tripb || !(Math.abs(V) >= (tripn ? 8 : 1) * tol0_)) break;
848849
// Update bracketing values

java/src/main/java/net/sf/geographiclib/package-info.java

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* <h2>Geodesic routines from GeographicLib implemented in Java</h2>
33
* @author Charles F. F. Karney (charles@karney.com)
4-
* @version 1.51
4+
* @version 1.52
55
*
66
* <p>
77
* The documentation for other versions is available at
@@ -29,15 +29,15 @@
2929
* GeographicLib-Java is part of GeographicLib which available for download at
3030
* <ul>
3131
* <li>
32-
* <a href="https://sourceforge.net/projects/geographiclib/files/distrib/GeographicLib-1.51.tar.gz">
33-
* GeographicLib-1.51.tar.gz</a>
32+
* <a href="https://sourceforge.net/projects/geographiclib/files/distrib/GeographicLib-1.52.tar.gz">
33+
* GeographicLib-1.52.tar.gz</a>
3434
* <li>
35-
* <a href="https://sourceforge.net/projects/geographiclib/files/distrib/GeographicLib-1.51.zip">
36-
* GeographicLib-1.51.zip</a>
35+
* <a href="https://sourceforge.net/projects/geographiclib/files/distrib/GeographicLib-1.52.zip">
36+
* GeographicLib-1.52.zip</a>
3737
* </ul>
3838
* <p>
3939
* as either a compressed tar file (tar.gz) or a zip file. After unpacking
40-
* the source, the Java library can be found in GeographicLib-1.51/java. (This
40+
* the source, the Java library can be found in GeographicLib-1.52/java. (This
4141
* library is completely independent from the rest of GeodegraphicLib.) The
4242
* library consists of the files in the src/main/java/net/sf/geographiclib
4343
* subdirectory.
@@ -50,7 +50,7 @@
5050
* <dependency>
5151
* <groupId>net.sf.geographiclib</groupId>
5252
* <artifactId>GeographicLib-Java</artifactId>
53-
* <version>1.51</version>
53+
* <version>1.52</version>
5454
* </dependency> }</pre>
5555
* in your {@code pom.xml}.
5656
*
@@ -119,9 +119,9 @@
119119
* some additional packages to your local repository.) Then compile and run
120120
* Inverse.java with <pre>
121121
* cd inverse/src/main/java
122-
* javac -cp .:../../../../target/GeographicLib-Java-1.51.jar Inverse.java
122+
* javac -cp .:../../../../target/GeographicLib-Java-1.52.jar Inverse.java
123123
* echo -30 0 29.5 179.5 |
124-
* java -cp .:../../../../target/GeographicLib-Java-1.51.jar Inverse </pre>
124+
* java -cp .:../../../../target/GeographicLib-Java-1.52.jar Inverse </pre>
125125
*
126126
* <h4>Using maven to build and run {@code Inverse.java}</h4>
127127
* The sample code includes a {@code pom.xml} which specifies
@@ -265,7 +265,15 @@
265265
* <h3>Change log</h3>
266266
* <ul>
267267
* <li>
268-
* <a href="https://geographiclib.sourceforge.io/1.47/java">Version 1.51</a>
268+
* <a href="https://geographiclib.sourceforge.io/1.52/java">Version 1.52</a>
269+
* (released 2021-mm-dd)
270+
* <ul>
271+
* <li>
272+
* Be more aggressive in preventing negative s12 and m12 for short
273+
* lines.
274+
* </ul>
275+
* <li>
276+
* <a href="https://geographiclib.sourceforge.io/1.51/java">Version 1.51</a>
269277
* (released 2020-11-22)
270278
* <ul>
271279
* <li>
@@ -284,7 +292,7 @@
284292
* Update to Java 1.7 or later to support testing on Mac OSX.
285293
* </ul>
286294
* <li>
287-
* <a href="https://geographiclib.sourceforge.io/1.47/java">Version 1.50</a>
295+
* <a href="https://geographiclib.sourceforge.io/1.50/java">Version 1.50</a>
288296
* (released 2019-09-24)
289297
* <ul>
290298
* <li>
@@ -303,14 +311,14 @@
303311
* &minus;0.
304312
* </ul>
305313
* <li>
306-
* <a href="https://geographiclib.sourceforge.io/1.47/java">Version 1.49</a>
314+
* <a href="https://geographiclib.sourceforge.io/1.49/java">Version 1.49</a>
307315
* (released 2017-10-05)
308316
* <ul>
309317
* <li>
310318
* Fix code formatting and add two tests.
311319
* </ul>
312320
* <li>
313-
* <a href="https://geographiclib.sourceforge.io/1.47/java">Version 1.48</a>
321+
* <a href="https://geographiclib.sourceforge.io/1.48/java">Version 1.48</a>
314322
* (released 2017-04-09)
315323
* <ul>
316324
* <li>

java/src/test/java/net/sf/geographiclib/GeodesicTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,9 @@ public void GeodSolve80() {
595595
assertEquals(inv.M12, 1, 1e-15);
596596
assertEquals(inv.M21, 1, 1e-15);
597597
assertEquals(inv.S12, 0, 1e-10);
598+
assertTrue(Math.copySign(1, inv.a12) > 0);
599+
assertTrue(Math.copySign(1, inv.s12) > 0);
600+
assertTrue(Math.copySign(1, inv.m12) > 0);
598601

599602
inv = Geodesic.WGS84.Inverse(90, 0, 90, 180, GeodesicMask.ALL);
600603
assertEquals(inv.a12, 0, 1e-13);
@@ -651,6 +654,18 @@ public void GeodSolve84() {
651654
assertTrue(isNaN(dir.azi2));
652655
}
653656

657+
@Test
658+
public void GeodSolve92() {
659+
// Check fix for inaccurate hypot with python 3.[89]. Problem reported
660+
// by agdhruv https://github.com/geopy/geopy/issues/466 ; see
661+
// https://bugs.python.org/issue43088
662+
GeodesicData inv = Geodesic.WGS84.Inverse(37.757540000000006, -122.47018,
663+
37.75754, -122.470177);
664+
assertEquals(inv.azi1, 89.99999923, 1e-7 );
665+
assertEquals(inv.azi2, 90.00000106, 1e-7 );
666+
assertEquals(inv.s12, 0.264, 0.5e-3);
667+
}
668+
654669
@Test
655670
public void Planimeter0() {
656671
// Check fix for pole-encircling bug found 2011-03-16

0 commit comments

Comments
 (0)