<commit_before># TLE

A package for parsing, formatting, and building TLEs [(Two Line Element Sets)](https://en.wikipedia.org/wiki/Two-line_element_set).

## Version 1.1.1 - 12/03/2016

[Full Change Log](https://github.com/zakrywilson/TLE/blob/master/CHANGELOG.md)

Improved efficiency of EpochUtils class

- No longer using *synchronized* methods but instead using a single atomic reference to the shared resource  
- Cutting down on java.util.Calendar instances  

Enhanced TLEBuilder

- Changing around steps for more intuitive TLE construction (e.g., mean motion has been taken out of orbital elements step)  
- Making TLEBuilder class more robust by adding more input parameter range checks (and throwing IllegalArgumentExceptions in such cases)  

Bug fixs in TLEFormatter

- Fixed issue where mean motion formatted strings could be shorter than needed  
- Now rounding *half up* for values exceeding precision when formatting  

## Getting Started

### Prerequisites

* Java 8  
* Maven 3 

### Installing

#### Linux / macOS

- Run the following commands:
```bash
git clone https://github.com/zakrywilson/TLE.git  
cd TLE  
mvn package  
cd target  
```
- Copy the JARs to your project.
- Add JARs to your project's classpath.

#### Windows

- Download repository [here](https://github.com/zakrywilson/TLE/archive/master.zip).  
- Unzip the file.  
- Navigate to the unzipped file.  
- Run the following commands inside the root folder:
```dos
mvn package  
cd target  
```
- Copy the JARs to your project.
- Add JARs to your project's classpath.

## How to Use

### Parsing a TLE

```java
// Say you have a TLE
String title = "ASTROSAT                ";
String line1 = "1 40930U 15052A   16332.17311884  .00000840  00000-0  29196-4 0  9990";
String line2 = "2 40930   5.9978 234.6882 0008785 270.8436  89.0759 14.76065788 63051";

// And you want to pull out the inclination, the RAAN, the BSTAR drag term
// Pass the lines into the constructor
TLE tle = new TLE(title, line1, line2);

// Now you can access any of the elements
double inclination = tle.getInclination();
double raan = tle.getRaan();
double dragTerm = tle.getDragTerm();
```

### Building a TLE

You can build a TLE from individual elements.  

#### A Little About the Design

This builder enforces the correct construction of a TLE. The [TLEBuilder](https://github.com/zakrywilson/TLE/blob/master/src/main/java/com/zakrywilson/astro/tle/TLEBuilder.java) class implements a variant of the builder pattern which enforces the user to, at a minimum, pass in the required elements into the builder for valid TLE construction. Once the required elements have been received, the `BuildStep#build()` method will be available. Part of this builder pattern's implementation is the use of *steps* which is a polymorphic procedural mitigation of the TLE's construction. For example, `SatelliteNumberStep#setSatelliteNumber(int)` returns the one option of `InternationalDesignatorStep#setInternationalDesignator(String)` which returns two options of `EpochStep#setEpoch(int, double)` or `EpochStep#setEpoch(long)`, and so forth. Once all the required steps have been completed, `BuildStep#build()` will be available for the TLE to be built. When the TLE is allowed to be built, the optional elements will also be available to be set, such as *classification* and *ephemeris type*. 

Note: there is also no checksum step: checksums are calculated when the TLE lines are generated.

The list of steps in order (after calling `TLEBuilder#newBuilder()` or `TLEBuilder#newBuilder(String)`):

1. **Satellite number step**  
2. **International designator step**  
3. **Epoch step**  
4. **Element set number step**  
5. **Orbital elements step**  
6. **Revolutions at epoch step**  <commit_msg>Added more to README<commit_after># TLE

A package for parsing, formatting, and building TLEs [(Two Line Element Sets)](https://en.wikipedia.org/wiki/Two-line_element_set).

## Version 1.1.1 - 12/03/2016

[Full Change Log](https://github.com/zakrywilson/TLE/blob/master/CHANGELOG.md)

Improved efficiency of EpochUtils class

- No longer using *synchronized* methods but instead using a single atomic reference to the shared resource  
- Cutting down on java.util.Calendar instances  

Enhanced TLEBuilder

- Changing around steps for more intuitive TLE construction (e.g., mean motion has been taken out of orbital elements step)  
- Making TLEBuilder class more robust by adding more input parameter range checks (and throwing IllegalArgumentExceptions in such cases)  

Bug fixs in TLEFormatter

- Fixed issue where mean motion formatted strings could be shorter than needed  
- Now rounding *half up* for values exceeding precision when formatting  

## Getting Started

### Prerequisites

* Java 8  
* Maven 3 

### Installing

#### Linux / macOS

- Run the following commands:
```bash
git clone https://github.com/zakrywilson/TLE.git  
cd TLE  
mvn package  
cd target  
```
- Copy the JARs to your project.
- Add JARs to your project's classpath.

#### Windows

- Download repository [here](https://github.com/zakrywilson/TLE/archive/master.zip).  
- Unzip the file.  
- Navigate to the unzipped file.  
- Run the following commands inside the root folder:
```dos
mvn package  
cd target  
```
- Copy the JARs to your project.
- Add JARs to your project's classpath.

## How to Use

### Parsing a TLE

Say you have a TLE and you want to pull out the inclination, the BSTAR drag term, and the right ascension of the ascending node (RAAN).

```java
String title = "ASTROSAT                ";
String line1 = "1 40930U 15052A   16332.17311884  .00000840  00000-0  29196-4 0  9990";
String line2 = "2 40930   5.9978 234.6882 0008785 270.8436  89.0759 14.76065788 63051";
```

Pass the lines into the constructor.

```java
TLE tle = new TLE(title, line1, line2);
```

Now you can access any of the elements

```java
double inclination = tle.getInclination();
System.out.println(inclination);
// 5.9978

double raan = tle.getRaan();
System.out.println(raan);
// 234.6882

double dragTerm = tle.getDragTerm();
System.out.println(dragTerm);
// 2.9196E-5
```

### Building a TLE

You can build a TLE from individual elements.  

#### A Little About the Design

This builder enforces the correct construction of a TLE. The [TLEBuilder](https://github.com/zakrywilson/TLE/blob/master/src/main/java/com/zakrywilson/astro/tle/TLEBuilder.java) class implements a variant of the builder pattern which enforces the user to, at a minimum, pass in the required elements into the builder for valid TLE construction. Once the required elements have been received, the `BuildStep#build()` method will be available. Part of this builder pattern's implementation is the use of *steps* which is a polymorphic procedural mitigation of the TLE's construction. For example, `SatelliteNumberStep#setSatelliteNumber(int)` returns the one option of `InternationalDesignatorStep#setInternationalDesignator(String)` which returns two options of `EpochStep#setEpoch(int, double)` or `EpochStep#setEpoch(long)`, and so forth. Once all the required steps have been completed, `BuildStep#build()` will be available for the TLE to be built. When the TLE is allowed to be built, the optional elements will also be available to be set, such as *classification* and *ephemeris type*. 

Note: there is also no checksum step: checksums are calculated when the TLE lines are generated.

The list of steps in order (after calling `TLEBuilder#newBuilder()` or `TLEBuilder#newBuilder(String)`):

1. **Satellite number step**  
2. **International designator step**  
3. **Epoch step**  
4. **Element set number step**  
5. **Orbital elements step**  
6. **Revolutions at epoch step**  
{'fraction_non_alphanumeric': 0.08851052768390955, 'fraction_numerical': 0.03483233688588511, 'mean_word_length': 4.174848688634835, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2155631', 'n_tokens_mistral': 2537, 'n_tokens_neox': 2249, 'n_words': 954}