This directory contains practical examples demonstrating how to use the predict4java library for satellite tracking and orbit prediction.
Shows how to:
- Load TLE data for a satellite
- Define a ground station position
- Calculate the current position of a satellite
- Determine if a satellite is visible from your location
Use case: Real-time satellite position tracking
Demonstrates:
- Predicting satellite passes over a ground station
- Filtering passes by elevation angle
- Calculating pass duration and timing
- Finding optimal viewing opportunities
Use case: Planning satellite observations, amateur radio contacts
Explains how to:
- Calculate Doppler shift for satellite communications
- Adjust uplink and downlink frequencies
- Account for satellite motion in radio communications
Use case: Amateur radio satellite operations, satellite communication systems
Shows:
- Tracking multiple satellites simultaneously
- Comparing positions of different satellites
- Managing multiple TLE datasets
Use case: Multi-satellite monitoring systems, satellite constellation tracking
- Java 11 or higher
- Maven 3.6 or higher
If you want to use predict4java in your own project, add this to your pom.xml:
<dependency>
<groupId>uk.me.g4dpz</groupId>
<artifactId>predict4java</artifactId>
<version>1.2.0</version>
</dependency>For Gradle projects, add to your build.gradle:
implementation 'uk.me.g4dpz:predict4java:1.2.0'All examples can be easily compiled and run using Maven. The pom.xml file in the examples directory handles all dependencies automatically.
# Navigate to examples directory
cd examples
# Compile and run BasicSatelliteTracking (default)
mvn compile exec:java
# Run a different example by changing the mainClass in pom.xml
# Or use the commands belowBasicSatelliteTracking:
mvn compile exec:java(This is the default mainClass in pom.xml)
PassPrediction:
Edit pom.xml and change:
<mainClass>BasicSatelliteTracking</mainClass>to:
<mainClass>PassPrediction</mainClass>Then run:
mvn compile exec:javaDopplerShiftCalculation:
Change mainClass to DopplerShiftCalculation and run:
mvn compile exec:javaMultiSatelliteTracking:
Change mainClass to MultiSatelliteTracking and run:
mvn compile exec:javaTo start fresh:
mvn clean compile exec:javaTLE (Two-Line Element) data is required for satellite tracking. You can obtain current TLE data from:
-
CelesTrak: https://celestrak.org/
- ISS: https://celestrak.org/NORAD/elements/gp.php?GROUP=stations&FORMAT=tle
- Weather satellites: https://celestrak.org/NORAD/elements/gp.php?GROUP=weather&FORMAT=tle
- Amateur radio satellites: https://celestrak.org/NORAD/elements/gp.php?GROUP=amateur&FORMAT=tle
-
Space-Track.org: https://www.space-track.org/ (requires free registration)
Important: TLE data becomes less accurate over time. Update your TLE data regularly (daily for LEO satellites, weekly for higher orbits).
The examples directory contains:
*.java- Example source filespom.xml- Maven build configuration with all dependenciesREADME.md- This filetarget/- Compiled classes (generated, not in git)
- Java 11 or higher
- Maven 3.6 or higher
- Internet connection (for downloading dependencies on first run)
The pom.xml automatically handles all dependencies:
- predict4java 1.2.0
- Apache Commons Lang3
- SLF4J API
- Joda-Time
The getPositions() method calculates satellite positions over a time range:
List<SatPos> positions = predictor.getPositions(
referenceDate, // The reference time
incrementSeconds, // Time step between calculations (seconds)
minutesBefore, // Minutes before reference time
minutesAfter // Minutes after reference time
);For a single position at the current time, use:
Date now = new Date();
List<SatPos> positions = predictor.getPositions(now, 60, 0, 1);
SatPos position = positions.get(0); // First position in the listThis calculates positions from now to now + 1 minute in 60-second steps, giving you one position.
- Latitude: Degrees, North is positive, South is negative (-90 to +90)
- Longitude: Degrees, East is positive, West is negative (-180 to +180)
- Altitude: Meters above mean sea level
- Azimuth: Compass direction (0° = North, 90° = East, 180° = South, 270° = West)
- Elevation: Angle above horizon (0° = horizon, 90° = directly overhead)
- Range: Distance from ground station to satellite (kilometers)
- Range Rate: Rate of change of range (km/s, negative = approaching, positive = receding)
- Update TLE Data Regularly: TLE accuracy degrades over time
- Check Elevation Angle: Passes with elevation > 10° are generally good for observation
- Account for Obstructions: Trees, buildings, and terrain affect actual visibility
- Time Zones: All calculations use UTC internally; convert to local time for display
- Doppler Shift: Critical for radio communications; recalculate frequently during a pass
These examples are provided under the same MIT license as the predict4java library.
For issues or questions:
- GitHub Issues: https://github.com/g4dpz/predict4java/issues
- Documentation: https://github.com/g4dpz/predict4java