Skybot3D

getPlanet

Heliocentric state vectors of planets & satellites

The methods getPlanet is intended to people who want to retrieve the heliocentric J2000 state vectors of planets and major natural satellites at a reference epoch.

HTTP Request

If you are a software/solutions developer, you might want to include the Skybot3D getPlanet method into your application. This can be done by using the web service method or by using the following HTTP request:
https://ssp.imcce.fr/webservices/skybot3d/api/getPlanet.php?[parameters]
where [parameters] is a list of parameters separated by the character &. The allowed parameters are:
ParameterDefinitionLimits
-ep=<dateTime> Requested epoch, expressed in Julian period, ISO format,
or formatted as any English textual datetime
2411320.0 .. 2473540.0
1889-11-13 12h .. 2060-03-21 12h
-class=<string> Population class to choose between planets, satellites or leave empty to get all bodies. planets | satellites | all
-limit=<integer> Maximum number of SSOs to retrieve Leave empty or put 0 to retrieve all objects (default)
-observer=<string> Code of the observer's location Ex.: 500 (geocenter), 007 (Paris), @kepler, ...
-coord=<string> Type of coordinates: rectangular for cartesian coordinates or spherical for RA and DEC rectangular (default) | spherical
-mime=<string> Mime type of the results votable | html | text | json
-getFile=<0|1> Active only if arguments class or limit are defined and not null. 0 (default) | 1
-from=<string> Word which define the name of the caller application,
or which describes the request
any short string
(no space character)

The output results are described in the following section, and are available in VOTable (default), HTML, plain text format, and JSON object (cf. examples). All input arguments are optional, and their value can be omitted, e.g. ...&-limit=&-mime=&...

Web service

The Skybot3D Web service provides methods based on SOAP and HTTP POST verb which allow one to interact between its own application and the Skybot3D service. Here is the useful information to invoke the getPlanet method:
Web Service URI:
https://ssp.imcce.fr/webservices/skybot3d/skybot3d.php
Namespace:
https://ssp.imcce.fr/webservices/skybot3d
WSDL:
https://ssp.imcce.fr/webservices/skybot3d/skybot3d.php?wsdl
SOAP header:
name of the SOAP header element: clientID
SOAP header's content: array('from' => 'YourName', 'hostip'=>'')
Methods:
getPlanet (inputArray)
The input parameter of the method is an array which must contained the following parameter:
VariableTypeUnitsLimits or valuesDefaultComment
epoch string dateTime 2411320.0 .. 2473540.0
1889-11-13 12h .. 2060-03-21 12h
none Requested epoch (julian period, ISO format, English textual datetime)
class string - Class or comma separated list of classes empty Requested population classes of objects
limit integer - ≥ 0 0 Maximum number of objects to retrieve
observer string - Code of observer's location 500 IAU observatory code or observer's location code
coord string - rectangular | spherical rectangular Requested type of coordinates of the targets: cartesian or spherical
mime string - votable | html | text | json votable Mime type of the results

The output of the methods is an object containing the following attributes:

'flag'
the status of the response: flag=1 means ok; flag=0 or flag=-1 mean that an error occured
'ticket'
the Unix timestamp of the response which can be useful to stamp the request
'status'
the HTTP status-code of the response (e.g. 400: bad request, 422: Unprocessable Entity, 500: internal error)
'nbsso'
the number of objects contained in the result file
'refdate'
the epoch of the ephemeris, in julian day
'file'
the URL of a Bzipped file containing the requested data (extension .bz2)
'filesize'
the size of the result file, in bytes

To get the result file, use a network downloader, such as wget or curl, or download the file by using your preferred Web browser. You will need to (b)unzip the file before to read it with any text editor.

Depending on the selected mime type, the output is formatted as:

votable
the data are written in the IVOA standard VOTable format
html
the data are transformed from VOTable to HTML by XSLT processing (Skybot3D XSL style sheet)
text
the data are returned in plain text where each value is separated by the pipe '|' character
json
the data are written in a JSON object.

Query examples

Output results

