-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
573 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
import { exampleDate } from '../lib/mockData'; | ||
import { Earth, EpochUTC, ITRF, Kilometers, Vector3D } from './../../src/main'; | ||
// Generated by CodiumAI | ||
|
||
describe('ITRF', () => { | ||
let epochUtc: EpochUTC; | ||
let itrf: ITRF; | ||
|
||
beforeEach(() => { | ||
epochUtc = EpochUTC.fromDateTime(exampleDate); | ||
itrf = new ITRF(epochUtc, new Vector3D(1000, 2000, 3000), new Vector3D(10, 20, 30)); | ||
}); | ||
|
||
// can get the name of the ITRF coordinate system | ||
it('should return the name of the coordinate system', () => { | ||
expect(itrf.name).toMatchSnapshot(); | ||
}); | ||
|
||
// can determine if the coordinate system is inertial | ||
it('should return whether the coordinate system is inertial', () => { | ||
expect(itrf.inertial).toMatchSnapshot(); | ||
}); | ||
|
||
/* | ||
* can get the height of the ITRF coordinate above the surface of the Earth in | ||
* kilometers | ||
*/ | ||
it('should return the height above the surface of the Earth in kilometers', () => { | ||
expect(itrf.height).toMatchSnapshot(); | ||
}); | ||
|
||
// can get the altitude in kilometers | ||
it('should return the altitude in kilometers', () => { | ||
expect(itrf.alt).toMatchSnapshot(); | ||
}); | ||
|
||
// can convert the current coordinate to the J2000 coordinate system | ||
it('should convert the current coordinate to the J2000 coordinate system', () => { | ||
expect(itrf.toJ2000()).toMatchSnapshot(); | ||
}); | ||
|
||
// can convert the current ITRF coordinate to Geodetic coordinate | ||
it('should convert the current ITRF coordinate to Geodetic coordinate', () => { | ||
expect(itrf.toGeodetic()).toMatchSnapshot(); | ||
}); | ||
|
||
// can handle position at the center of the Earth | ||
it('should handle position at the center of the Earth', () => { | ||
itrf = new ITRF(epochUtc, new Vector3D(0, 0, 0), new Vector3D(0, 0, 0)); | ||
expect(itrf.toJ2000()).toMatchSnapshot(); | ||
}); | ||
|
||
// can handle position at the North Pole | ||
it('should handle position at the North Pole', () => { | ||
const itrf = new ITRF( | ||
epochUtc, | ||
new Vector3D<Kilometers>(0 as Kilometers, 0 as Kilometers, Earth.radiusPolar), | ||
new Vector3D(0, 0, 0), | ||
); | ||
|
||
expect(itrf.toJ2000()).toMatchSnapshot(); | ||
// Test the toGeodetic method | ||
expect(itrf.toGeodetic()).toMatchSnapshot(); | ||
}); | ||
|
||
// can handle position at the South Pole | ||
it('should handle position at the South Pole', () => { | ||
const itrf = new ITRF(epochUtc, new Vector3D(0, 0, -Earth.radiusPolar), new Vector3D(0, 0, 0)); | ||
|
||
itrf.position = new Vector3D(0, 0, -Earth.radiusPolar); | ||
expect(itrf.toJ2000()).toMatchSnapshot(); | ||
// Test the toGeodetic method | ||
expect(itrf.toGeodetic()).toMatchSnapshot(); | ||
}); | ||
|
||
// can handle position at the International Date Line | ||
it('should handle position at the International Date Line', () => { | ||
const itrf = new ITRF( | ||
epochUtc, | ||
new Vector3D<Kilometers>(Earth.radiusEquator, 0 as Kilometers, 0 as Kilometers), | ||
new Vector3D(0, 0, 0), | ||
); | ||
|
||
// Test height | ||
expect(itrf.height).toMatchSnapshot(); | ||
|
||
// Test alt | ||
expect(itrf.alt).toMatchSnapshot(); | ||
|
||
// Test toJ2000 | ||
expect(itrf.toJ2000()).toMatchSnapshot(); | ||
|
||
// Test toGeodetic | ||
expect(itrf.toGeodetic()).toMatchSnapshot(); | ||
}); | ||
|
||
// can handle position at the Prime Meridian | ||
it('should handle position at the Prime Meridian', () => { | ||
const itrf = new ITRF( | ||
epochUtc, | ||
new Vector3D<Kilometers>(0 as Kilometers, Earth.radiusEquator, 0 as Kilometers), | ||
new Vector3D(0, 0, 0), | ||
); | ||
|
||
expect(itrf.name).toMatchSnapshot(); | ||
expect(itrf.inertial).toMatchSnapshot(); | ||
expect(itrf.height).toMatchSnapshot(); | ||
expect(itrf.alt).toMatchSnapshot(); | ||
expect(itrf.toJ2000()).toMatchSnapshot(); | ||
expect(itrf.toGeodetic()).toMatchSnapshot(); | ||
}); | ||
|
||
// can handle position at high altitude | ||
it('should handle position at high altitude', () => { | ||
const itrf = new ITRF( | ||
epochUtc, | ||
new Vector3D<Kilometers>(0 as Kilometers, (Earth.radiusEquator + 1000) as Kilometers, 0 as Kilometers), | ||
new Vector3D(0, 0, 0), | ||
); | ||
|
||
expect(itrf.height).toMatchSnapshot(); | ||
expect(itrf.alt).toMatchSnapshot(); | ||
expect(itrf.toJ2000()).toMatchSnapshot(); | ||
expect(itrf.toGeodetic()).toMatchSnapshot(); | ||
}); | ||
|
||
// can handle position at low altitude | ||
it('should handle position at low altitude', () => { | ||
const itrf = new ITRF( | ||
epochUtc, | ||
new Vector3D<Kilometers>(0 as Kilometers, (Earth.radiusEquator - 10) as Kilometers, 0 as Kilometers), | ||
new Vector3D(0, 0, 0), | ||
); | ||
|
||
expect(itrf.height).toMatchSnapshot(); | ||
expect(itrf.alt).toMatchSnapshot(); | ||
expect(itrf.toJ2000()).toMatchSnapshot(); | ||
expect(itrf.toGeodetic()).toMatchSnapshot(); | ||
}); | ||
|
||
// can handle position at the antimeridian | ||
it('should handle position at the antimeridian', () => { | ||
const itrf = new ITRF( | ||
epochUtc, | ||
new Vector3D(0 as Kilometers, 0 as Kilometers, Earth.radiusEquator), | ||
new Vector3D(0, 0, 0), | ||
); | ||
|
||
// Test the height property | ||
expect(itrf.height).toMatchSnapshot(); | ||
|
||
// Test the alt property | ||
expect(itrf.alt).toMatchSnapshot(); | ||
|
||
// Test the toJ2000 method | ||
expect(itrf.toJ2000()).toMatchSnapshot(); | ||
|
||
// Test the toGeodetic method | ||
expect(() => itrf.toGeodetic()).toMatchSnapshot(); | ||
}); | ||
|
||
// can handle position at the equator | ||
it('should handle position at the equator with negative y-coordinate', () => { | ||
const itrf = new ITRF(epochUtc, new Vector3D(0, -Earth.radiusEquator, 0), new Vector3D(0, 0, 0)); | ||
|
||
expect(itrf.name).toMatchSnapshot(); | ||
expect(itrf.inertial).toMatchSnapshot(); | ||
expect(itrf.height).toMatchSnapshot(); | ||
expect(itrf.alt).toMatchSnapshot(); | ||
expect(itrf.toJ2000()).toMatchSnapshot(); | ||
expect(itrf.toGeodetic()).toMatchSnapshot(); | ||
}); | ||
|
||
// can handle position at different epochs | ||
it('should handle position at different epochs', () => { | ||
const position = new Vector3D(1000, 2000, 3000); | ||
const velocity = new Vector3D(10, 20, 30); | ||
const epoch1 = EpochUTC.fromDateTime(exampleDate); | ||
const epoch2 = EpochUTC.fromDateTime(new Date(exampleDate.getTime() + 1000)); | ||
const itrf1 = new ITRF(epoch1, position, velocity); | ||
const itrf2 = new ITRF(epoch2, position, velocity); | ||
|
||
// Test height property | ||
expect(itrf1.height).toMatchSnapshot(); | ||
expect(itrf2.height).toMatchSnapshot(); | ||
|
||
// Test alt property | ||
expect(itrf1.alt).toMatchSnapshot(); | ||
expect(itrf2.alt).toMatchSnapshot(); | ||
|
||
// Test toJ2000 method | ||
const j2000 = itrf1.toJ2000(); | ||
|
||
expect(j2000).toMatchSnapshot(); | ||
|
||
// Test toGeodetic method | ||
const geodetic = itrf1.toGeodetic(); | ||
|
||
expect(geodetic).toMatchSnapshot(); | ||
}); | ||
}); |
Oops, something went wrong.