getOrbites.php 3.3 KB
<?php

/**
 * @api {get} getOrbites.php getOrbites
 * @apiDescription Provides the trajectory of a spacecraft during a period of time. The list of S/C for which an orbit
 * is available is given below. Check on the current version of AMDA (amda.cdpp.eu) the coordinate systems, units, and
 * time spans available for each S/C. For example, the orbit of INTERBALL-TAIL is only available in GSE or GSM
 * coordinate systems and time ranges between 1995 and 2000.
 * @apiName getOrbites
 * @apiGroup webservices
 *
 * @apiParam {String} token The API token.
 * @apiParam {String} startTime Beginning of the time interval (ISO 8601 or UNIXTIME format).
 * @apiParam {String} stopTime End of the time interval (ISO 8601 or UNIXTIME format)
 * @apiParam {String} spacecraft Name of the spacecraft. Possible values: "ACE", "CASSINI", "CLUSTER1", "CLUSTER2",
 * "CLUSTER3", "CLUSTER4", "DOUBLESTAR1", "GALILEO", "GEOTAIL", "IMP-8", "INTERBALL-TAIL", "ISEE-1", "ISEE-2", "MAVEN",
 * "MESSENGER", "MEX", "MGS", "Pioneer_10", "Pioneer_11", "POLAR", "PVO "Stereo-A", "Stereo-B", "THEMIS-A",
 * "THEMIS-B", "THEMIS-C", "THEMIS-D", "THEMIS-E", "ULYSSES", "VEX", "Voyager_1", "Voyager_2", "WIND".
 * @apiParam {String} CoordinateSystem Identifier of the coordinate system to be used. Possible values: "Carrington",
 * "CGM", "CPHIO", "DM", "EPHIO", "Equatorial", "GEI", "GEO", "GPHIO", "GSE", "GSEQ", "GSM", "HAE", "HCC", "HCI", "HCR",
 * "HEE", "HEEQ", "HG", "HGI", "HPC", "HPR", "IPHIO", "J2000", "LGM", "MAG", "MFA", "MSO", "RTN", "SC", "SE", "SM",
 * "SR", "SR2", "SSE", "SSE_L", "SpacecraftOrbitPlane", "VSO", "WGS84".
 * @apiParam {String} [sampling] Sampling of data (seconds).
 * @apiParam {String} [units] Units of orbits: radius or km. (Default = km) Possible values: "km", "Rs", "Rj", "Rca",
 * "Rga", "Rio", "Reu", "Rv", "Rm", "Re", "AU".
 * @apiParam {String} [userID] Identifier of the user in AMDA (*mandatory for user owned data*)
 * @apiParam {String} [password] Password of the user in AMDA (*mandatory for user owned data*)
 * @apiParam {String} [outputFormat] Format of the returned file. Two options: "VOTable", "ASCII".
 * @apiParam {String} [timeFormat] Format of time in the data files. Two options: "ISO8601", "UNIXTIME".
 * @apiParam {String} [gzip] "1" if the file must be compressed before delivery
 *
 * @apiSuccess {String} success `true`
 * @apiSuccess {String} url_XYZ URL of the file containing the points.
 * @apiSuccess {String} status status of the job ( done | in_progress )
 *

 * @apiSuccessExample Success-Response:
 *     HTTP/1.1 200 OK
 *     [success] => 1
 *     http://amda.irap.omp.eu/AMDA/data/WSRESULT/getorbites_ace_xyz_gse_km_20130923T090000_20130924T130000.txt
 *     [status] => done
 *
 * @apiErrorExample Error-Response:
 *     {"error":"Cannot find orbit data for ACE1 for 2013-09-23T09:00-2013-09-24T13:00 in km GSE( - )"}
 */

	require_once '../config.php';

	if (!key_exists("token", $_GET)) 
	{
		$result = array('success' => false, 'message' => "Authentication is required for this webservice.");
		exit(json_encode($result));
	} 
	
	$amda_ws = new WebServer();
	
	if ($amda_ws->getNewToken()['token'] != $_GET["token"]) 
	{
		$result = array('success' => false, 'status' => 'expired', 'message' => "Token expired. Please authenticate again.");
	} else 
	{
		$result = $amda_ws->getOrbites($_GET);
	}

	echo json_encode($result);

?>