Unlike asteroids and comets, the output results do not depend on the context of the request. The output parameters are described in the following tables, depending on the value of the coord argument:
  • FieldDefinitionUnits
    1 Planet's Id -
    2-3 Heliocentric mean J2000 equatorial RA and DEC deg
    4 Heliocentric distance au
    5-6 Heliocentric mean J2000 equatorial motion ΔRA cos(δ) and Δδ deg/d
    7 Visual magnitude V(1,0) mag
    8 Planet or satellite name -
    9 Sso diameter (only in JSON format) km
    10 Sso type (only in JSON format) -
  • FieldDefinitionUnits
    1 Planet's Id -
    2-4 Heliocentric mean J2000 equatorial position vector (x, y, z) au
    5-7 Heliocentric mean J2000 equatorial velocity vector (vx, vy, vz) au/d
    8 Visual magnitude V(1,0) mag
    9 Planet or satellite name -
    10 Sso diameter (only in JSON format) km
    11 Sso type (only in JSON format) -

The state vectors of planets are computed on the fly using INPOP planetary theory. Those of major satellites are computed using dedicated solution of their motion: V. Lainey, V. Dehant and M. Pätzold 2007 for Mars, V. Lainey, L. Duriez and A. Vienne 2004 for Jupiter, A. Vienne and L. Duriez 1995 for Saturn, J. Laskar and R.A. Jacobson 1987 for Uranus, and C. Le Guyader 1993 for Neptune.

Structure of the output JSON object

When the output mime type is the JSON data-interchange format, the output of the getPlanet method is encapsulated in a structure defined as follows:
{
  "flag": (int),
  "ticket": (long),
  "status": (int),
  "nbsso": (int),
  "refdate": (float),
  "file": (URL),
  "size(bytes)": (int)
}

And the data are encapsulated in a structure defined as:

{
  "nbsso": (int),
  "refdate": (float),
  "planets": [ [ SSO1 ], [ SSO2 ], ... ]
}
where [SSOi] is an array which contains the parameters described in the Output results section.

How to consume

You have two ways to use the Sbybot3D web service: by writting a client to send requests to the Skybot3D server and to receive and analyze the response, or by using a command line interface and a data transfert program such as curl or wget. For that, just execute one of the following commands in a console:
$> curl "<URL>"
or
$> wget "<URL>"
where <URL> is described in section HTTP request.

In order to help you to invoke the Skybot3D web service, we provide some clients written in differents languages. Here are some detailed explanations to write a client with PHP and SOAP which invokes the getPlanet method:

1/ Provide the input parameters which are mandatory for the service:

// Client's ID: provide the name of your project or organisation or yourself
$from = 'MyName';
// Input parameters
$param = array('epoch'    => 'now',
               'class'    => '',
               'limit'    => 10,
               'observer' => 500
               'coord'    => 'spherical',
               'mime'     => 'json');
// Boolean to download (1) or not (0) the result file
$getFile = 0;

2/ Define the SOAP options, the namespace and the WSDL URI of Skybot3D web service:

// Enables or disables the WSDL caching feature
ini_set('soap.wsdl_cache_enabled', 1);
// Skybot3D namespace
$namespace = 'https://ssp.imcce.fr/webservices/skybot3d';
// Skybot3D WSDL
$uriwsdl = $namespace.'/skybot3d.wsdl';

3/ Create a SoapClient object in WSDL mode, set the SOAP header, then call the method and catch exceptions:

