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