Click or drag to resize

Satellite Tracker

This Swing application computes access between a user-selected satellite viewed from a user-defined location during a user-specified time period, and generates ground tracks on an interactive map component, as well as producing a table of viewing opportunities.

Satellite Tracker
Satellite Tracker

The source code files for the application can be found in the STK Components install at Examples\SatelliteTracker\.

Since the code is fully commented, only selected classes, properties and methods are discussed here briefly.

Identifying Viewing Opportunities

Among other things, the application identifies time intervals when the satellite can be viewed from a defined location. As illustrated in the above figure, portions of the satellite's ground track corresponding to periods when it can be seen from the defined location are highlighted in a different color than the rest of the ground track, and information about those periods of visibility, including the azimuth and elevation of the satellite's approach and departure, is listed in a table.

The SatelliteTracker class is the window that collects user input from the UI controls, via Swing listener classes, into a UserInput class. This object is then used to construct a Computation class, which is where the majority of the work is done.

The Computation class begins by creating Platform objects representing the user-specified satellite and viewing location, then creates an ElevationAngleConstraint instance based on user input for the minimum elevation angle, and an AccessQuery instance using those platforms and the constraint.

Then, access is calculated, and for each interval of access, the approach and departure azimuth and elevation are computed. Finally, a list of GroundTrackPosition objects are created to trace the position of the satellite to be drawn on the map.

The same STK Components types are used in substantially the same way in the Tutorial. Please see that topic for details on how the access computation works.

Visualization

An interactive map is presented to visualize the results. This map is a Swing component that is available as part of the SwingX project, and displays map image data from OpenStreetMap.

Satellite Database

This application lets the user select the satellite of interest from a specified category:

Satellite Tracker Select Satellite

The functionality utilized here is provided by the Database class:

Java
public class Database {
    public Database() {
        m_stkSatelliteDatabase = new StkSatelliteDatabase(SatelliteTracker.getDataFilePath("SatelliteDatabase"), "stkSatDb");

        ArrayList<String> categories = new ArrayList<>();
        for (String mission : m_stkSatelliteDatabase.getMissions()) {
            if (categoryHasSatellites(mission)) {
                categories.add(mission);
            }
        }

        Collections.sort(categories);
        categories.add(USER_ENTERED_TLE);
        m_categories = Collections.unmodifiableList(categories);
    }

    private boolean categoryHasSatellites(String category) {
        StkSatelliteDatabaseQuery query = new StkSatelliteDatabaseQuery();
        query.setMission(Pattern.compile(category));

        for (StkSatelliteDatabaseEntry entry : m_stkSatelliteDatabase.getEntries(query)) {
            if (entry.getTwoLineElementSet() != null) {
                return true;
            }
        }
        return false;
    }

    public GregorianDate getLastUpdateDate() {
        return m_stkSatelliteDatabase.getLastUpdateDate();
    }

    /**
     * Query the database for an array of names of satellites that are in a
     * given category.
     *
     * @param category
     *            The category (mission) of the satellites.
     * @return An array of names of satellites that are in the category.
     */
    public String[] getSatellitesInCategory(String category) {
        ArrayList<String> result = new ArrayList<>();

        StkSatelliteDatabaseQuery query = new StkSatelliteDatabaseQuery();
        query.setMission(Pattern.compile(category));
        for (StkSatelliteDatabaseEntry entry : m_stkSatelliteDatabase.getEntries(query)) {
            if (entry.getTwoLineElementSet() != null) {
                result.add(entry.getCommonName());
            }
        }

        Collections.sort(result);
        return result.toArray(new String[result.size()]);
    }

    /**
     * Query the database for an array of category names.
     *
     * @return An array of names of categories (missions) for satellites.
     */
    public String[] getCategories() {
        return m_categories.toArray(new String[m_categories.size()]);
    }

    /**
     * Query the database to find the TLE for a particular satellite.
     *
     * @param category
     *            The category (mission) of the satellite.
     * @param spacecraft
     *            The name of the satellite.
     * @return The TLE for the given satellite if it exists, otherwise an empty
     *         string.
     */
    public String getTLEText(String category, String spacecraft) {
        StkSatelliteDatabaseQuery query = new StkSatelliteDatabaseQuery();
        query.setMission(Pattern.compile(category));
        query.setCommonName(Pattern.compile(spacecraft));

        for (StkSatelliteDatabaseEntry entry : m_stkSatelliteDatabase.getEntries(query)) {
            if (entry.getTwoLineElementSet() != null) {
                return entry.getTwoLineElementSet().toTleString();
            }
        }

        return "";
    }

    public static final String USER_ENTERED_TLE = "User-entered TLE";

    private final StkSatelliteDatabase m_stkSatelliteDatabase;
    private final List<String> m_categories;
}