gpsaltprofile4j
Little Java library for turning GPS traces with altitude information into altitude profiles.
Uses Spherical law of cosines for calculating distances between points of the trace, using the geocalc library.
Supported formats
Currently the following input formats are supported (using gpsformats4j):
- CSV (requires columns in this order: track, time, lat, lon, elevation)
- GPX
- TCX
- KML (only
LineString
tag)
Current supported output formats:
- CSV (columns: track, time, distance, elevation)
- PNG (options: width, height)
Example usage
Using it with the provided generate.sh
/generate.bat
scripts (custom dimensions for image):
./generate.sh --in_file test.gpx --in_format GPX --out_file out.csv --out_format PNG --out_options "width=2000 height=400"
Calling the Generate
class directly:
java -cp "./lib/*" com.github.fracpete.gpsaltprofile4j.Generate \
--in_file test.gpx --in_format GPX \
--out_file out.png --out_format PNG --out_options "width=2000 height=400"
Using Java code:
import com.github.fracpete.gpsaltprofile4j.Generate;
import java.io.File;
...
Genreate generate = new Generate();
generate.setInputFile(new File("test.gpx"));
generate.setInputFormat("GPX");
generate.setOutputFile(new File("out.png"));
generate.setOutputFormat("PNG");
generate.setOutputOptions("width=2000 height=400");
String msg = generate.execute();
// successful if null returned:
if (msg != null)
System.err.println(msg);
Releases
The following releases are available:
Maven
Use the following dependency to include the library in your Maven project:
<dependency>
<groupId>com.github.fracpete</groupId>
<artifactId>gpsaltprofile4j</artifactId>
<version>0.0.1</version>
</dependency>
Screenshot
Example profile: