mirror of
https://github.com/NASAWorldWind/WebWorldWind.git
synced 2026-01-18 15:12:57 +00:00
removed normalizeAngle from SunPosition replaced if_gt function with the build in glsl step function
132 lines
6.7 KiB
JavaScript
132 lines
6.7 KiB
JavaScript
/*
|
|
* Copyright (C) 2014 United States Government as represented by the Administrator of the
|
|
* National Aeronautics and Space Administration. All Rights Reserved.
|
|
*/
|
|
|
|
define([
|
|
'src/util/SunPosition'
|
|
],
|
|
function (SunPosition) {
|
|
'use strict';
|
|
|
|
describe('SunPosition Test', function () {
|
|
|
|
describe('Compute the Sun\'s geographic location', function () {
|
|
|
|
it('Computes the Sun\'s geographic location', function () {
|
|
var dates = [
|
|
new Date('2017-01-01T12:00:00.000Z'),
|
|
new Date('2017-06-19T18:00:00.000Z'),
|
|
new Date('2017-06-22T06:00:00.000Z'),
|
|
new Date('2017-08-01T14:00:00.000Z'),
|
|
new Date('2017-12-19T16:00:00.000Z'),
|
|
new Date('2017-12-22T22:00:00.000Z'),
|
|
];
|
|
var expectedLocations = [
|
|
{latitude: -22.958797136581314, longitude: 0.9185710746913855},
|
|
{latitude: 23.42944558814554, longitude: -89.63447863631922},
|
|
{latitude: 23.432472410610977, longitude: 90.501526864205},
|
|
{latitude: 17.86912793173116, longitude: -28.41907808241126},
|
|
{latitude: -23.420379101540863, longitude: -60.68413749323872},
|
|
{latitude: -23.430434209235372, longitude: -150.2805549482439}
|
|
];
|
|
var computedLocations = dates.map(function (date) {
|
|
return SunPosition.getAsGeographicLocation(date);
|
|
});
|
|
expectedLocations.forEach(function (expectedResult, i) {
|
|
expect(expectedResult.latitude).toBeCloseTo(computedLocations[i].latitude);
|
|
expect(expectedResult.longitude).toBeCloseTo(computedLocations[i].longitude);
|
|
});
|
|
});
|
|
|
|
});
|
|
|
|
describe('Computes the Sun\'s celestial location', function () {
|
|
|
|
it('Computes the Sun\'s celestial location', function () {
|
|
var dates = [
|
|
new Date('2017-01-01T12:00:00.000Z'),
|
|
new Date('2017-06-19T18:00:00.000Z'),
|
|
new Date('2017-06-22T06:00:00.000Z'),
|
|
new Date('2017-08-01T14:00:00.000Z'),
|
|
new Date('2017-12-19T16:00:00.000Z'),
|
|
new Date('2017-12-22T22:00:00.000Z'),
|
|
];
|
|
var expectedLocations = [
|
|
{declination: -22.958797136581314, rightAscension: 282.2493341054377},
|
|
{declination: 23.42944558814554, rightAscension: 88.51710113901169},
|
|
{declination: 23.432472410610977, rightAscension: 91.11722505541856},
|
|
{declination: 17.86912793173116, rightAscension: 131.95106393893616},
|
|
{declination: -23.420379101540863, rightAscension: 267.75877297672787},
|
|
{declination: -23.430434209235372, rightAscension: 271.36570946223924},
|
|
];
|
|
var computedLocations = dates.map(function (date) {
|
|
return SunPosition.getAsCelestialLocation(date);
|
|
});
|
|
expectedLocations.forEach(function (expectedResult, i) {
|
|
expect(expectedResult.declination).toBeCloseTo(computedLocations[i].declination);
|
|
expect(expectedResult.rightAscension).toBeCloseTo(computedLocations[i].rightAscension);
|
|
});
|
|
});
|
|
|
|
});
|
|
|
|
describe('Convert celestial to geographic coordinates', function () {
|
|
|
|
it('Convert celestial to geographic coordinates', function () {
|
|
var celestialLocations = [
|
|
{declination: -22.958797136581314, rightAscension: 282.2493341054377},
|
|
{declination: 23.42944558814554, rightAscension: 88.51710113901169},
|
|
{declination: 23.432472410610977, rightAscension: 91.11722505541856},
|
|
{declination: 17.86912793173116, rightAscension: 131.95106393893616},
|
|
{declination: -23.420379101540863, rightAscension: 267.75877297672787},
|
|
{declination: -23.430434209235372, rightAscension: 271.36570946223924},
|
|
];
|
|
var expectedGeographicLocations = [
|
|
{latitude: -22.958797136581314, longitude: 91.16498291601772},
|
|
{latitude: 23.42944558814554, longitude: -102.56725005040829},
|
|
{latitude: 23.432472410610977, longitude: -99.96712613400142},
|
|
{latitude: 17.86912793173116, longitude: -59.13328725048382},
|
|
{latitude: -23.420379101540863, longitude: 76.67442178730789},
|
|
{latitude: -23.430434209235372, longitude: 80.28135827281926}
|
|
];
|
|
var date = new Date('2017-01-01T06:00:00.000Z');
|
|
var geographicLocations = celestialLocations.map(function (celestialLocation) {
|
|
return SunPosition.celestialToGeographic(celestialLocation, date);
|
|
});
|
|
expectedGeographicLocations.forEach(function (expectedResult, i) {
|
|
expect(expectedResult.latitude).toBeCloseTo(geographicLocations[i].latitude);
|
|
expect(expectedResult.longitude).toBeCloseTo(geographicLocations[i].longitude);
|
|
});
|
|
});
|
|
|
|
});
|
|
|
|
describe('Compute julian date', function () {
|
|
|
|
it('Compute julian date', function () {
|
|
var dates = [
|
|
new Date('2017-01-01T12:00:00.000Z'),
|
|
new Date('2017-06-19T18:00:00.000Z'),
|
|
new Date('2017-06-22T06:00:00.000Z'),
|
|
new Date('2017-08-01T14:00:00.000Z'),
|
|
new Date('2017-12-19T16:00:00.000Z'),
|
|
new Date('2017-12-22T22:00:00.000Z'),
|
|
];
|
|
var expectedJulianDates = [2457755, 2457924.25, 2457926.75, 2457967.0833333335, 2458107.1666666665,
|
|
2458110.4166666665];
|
|
var computedJulianDates = dates.map(function (date) {
|
|
return SunPosition.computeJulianDate(date);
|
|
});
|
|
expectedJulianDates.forEach(function (expectedResult, i) {
|
|
expect(expectedResult).toBeCloseTo(computedJulianDates[i]);
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|