Index Page bodc2s_c
A B C D E F G H I J K L M N O P Q R S T U V W X
Procedure Abstract Required_Reading Keywords Brief_I/O Detailed_Input | Detailed_Output Parameters Exceptions Files Particulars Examples | Restrictions Literature_References Author_and_Institution Version Index_Entries
#### Procedure
       void bodc2s_c ( SpiceInt        code,
                       SpiceInt        lenout,
                       SpiceChar     * name )
#### Abstract
       Translate a body ID code to either the corresponding name or if no
       name to ID code mapping exists, the string representation of the
       body ID value.
#### Required_Reading
       NAIF_IDS
#### Keywords
       BODY
       CONVERSION
#### Brief_I/O
       Variable  I/O  Description
       --------  ---  --------------------------------------------------
       code       I   Integer ID code to translate to a string.
       lenout     I   Maximum length of output name.
       name       O   String corresponding to 'code'.
#### Detailed_Input
       code        the integer code for a body: planet, satellite,
                   barycenter, spacecraft, asteroid, comet, or
                   other ephemeris object.

       lenout      is the maximum allowed length of the output name,
                   including the terminating null character.  For example,
                   if the caller wishes to be able to accept a 32-character
                   name, lenout must be set to (at least) 33. The current
                   maximum name length is 32 characters, so a value of 33
                   for lenout will suffice.
#### Detailed_Output
       name        the string name of the body identified by 'code'
                   if a mapping between 'code' and a body name exists
                   within SPICE.

                   If 'code' has more than one translation, then the
                   most recently defined 'name' corresponding to 'code'
                   is returned. 'name' will have the exact format (case
                   and blanks) as when the name/code pair was defined.

                   If the input value of 'code' does not map to a body
                   name, 'name' returns with the string representation
                   of 'code'.
#### Parameters
       None.
#### Exceptions
       1) If the output string pointer is null, the error SPICE(NULLPOINTER)
          is signaled.

       2) If the output string has length less than two characters, it
          is too short to contain one character of output data plus a null
          terminator, so it cannot be passed to the underlying Fortran
          routine.  In this event, the error SPICE(STRINGTOOSHORT) is
          signaled.
#### Files
       Body-name mappings may be defined at run time by loading text
       kernels containing kernel variable assignments of the form

          NAIF_BODY_NAME += ( <name 1>, ... )
          NAIF_BODY_CODE += ( <code 1>, ... )

       See NAIF_ID.REQ for details.
#### Particulars
       bodc2s_c is one of five related subroutines,

          bods2c_c      Body string to code
          bodc2s_c      Body code to string
          bodn2c_c      Body name to code
          bodc2n_c      Body code to name
          boddef_c      Body name/code definition

       bods2c_c, bodc2s_c, bodn2c_c, and bodc2n_c perform translations between
       body names and their corresponding integer ID codes which are
       used in SPICE files and routines.

       bods2c_c is a slightly more general version of bodn2c_c: support
       for strings containing ID codes in string format enables a caller
       to identify a body using a string, even when no name is
       associated with that body.

       bodc2s_c is a general version of bodc2n_c; the routine returns either
       the name assigned in the body ID to name mapping or a string
       representation of the CODE value if no mapping exists.

       boddef_c assigns a body name to ID mapping. The mapping has priority
       in name-to-ID and ID-to-name translations.

       Refer to NAIF_ID.REQ for the list of name/code associations built into
       SPICE, and for details concerning adding new name/code
       associations at run time by loading text kernels.
#### Examples
       Apply the BODC2S call to several IDs representing codes
       included in the default SPICE ID-name lists and codes not
       included in the list.

       #include <stdio.h>
       #include "SpiceUsr.h"
       #define  LEN               32

       int main()
          {

          /.
          Assign an array of body ID codes. Not all the listed codes
          map to a body name.
          ./

          SpiceInt                code[] = { 399, 0, 3, -77,
                                             11, -1, 6000001 };

          SpiceInt                lenout = LEN;
          SpiceChar               name [LEN];
          SpiceInt                i;

          /.
          Loop over the 'code' array, call bodc2s_c for each
          element of 'code'.
          ./

          for (i=0; i<7; i++ )
             {
             (void) bodc2s_c ( code[i], lenout, name );
             printf("%d   %s\n", (int)code[i], name);
             }

          return ( 0 );
          }

        Given these codes, bodc2s_c returns the following 'name' strings:

              Code        Name
              -------     -------------------
                  399     'EARTH'
                    0     'SOLAR SYSTEM BARYCENTER'
                    3     'EARTH BARYCENTER'
                  -77     'GALILEO ORBITER'
                   11     '11'
                   -1     'GEOTAIL'
              6000001     '6000001'

       The codes 11 and 6000001 did not map to a name so the call
       returns as 'name' the string expression of the codes.
#### Restrictions
       None.
#### Literature_References
       None.
#### Author_and_Institution
      E.D. Wright     (JPL)
#### Version
       -CSPICE Version 1.0.1, 12-JUL-2016 (EDW)

          Edit to example program to use "%d" with explicit casts
          to int for printing SpiceInts with printf.

        -CSPICE Version 1.0.0, 24-APR-2010 (EDW)
#### Index_Entries
       body id code to string
#### Link to routine bodc2s_c source file bodc2s_c.c

    Wed Apr  5 17:54:28 2017