1 /*
2 
3 -Procedure pckfrm_c ( PCK reference frame class ID set )
4 
5 -Abstract
6 
7    Find the set of reference frame class ID codes of all frames
8    in a specified binary PCK file.
9 
10 -Disclaimer
11 
12    THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE
13    CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S.
14    GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE
15    ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE
16    PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS"
17    TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY
18    WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A
19    PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC
20    SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE
21    SOFTWARE AND RELATED MATERIALS, HOWEVER USED.
22 
23    IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA
24    BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT
25    LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND,
26    INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS,
27    REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE
28    REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY.
29 
30    RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF
31    THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY
32    CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE
33    ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE.
34 
35 -Required_Reading
36 
37    CELLS
38    DAF
39    SETS
40    PCK
41 
42 -Keywords
43 
44    ORIENTATION
45    UTILITY
46 
47 */
48 
49    #include "SpiceUsr.h"
50    #include "SpiceZfc.h"
51    #include "SpiceZmc.h"
52 
pckfrm_c(ConstSpiceChar * pck,SpiceCell * ids)53    void pckfrm_c ( ConstSpiceChar  * pck,
54                    SpiceCell       * ids  )
55 
56 /*
57 
58 -Brief_I/O
59 
60    Variable  I/O  Description
61    --------  ---  --------------------------------------------------
62    pck        I   Name of PCK file.
63    ids       I/O  Set of frame class ID codes of frames in PCK file.
64 
65 -Detailed_Input
66 
67    pck            is the name of a binary PCK file.
68 
69    ids            is an initialized CSPICE set data structure. `ids'
70                   optionally may contain a set of ID codes on input; on
71                   output, the data already present in `ids' will be
72                   combined with ID code set found for the file PCK.
73 
74                   If `ids' contains no data on input, its size and
75                   cardinality still must be initialized.
76 
77 -Detailed_Output
78 
79    ids            is a CSPICE set data structure which contains the
80                   union of its contents upon input with the set of
81                   reference frame class ID codes of each frame for
82                   which data are present in the indicated PCK file. The
83                   elements of CSPICE sets are unique; hence each ID
84                   code in `ids' appears only once, even if the PCK file
85                   contains multiple segments for that ID code.
86 
87                   See the Examples section below for a complete example
88                   program showing how to retrieve the ID codes from
89                   `ids'.
90 
91 -Parameters
92 
93    None.
94 
95 -Exceptions
96 
97    1)  If the input file has transfer format, the error
98        SPICE(INVALIDFORMAT) is signaled.
99 
100    2)  If the input file is not a transfer file but has architecture
101        other than DAF, the error SPICE(BADARCHTYPE) is signaled.
102 
103    3)  If the input file is a binary DAF file of type other than
104        PCK, the error SPICE(BADFILETYPE) is signaled.
105 
106    4)  If the PCK file cannot be opened or read, the error will
107        be diagnosed by routines called by this routine.
108 
109    5)  If the size of the output set argument `ids' is insufficient to
110        contain the actual number of ID codes of frames covered by
111        the indicated PCK file, the error will be diagnosed by
112        routines called by this routine.
113 
114    6)  The error SPICE(EMPTYSTRING) is signaled if the input string
115        `pck' does not contain at least one character, since the input
116        string cannot be converted to a Fortran-style string in this
117        case.
118 
119    7)  The error SPICE(NULLPOINTER) is signaled if the input string
120        pointer `pck' is null.
121 
122 -Files
123 
124    None.
125 
126 -Particulars
127 
128    This routine provides an API via which applications can determine
129    the set of reference frames for which there are data in a
130    specified PCK file.
131 
132 -Examples
133 
134    1)  Display the coverage for each frame in a specified PCK file.
135        Find the set of frames in the file.  Loop over the contents
136        of the ID code set:  find the coverage for each item in the
137        set and display the coverage.
138 
139 
140           #include <stdio.h>
141           #include "SpiceUsr.h"
142 
143           int main()
144           {
145              /.
146              Local parameters
147              ./
148              #define  FILSIZ         256
149              #define  MAXIV          1000
150              #define  WINSIZ         ( 2 * MAXIV )
151              #define  TIMLEN         51
152              #define  MAXOBJ         1000
153 
154              /.
155              Local variables
156              ./
157              SPICEDOUBLE_CELL        ( cover, WINSIZ );
158              SPICEINT_CELL           ( ids,   MAXOBJ );
159 
160              SpiceChar               lsk     [ FILSIZ ];
161              SpiceChar               pck     [ FILSIZ ];
162              SpiceChar               timstr  [ TIMLEN ];
163 
164              SpiceDouble             b;
165              SpiceDouble             e;
166 
167              SpiceInt                i;
168              SpiceInt                j;
169              SpiceInt                niv;
170              SpiceInt                obj;
171 
172 
173              /.
174              Load a leapseconds kernel for output time conversion.
175              PCKCOV itself does not require a leapseconds kernel.
176              ./
177              prompt_c ( "Name of leapseconds kernel > ", FILSIZ, lsk );
178              furnsh_c ( lsk );
179 
180              /.
181              Get name of PCK file.
182              ./
183              prompt_c ( "Name of PCK file           > ", FILSIZ, pck    );
184 
185              /.
186              Find the set of frames in the PCK file.
187              ./
188              pckfrm_c ( pck, &ids );
189 
190              /.
191              We want to display the coverage for each frame. Loop over
192              the contents of the ID code set, find the coverage for
193              each item in the set, and display the coverage.
194              ./
195              for ( i = 0;  i < card_c( &ids );  i++  )
196              {
197                 /.
198                 Find the coverage window for the current frame.
199                 Empty the coverage window each time so we don't
200                 include data for the previous frame.
201                 ./
202                 obj  =  SPICE_CELL_ELEM_I( &ids, i );
203 
204                 scard_c  ( 0,        &cover );
205                 pckcov_c ( pck, obj, &cover );
206 
207                 /.
208                 Get the number of intervals in the coverage window.
209                 ./
210                 niv = wncard_c ( &cover );
211 
212                 /.
213                 Display a simple banner.
214                 ./
215                 printf ( "%s\n", "========================================" );
216 
217                 printf ( "Coverage for frame %d\n", (int)obj );
218 
219                 /.
220                 Convert the coverage interval start and stop times to TDB
221                 calendar strings.
222                 ./
223                 for ( j = 0;  j < niv;  j++  )
224                 {
225                    /.
226                    Get the endpoints of the jth interval.
227                    ./
228                    wnfetd_c ( &cover, j, &b, &e );
229 
230                    /.
231                    Convert the endpoints to TDB calendar
232                    format time strings and display them.
233                    ./
234                    timout_c ( b,
235                               "YYYY MON DD HR:MN:SC.### (TDB) ::TDB",
236                               TIMLEN,
237                               timstr                                  );
238 
239                    printf ( "\n"
240                             "Interval:  %d\n"
241                             "Start:     %s\n",
242                             (int)j,
243                             timstr            );
244 
245                    timout_c ( e,
246                               "YYYY MON DD HR:MN:SC.### (TDB) ::TDB",
247                               TIMLEN,
248                               timstr                                  );
249                    printf ( "Stop:      %s\n", timstr );
250 
251                 }
252 
253              }
254              return ( 0 );
255           }
256 
257 
258 -Restrictions
259 
260    1) If an error occurs while this routine is updating the set
261       `ids', the set may be corrupted.
262 
263 -Literature_References
264 
265    None.
266 
267 -Author_and_Institution
268 
269    N.J. Bachman   (JPL)
270 
271 -Version
272 
273    -CSPICE Version 1.0.1, 12-JUL-2016 (EDW)
274 
275       Edit to example program to use "%d" with explicit casts
276       to int for printing SpiceInts with printf.
277 
278    -CSPICE Version 1.0.0, 01-DEC-2007 (NJB)
279 
280 -Index_Entries
281 
282    find frame class id codes of frames in binary pck file
283 
284 -&
285 */
286 
287 { /* Begin pckfrm_c */
288 
289 
290    /*
291    Participate in error tracing.
292    */
293    if ( return_c() )
294    {
295       return;
296    }
297    chkin_c ( "pckfrm_c" );
298 
299 
300    /*
301    Check the input string `pck' to make sure the pointer is non-null
302    and the string length is non-zero.
303    */
304    CHKFSTR ( CHK_STANDARD, "pckfrm_c", pck );
305 
306    /*
307    Make sure cell data type is SpiceInt.
308    */
309    CELLTYPECHK ( CHK_STANDARD, "pckfrm_c", SPICE_INT, ids );
310 
311    /*
312    Initialize the cell if necessary.
313    */
314    CELLINIT ( ids );
315 
316    /*
317    Call the f2c'd Fortran routine.
318    */
319    pckfrm_ ( ( char       * ) pck,
320              ( integer    * ) (ids->base),
321              ( ftnlen       ) strlen(pck)   );
322 
323    /*
324    Sync the output cell.
325    */
326    if ( !failed_c() )
327    {
328       zzsynccl_c ( F2C, ids );
329    }
330 
331    chkout_c ( "pckfrm_c" );
332 
333 } /* End pckfrm_c */
334