WCSLIB 6.2

prj.h
Go to the documentation of this file.
1 /*============================================================================
2
3 WCSLIB 6.2 - an implementation of the FITS WCS standard.
4 Copyright (C) 1995-2018, Mark Calabretta
5
6 This file is part of WCSLIB.
7
8 WCSLIB is free software: you can redistribute it and/or modify it under the
9 terms of the GNU Lesser General Public License as published by the Free
10 Software Foundation, either version 3 of the License, or (at your option)
11 any later version.
12
13 WCSLIB is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
16 more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with WCSLIB. If not, see http://www.gnu.org/licenses.
20
21 Direct correspondence concerning WCSLIB to mark@calabretta.id.au
22
23 Author: Mark Calabretta, Australia Telescope National Facility, CSIRO.
24 http://www.atnf.csiro.au/people/Mark.Calabretta
25 $Id: prj.h,v 6.2 2018/10/20 10:03:13 mcalabre Exp $
26 *=============================================================================
27 *
28 * WCSLIB 6.2 - C routines that implement the FITS World Coordinate System
29 * (WCS) standard. Refer to the README file provided with WCSLIB for an
30 * overview of the library.
31 *
32 *
33 * Summary of the prj routines
34 * ---------------------------
35 * Routines in this suite implement the spherical map projections defined by
36 * the FITS World Coordinate System (WCS) standard, as described in
37 *
38 = "Representations of world coordinates in FITS",
39 = Greisen, E.W., & Calabretta, M.R. 2002, A&A, 395, 1061 (WCS Paper I)
40 =
41 = "Representations of celestial coordinates in FITS",
42 = Calabretta, M.R., & Greisen, E.W. 2002, A&A, 395, 1077 (WCS Paper II)
43 =
44 = "Mapping on the HEALPix grid",
45 = Calabretta, M.R., & Roukema, B.F. 2007, MNRAS, 381, 865 (WCS Paper V)
46 =
47 = "Representing the 'Butterfly' Projection in FITS -- Projection Code XPH",
48 = Calabretta, M.R., & Lowe, S.R. 2013, PASA, 30, e050 (WCS Paper VI)
49 *
50 * These routines are based on the prjprm struct which contains all information
51 * needed for the computations. The struct contains some members that must be
52 * set by the user, and others that are maintained by these routines, somewhat
53 * like a C++ class but with no encapsulation.
54 *
55 * Routine prjini() is provided to initialize the prjprm struct with default
56 * values, prjfree() reclaims any memory that may have been allocated to store
57 * an error message, and prjprt() prints its contents.
58 *
59 * prjperr() prints the error message(s) (if any) stored in a prjprm struct.
60 * prjbchk() performs bounds checking on native spherical coordinates.
61 *
62 * Setup routines for each projection with names of the form ???set(), where
63 * "???" is the down-cased three-letter projection code, compute intermediate
64 * values in the prjprm struct from parameters in it that were supplied by the
65 * user. The struct always needs to be set by the projection's setup routine
66 * but that need not be called explicitly - refer to the explanation of
67 * prjprm::flag.
68 *
69 * Each map projection is implemented via separate functions for the spherical
70 * projection, ???s2x(), and deprojection, ???x2s().
71 *
72 * A set of driver routines, prjset(), prjx2s(), and prjs2x(), provides a
73 * generic interface to the specific projection routines which they invoke
74 * via pointers-to-functions stored in the prjprm struct.
75 *
76 * In summary, the routines are:
77 * - prjini() Initialization routine for the prjprm struct.
78 * - prjfree() Reclaim memory allocated for error messages.
79 * - prjprt() Print the prjprm struct.
80 * - prjperr() Print error message (if any).
81 * - prjbchk() Bounds checking on native coordinates.
82 *
83 * - prjset(), prjx2s(), prjs2x(): Generic driver routines
84 *
85 * - azpset(), azpx2s(), azps2x(): AZP (zenithal/azimuthal perspective)
86 * - szpset(), szpx2s(), szps2x(): SZP (slant zenithal perspective)
87 * - tanset(), tanx2s(), tans2x(): TAN (gnomonic)
88 * - stgset(), stgx2s(), stgs2x(): STG (stereographic)
89 * - sinset(), sinx2s(), sins2x(): SIN (orthographic/synthesis)
90 * - arcset(), arcx2s(), arcs2x(): ARC (zenithal/azimuthal equidistant)
91 * - zpnset(), zpnx2s(), zpns2x(): ZPN (zenithal/azimuthal polynomial)
92 * - zeaset(), zeax2s(), zeas2x(): ZEA (zenithal/azimuthal equal area)
93 * - airset(), airx2s(), airs2x(): AIR (Airy)
94 * - cypset(), cypx2s(), cyps2x(): CYP (cylindrical perspective)
95 * - ceaset(), ceax2s(), ceas2x(): CEA (cylindrical equal area)
96 * - carset(), carx2s(), cars2x(): CAR (Plate carree)
97 * - merset(), merx2s(), mers2x(): MER (Mercator)
98 * - sflset(), sflx2s(), sfls2x(): SFL (Sanson-Flamsteed)
99 * - parset(), parx2s(), pars2x(): PAR (parabolic)
100 * - molset(), molx2s(), mols2x(): MOL (Mollweide)
101 * - aitset(), aitx2s(), aits2x(): AIT (Hammer-Aitoff)
102 * - copset(), copx2s(), cops2x(): COP (conic perspective)
103 * - coeset(), coex2s(), coes2x(): COE (conic equal area)
104 * - codset(), codx2s(), cods2x(): COD (conic equidistant)
105 * - cooset(), coox2s(), coos2x(): COO (conic orthomorphic)
106 * - bonset(), bonx2s(), bons2x(): BON (Bonne)
107 * - pcoset(), pcox2s(), pcos2x(): PCO (polyconic)
108 * - tscset(), tscx2s(), tscs2x(): TSC (tangential spherical cube)
109 * - cscset(), cscx2s(), cscs2x(): CSC (COBE spherical cube)
110 * - qscset(), qscx2s(), qscs2x(): QSC (quadrilateralized spherical cube)
111 * - hpxset(), hpxx2s(), hpxs2x(): HPX (HEALPix)
112 * - xphset(), xphx2s(), xphs2x(): XPH (HEALPix polar, aka "butterfly")
113 *
114 * Argument checking (projection routines):
115 * ----------------------------------------
116 * The values of phi and theta (the native longitude and latitude) normally lie
117 * in the range [-180,180] for phi, and [-90,90] for theta. However, all
118 * projection routines will accept any value of phi and will not normalize it.
119 *
120 * The projection routines do not explicitly check that theta lies within the
121 * range [-90,90]. They do check for any value of theta that produces an
122 * invalid argument to the projection equations (e.g. leading to division by
123 * zero). The projection routines for AZP, SZP, TAN, SIN, ZPN, and COP also
124 * return error 2 if (phi,theta) corresponds to the overlapped (far) side of
125 * the projection but also return the corresponding value of (x,y). This
126 * strict bounds checking may be relaxed at any time by setting
127 * prjprm::bounds%2 to 0 (rather than 1); the projections need not be
128 * reinitialized.
129 *
130 * Argument checking (deprojection routines):
131 * ------------------------------------------
132 * Error checking on the projected coordinates (x,y) is limited to that
133 * required to ascertain whether a solution exists. Where a solution does
134 * exist, an optional check is made that the value of phi and theta obtained
135 * lie within the ranges [-180,180] for phi, and [-90,90] for theta. This
136 * check, performed by prjbchk(), is enabled by default. It may be disabled by
137 * setting prjprm::bounds%4 to 0 (rather than 1); the projections need not be
138 * reinitialized.
139 *
140 * Accuracy:
141 * ---------
142 * No warranty is given for the accuracy of these routines (refer to the
143 * copyright notice); intending users must satisfy for themselves their
144 * adequacy for the intended purpose. However, closure to a precision of at
145 * least 1E-10 degree of longitude and latitude has been verified for typical
146 * projection parameters on the 1 degree graticule of native longitude and
147 * latitude (to within 5 degrees of any latitude where the projection may
148 * diverge). Refer to the tprj1.c and tprj2.c test routines that accompany
149 * this software.
150 *
151 *
152 * prjini() - Default constructor for the prjprm struct
153 * ----------------------------------------------------
154 * prjini() sets all members of a prjprm struct to default values. It should
155 * be used to initialize every prjprm struct.
156 *
157 * Returned:
158 * prj struct prjprm*
159 * Projection parameters.
160 *
161 * Function return value:
162 * int Status return value:
163 * 0: Success.
164 * 1: Null prjprm pointer passed.
165 *
166 *
167 * prjfree() - Destructor for the prjprm struct
168 * --------------------------------------------
169 * prjfree() frees any memory that may have been allocated to store an error
170 * message in the prjprm struct.
171 *
172 * Given:
173 * prj struct prjprm*
174 * Projection parameters.
175 *
176 * Function return value:
177 * int Status return value:
178 * 0: Success.
179 * 1: Null prjprm pointer passed.
180 *
181 *
182 * prjprt() - Print routine for the prjprm struct
183 * ----------------------------------------------
184 * prjprt() prints the contents of a prjprm struct using wcsprintf(). Mainly
185 * intended for diagnostic purposes.
186 *
187 * Given:
188 * prj const struct prjprm*
189 * Projection parameters.
190 *
191 * Function return value:
192 * int Status return value:
193 * 0: Success.
194 * 1: Null prjprm pointer passed.
195 *
196 *
197 * prjperr() - Print error messages from a prjprm struct
198 * -----------------------------------------------------
199 * prjperr() prints the error message(s) (if any) stored in a prjprm struct.
200 * If there are no errors then nothing is printed. It uses wcserr_prt(), q.v.
201 *
202 * Given:
203 * prj const struct prjprm*
204 * Projection parameters.
205 *
206 * prefix const char *
207 * If non-NULL, each output line will be prefixed with
208 * this string.
209 *
210 * Function return value:
211 * int Status return value:
212 * 0: Success.
213 * 1: Null prjprm pointer passed.
214 *
215 *
216 * prjbchk() - Bounds checking on native coordinates
217 * -------------------------------------------------
218 * prjbchk() performs bounds checking on native spherical coordinates. As
219 * returned by the deprojection (x2s) routines, native longitude is expected
220 * to lie in the closed interval [-180,180], with latitude in [-90,90].
221 *
222 * A tolerance may be specified to provide a small allowance for numerical
223 * imprecision. Values that lie outside the allowed range by not more than
224 * the specified tolerance will be adjusted back into range.
225 *
226 * If prjprm::bounds&4 is set, as it is by prjini(), then prjbchk() will be
227 * invoked automatically by the Cartesian-to-spherical deprojection (x2s)
228 * routines with an appropriate tolerance set for each projection.
229 *
230 * Given:
231 * tol double Tolerance for the bounds check [deg].
232 *
233 * nphi,
234 * ntheta int Vector lengths.
235 *
236 * spt int Vector stride.
237 *
238 * Given and returned:
239 * phi,theta double[] Native longitude and latitude (phi,theta) [deg].
240 *
241 * Returned:
242 * stat int[] Status value for each vector element:
243 * 0: Valid value of (phi,theta).
244 * 1: Invalid value.
245 *
246 * Function return value:
247 * int Status return value:
248 * 0: Success.
249 * 1: One or more of the (phi,theta) coordinates
250 * were, invalid, as indicated by the stat vector.
251 *
252 *
253 * prjset() - Generic setup routine for the prjprm struct
254 * ------------------------------------------------------
255 * prjset() sets up a prjprm struct according to information supplied within
256 * it.
257 *
258 * Note that this routine need not be called directly; it will be invoked by
259 * prjx2s() and prjs2x() if prj.flag is anything other than a predefined magic
260 * value.
261 *
262 * The one important distinction between prjset() and the setup routines for
263 * the specific projections is that the projection code must be defined in the
264 * prjprm struct in order for prjset() to identify the required projection.
265 * Once prjset() has initialized the prjprm struct, prjx2s() and prjs2x() use
266 * the pointers to the specific projection and deprojection routines contained
267 * therein.
268 *
269 * Given and returned:
270 * prj struct prjprm*
271 * Projection parameters.
272 *
273 * Function return value:
274 * int Status return value:
275 * 0: Success.
276 * 1: Null prjprm pointer passed.
277 * 2: Invalid projection parameters.
278 *
279 * For returns > 1, a detailed error message is set in
280 * prjprm::err if enabled, see wcserr_enable().
281 *
282 *
283 * prjx2s() - Generic Cartesian-to-spherical deprojection
284 * ------------------------------------------------------
285 * Deproject Cartesian (x,y) coordinates in the plane of projection to native
286 * spherical coordinates (phi,theta).
287 *
288 * The projection is that specified by prjprm::code.
289 *
290 * Given and returned:
291 * prj struct prjprm*
292 * Projection parameters.
293 *
294 * Given:
295 * nx,ny int Vector lengths.
296 *
297 * sxy,spt int Vector strides.
298 *
299 * x,y const double[]
300 * Projected coordinates.
301 *
302 * Returned:
303 * phi,theta double[] Longitude and latitude (phi,theta) of the projected
304 * point in native spherical coordinates [deg].
305 *
306 * stat int[] Status value for each vector element:
307 * 0: Success.
308 * 1: Invalid value of (x,y).
309 *
310 * Function return value:
311 * int Status return value:
312 * 0: Success.
313 * 1: Null prjprm pointer passed.
314 * 2: Invalid projection parameters.
315 * 3: One or more of the (x,y) coordinates were
316 * invalid, as indicated by the stat vector.
317 *
318 * For returns > 1, a detailed error message is set in
319 * prjprm::err if enabled, see wcserr_enable().
320 *
321 *
322 * prjs2x() - Generic spherical-to-Cartesian projection
323 * ----------------------------------------------------
324 * Project native spherical coordinates (phi,theta) to Cartesian (x,y)
325 * coordinates in the plane of projection.
326 *
327 * The projection is that specified by prjprm::code.
328 *
329 * Given and returned:
330 * prj struct prjprm*
331 * Projection parameters.
332 *
333 * Given:
334 * nphi,
335 * ntheta int Vector lengths.
336 *
337 * spt,sxy int Vector strides.
338 *
339 * phi,theta const double[]
340 * Longitude and latitude (phi,theta) of the projected
341 * point in native spherical coordinates [deg].
342 *
343 * Returned:
344 * x,y double[] Projected coordinates.
345 *
346 * stat int[] Status value for each vector element:
347 * 0: Success.
348 * 1: Invalid value of (phi,theta).
349 *
350 * Function return value:
351 * int Status return value:
352 * 0: Success.
353 * 1: Null prjprm pointer passed.
354 * 2: Invalid projection parameters.
355 * 4: One or more of the (phi,theta) coordinates
356 * were, invalid, as indicated by the stat vector.
357 *
358 * For returns > 1, a detailed error message is set in
359 * prjprm::err if enabled, see wcserr_enable().
360 *
361 *
362 * ???set() - Specific setup routines for the prjprm struct
363 * --------------------------------------------------------
364 * Set up a prjprm struct for a particular projection according to information
365 * supplied within it.
366 *
367 * Given and returned:
368 * prj struct prjprm*
369 * Projection parameters.
370 *
371 * Function return value:
372 * int Status return value:
373 * 0: Success.
374 * 1: Null prjprm pointer passed.
375 * 2: Invalid projection parameters.
376 *
377 * For returns > 1, a detailed error message is set in
378 * prjprm::err if enabled, see wcserr_enable().
379 *
380 *
381 * ???x2s() - Specific Cartesian-to-spherical deprojection routines
382 * ----------------------------------------------------------------
383 * Transform (x,y) coordinates in the plane of projection to native spherical
384 * coordinates (phi,theta).
385 *
386 * Given and returned:
387 * prj struct prjprm*
388 * Projection parameters.
389 *
390 * Given:
391 * nx,ny int Vector lengths.
392 *
393 * sxy,spt int Vector strides.
394 *
395 * x,y const double[]
396 * Projected coordinates.
397 *
398 * Returned:
399 * phi,theta double[] Longitude and latitude of the projected point in
400 * native spherical coordinates [deg].
401 *
402 * stat int[] Status value for each vector element:
403 * 0: Success.
404 * 1: Invalid value of (x,y).
405 *
406 * Function return value:
407 * int Status return value:
408 * 0: Success.
409 * 1: Null prjprm pointer passed.
410 * 2: Invalid projection parameters.
411 * 3: One or more of the (x,y) coordinates were
412 * invalid, as indicated by the stat vector.
413 *
414 * For returns > 1, a detailed error message is set in
415 * prjprm::err if enabled, see wcserr_enable().
416 *
417 *
418 * ???s2x() - Specific spherical-to-Cartesian projection routines
419 *---------------------------------------------------------------
420 * Transform native spherical coordinates (phi,theta) to (x,y) coordinates in
421 * the plane of projection.
422 *
423 * Given and returned:
424 * prj struct prjprm*
425 * Projection parameters.
426 *
427 * Given:
428 * nphi,
429 * ntheta int Vector lengths.
430 *
431 * spt,sxy int Vector strides.
432 *
433 * phi,theta const double[]
434 * Longitude and latitude of the projected point in
435 * native spherical coordinates [deg].
436 *
437 * Returned:
438 * x,y double[] Projected coordinates.
439 *
440 * stat int[] Status value for each vector element:
441 * 0: Success.
442 * 1: Invalid value of (phi,theta).
443 *
444 * Function return value:
445 * int Status return value:
446 * 0: Success.
447 * 1: Null prjprm pointer passed.
448 * 2: Invalid projection parameters.
449 * 4: One or more of the (phi,theta) coordinates
450 * were, invalid, as indicated by the stat vector.
451 *
452 * For returns > 1, a detailed error message is set in
453 * prjprm::err if enabled, see wcserr_enable().
454 *
455 *
456 * prjprm struct - Projection parameters
457 * -------------------------------------
458 * The prjprm struct contains all information needed to project or deproject
459 * native spherical coordinates. It consists of certain members that must be
460 * set by the user ("given") and others that are set by the WCSLIB routines
461 * ("returned"). Some of the latter are supplied for informational purposes
462 * while others are for internal use only.
463 *
464 * int flag
465 * (Given and returned) This flag must be set to zero whenever any of the
466 * following prjprm struct members are set or changed:
467 *
468 * - prjprm::code,
469 * - prjprm::r0,
470 * - prjprm::pv[],
471 * - prjprm::phi0,
472 * - prjprm::theta0.
473 *
474 * This signals the initialization routine (prjset() or ???set()) to
475 * recompute the returned members of the prjprm struct. flag will then be
476 * reset to indicate that this has been done.
477 *
478 * Note that flag need not be reset when prjprm::bounds is changed.
479 *
480 * char code[4]
481 * (Given) Three-letter projection code defined by the FITS standard.
482 *
483 * double r0
484 * (Given) The radius of the generating sphere for the projection, a linear
485 * scaling parameter. If this is zero, it will be reset to its default
486 * value of 180/pi (the value for FITS WCS).
487 *
488 * double pv[30]
489 * (Given) Projection parameters. These correspond to the PVi_ma keywords
490 * in FITS, so pv[0] is PVi_0a, pv[1] is PVi_1a, etc., where i denotes the
491 * latitude-like axis. Many projections use pv[1] (PVi_1a), some also use
492 * pv[2] (PVi_2a) and SZP uses pv[3] (PVi_3a). ZPN is currently the only
493 * projection that uses any of the others.
494 *
495 * Usage of the pv[] array as it applies to each projection is described in
496 * the prologue to each trio of projection routines in prj.c.
497 *
498 * double phi0
499 * (Given) The native longitude, phi_0 [deg], and ...
500 * double theta0
501 * (Given) ... the native latitude, theta_0 [deg], of the reference point,
502 * i.e. the point (x,y) = (0,0). If undefined (set to a magic value by
503 * prjini()) the initialization routine will set this to a
504 * projection-specific default.
505 *
506 * int bounds
507 * (Given) Controls bounds checking. If bounds&1 then enable strict bounds
508 * checking for the spherical-to-Cartesian (s2x) transformation for the
509 * AZP, SZP, TAN, SIN, ZPN, and COP projections. If bounds&2 then enable
510 * strict bounds checking for the Cartesian-to-spherical transformation
511 * (x2s) for the HPX and XPH projections. If bounds&4 then the Cartesian-
512 * to-spherical transformations (x2s) will invoke prjbchk() to perform
513 * bounds checking on the computed native coordinates, with a tolerance set
514 * to suit each projection. bounds is set to 7 by prjini() by default
515 * which enables all checks. Zero it to disable all checking.
516 *
517 * It is not necessary to reset the prjprm struct (via prjset() or
518 * ???set()) when prjprm::bounds is changed.
519 *
520 * The remaining members of the prjprm struct are maintained by the setup
521 * routines and must not be modified elsewhere:
522 *
523 * char name[40]
524 * (Returned) Long name of the projection.
525 *
526 * Provided for information only, not used by the projection routines.
527 *
528 * int category
529 * (Returned) Projection category matching the value of the relevant global
530 * variable:
531 *
532 * - ZENITHAL,
533 * - CYLINDRICAL,
534 * - PSEUDOCYLINDRICAL,
535 * - CONVENTIONAL,
536 * - CONIC,
537 * - POLYCONIC,
538 * - QUADCUBE, and
539 * - HEALPIX.
540 *
541 * The category name may be identified via the prj_categories character
542 * array, e.g.
543 *
544 = struct prjprm prj;
545 = ...
546 = printf("%s\n", prj_categories[prj.category]);
547 *
548 * Provided for information only, not used by the projection routines.
549 *
550 * int pvrange
551 * (Returned) Range of projection parameter indices: 100 times the first
552 * allowed index plus the number of parameters, e.g. TAN is 0 (no
553 * parameters), SZP is 103 (1 to 3), and ZPN is 30 (0 to 29).
554 *
555 * Provided for information only, not used by the projection routines.
556 *
557 * int simplezen
558 * (Returned) True if the projection is a radially-symmetric zenithal
559 * projection.
560 *
561 * Provided for information only, not used by the projection routines.
562 *
563 * int equiareal
564 * (Returned) True if the projection is equal area.
565 *
566 * Provided for information only, not used by the projection routines.
567 *
568 * int conformal
569 * (Returned) True if the projection is conformal.
570 *
571 * Provided for information only, not used by the projection routines.
572 *
573 * int global
574 * (Returned) True if the projection can represent the whole sphere in a
575 * finite, non-overlapped mapping.
576 *
577 * Provided for information only, not used by the projection routines.
578 *
579 * int divergent
580 * (Returned) True if the projection diverges in latitude.
581 *
582 * Provided for information only, not used by the projection routines.
583 *
584 * double x0
585 * (Returned) The offset in x, and ...
586 * double y0
587 * (Returned) ... the offset in y used to force (x,y) = (0,0) at
588 * (phi_0,theta_0).
589 *
590 * struct wcserr *err
591 * (Returned) If enabled, when an error status is returned, this struct
592 * contains detailed information about the error, see wcserr_enable().
593 *
594 * void *padding
595 * (An unused variable inserted for alignment purposes only.)
596 *
597 * double w[10]
598 * (Returned) Intermediate floating-point values derived from the
599 * projection parameters, cached here to save recomputation.
600 *
601 * Usage of the w[] array as it applies to each projection is described in
602 * the prologue to each trio of projection routines in prj.c.
603 *
604 * int n
605 * (Returned) Intermediate integer value (used only for the ZPN and HPX
606 * projections).
607 *
608 * int (*prjx2s)(PRJX2S_ARGS)
609 * (Returned) Pointer to the spherical projection ...
610 * int (*prjs2x)(PRJ_ARGS)
611 * (Returned) ... and deprojection routines.
612 *
613 *
614 * Global variable: const char *prj_errmsg[] - Status return messages
615 * ------------------------------------------------------------------
616 * Error messages to match the status value returned from each function.
617 *
618 *===========================================================================*/
619
620 #ifndef WCSLIB_PROJ
621 #define WCSLIB_PROJ
622
623 #ifdef __cplusplus
624 extern "C" {
625 #endif
626
627
628 /* Total number of projection parameters; 0 to PVN-1. */
629 #define PVN 30
630
631 extern const char *prj_errmsg[];
632
633 enum prj_errmsg_enum {
634 PRJERR_SUCCESS = 0, /* Success. */
635 PRJERR_NULL_POINTER = 1, /* Null prjprm pointer passed. */
636 PRJERR_BAD_PARAM = 2, /* Invalid projection parameters. */
637 PRJERR_BAD_PIX = 3, /* One or more of the (x, y) coordinates were
638 invalid. */
639 PRJERR_BAD_WORLD = 4 /* One or more of the (phi, theta) coordinates
640 were invalid. */
641 };
642
643 extern const int CONIC, CONVENTIONAL, CYLINDRICAL, POLYCONIC,
644 PSEUDOCYLINDRICAL, QUADCUBE, ZENITHAL, HEALPIX;
645 extern const char prj_categories[9][32];
646
647 extern const int prj_ncode;
648 extern const char prj_codes[28][4];
649
650 #ifdef PRJX2S_ARGS
651 #undef PRJX2S_ARGS
652 #endif
653
654 #ifdef PRJS2X_ARGS
655 #undef PRJS2X_ARGS
656 #endif
657
658 /* For use in declaring deprojection function prototypes. */
659 #define PRJX2S_ARGS struct prjprm *prj, int nx, int ny, int sxy, int spt, \
660 const double x[], const double y[], double phi[], double theta[], int stat[]
661
662 /* For use in declaring projection function prototypes. */
663 #define PRJS2X_ARGS struct prjprm *prj, int nx, int ny, int sxy, int spt, \
664 const double phi[], const double theta[], double x[], double y[], int stat[]
665
666
667 struct prjprm {
668 /* Initialization flag (see the prologue above). */
669 /*------------------------------------------------------------------------*/
670 int flag; /* Set to zero to force initialization. */
671
672 /* Parameters to be provided (see the prologue above). */
673 /*------------------------------------------------------------------------*/
674 char code[4]; /* Three-letter projection code. */
675 double r0; /* Radius of the generating sphere. */
676 double pv[PVN]; /* Projection parameters. */
677 double phi0, theta0; /* Fiducial native coordinates. */
678 int bounds; /* Controls bounds checking. */
679
680 /* Information derived from the parameters supplied. */
681 /*------------------------------------------------------------------------*/
682 char name[40]; /* Projection name. */
683 int category; /* Projection category. */
684 int pvrange; /* Range of projection parameter indices. */
685 int simplezen; /* Is it a simple zenithal projection? */
686 int equiareal; /* Is it an equal area projection? */
687 int conformal; /* Is it a conformal projection? */
688 int global; /* Can it map the whole sphere? */
689 int divergent; /* Does the projection diverge in latitude? */
690 double x0, y0; /* Fiducial offsets. */
691
692 /* Error handling */
693 /*------------------------------------------------------------------------*/
694 struct wcserr *err;
695
696 /* Private */
697 /*------------------------------------------------------------------------*/
698 void *padding; /* (Dummy inserted for alignment purposes.) */
699 double w[10]; /* Intermediate values. */
700 int m, n; /* Intermediate values. */
701
702 int (*prjx2s)(PRJX2S_ARGS); /* Pointers to the spherical projection and */
703 int (*prjs2x)(PRJS2X_ARGS); /* deprojection functions. */
704 };
705
706 /* Size of the prjprm struct in int units, used by the Fortran wrappers. */
707 #define PRJLEN (sizeof(struct prjprm)/sizeof(int))
708
709
710 /* Use the preprocessor to help declare function prototypes (see above). */
711 int prjini(struct prjprm *prj);
712 int prjfree(struct prjprm *prj);
713 int prjprt(const struct prjprm *prj);
714 int prjperr(const struct prjprm *prj, const char *prefix);
715 int prjbchk(double tol, int nphi, int ntheta, int spt, double phi[],
716 double theta[], int stat[]);
717
718 int prjset(struct prjprm *prj);
719 int prjx2s(PRJX2S_ARGS);
720 int prjs2x(PRJS2X_ARGS);
721
722 int azpset(struct prjprm *prj);
723 int azpx2s(PRJX2S_ARGS);
724 int azps2x(PRJS2X_ARGS);
725
726 int szpset(struct prjprm *prj);
727 int szpx2s(PRJX2S_ARGS);
728 int szps2x(PRJS2X_ARGS);
729
730 int tanset(struct prjprm *prj);
731 int tanx2s(PRJX2S_ARGS);
732 int tans2x(PRJS2X_ARGS);
733
734 int stgset(struct prjprm *prj);
735 int stgx2s(PRJX2S_ARGS);
736 int stgs2x(PRJS2X_ARGS);
737
738 int sinset(struct prjprm *prj);
739 int sinx2s(PRJX2S_ARGS);
740 int sins2x(PRJS2X_ARGS);
741
742 int arcset(struct prjprm *prj);
743 int arcx2s(PRJX2S_ARGS);
744 int arcs2x(PRJS2X_ARGS);
745
746 int zpnset(struct prjprm *prj);
747 int zpnx2s(PRJX2S_ARGS);
748 int zpns2x(PRJS2X_ARGS);
749
750 int zeaset(struct prjprm *prj);
751 int zeax2s(PRJX2S_ARGS);
752 int zeas2x(PRJS2X_ARGS);
753
754 int airset(struct prjprm *prj);
755 int airx2s(PRJX2S_ARGS);
756 int airs2x(PRJS2X_ARGS);
757
758 int cypset(struct prjprm *prj);
759 int cypx2s(PRJX2S_ARGS);
760 int cyps2x(PRJS2X_ARGS);
761
762 int ceaset(struct prjprm *prj);
763 int ceax2s(PRJX2S_ARGS);
764 int ceas2x(PRJS2X_ARGS);
765
766 int carset(struct prjprm *prj);
767 int carx2s(PRJX2S_ARGS);
768 int cars2x(PRJS2X_ARGS);
769
770 int merset(struct prjprm *prj);
771 int merx2s(PRJX2S_ARGS);
772 int mers2x(PRJS2X_ARGS);
773
774 int sflset(struct prjprm *prj);
775 int sflx2s(PRJX2S_ARGS);
776 int sfls2x(PRJS2X_ARGS);
777
778 int parset(struct prjprm *prj);
779 int parx2s(PRJX2S_ARGS);
780 int pars2x(PRJS2X_ARGS);
781
782 int molset(struct prjprm *prj);
783 int molx2s(PRJX2S_ARGS);
784 int mols2x(PRJS2X_ARGS);
785
786 int aitset(struct prjprm *prj);
787 int aitx2s(PRJX2S_ARGS);
788 int aits2x(PRJS2X_ARGS);
789
790 int copset(struct prjprm *prj);
791 int copx2s(PRJX2S_ARGS);
792 int cops2x(PRJS2X_ARGS);
793
794 int coeset(struct prjprm *prj);
795 int coex2s(PRJX2S_ARGS);
796 int coes2x(PRJS2X_ARGS);
797
798 int codset(struct prjprm *prj);
799 int codx2s(PRJX2S_ARGS);
800 int cods2x(PRJS2X_ARGS);
801
802 int cooset(struct prjprm *prj);
803 int coox2s(PRJX2S_ARGS);
804 int coos2x(PRJS2X_ARGS);
805
806 int bonset(struct prjprm *prj);
807 int bonx2s(PRJX2S_ARGS);
808 int bons2x(PRJS2X_ARGS);
809
810 int pcoset(struct prjprm *prj);
811 int pcox2s(PRJX2S_ARGS);
812 int pcos2x(PRJS2X_ARGS);
813
814 int tscset(struct prjprm *prj);
815 int tscx2s(PRJX2S_ARGS);
816 int tscs2x(PRJS2X_ARGS);
817
818 int cscset(struct prjprm *prj);
819 int cscx2s(PRJX2S_ARGS);
820 int cscs2x(PRJS2X_ARGS);
821
822 int qscset(struct prjprm *prj);
823 int qscx2s(PRJX2S_ARGS);
824 int qscs2x(PRJS2X_ARGS);
825
826 int hpxset(struct prjprm *prj);
827 int hpxx2s(PRJX2S_ARGS);
828 int hpxs2x(PRJS2X_ARGS);
829
830 int xphset(struct prjprm *prj);
831 int xphx2s(PRJX2S_ARGS);
832 int xphs2x(PRJS2X_ARGS);
833
834
835 /* Deprecated. */
836 #define prjini_errmsg prj_errmsg
837 #define prjprt_errmsg prj_errmsg
838 #define prjset_errmsg prj_errmsg
839 #define prjx2s_errmsg prj_errmsg
840 #define prjs2x_errmsg prj_errmsg
841
842 #ifdef __cplusplus
843 }
844 #endif
845
846 #endif /* WCSLIB_PROJ */
sinx2s
int sinx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the orthographic/synthesis (SIN) projection.
cars2x
int cars2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the plate carrée (CAR) projection.
molset
int molset(struct prjprm *prj)
Set up a prjprm struct for Mollweide&#39;s (MOL) projection.
stgset
int stgset(struct prjprm *prj)
Set up a prjprm struct for the stereographic (STG) projection.
tanset
int tanset(struct prjprm *prj)
Set up a prjprm struct for the gnomonic (TAN) projection.
prjprt
int prjprt(const struct prjprm *prj)
Print routine for the prjprm struct.
CONVENTIONAL
const int CONVENTIONAL
Identifier for conventional projections.
arcx2s
int arcx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the zenithal/azimuthal equidistant (ARC) projection...
arcset
int arcset(struct prjprm *prj)
Set up a prjprm struct for the zenithal/azimuthal equidistant (ARC) projection.
bonx2s
int bonx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for Bonne&#39;s (BON) projection.
prjprm::simplezen
int simplezen
Definition: prj.h:685
coeset
int coeset(struct prjprm *prj)
Set up a prjprm struct for the conic equal area (COE) projection.
wcserr
Error message handling.
Definition: wcserr.h:223
prjprm::equiareal
int equiareal
Definition: prj.h:686
sflset
int sflset(struct prjprm *prj)
Set up a prjprm struct for the Sanson-Flamsteed (SFL) projection.
bons2x
int bons2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for Bonne&#39;s (BON) projection.
prjprm::m
int m
Definition: prj.h:700
prj_categories
const char prj_categories[9][32]
Projection categories.
copset
int copset(struct prjprm *prj)
Set up a prjprm struct for the conic perspective (COP) projection.
tanx2s
int tanx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the gnomonic (TAN) projection.
airx2s
int airx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for Airy&#39;s (AIR) projection.
xphs2x
int xphs2x(PRJS2X_ARGS)
prj_errmsg_enum
prj_errmsg_enum
Definition: prj.h:633
stgx2s
int stgx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the stereographic (STG) projection.
prj_codes
const char prj_codes[28][4]
Recognized three-letter projection codes.
szpset
int szpset(struct prjprm *prj)
Set up a prjprm struct for the slant zenithal perspective (SZP) projection.
aits2x
int aits2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the Hammer-Aitoff (AIT) projection.
cooset
int cooset(struct prjprm *prj)
Set up a prjprm struct for the conic orthomorphic (COO) projection.
zpns2x
int zpns2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the zenithal/azimuthal polynomial (ZPN) projection...
merx2s
int merx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for Mercator&#39;s (MER) projection.
merset
int merset(struct prjprm *prj)
Set up a prjprm struct for Mercator&#39;s (MER) projection.
parx2s
int parx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the parabolic (PAR) projection.
coes2x
int coes2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the conic equal area (COE) projection.
PRJERR_BAD_WORLD
Definition: prj.h:639
PRJERR_BAD_PARAM
Definition: prj.h:636
carx2s
int carx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the plate carrée (CAR) projection.
prjprm::padding
void * padding
Definition: prj.h:698
prjprm::pv
double pv[PVN]
Definition: prj.h:676
prjprm::prjs2x
int(* prjs2x)(PRJS2X_ARGS)
Definition: prj.h:703
cypx2s
int cypx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the cylindrical perspective (CYP) projection.
cscset
int cscset(struct prjprm *prj)
Set up a prjprm struct for the COBE spherical cube (CSC) projection.
prjprm::category
int category
Definition: prj.h:683
aitset
int aitset(struct prjprm *prj)
Set up a prjprm struct for the Hammer-Aitoff (AIT) projection.
prjbchk
int prjbchk(double tol, int nphi, int ntheta, int spt, double phi[], double theta[], int stat[])
Bounds checking on native coordinates.
CYLINDRICAL
const int CYLINDRICAL
Identifier for cylindrical projections.
cops2x
int cops2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the conic perspective (COP) projection. ...
pcox2s
int pcox2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the polyconic (PCO) projection.
prjfree
int prjfree(struct prjprm *prj)
Destructor for the prjprm struct.
carset
int carset(struct prjprm *prj)
Set up a prjprm struct for the plate carrée (CAR) projection.
xphx2s
int xphx2s(PRJX2S_ARGS)
tscset
int tscset(struct prjprm *prj)
Set up a prjprm struct for the tangential spherical cube (TSC) projection.
prjs2x
int prjs2x(PRJS2X_ARGS)
Generic spherical-to-Cartesian projection.
cscx2s
int cscx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the COBE spherical cube (CSC) projection.
airset
int airset(struct prjprm *prj)
Set up a prjprm struct for Airy&#39;s (AIR) projection.
cscs2x
int cscs2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the COBE spherical cube (CSC) projection.
prjprm
Projection parameters.
Definition: prj.h:667
pcos2x
int pcos2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the polyconic (PCO) projection.
szps2x
int szps2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the slant zenithal perspective (SZP) projection.
zeax2s
int zeax2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the zenithal/azimuthal equal area (ZEA) projection...
qscx2s
int qscx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the quadrilateralized spherical cube (QSC) projection...
prjprm::phi0
double phi0
Definition: prj.h:677
prjprm::r0
double r0
Definition: prj.h:675
POLYCONIC
const int POLYCONIC
Identifier for polyconic projections.
qscset
int qscset(struct prjprm *prj)
Set up a prjprm struct for the quadrilateralized spherical cube (QSC) projection. ...
zeaset
int zeaset(struct prjprm *prj)
Set up a prjprm struct for the zenithal/azimuthal equal area (ZEA) projection.
sinset
int sinset(struct prjprm *prj)
Set up a prjprm struct for the orthographic/synthesis (SIN) projection.
prjprm::code
char code[4]
Definition: prj.h:674
prjprm::prjx2s
int(* prjx2s)(PRJX2S_ARGS)
Definition: prj.h:702
PRJS2X_ARGS
#define PRJS2X_ARGS
For use in declaring projection function prototypes.
Definition: prj.h:663
hpxset
int hpxset(struct prjprm *prj)
Set up a prjprm struct for the HEALPix (HPX) projection.
QUADCUBE
const int QUADCUBE
Identifier for quadcube projections.
sflx2s
int sflx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the Sanson-Flamsteed (SFL) projection.
prj_errmsg
const char * prj_errmsg[]
Status return messages.
prj_ncode
const int prj_ncode
The number of recognized three-letter projection codes.
zeas2x
int zeas2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the zenithal/azimuthal equal area (ZEA) projection...
airs2x
int airs2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for Airy&#39;s (AIR) projection.
tscx2s
int tscx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the tangential spherical cube (TSC) projection.
prjprm::name
char name[40]
Definition: prj.h:682
copx2s
int copx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the conic perspective (COP) projection. ...
prjprm::x0
double x0
Definition: prj.h:690
cods2x
int cods2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the conic equidistant (COD) projection. ...
prjset
int prjset(struct prjprm *prj)
Generic setup routine for the prjprm struct.
prjprm::conformal
int conformal
Definition: prj.h:687
prjperr
int prjperr(const struct prjprm *prj, const char *prefix)
Print error messages from a prjprm struct.
prjprm::pvrange
int pvrange
Definition: prj.h:684
sins2x
int sins2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the orthographic/synthesis (SIN) projection.
CONIC
const int CONIC
Identifier for conic projections.
cyps2x
int cyps2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the cylindrical perspective (CYP) projection.
arcs2x
int arcs2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the zenithal/azimuthal equidistant (ARC) projection...
prjprm::w
double w[10]
Definition: prj.h:699
prjprm::n
int n
Definition: prj.h:700
HEALPIX
const int HEALPIX
Identifier for the HEALPix projection.
mers2x
int mers2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for Mercator&#39;s (MER) projection.
codset
int codset(struct prjprm *prj)
Set up a prjprm struct for the conic equidistant (COD) projection.
tscs2x
int tscs2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the tangential spherical cube (TSC) projection.
ZENITHAL
const int ZENITHAL
Identifier for zenithal/azimuthal projections.
coox2s
int coox2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the conic orthomorphic (COO) projection.
qscs2x
int qscs2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the quadrilateralized spherical cube (QSC) projection...
hpxx2s
int hpxx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the HEALPix (HPX) projection.
bonset
int bonset(struct prjprm *prj)
Set up a prjprm struct for Bonne&#39;s (BON) projection.
coex2s
int coex2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the conic equal area (COE) projection.
xphset
int xphset(struct prjprm *prj)
PSEUDOCYLINDRICAL
const int PSEUDOCYLINDRICAL
Identifier for pseudocylindrical projections.
PRJERR_NULL_POINTER
Definition: prj.h:635
szpx2s
int szpx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the slant zenithal perspective (SZP) projection.
PVN
#define PVN
Total number of projection parameters.
Definition: prj.h:629
PRJERR_BAD_PIX
Definition: prj.h:637
ceas2x
int ceas2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the cylindrical equal area (CEA) projection.
prjprm::y0
double y0
Definition: prj.h:690
coos2x
int coos2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the conic orthomorphic (COO) projection.
aitx2s
int aitx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the Hammer-Aitoff (AIT) projection.
zpnset
int zpnset(struct prjprm *prj)
Set up a prjprm struct for the zenithal/azimuthal polynomial (ZPN) projection.
sfls2x
int sfls2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the Sanson-Flamsteed (SFL) projection.
mols2x
int mols2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for Mollweide&#39;s (MOL) projection.
prjprm::global
int global
Definition: prj.h:688
pcoset
int pcoset(struct prjprm *prj)
Set up a prjprm struct for the polyconic (PCO) projection.
ceaset
int ceaset(struct prjprm *prj)
Set up a prjprm struct for the cylindrical equal area (CEA) projection.
prjini
int prjini(struct prjprm *prj)
Default constructor for the prjprm struct.
prjprm::bounds
int bounds
Definition: prj.h:678
prjprm::err
struct wcserr * err
Definition: prj.h:694
tans2x
int tans2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the gnomonic (TAN) projection.
azpset
int azpset(struct prjprm *prj)
Set up a prjprm struct for the zenithal/azimuthal perspective (AZP) projection.
prjprm::flag
int flag
Definition: prj.h:670
parset
int parset(struct prjprm *prj)
Set up a prjprm struct for the parabolic (PAR) projection.
azps2x
int azps2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the zenithal/azimuthal perspective (AZP) projection...
stgs2x
int stgs2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the stereographic (STG) projection.
ceax2s
int ceax2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the cylindrical equal area (CEA) projection.
hpxs2x
int hpxs2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the HEALPix (HPX) projection.
zpnx2s
int zpnx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the zenithal/azimuthal polynomial (ZPN) projection...
azpx2s
int azpx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the zenithal/azimuthal perspective (AZP) projection...
prjx2s
int prjx2s(PRJX2S_ARGS)
Generic Cartesian-to-spherical deprojection.
molx2s
int molx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for Mollweide&#39;s (MOL) projection.
PRJERR_SUCCESS
Definition: prj.h:634
PRJX2S_ARGS
#define PRJX2S_ARGS
For use in declaring deprojection function prototypes.
Definition: prj.h:659
prjprm::theta0
double theta0
Definition: prj.h:677
prjprm::divergent
int divergent
Definition: prj.h:689
pars2x
int pars2x(PRJS2X_ARGS)
Spherical-to-Cartesian transformation for the parabolic (PAR) projection.
cypset
int cypset(struct prjprm *prj)
Set up a prjprm struct for the cylindrical perspective (CYP) projection.
codx2s
int codx2s(PRJX2S_ARGS)
Cartesian-to-spherical transformation for the conic equidistant (COD) projection. ...