Giter Site home page Giter Site logo

spacetrack-client's Introduction

Space-Track Client

This project is a Java client for querying space data (satellites, two-line element sets, etc.) from the "basicspacedata" controller of the Space-Track.org REST API. It uses builder objects to construct queries and automatically deserializes the results into convenient data model objects.

Maven Central Javadoc License

Getting Started

Prerequisites

Space-Track Client requires Java 8+ and uses SLF4J for logging.

Installation

To include Space-Track Client in a Maven project, add the following dependency:

<dependencies>
  ...
  <dependency>
    <groupId>com.stevenpaligo</groupId>
    <artifactId>spacetrack-client</artifactId>
    <version>${spacetrack-client.version}</version>
  </dependency>
  ...
</dependencies>

For non-Maven projects, download the JAR from Maven's Central Repository. The list of dependencies can be found in the pom.xml file (see the source on GitHub)

Usage

The following is a quick "Hello World" example of querying data. The example queries the Satellite Catalog (a.k.a. SatCat) for the International Space Station's data and prints out its apogee height.

/*
   Query for the International Space Station's satellite record (catalog number 25544). Start by
   instantiating the query class that represents Space-Track.org's "request class" (SatCatQuery, TleQuery,
   etc.). Next, set the query's credentials. Then set any predicates, limits, sorting, etc. that
   define how the query functions. In this example, the query is searching for the satellite whose catalog
   number is equal to 25544. Finally, call the `execute()` method to run the query and return results as
   deserialized data model objects.
*/
List<SatCat> results = new SatCatQuery().setCredentials("<user>", "<password>")
  .equal(SatCatQueryField.CATALOG_NUMBER, 25544).execute();


/*
   Print out the apogee height
*/
SatCat internationalSpaceStation = results.get(0);

if (internationalSpaceStation.getApogeeHeightKilometers().isPresent()) {

  long apogeeHeightKm = internationalSpaceStation.getApogeeHeightKilometers().get();
  System.out.println("The International Space Station's apogee height is: " + apogeeHeightKm + " km");

} else {

  System.out.println("The International Space Station's apogee height is: unknown");
}

See the JavaDoc for more information.

Contributions

Contributions (bug reports, feature requests, etc.) are always welcome and should be coordinated through the GitHub Issues system.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the Apache License Version 2.0. See the license file file for details.

spacetrack-client's People

Contributors

stevenpaligo avatar

Stargazers

 avatar

Watchers

 avatar

spacetrack-client's Issues

Add query method to get one result

The queries have an execute() method that returns a list. The client should provide a method for times where the user expects a maximum of one record.

Document TLE's derived values

There are four derived values for TLEs and Latest TLEs: period, SMA, apogee height, perigee height. They may not be calculated how the user expects, so they should be documented. The following formulas come from the SpaceTrack website:

  • period = 1440/n
  • Using mu, the standard gravitational parameter for the earth (398600.4418), semi-major axis "a" = (mu/(n2pi/(24*3600))^2)^(1/3)
  • Using semi-major axis "a", eccentricity "e", and the Earth's radius in km, apogee = (a * (1 + e))- 6378.135
  • Using semi-major axis "a", eccentricity "e", and the Earth's radius in km, perigee = (a * (1 - e))- 6378.135

Perhaps those TLE-related classes would include getters for apogee/perigee radius as well.

Cannot use StartsWith predicate

This doesn't work:

new SatCatQuery()
    .setCredentials(credentials)
    .addPredicate(new StartsWith<>(SatCatQueryField.INTERNATIONAL_DESIGNATOR, "2021-069"))
    .execute();

It should return 4 objects as per:
https://www.space-track.org/basicspacedata/query/class/satcat/INTLDES/^2021-069/format/json

Instead Space-Track API rejects the request with an HTML error message:

<!DOCTYPE html>
<html lang="en-US">
<head>
    <title>Space-Track.Org</title>
    <meta charset="utf-8">
    <meta name="viewport"    content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Space-Track.Org">
    <meta name="keywords"    content="Space, TLE, orbit, satellites, space objects">
    <meta name="author"      content="SAIC [email protected]">
    <meta name="googlebot"   content="noindex">
    <meta name="apple-mobile-web-app-title" content="Space-Track">
    <meta name="application-name" content="Space-Track">
    <meta name="theme-color" content="#ffffff">

    <link rel="apple-touch-icon" sizes="180x180" href="https://www.space-track.org/assets/ico/production/apple-touch-icon.png">
    <link rel="icon" type="image/png" sizes="32x32" href="https://www.space-track.org/assets/ico/production/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="https://www.space-track.org/assets/ico/production/favicon-16x16.png">
    <link rel="icon" type="image/png" sizes="192x192" href="https://www.space-track.org/assets/ico/production/android-chrome-192x192.png">
    <link rel="manifest" href="https://www.space-track.org/assets/ico/production/manifest.json">
    <link rel="mask-icon" href="https://www.space-track.org/assets/ico/production/safari-pinned-tab.svg" color="#2b5797">
    <link rel="shortcut icon" href="https://www.space-track.org/assets/ico/production/favicon.ico?v=m2l0MBPYLl" type="image/ico">

    <script src="https://www.space-track.org/assets/js/jquery-2.1.4.min.js"></script>
    <script src="https://www.space-track.org/assets/js/bootstrap.min.js"></script>
    <script src="https://www.space-track.org/assets/js/st-custom.js"></script>
    
    <link href="https://www.space-track.org/assets/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://www.space-track.org/assets/css/theme/st-slate/bootstrap-theme.min.css" rel="stylesheet">
    <link href="https://www.space-track.org/assets/css/st-custom.css" rel="stylesheet">
    <link href="https://www.space-track.org/assets/css/theme/st-slate/st-custom.css" rel="stylesheet">
</head>
<body>
<div id="container" class="container">
    <div class="row">
        <div class="col-md-12">
            <div class="alert alert-danger">
                <h2>Uh Oh. Something Has Gone Horribly, Horribly Wrong!</h2>
                <p>The URI you submitted has disallowed characters.</p>                <p>If you are coming back to the site after a while, your session may have expired. If so please <a href="/auth/login">log in</a> and try again.</p>
                <p class="text-info">Go <a href="#" onclick="window.history.back();window.location.href='/'; return false;">back</a> or <a href="/">Return to Home Page</a></p>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12 centered">
            <img src="https://www.space-track.org/assets/img/error.jpg" alt="Meteor Hitting Earth" style="width:100%;max-width:800px;" />
        </div>
    </div>
        <div class="push"></div>
        <footer class="footer navbar-fixed-bottom">
                        <p>
                <a href="https://www.facebook.com/SpaceTrack" target="_blank"><img src="https://www.space-track.org/assets/ico/facebooklogo.png" class="social-media-icon" alt="Facebook"></a>
                <a href="https://twitter.com/spacetrackorg" target="_blank"><img src="https://www.space-track.org/assets/ico/twitterlogo.png" class="social-media-icon" alt="Twitter"></a>
                &nbsp;&nbsp;
                Developed by <a href="http://www.saic.com" target='_blank'>SAIC</a> under contract to CFSCC CJ3/6. <a href="https://www.space-track.org/documentation#/contact">Contact Us</a>
            </p>
        </footer>
    </div><!-- /container -->
</body>
</html>

Maybe the ^ should be escaped?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.