getOrbites.php 3.26 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} 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} [gzip] "1" if the file must be compressed before delivery
 * @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".
 *
 * @apiSuccess {String} success `true`
 * @apiSuccess {String} url_XYZ URL of the file containing the points.
 *
 * @apiError {String} success `false`
 * @apiError {String} faultcode The error code.
 * @apiError {String} faultstring The error message.

 * @apiSuccessExample Success-Response:
 *     HTTP/1.1 200 OK
 *     http://amda.irap.omp.eu/AMDA/data/WSRESULT/obsdatatree_impex_20180727_AmdaLocalDataBaseParameters.xml
 *
 * @apiErrorExample
 *     HTTP/1.1 4xx OK
 *     {"success":false,"faultcode":"server00","faultstring":"Server error"}
 */

	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);

?>