try {
  // Constructs the client
  $client = new SoapClient($uriwsdl, array('exceptions'=>1));
  // SOAP header
  $header = array('from'=>$from, 'hostip'=>'');
  $client->__setSoapHeaders(array(new SOAPHeader($namespace, 'clientID', $header)));  
  // Call the resolver method
  $response = $client->__soapCall('getPlanet',$param);
  // Display the results
  if ($param['mime'] == 'text')
  {
    if ($response->flag > 0) {
      if ($getFile == 0) {
        header("HTTP/1.0 ".$response->status);
        header("Content-Type: text/plain");
        echo "# Flag     : ".$response->flag.PHP_EOL;
        echo "# Ticket   : ".$response->ticket.PHP_EOL;
        echo "# nbAster  : ".$response->nbsso.PHP_EOL;
        echo "# refDate  : ".$response->refdate.PHP_EOL;
        echo "# fileName : ".$response->file.PHP_EOL;
        echo "# fileSize : ".$response->size." bytes".PHP_EOL;
      } else {
        $bz = bzopen($response->file,'r');
        $data = '';
        while (!feof($bz)) {
          $buffer = bzread($bz);
          if ($buffer === FALSE) {
            header("HTTP/1.0 500");
            header("Content-Type: text/plain");
            echo 'Error: Skybot3d getPlanet: Cannot read the bzipped file: '.$js->file;
            exit();
          } else if (bzerrno($bz) !== 0) {
            $error = bzerror($bz);
            header("HTTP/1.0 500");
            header("Content-Type: text/plain");
            echo 'Error: Skybot3d getPlanet: Cannot read the bzipped file: '.$js->file.', Error: '.$error['errstr'];
            exit();
          } else {
            $data .= $buffer;
          }
        }
        bzclose($bz);
        header("HTTP/1.0 ".$response->status);
        header("Content-Type: text/plain");
        echo $data;
      }
    } else {
      header("HTTP/1.0 ".$response->status);
      header("Content-Type: text/plain");
      echo "# Flag    : ".$response->flag.PHP_EOL;
      echo "# Ticket  : ".$response->ticket.PHP_EOL;
      echo "# Message : ".$response->result.PHP_EOL;
    }
  }
  else if ($param['mime'] == 'json')
  {
    if ($response->flag > 0) {
      if ($getFile == 0) {
        $js = json_decode($response->result);
        header("HTTP/1.0 ".$js->status);
        header("Content-Type: application/json");
        echo $response->result;
      } else {
        $js = json_decode($response->result);
        $status = $js->status;
        $bz = bzopen($js->file,'r');
        $jsdata = '';
        while (!feof($bz)) {
          $buffer = bzread($bz);
          if ($buffer === FALSE) {
            header("Content-Type: text/plain");
            echo 'Error: Skybot3d getPlanet: Cannot read the bzipped file: '.$js->file;
            exit();
          } else if (bzerrno($bz) !== 0) {
            $error = bzerror($bz);
            header("Content-Type: text/plain");
            echo 'Error: Skybot3d getPlanet: Cannot read the bzipped file: '.$js->file.', Error: '.$error['errstr'];
            exit();
          } else {
            $jsdata .= $buffer;
          }
        }
        bzclose($bz);
        header("HTTP/1.0 ".$status);
        header("Content-Type: application/json");
        echo $jsdata;
      }
    } else {
      header("HTTP/1.0 ".$js->status);
      header("Content-Type: application/json");
      echo $response->result;
    }
  }
  else
  {
    if ($response->flag > 0) {
      if ($getFile == 0) {
        header("HTTP/1.0 ".$response->status);
        header("Content-Type: text/xml;content=x-votable");
        echo $response->result;
      } else {
        $fdata = Data::getSkybot3DFileFromVOtable($response->result);
        $bz = bzopen(str_replace('${Filename}', $fdata['filename'], $fdata['link']), 'r');
        $votdata = '';
        while (!feof($bz)) {
          $buffer = bzread($bz);
          if ($buffer === FALSE) {
            header("Content-Type: text/plain");
            echo 'Error: Skybot3d getPlanet: Cannot read the bzipped file: '.$js->file;
            exit();
          } else if (bzerrno($bz) !== 0) {
            $error = bzerror($bz);
            header("Content-Type: text/plain");
            echo 'Error: Skybot3d getPlanet: Cannot read the bzipped file: '.$js->file.', Error: '.$error['errstr'];
            exit();
          } else {
            $votdata .= $buffer;
          }
        }
        bzclose($bz);
        header("HTTP/1.0 ".$response->status);
        header("Content-Type: text/xml;content=x-votable");
        echo $votdata;
      }
    } else {
      header("HTTP/1.0 ".$response->status);
      header("Content-Type: text/xml;content=x-votable");
      echo $response->result;
    }
  }
} 
catch (SoapFault $fault) 
{
   trigger_error("SOAP Fault: {$fault->getTraceAsString()} (faultcode: {$fault->faultcode},
                               faultstring: {$fault->faultstring})", E_USER_ERROR);
}