See: Description
Class  Description 

Accumulator 
An accumulator for sums.

Constants 
Constants needed by GeographicLib.

Geodesic 
Geodesic calculations.

GeodesicData 
The results of geodesic calculations.

GeodesicLine 
A geodesic line.

GeodesicMask 
Bit masks for what geodesic calculations to do.

GeoMath 
Mathematical functions needed by GeographicLib.

Gnomonic 
Gnomonic projection.

GnomonicData 
The results of gnomonic projection.

Pair 
A pair of double precision numbers.

PolygonArea 
Polygon areas.

PolygonResult 
A container for the results from PolygonArea.

Exception  Description 

GeographicErr 
Exception handling for GeographicLib.

The documentation for other versions is available at https://geographiclib.sourceforge.io/m.nn/java for versions numbers m.nn ≥ 1.31.
Licensed under the MIT/X11 License; see LICENSE.txt.
GeographicLibJava is a Java implementation of the geodesic algorithms from GeographicLib. This is a selfcontained library which makes it easy to do geodesic computations for an ellipsoid of revolution in a Java program. It requires Java version 1.2 or later.
Download either the source or the prebuilt package as follows:
as either a compressed tar file (tar.gz) or a zip file. After unpacking the source, the Java library can be found in GeographicLib1.48/java. (This library is completely independent from the rest of GeodegraphicLib.) The library consists of the files in the src/main/java/net/sf/geographiclib subdirectory.
<dependency>
<groupId>net.sf.geographiclib</groupId>
<artifactId>GeographicLibJava</artifactId>
<version>1.48</version>
</dependency>
in your pom.xml
.
Included with the source are 3 small test programs
direct/src/main/java/Direct.java
is a simple command line utility
for solving the direct geodesic problem;
inverse/src/main/java/Inverse.java
is a simple command line
utility for solving the inverse geodesic problem;
planimeter/src/main/java/Planimeter.java
is a simple command line
utility for computing the area of a geodesic polygon given its vertices.
Here, for example, is Inverse.java
// Solve the inverse geodesic problem.
// This program reads in lines with lat1, lon1, lat2, lon2 and prints
// out lines with azi1, azi2, s12 (for the WGS84 ellipsoid).
import java.util.*;
import net.sf.geographiclib.*;
public class Inverse {
public static void main(String[] args) {
try {
Scanner in = new Scanner(System.in);
double lat1, lon1, lat2, lon2;
while (true) {
lat1 = in.nextDouble(); lon1 = in.nextDouble();
lat2 = in.nextDouble(); lon2 = in.nextDouble();
GeodesicData g = Geodesic.WGS84.Inverse(lat1, lon1, lat2, lon2);
System.out.println(g.azi1 + " " + g.azi2 + " " + g.s12);
}
}
catch (Exception e) {}
}
}
Three difference ways of compiling and running Inverse.java
are
given. These differ in the degree to which they utilize
maven to manage your Java code and
its dependencies. (Thanks to Skip Breidbach for supplying the maven
support.)
cd inverse/src/main/java javac cp .:../../../../src/main/java Inverse.java echo 30 0 29.5 179.5  java cp .:../../../../src/main/java InverseOn Windows, change this to
cd inverse\src\main\java javac cp .;../../../../src/main/java Inverse.java echo 30 0 29.5 179.5  java cp .;../../../../src/main/java Inverse
mvn package(Your first run of maven may take a long time, because it needs to download some additional packages to your local repository.) Then compile and run Inverse.java with
cd inverse/src/main/java javac cp .:../../../../target/GeographicLibJava1.48.jar Inverse.java echo 30 0 29.5 179.5  java cp .:../../../../target/GeographicLibJava1.48.jar Inverse
Inverse.java
pom.xml
which specifies
GeographicLibJave as a dependency. You can build and install this
dependency by running (in the main java directory) mvn installAlternatively, you can let maven download it from Maven Central. You can compile and run Inverse.java with
cd inverse mvn compile echo 30 0 29.5 179.5  mvn q exec:java
import net.sf.geographiclib.*in your source code.
The important classes are
Geodesic
, for direct and inverse geodesic
calculations;
GeodesicLine
, an efficient way of
calculating multiple points on a single geodesic;
GeodesicData
, the object containing the
results of the geodesic calculations;
GeodesicMask
, the constants that let you
specify the variables to return in GeodesicData
and the capabilities of a GeodesicLine
;
Constants
, the parameters for the WGS84
ellipsoid;
PolygonArea
, a class to compute the
perimeter and area of a geodesic polygon (returned as a PolygonResult
).
The documentation is generated using javadoc when
mvn package P release
is run (the top of the documentation tree is
target/apidocs/index.html
). This is also available on the web at
https://geographiclib.sourceforge.io/html/java/index.html.
Gnomonic
(courtesy of Sebastian Mattheis).
Copyright © 2017. All Rights Reserved.