Skip to content

Commit

Permalink
Version 4.1.4.
Browse files Browse the repository at this point in the history
  • Loading branch information
ezze committed Jul 18, 2022
2 parents cb2fc41 + e7a393a commit 3c1efc0
Show file tree
Hide file tree
Showing 17 changed files with 1,174 additions and 503 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
language: node_js
node_js:
- "15"
- "14"
- "13"
- "12"
- "11"
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 4.1.4 (2022-07-18)

- TypeScript definition for `ecfToEci` function is added.

## 4.1.3 (2020-12-18)

- Fixed calculation of Doppler effect (`dopplerFactor`).
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ git merge origin/develop
git checkout -b my-feature
```

Make sure that your changes don't brake the existing code by running
Make sure that your changes don't break the existing code by running

```bash
npm test
Expand Down Expand Up @@ -301,6 +301,14 @@ These is a full list of all available NPM scripts:
COVERALLS_REPO_TOKEN=<token> npm run test:coveralls
```

## ES5 and satellite.min.js

Some people are confused that they can't just download a single satellite.js or satellite.min.js file. That is because satellite.js is not written in plain old JavaScript (ES5) anymore but ported to latter JavaScript versions ES6+.
Only the "src" directory is included in the Git repository, "dist" and "lib" directories are ignored. It's done intentionally to retain the size of the repository as small as possible. A full detailed explanation of why is located [here](https://github.com/shashwatak/satellite-js/issues/80#issuecomment-749225324).

You should install satellite.js with your package manager (npm or yarn) and then find satellite.js and satellite.min.js in node_modules/satellite.js/dist directory.

## TODO

Optional functions that utilize Worker Threads
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "satellite.js",
"version": "4.1.3",
"version": "4.1.4",
"description": "SGP4/SDP4 calculation library",
"main": "lib/index.js",
"jsnext:main": "dist/satellite.es.js",
Expand Down
12 changes: 6 additions & 6 deletions test/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "airbnb-base",
"env": {
"jest": true
}
}
{
"extends": "airbnb-base",
"env": {
"jest": true
}
}
24 changes: 23 additions & 1 deletion test/dopplerFactor.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import dopplerFactor from '../src/dopplerFactor'; // eslint-disable-line
import dopplerFactor from '../src/dopplerFactor';

const numDigits = 8;

Expand Down Expand Up @@ -67,4 +67,26 @@ describe('Doppler factor', () => {
const dopFactor = dopplerFactor(observerEcf, positionEcf, velocityEcf);
expect(dopFactor).toBeCloseTo(1.0000107847789212, numDigits);
});

it('calculated from a negative range rate', () => {
// North Pole
const observerEcf = {
x: -500,
y: 0,
z: earthRadius + 500,
};
const positionEcf = {
x: 500,
y: 0,
z: earthRadius,
};
// Escape velocity
const velocityEcf = {
x: -7.91,
y: -3.12,
z: 0,
};
const dopFactor = dopplerFactor(observerEcf, positionEcf, velocityEcf);
expect(dopFactor).toBeCloseTo(1.0000235993898179, numDigits);
});
});
47 changes: 24 additions & 23 deletions test/ext.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import compareVectors from './compareVectors';

import {
jday,
invjday,
} from '../src/ext';
import { jday, invjday } from '../src/ext';
import twoline2satrec from '../src/io';
import { propagate, gstime } from '../src/propagation';

Expand All @@ -15,15 +12,17 @@ describe('Julian date / time', () => {

describe('jday & invjday', () => {
it('gives the same result with different arguments describing the same time', () => {
expect(jday(now)).toEqual(jday(
now.getUTCFullYear(),
now.getUTCMonth() + 1,
now.getUTCDate(),
now.getUTCHours(),
now.getUTCMinutes(),
now.getUTCSeconds(),
now.getUTCMilliseconds(),
));
expect(jday(now)).toEqual(
jday(
now.getUTCFullYear(),
now.getUTCMonth() + 1,
now.getUTCDate(),
now.getUTCHours(),
now.getUTCMinutes(),
now.getUTCSeconds(),
now.getUTCMilliseconds(),
),
);
});

it('outputs different results when milliseconds are passed', () => {
Expand Down Expand Up @@ -89,21 +88,23 @@ describe('Julian date / time', () => {

it('date to jday and inverse conversion', () => {
const jd = jday(now);
const expected = ((now.getTime() - now.getMilliseconds()) / 1000);
const expected = (now.getTime() - now.getMilliseconds()) / 1000;
expect(invjday(jd).getTime() / 1000).toEqual(expected);
});
});

it('gstime gives the same result with different arguments describing the same time', () => {
expect(gstime(now)).toEqual(gstime(
now.getUTCFullYear(),
now.getUTCMonth() + 1,
now.getUTCDate(),
now.getUTCHours(),
now.getUTCMinutes(),
now.getUTCSeconds(),
now.getUTCMilliseconds(),
));
expect(gstime(now)).toEqual(
gstime(
now.getUTCFullYear(),
now.getUTCMonth() + 1,
now.getUTCDate(),
now.getUTCHours(),
now.getUTCMinutes(),
now.getUTCSeconds(),
now.getUTCMilliseconds(),
),
);
});

it('propagation gives the same result with different arguments describing the same time', () => {
Expand Down
34 changes: 34 additions & 0 deletions test/io.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"tleLine1": "1 00001U 57001B 21005.53831292 -.00000083 00000-0 -11575-3 0 9996",
"tleLine2": "2 00001 34.2508 325.6936 1846988 181.8107 177.4919 00.00000000227203",
"description": "Mean motion is zero and that is not allowed.",
"results": [{
"error": 2
}]
},
{
"tleLine1": "1 00002U 57001B 21005.53831292 -.00000083 00000-0 -11575-3 0 9996",
"tleLine2": "2 00002 34.2508 325.6936 1846988 181.8107 177.4919 00.00000001227203",
"description": "Eccentricity is way too high because mean motion is nearly zero.",
"results": [{
"error": 3
}]
},
{
"tleLine1": "1 00004U 57001B 21005.53831292 -.00000083 00000-0 -11575-3 0 9996",
"tleLine2": "2 00004 34.2508 325.6936 9999999 181.8107 177.4919 10.84863720227203",
"description": "Mean motion is zero and that is not allowed.",
"results": [{
"error": 4
}]
},
{
"tleLine1": "1 00006U 57001B 21005.53831292 -.00000083 00000-0 -11575-3 0 9996",
"tleLine2": "2 00005 34.2508 325.6936 1846988 181.8107 177.4919 25.84863720227203",
"description": "Satellite should be decayed already.",
"results": [{
"error": 6
}]
}
]
11 changes: 9 additions & 2 deletions test/io.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import twoline2satrec from '../src/io'; // eslint-disable-line
import twoline2satrec from '../src/io';
import badTleData from './io.json';

describe('Twoline', () => {
it('twoline to satellite record', () => {
// TODO:
badTleData.forEach((tleDataItem) => {
const satrec = twoline2satrec(tleDataItem.tleLine1, tleDataItem.tleLine2);
tleDataItem.results.forEach((expected) => {
// Fetching satellite record from incorrectly formatted TLE lines
expect(satrec.error).toEqual(expected.error);
});
});
});
});
Loading

0 comments on commit 3c1efc0

Please sign in to comment.