<html>

<head>
<title>Image</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<script  src="../src/js/require.min.js"></script>
<link rel="stylesheet" href="../src/css/jquery-ui-1.9.2.custom.css">

<script src="http://code.jquery.com/jquery-latest.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css" media="screen" />
<script type="text/javascript" src="http://code.jquery.com/qunit/qunit-git.js"></script>

<script type="text/javascript">

require.config({
	paths: {
		"fits": "../src/externals/fits"
	},
	waitSeconds: 0
}); 
	
require(['../src/js/FitsLoader', '../src/externals/wcs'], function (FitsLoader)
{

	asyncTest("Test with rotated fits", 2, function()
	{
		/**
		 *	Handle fits data
		 */
		function handleFits(fits)
		{
			var hdu = fits.getHDU();
			var fitsData = hdu.data;
				
			// Create mapper
			wcs = new WCS.Mapper(hdu.header);
			var coords = [];

			var worldCoordinate = wcs.pixelToCoordinate( [0, fitsData.height] );
			var pixelCoordinate = wcs.coordinateToPixel( worldCoordinate.ra, worldCoordinate.dec );

			// Test if initial pixel is almost identical after convertion
			deepEqual( 0, pixelCoordinate.x );
			deepEqual( fitsData.height, pixelCoordinate.y );
			start();
		}

		FitsLoader.loadFits("rotated.fits", handleFits);

	});

	asyncTest("Test with aligned to north fits", 2, function()
	{
		/**
		 *	Handle fits data
		 */
		function handleFits(fits)
		{
			var hdu = fits.getHDU();
			var fitsData = hdu.data;
				
			// Create mapper
			wcs = new WCS.Mapper(hdu.header);
			var coords = [];

			var worldCoordinate = wcs.pixelToCoordinate( [0, fitsData.height] );
			var pixelCoordinate = wcs.coordinateToPixel( worldCoordinate.ra, worldCoordinate.dec );

			// Test if initial pixel is almost identical after convertion
			deepEqual( 0, pixelCoordinate.x );
			deepEqual( fitsData.height, pixelCoordinate.y );
			start();
		}

		FitsLoader.loadFits("notRotated.fits", handleFits);

	});
});


</script>

</head>


<body>
	<h1 id="qunit-header">QUnit GlobWeb</h1>
	<h2 id="qunit-banner"></h2>
	<div id="qunit-testrunner-toolbar"></div>
	<h2 id="qunit-userAgent"></h2>
	<ol id="qunit-tests"></ol>
 </body>

</html>

