Blame view

php/rest/getOrbites.php 3.59 KB
16035364   Benjamin Renard   First commit
1
<?php
16035364   Benjamin Renard   First commit
2

70880168   Nathanael Jourdane   Add rate limit on...
3
/**
d8f6b7eb   Nathanaël Jourdane   Add API documenta...
4
5
6
7
8
9
10
11
 * @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
 *
6185ceeb   Myriam Bouchemit   update for apidoc
12
 * @apiParam {String} token The API token.
d8f6b7eb   Nathanaël Jourdane   Add API documenta...
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 * @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*)
d8f6b7eb   Nathanaël Jourdane   Add API documenta...
28
29
 * @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".
eb6baf5b   Myriam Bouchemit   gzip is boolean
30
 * @apiParam {Boolean} [gzip] "1" if the file must be compressed before delivery
d8f6b7eb   Nathanaël Jourdane   Add API documenta...
31
32
33
 *
 * @apiSuccess {String} success `true`
 * @apiSuccess {String} url_XYZ URL of the file containing the points.
0cb6a7aa   Myriam Bouchemit   add info for apidoc
34
 * @apiSuccess {String} status status of the job ( done | in_progress )
d8f6b7eb   Nathanaël Jourdane   Add API documenta...
35
 *
d8f6b7eb   Nathanaël Jourdane   Add API documenta...
36
37
38

 * @apiSuccessExample Success-Response:
 *     HTTP/1.1 200 OK
0cb6a7aa   Myriam Bouchemit   add info for apidoc
39
40
41
 *     [success] => 1
 *     http://amda.irap.omp.eu/AMDA/data/WSRESULT/getorbites_ace_xyz_gse_km_20130923T090000_20130924T130000.txt
 *     [status] => done
d8f6b7eb   Nathanaël Jourdane   Add API documenta...
42
 *
ddedb507   Myriam Bouchemit   layout for apidoc
43
 * @apiErrorExample Error-Response:
6185ceeb   Myriam Bouchemit   update for apidoc
44
 *     {"error":"Cannot find orbit data for ACE1 for 2013-09-23T09:00-2013-09-24T13:00 in km GSE( - )"}
70880168   Nathanael Jourdane   Add rate limit on...
45
 */
16035364   Benjamin Renard   First commit
46

5e2ea05e   Elena.Budnik   update REST
47
	require_once '../config.php';
16035364   Benjamin Renard   First commit
48

5e2ea05e   Elena.Budnik   update REST
49
50
51
52
53
54
	if (!key_exists("token", $_GET)) 
	{
		$result = array('success' => false, 'message' => "Authentication is required for this webservice.");
		exit(json_encode($result));
	} 
	
189a6f4f   Elena.Budnik   coorect timie
55
56
57
58
59
60
61
	if ($_GET['startTime'] && strpos($_GET['startTime'], ' ') !== false) 
	{
		$result = array('success' => false, 
					'message' => "Check that there is no + (plus) character in your time definition. + is a special character and should be encoded by %2B");
		exit(json_encode($result));
	}
	
5e2ea05e   Elena.Budnik   update REST
62
63
64
65
66
67
68
69
70
	$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);
	}
70880168   Nathanael Jourdane   Add rate limit on...
71

5e2ea05e   Elena.Budnik   update REST
72
	echo json_encode($result);
16035364   Benjamin Renard   First commit
73

d8f6b7eb   Nathanaël Jourdane   Add API documenta...
74
?>