1 /******************************************************************************
2  * Project:  PROJ.4
3  * Purpose:  Revised, experimental API for PROJ.4, intended as the foundation
4  *           for added geodetic functionality.
5  *
6  *           The original proj API (defined previously in projects.h) has grown
7  *           organically over the years, but it has also grown somewhat messy.
8  *
9  *           The same has happened with the newer high level API (defined in
10  *           proj_api.h): To support various historical objectives, proj_api.h
11  *           contains a rather complex combination of conditional defines and
12  *           typedefs. Probably for good (historical) reasons, which are not
13  *           always evident from today's perspective.
14  *
15  *           This is an evolving attempt at creating a re-rationalized API
16  *           with primary design goals focused on sanitizing the namespaces.
17  *           Hence, all symbols exposed are being moved to the proj_ namespace,
18  *           while all data types are being moved to the PJ_ namespace.
19  *
20  *           Please note that this API is *orthogonal* to  the previous APIs:
21  *           Apart from some inclusion guards, projects.h and proj_api.h are not
22  *           touched - if you do not include proj.h, the projects and proj_api
23  *           APIs should work as they always have.
24  *
25  *           A few implementation details:
26  *
27  *           Apart from the namespacing efforts, I'm trying to eliminate three
28  *           proj_api elements, which I have found especially confusing.
29  *
30  *           FIRST and foremost, I try to avoid typedef'ing away pointer
31  *           semantics. I agree that it can be occasionally useful, but I
32  *           prefer having the pointer nature of function arguments being
33  *           explicitly visible.
34  *
35  *           Hence, projCtx has been replaced by PJ_CONTEXT *.
36  *           and    projPJ  has been replaced by PJ *
37  *
38  *           SECOND, I try to eliminate cases of information hiding implemented
39  *           by redefining data types to void pointers.
40  *
41  *           I prefer using a combination of forward declarations and typedefs.
42  *           Hence:
43  *               typedef void *projCtx;
44  *           Has been replaced by:
45  *               struct projCtx_t;
46  *               typedef struct projCtx_t PJ_CONTEXT;
47  *           This makes it possible for the calling program to know that the
48  *           PJ_CONTEXT data type exists, and handle pointers to that data type
49  *           without having any idea about its internals.
50  *
51  *           (obviously, in this example, struct projCtx_t should also be
52  *           renamed struct pj_ctx some day, but for backwards compatibility
53  *           it remains as-is for now).
54  *
55  *           THIRD, I try to eliminate implicit type punning. Hence this API
56  *           introduces the PJ_COORD union data type, for generic 4D coordinate
57  *           handling.
58  *
59  *           PJ_COORD makes it possible to make explicit the previously used
60  *           "implicit type punning", where a XY is turned into a LP by
61  *           re#defining both as UV, behind the back of the user.
62  *
63  *           The PJ_COORD union is used for storing 1D, 2D, 3D and 4D coordinates.
64  *
65  *           The bare essentials API presented here follows the PROJ.4
66  *           convention of sailing the coordinate to be reprojected, up on
67  *           the stack ("call by value"), and symmetrically returning the
68  *           result on the stack. Although the PJ_COORD object is twice as large
69  *           as the traditional XY and LP objects, timing results have shown the
70  *           overhead to be very reasonable.
71  *
72  *           Contexts and thread safety
73  *           --------------------------
74  *
75  *           After a year of experiments (and previous experience from the
76  *           trlib transformation library) it has become clear that the
77  *           context subsystem is unavoidable in a multi-threaded world.
78  *           Hence, instead of hiding it away, we move it into the limelight,
79  *           highly recommending (but not formally requiring) the bracketing
80  *           of any code block calling PROJ.4 functions with calls to
81  *           proj_context_create(...)/proj_context_destroy()
82  *
83  *           Legacy single threaded code need not do anything, but *may*
84  *           implement a bit of future compatibility by using the backward
85  *           compatible call proj_context_create(0), which will not create
86  *           a new context, but simply provide a pointer to the default one.
87  *
88  *           See proj_4D_api_test.c for examples of how to use the API.
89  *
90  * Author:   Thomas Knudsen, <thokn@sdfe.dk>
91  *           Benefitting from a large number of comments and suggestions
92  *           by (primarily) Kristian Evers and Even Rouault.
93  *
94  ******************************************************************************
95  * Copyright (c) 2016, 2017, Thomas Knudsen / SDFE
96  * Copyright (c) 2018, Even Rouault
97  *
98  * Permission is hereby granted, free of charge, to any person obtaining a
99  * copy of this software and associated documentation files (the "Software"),
100  * to deal in the Software without restriction, including without limitation
101  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
102  * and/or sell copies of the Software, and to permit persons to whom the
103  * Software is furnished to do so, subject to the following conditions:
104  *
105  * The above copyright notice and this permission notice shall be included
106  * in all copies or substantial portions of the Software.
107  *
108  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
109  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
110  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO COORD SHALL
111  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
112  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
113  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
114  * DEALINGS IN THE SOFTWARE.
115  *****************************************************************************/
116 
117 #ifndef PROJ_H
118 #define PROJ_H
119 
120 #include <stddef.h>  /* For size_t */
121 
122 #ifdef PROJ_API_H
123 #error proj.h must be included before proj_api.h
124 #endif
125 
126 #ifdef PROJ_RENAME_SYMBOLS
127 #include "proj_symbol_rename.h"
128 #endif
129 
130 #ifdef __cplusplus
131 extern "C" {
132 #endif
133 
134 /**
135  * \file proj.h
136  *
137  * C API new generation
138  */
139 
140 /*! @cond Doxygen_Suppress */
141 
142 #ifndef PROJ_DLL
143 #ifdef PROJ_MSVC_DLL_EXPORT
144 #define PROJ_DLL __declspec(dllexport)
145 #elif defined(PROJ_MSVC_DLL_IMPORT)
146 #define PROJ_DLL __declspec(dllimport)
147 #elif defined(__GNUC__)
148 #define PROJ_DLL __attribute__ ((visibility("default")))
149 #else
150 #define PROJ_DLL
151 #endif
152 #endif
153 
154 #ifdef PROJ_SUPPRESS_DEPRECATION_MESSAGE
155   #define PROJ_DEPRECATED(decl, msg)            decl
156 #elif defined(__has_extension)
157   #if __has_extension(attribute_deprecated_with_message)
158     #define PROJ_DEPRECATED(decl, msg)          decl __attribute__ ((deprecated(msg)))
159   #elif defined(__GNUC__)
160     #define PROJ_DEPRECATED(decl, msg)          decl __attribute__ ((deprecated))
161   #else
162     #define PROJ_DEPRECATED(decl, msg)          decl
163   #endif
164 #elif defined(__GNUC__)
165   #define PROJ_DEPRECATED(decl, msg)            decl __attribute__ ((deprecated))
166 #elif defined(_MSVC_VER)
167   #define PROJ_DEPRECATED(decl, msg)            __declspec(deprecated(msg)) decl
168 #else
169   #define PROJ_DEPRECATED(decl, msg)            decl
170 #endif
171 
172 /* The version numbers should be updated with every release! **/
173 #define PROJ_VERSION_MAJOR 7
174 #define PROJ_VERSION_MINOR 2
175 #define PROJ_VERSION_PATCH 1
176 
177 extern char const PROJ_DLL pj_release[]; /* global release id string */
178 
179 /* first forward declare everything needed */
180 
181 /* Data type for generic geodetic 3D data plus epoch information */
182 union PJ_COORD;
183 typedef union PJ_COORD PJ_COORD;
184 
185 struct PJ_AREA;
186 typedef struct PJ_AREA PJ_AREA;
187 
188 struct P5_FACTORS {                  /* Common designation */
189     double meridional_scale;               /* h */
190     double parallel_scale;                 /* k */
191     double areal_scale;                    /* s */
192 
193     double angular_distortion;             /* omega */
194     double meridian_parallel_angle;        /* theta-prime */
195     double meridian_convergence;           /* alpha */
196 
197     double tissot_semimajor;               /* a */
198     double tissot_semiminor;               /* b */
199 
200     double dx_dlam, dx_dphi;
201     double dy_dlam, dy_dphi;
202 };
203 typedef struct P5_FACTORS PJ_FACTORS;
204 
205 /* Data type for projection/transformation information */
206 struct PJconsts;
207 typedef struct PJconsts PJ;         /* the PJ object herself */
208 
209 /* Data type for library level information */
210 struct PJ_INFO;
211 typedef struct PJ_INFO PJ_INFO;
212 
213 struct PJ_PROJ_INFO;
214 typedef struct PJ_PROJ_INFO PJ_PROJ_INFO;
215 
216 struct PJ_GRID_INFO;
217 typedef struct PJ_GRID_INFO PJ_GRID_INFO;
218 
219 struct PJ_INIT_INFO;
220 typedef struct PJ_INIT_INFO PJ_INIT_INFO;
221 
222 /* Data types for list of operations, ellipsoids, datums and units used in PROJ.4 */
223 struct PJ_LIST {
224     const char  *id;                /* projection keyword */
225     PJ          *(*proj)(PJ *);     /* projection entry point */
226     const char  * const *descr;     /* description text */
227 };
228 
229 typedef struct PJ_LIST PJ_OPERATIONS;
230 
231 struct PJ_ELLPS {
232     const char  *id;    /* ellipse keyword name */
233     const char  *major; /* a= value */
234     const char  *ell;   /* elliptical parameter */
235     const char  *name;  /* comments */
236 };
237 typedef struct PJ_ELLPS PJ_ELLPS;
238 
239 struct PJ_UNITS {
240     const char  *id;        /* units keyword */
241     const char  *to_meter;  /* multiply by value to get meters */
242     const char  *name;      /* comments */
243     double      factor;     /* to_meter factor in actual numbers */
244 };
245 typedef struct PJ_UNITS PJ_UNITS;
246 
247 struct PJ_PRIME_MERIDIANS {
248     const char  *id;        /* prime meridian keyword */
249     const char  *defn;      /* offset from greenwich in DMS format. */
250 };
251 typedef struct PJ_PRIME_MERIDIANS PJ_PRIME_MERIDIANS;
252 
253 
254 /* Geodetic, mostly spatiotemporal coordinate types */
255 typedef struct { double   x,   y,  z, t; }  PJ_XYZT;
256 typedef struct { double   u,   v,  w, t; }  PJ_UVWT;
257 typedef struct { double lam, phi,  z, t; }  PJ_LPZT;
258 typedef struct { double o, p, k; }          PJ_OPK;  /* Rotations: omega, phi, kappa */
259 typedef struct { double e, n, u; }          PJ_ENU;  /* East, North, Up */
260 typedef struct { double s, a1, a2; }        PJ_GEOD; /* Geodesic length, fwd azi, rev azi */
261 
262 /* Classic proj.4 pair/triplet types - moved into the PJ_ name space */
263 typedef struct { double   u,   v; }  PJ_UV;
264 typedef struct { double   x,   y; }  PJ_XY;
265 typedef struct { double lam, phi; }  PJ_LP;
266 
267 typedef struct { double   x,   y,  z; }  PJ_XYZ;
268 typedef struct { double   u,   v,  w; }  PJ_UVW;
269 typedef struct { double lam, phi,  z; }  PJ_LPZ;
270 
271 
272 /* Avoid preprocessor renaming and implicit type-punning: Use a union to make it explicit */
273 union PJ_COORD {
274      double v[4];   /* First and foremost, it really is "just 4 numbers in a vector" */
275     PJ_XYZT xyzt;
276     PJ_UVWT uvwt;
277     PJ_LPZT lpzt;
278     PJ_GEOD geod;
279      PJ_OPK opk;
280      PJ_ENU enu;
281      PJ_XYZ xyz;
282      PJ_UVW uvw;
283      PJ_LPZ lpz;
284       PJ_XY xy;
285       PJ_UV uv;
286       PJ_LP lp;
287 };
288 
289 
290 struct PJ_INFO {
291     int         major;              /* Major release number                 */
292     int         minor;              /* Minor release number                 */
293     int         patch;              /* Patch level                          */
294     const char  *release;           /* Release info. Version + date         */
295     const char  *version;           /* Full version number                  */
296     const char  *searchpath;        /* Paths where init and grid files are  */
297                                     /* looked for. Paths are separated by   */
298                                     /* semi-colons on Windows, and colons   */
299                                     /* on non-Windows platforms.            */
300     const char * const *paths;
301     size_t path_count;
302 };
303 
304 struct PJ_PROJ_INFO {
305     const char  *id;                /* Name of the projection in question                       */
306     const char  *description;       /* Description of the projection                            */
307     const char  *definition;        /* Projection definition                                    */
308     int         has_inverse;        /* 1 if an inverse mapping exists, 0 otherwise              */
309     double      accuracy;           /* Expected accuracy of the transformation. -1 if unknown.  */
310 };
311 
312 struct PJ_GRID_INFO {
313     char        gridname[32];       /* name of grid                         */
314     char        filename[260];      /* full path to grid                    */
315     char        format[8];          /* file format of grid                  */
316     PJ_LP       lowerleft;          /* Coordinates of lower left corner     */
317     PJ_LP       upperright;         /* Coordinates of upper right corner    */
318     int         n_lon, n_lat;       /* Grid size                            */
319     double      cs_lon, cs_lat;     /* Cell size of grid                    */
320 };
321 
322 struct PJ_INIT_INFO {
323     char        name[32];           /* name of init file                        */
324     char        filename[260];      /* full path to the init file.              */
325     char        version[32];        /* version of the init file                 */
326     char        origin[32];         /* origin of the file, e.g. EPSG            */
327     char        lastupdate[16];     /* Date of last update in YYYY-MM-DD format */
328 };
329 
330 typedef enum PJ_LOG_LEVEL {
331     PJ_LOG_NONE  = 0,
332     PJ_LOG_ERROR = 1,
333     PJ_LOG_DEBUG = 2,
334     PJ_LOG_TRACE = 3,
335     PJ_LOG_TELL  = 4,
336     PJ_LOG_DEBUG_MAJOR = 2, /* for proj_api.h compatibility */
337     PJ_LOG_DEBUG_MINOR = 3  /* for proj_api.h compatibility */
338 } PJ_LOG_LEVEL;
339 
340 typedef void (*PJ_LOG_FUNCTION)(void *, int, const char *);
341 
342 
343 /* The context type - properly namespaced synonym for projCtx */
344 struct projCtx_t;
345 typedef struct projCtx_t PJ_CONTEXT;
346 
347 /* A P I */
348 
349 /**
350  * The objects returned by the functions defined in this section have minimal
351  * interaction with the functions of the
352  * \ref iso19111_functions section, and vice versa. See its introduction
353  * paragraph for more details.
354  */
355 
356 /* Functionality for handling thread contexts */
357 #ifdef __cplusplus
358 #define PJ_DEFAULT_CTX nullptr
359 #else
360 #define PJ_DEFAULT_CTX 0
361 #endif
362 PJ_CONTEXT PROJ_DLL *proj_context_create (void);
363 PJ_CONTEXT PROJ_DLL *proj_context_destroy (PJ_CONTEXT *ctx);
364 PJ_CONTEXT PROJ_DLL *proj_context_clone (PJ_CONTEXT *ctx);
365 
366 /** Callback to resolve a filename to a full path */
367 typedef const char* (*proj_file_finder) (PJ_CONTEXT *ctx, const char*, void* user_data);
368 
369 void PROJ_DLL proj_context_set_file_finder(PJ_CONTEXT *ctx, proj_file_finder finder, void* user_data);
370 void PROJ_DLL proj_context_set_search_paths(PJ_CONTEXT *ctx, int count_paths, const char* const* paths);
371 void PROJ_DLL proj_context_set_ca_bundle_path(PJ_CONTEXT *ctx, const char *path);
372 void PROJ_DLL proj_context_use_proj4_init_rules(PJ_CONTEXT *ctx, int enable);
373 int PROJ_DLL proj_context_get_use_proj4_init_rules(PJ_CONTEXT *ctx, int from_legacy_code_path);
374 
375 /*! @endcond */
376 
377 /** Opaque structure for PROJ for a file handle. Implementations might cast it to their
378  * structure/class of choice. */
379 typedef struct PROJ_FILE_HANDLE PROJ_FILE_HANDLE;
380 
381 /** Open access / mode */
382 typedef enum PROJ_OPEN_ACCESS
383 {
384     /** Read-only access. Equivalent to "rb" */
385     PROJ_OPEN_ACCESS_READ_ONLY,
386 
387     /** Read-update access. File should be created if not existing. Equivalent to "r+b" */
388     PROJ_OPEN_ACCESS_READ_UPDATE,
389 
390     /** Create access. File should be truncated to 0-byte if already existing. Equivalent to "w+b" */
391     PROJ_OPEN_ACCESS_CREATE
392 } PROJ_OPEN_ACCESS;
393 
394 /** File API callbacks */
395 typedef struct PROJ_FILE_API
396 {
397     /** Version of this structure. Should be set to 1 currently. */
398     int version;
399 
400     /** Open file. Return NULL if error */
401     PROJ_FILE_HANDLE* (*open_cbk)(PJ_CONTEXT *ctx, const char *filename, PROJ_OPEN_ACCESS access, void* user_data);
402 
403     /** Read sizeBytes into buffer from current position and return number of bytes read */
404     size_t            (*read_cbk)(PJ_CONTEXT *ctx, PROJ_FILE_HANDLE*, void* buffer, size_t sizeBytes, void* user_data);
405 
406     /** Write sizeBytes into buffer from current position and return number of bytes written */
407     size_t            (*write_cbk)(PJ_CONTEXT *ctx, PROJ_FILE_HANDLE*, const void* buffer, size_t sizeBytes, void* user_data);
408 
409     /** Seek to offset using whence=SEEK_SET/SEEK_CUR/SEEK_END. Return TRUE in case of success */
410     int               (*seek_cbk)(PJ_CONTEXT *ctx, PROJ_FILE_HANDLE*, long long offset, int whence, void* user_data);
411 
412     /** Return current file position */
413     unsigned long long (*tell_cbk)(PJ_CONTEXT *ctx, PROJ_FILE_HANDLE*, void* user_data);
414 
415     /** Close file */
416     void              (*close_cbk)(PJ_CONTEXT *ctx, PROJ_FILE_HANDLE*, void* user_data);
417 
418     /** Return TRUE if a file exists */
419     int (*exists_cbk)(PJ_CONTEXT *ctx, const char *filename, void* user_data);
420 
421     /** Return TRUE if directory exists or could be created  */
422     int (*mkdir_cbk)(PJ_CONTEXT *ctx, const char *filename, void* user_data);
423 
424     /** Return TRUE if file could be removed  */
425     int (*unlink_cbk)(PJ_CONTEXT *ctx, const char *filename, void* user_data);
426 
427     /** Return TRUE if file could be renamed  */
428     int (*rename_cbk)(PJ_CONTEXT *ctx, const char *oldPath, const char *newPath, void* user_data);
429 } PROJ_FILE_API;
430 
431 int PROJ_DLL proj_context_set_fileapi(
432     PJ_CONTEXT* ctx, const PROJ_FILE_API* fileapi, void* user_data);
433 
434 void PROJ_DLL proj_context_set_sqlite3_vfs_name(PJ_CONTEXT* ctx, const char* name);
435 
436 /** Opaque structure for PROJ for a network handle. Implementations might cast it to their
437  * structure/class of choice. */
438 typedef struct PROJ_NETWORK_HANDLE PROJ_NETWORK_HANDLE;
439 
440 /** Network access: open callback
441  *
442  * Should try to read the size_to_read first bytes at the specified offset of
443  * the file given by URL url,
444  * and write them to buffer. *out_size_read should be updated with the actual
445  * amount of bytes read (== size_to_read if the file is larger than size_to_read).
446  * During this read, the implementation should make sure to store the HTTP
447  * headers from the server response to be able to respond to
448  * proj_network_get_header_value_cbk_type callback.
449  *
450  * error_string_max_size should be the maximum size that can be written into
451  * the out_error_string buffer (including terminating nul character).
452  *
453  * @return a non-NULL opaque handle in case of success.
454  */
455 typedef PROJ_NETWORK_HANDLE* (*proj_network_open_cbk_type)(
456                                                       PJ_CONTEXT* ctx,
457                                                       const char* url,
458                                                       unsigned long long offset,
459                                                       size_t size_to_read,
460                                                       void* buffer,
461                                                       size_t* out_size_read,
462                                                       size_t error_string_max_size,
463                                                       char* out_error_string,
464                                                       void* user_data);
465 
466 /** Network access: close callback */
467 typedef void (*proj_network_close_cbk_type)(PJ_CONTEXT* ctx,
468                                             PROJ_NETWORK_HANDLE* handle,
469                                             void* user_data);
470 
471 /** Network access: get HTTP headers */
472 typedef const char* (*proj_network_get_header_value_cbk_type)(
473                                             PJ_CONTEXT* ctx,
474                                             PROJ_NETWORK_HANDLE* handle,
475                                             const char* header_name,
476                                             void* user_data);
477 
478 /** Network access: read range
479  *
480  * Read size_to_read bytes from handle, starting at offset, into
481  * buffer.
482  * During this read, the implementation should make sure to store the HTTP
483  * headers from the server response to be able to respond to
484  * proj_network_get_header_value_cbk_type callback.
485  *
486  * error_string_max_size should be the maximum size that can be written into
487  * the out_error_string buffer (including terminating nul character).
488  *
489  * @return the number of bytes actually read (0 in case of error)
490  */
491 typedef size_t (*proj_network_read_range_type)(
492                                             PJ_CONTEXT* ctx,
493                                             PROJ_NETWORK_HANDLE* handle,
494                                             unsigned long long offset,
495                                             size_t size_to_read,
496                                             void* buffer,
497                                             size_t error_string_max_size,
498                                             char* out_error_string,
499                                             void* user_data);
500 
501 int PROJ_DLL proj_context_set_network_callbacks(
502     PJ_CONTEXT* ctx,
503     proj_network_open_cbk_type open_cbk,
504     proj_network_close_cbk_type close_cbk,
505     proj_network_get_header_value_cbk_type get_header_value_cbk,
506     proj_network_read_range_type read_range_cbk,
507     void* user_data);
508 
509 int PROJ_DLL proj_context_set_enable_network(PJ_CONTEXT* ctx,
510                                              int enabled);
511 
512 int PROJ_DLL proj_context_is_network_enabled(PJ_CONTEXT* ctx);
513 
514 void PROJ_DLL proj_context_set_url_endpoint(PJ_CONTEXT* ctx, const char* url);
515 
516 const char PROJ_DLL *proj_context_get_url_endpoint(PJ_CONTEXT* ctx);
517 
518 const char PROJ_DLL *proj_context_get_user_writable_directory(PJ_CONTEXT *ctx, int create);
519 
520 void PROJ_DLL proj_grid_cache_set_enable(PJ_CONTEXT* ctx, int enabled);
521 
522 void PROJ_DLL proj_grid_cache_set_filename(PJ_CONTEXT* ctx, const char* fullname);
523 
524 void PROJ_DLL proj_grid_cache_set_max_size(PJ_CONTEXT* ctx, int max_size_MB);
525 
526 void PROJ_DLL proj_grid_cache_set_ttl(PJ_CONTEXT* ctx, int ttl_seconds);
527 
528 void PROJ_DLL proj_grid_cache_clear(PJ_CONTEXT* ctx);
529 
530 int PROJ_DLL proj_is_download_needed(PJ_CONTEXT* ctx,
531                                      const char* url_or_filename,
532                                      int ignore_ttl_setting);
533 int PROJ_DLL proj_download_file(PJ_CONTEXT *ctx, const char *url_or_filename,
534                                 int ignore_ttl_setting,
535                                 int (*progress_cbk)(PJ_CONTEXT *, double pct,
536                                                     void *user_data),
537                                 void *user_data);
538 
539 /*! @cond Doxygen_Suppress */
540 
541 /* Manage the transformation definition object PJ */
542 PJ PROJ_DLL *proj_create (PJ_CONTEXT *ctx, const char *definition);
543 PJ PROJ_DLL *proj_create_argv (PJ_CONTEXT *ctx, int argc, char **argv);
544 PJ PROJ_DLL *proj_create_crs_to_crs(PJ_CONTEXT *ctx, const char *source_crs, const char *target_crs, PJ_AREA *area);
545 PJ PROJ_DLL *proj_create_crs_to_crs_from_pj(PJ_CONTEXT *ctx,
546                                             const PJ *source_crs,
547                                             const PJ *target_crs,
548                                             PJ_AREA *area,
549                                             const char* const *options);
550 /*! @endcond Doxygen_Suppress */
551 PJ PROJ_DLL *proj_normalize_for_visualization(PJ_CONTEXT *ctx, const PJ* obj);
552 /*! @cond Doxygen_Suppress */
553 void PROJ_DLL proj_assign_context(PJ* pj, PJ_CONTEXT* ctx);
554 PJ PROJ_DLL *proj_destroy (PJ *P);
555 
556 
557 PJ_AREA PROJ_DLL *proj_area_create(void);
558 void PROJ_DLL proj_area_set_bbox(PJ_AREA *area,
559                                  double west_lon_degree,
560                                  double south_lat_degree,
561                                  double east_lon_degree,
562                                  double north_lat_degree);
563 void PROJ_DLL proj_area_destroy(PJ_AREA* area);
564 
565 /* Apply transformation to observation - in forward or inverse direction */
566 enum PJ_DIRECTION {
567     PJ_FWD   =  1,   /* Forward    */
568     PJ_IDENT =  0,   /* Do nothing */
569     PJ_INV   = -1    /* Inverse    */
570 };
571 typedef enum PJ_DIRECTION PJ_DIRECTION;
572 
573 
574 int PROJ_DLL proj_angular_input (PJ *P, enum PJ_DIRECTION dir);
575 int PROJ_DLL proj_angular_output (PJ *P, enum PJ_DIRECTION dir);
576 
577 int PROJ_DLL proj_degree_input (PJ *P, enum PJ_DIRECTION dir);
578 int PROJ_DLL proj_degree_output (PJ *P, enum PJ_DIRECTION dir);
579 
580 PJ_COORD PROJ_DLL proj_trans (PJ *P, PJ_DIRECTION direction, PJ_COORD coord);
581 int PROJ_DLL proj_trans_array (PJ *P, PJ_DIRECTION direction, size_t n, PJ_COORD *coord);
582 size_t PROJ_DLL proj_trans_generic (
583     PJ *P,
584     PJ_DIRECTION direction,
585     double *x, size_t sx, size_t nx,
586     double *y, size_t sy, size_t ny,
587     double *z, size_t sz, size_t nz,
588     double *t, size_t st, size_t nt
589 );
590 
591 
592 /* Initializers */
593 PJ_COORD PROJ_DLL proj_coord (double x, double y, double z, double t);
594 
595 /* Measure internal consistency - in forward or inverse direction */
596 double PROJ_DLL proj_roundtrip (PJ *P, PJ_DIRECTION direction, int n, PJ_COORD *coord);
597 
598 /* Geodesic distance between two points with angular 2D coordinates */
599 double PROJ_DLL proj_lp_dist (const PJ *P, PJ_COORD a, PJ_COORD b);
600 
601 /* The geodesic distance AND the vertical offset */
602 double PROJ_DLL proj_lpz_dist (const PJ *P, PJ_COORD a, PJ_COORD b);
603 
604 /* Euclidean distance between two points with linear 2D coordinates */
605 double PROJ_DLL proj_xy_dist (PJ_COORD a, PJ_COORD b);
606 
607 /* Euclidean distance between two points with linear 3D coordinates */
608 double PROJ_DLL proj_xyz_dist (PJ_COORD a, PJ_COORD b);
609 
610 /* Geodesic distance (in meter) + fwd and rev azimuth between two points on the ellipsoid */
611 PJ_COORD PROJ_DLL proj_geod (const PJ *P, PJ_COORD a, PJ_COORD b);
612 
613 
614 /* Set or read error level */
615 int  PROJ_DLL proj_context_errno (PJ_CONTEXT *ctx);
616 int  PROJ_DLL proj_errno (const PJ *P);
617 int  PROJ_DLL proj_errno_set (const PJ *P, int err);
618 int  PROJ_DLL proj_errno_reset (const PJ *P);
619 int  PROJ_DLL proj_errno_restore (const PJ *P, int err);
620 const char PROJ_DLL * proj_errno_string (int err);
621 
622 PJ_LOG_LEVEL PROJ_DLL proj_log_level (PJ_CONTEXT *ctx, PJ_LOG_LEVEL log_level);
623 void PROJ_DLL proj_log_func (PJ_CONTEXT *ctx, void *app_data, PJ_LOG_FUNCTION logf);
624 
625 /* Scaling and angular distortion factors */
626 PJ_FACTORS PROJ_DLL proj_factors(PJ *P, PJ_COORD lp);
627 
628 /* Info functions - get information about various PROJ.4 entities */
629 PJ_INFO PROJ_DLL proj_info(void);
630 PJ_PROJ_INFO PROJ_DLL proj_pj_info(PJ *P);
631 PJ_GRID_INFO PROJ_DLL proj_grid_info(const char *gridname);
632 PJ_INIT_INFO PROJ_DLL proj_init_info(const char *initname);
633 
634 /* List functions: */
635 /* Get lists of operations, ellipsoids, units and prime meridians. */
636 const PJ_OPERATIONS       PROJ_DLL *proj_list_operations(void);
637 const PJ_ELLPS            PROJ_DLL *proj_list_ellps(void);
638 PROJ_DEPRECATED(const PJ_UNITS            PROJ_DLL *proj_list_units(void), "Deprecated by proj_get_units_from_database");
639 PROJ_DEPRECATED(const PJ_UNITS            PROJ_DLL *proj_list_angular_units(void), "Deprecated by proj_get_units_from_database");
640 const PJ_PRIME_MERIDIANS  PROJ_DLL *proj_list_prime_meridians(void);
641 
642 /* These are trivial, and while occasionally useful in real code, primarily here to      */
643 /* simplify demo code, and in acknowledgement of the proj-internal discrepancy between   */
644 /* angular units expected by classical proj, and by Charles Karney's geodesics subsystem */
645 double PROJ_DLL proj_torad (double angle_in_degrees);
646 double PROJ_DLL proj_todeg (double angle_in_radians);
647 
648 double PROJ_DLL proj_dmstor(const char *is, char **rs);
649 char PROJ_DLL * proj_rtodms(char *s, double r, int pos, int neg);
650 
651 void PROJ_DLL proj_cleanup(void);
652 
653 /*! @endcond */
654 
655 /* ------------------------------------------------------------------------- */
656 /* Binding in C of C++ API */
657 /* ------------------------------------------------------------------------- */
658 
659 
660 /** @defgroup iso19111_types Data types for ISO19111 C API
661  *  Data types for ISO19111 C API
662  *  @{
663  */
664 
665 /** \brief Type representing a NULL terminated list of NULL-terminate strings. */
666 typedef char **PROJ_STRING_LIST;
667 
668 /** \brief Guessed WKT "dialect". */
669 typedef enum
670 {
671     /** \ref WKT2_2019 */
672     PJ_GUESSED_WKT2_2019,
673 
674     /** Deprecated alias for PJ_GUESSED_WKT2_2019 */
675     PJ_GUESSED_WKT2_2018 = PJ_GUESSED_WKT2_2019,
676 
677     /** \ref WKT2_2015 */
678     PJ_GUESSED_WKT2_2015,
679 
680     /** \ref WKT1 */
681     PJ_GUESSED_WKT1_GDAL,
682 
683     /** ESRI variant of WKT1 */
684     PJ_GUESSED_WKT1_ESRI,
685 
686     /** Not WKT / unrecognized */
687     PJ_GUESSED_NOT_WKT
688 } PJ_GUESSED_WKT_DIALECT;
689 
690 /** \brief Object category. */
691 typedef enum
692 {
693     PJ_CATEGORY_ELLIPSOID,
694     PJ_CATEGORY_PRIME_MERIDIAN,
695     PJ_CATEGORY_DATUM,
696     PJ_CATEGORY_CRS,
697     PJ_CATEGORY_COORDINATE_OPERATION
698 } PJ_CATEGORY;
699 
700 /** \brief Object type. */
701 typedef enum
702 {
703     PJ_TYPE_UNKNOWN,
704 
705     PJ_TYPE_ELLIPSOID,
706 
707     PJ_TYPE_PRIME_MERIDIAN,
708 
709     PJ_TYPE_GEODETIC_REFERENCE_FRAME,
710     PJ_TYPE_DYNAMIC_GEODETIC_REFERENCE_FRAME,
711     PJ_TYPE_VERTICAL_REFERENCE_FRAME,
712     PJ_TYPE_DYNAMIC_VERTICAL_REFERENCE_FRAME,
713     PJ_TYPE_DATUM_ENSEMBLE,
714 
715     /** Abstract type, not returned by proj_get_type() */
716     PJ_TYPE_CRS,
717 
718     PJ_TYPE_GEODETIC_CRS,
719     PJ_TYPE_GEOCENTRIC_CRS,
720 
721     /** proj_get_type() will never return that type, but
722      * PJ_TYPE_GEOGRAPHIC_2D_CRS or PJ_TYPE_GEOGRAPHIC_3D_CRS. */
723     PJ_TYPE_GEOGRAPHIC_CRS,
724 
725     PJ_TYPE_GEOGRAPHIC_2D_CRS,
726     PJ_TYPE_GEOGRAPHIC_3D_CRS,
727     PJ_TYPE_VERTICAL_CRS,
728     PJ_TYPE_PROJECTED_CRS,
729     PJ_TYPE_COMPOUND_CRS,
730     PJ_TYPE_TEMPORAL_CRS,
731     PJ_TYPE_ENGINEERING_CRS,
732     PJ_TYPE_BOUND_CRS,
733     PJ_TYPE_OTHER_CRS,
734 
735     PJ_TYPE_CONVERSION,
736     PJ_TYPE_TRANSFORMATION,
737     PJ_TYPE_CONCATENATED_OPERATION,
738     PJ_TYPE_OTHER_COORDINATE_OPERATION,
739 
740     PJ_TYPE_TEMPORAL_DATUM,
741     PJ_TYPE_ENGINEERING_DATUM,
742     PJ_TYPE_PARAMETRIC_DATUM,
743 } PJ_TYPE;
744 
745 /** Comparison criterion. */
746 typedef enum
747 {
748     /** All properties are identical. */
749     PJ_COMP_STRICT,
750 
751     /** The objects are equivalent for the purpose of coordinate
752     * operations. They can differ by the name of their objects,
753     * identifiers, other metadata.
754     * Parameters may be expressed in different units, provided that the
755     * value is (with some tolerance) the same once expressed in a
756     * common unit.
757     */
758     PJ_COMP_EQUIVALENT,
759 
760     /** Same as EQUIVALENT, relaxed with an exception that the axis order
761     * of the base CRS of a DerivedCRS/ProjectedCRS or the axis order of
762     * a GeographicCRS is ignored. Only to be used
763     * with DerivedCRS/ProjectedCRS/GeographicCRS */
764     PJ_COMP_EQUIVALENT_EXCEPT_AXIS_ORDER_GEOGCRS,
765 } PJ_COMPARISON_CRITERION;
766 
767 
768 /** \brief WKT version. */
769 typedef enum
770 {
771     /** cf osgeo::proj::io::WKTFormatter::Convention::WKT2 */
772     PJ_WKT2_2015,
773     /** cf osgeo::proj::io::WKTFormatter::Convention::WKT2_SIMPLIFIED */
774     PJ_WKT2_2015_SIMPLIFIED,
775     /** cf osgeo::proj::io::WKTFormatter::Convention::WKT2_2019 */
776     PJ_WKT2_2019,
777     /** Deprecated alias for PJ_WKT2_2019 */
778     PJ_WKT2_2018 = PJ_WKT2_2019,
779     /** cf osgeo::proj::io::WKTFormatter::Convention::WKT2_2019_SIMPLIFIED */
780     PJ_WKT2_2019_SIMPLIFIED,
781     /** Deprecated alias for PJ_WKT2_2019 */
782     PJ_WKT2_2018_SIMPLIFIED = PJ_WKT2_2019_SIMPLIFIED,
783     /** cf osgeo::proj::io::WKTFormatter::Convention::WKT1_GDAL */
784     PJ_WKT1_GDAL,
785     /** cf osgeo::proj::io::WKTFormatter::Convention::WKT1_ESRI */
786     PJ_WKT1_ESRI
787 } PJ_WKT_TYPE;
788 
789 /** Specify how source and target CRS extent should be used to restrict
790   * candidate operations (only taken into account if no explicit area of
791   * interest is specified. */
792 typedef enum
793 {
794     /** Ignore CRS extent */
795     PJ_CRS_EXTENT_NONE,
796 
797     /** Test coordinate operation extent against both CRS extent. */
798     PJ_CRS_EXTENT_BOTH,
799 
800     /** Test coordinate operation extent against the intersection of both
801         CRS extent. */
802     PJ_CRS_EXTENT_INTERSECTION,
803 
804     /** Test coordinate operation against the smallest of both CRS extent. */
805     PJ_CRS_EXTENT_SMALLEST
806 } PROJ_CRS_EXTENT_USE;
807 
808 /** Describe how grid availability is used. */
809 typedef enum {
810     /** Grid availability is only used for sorting results. Operations
811         * where some grids are missing will be sorted last. */
812     PROJ_GRID_AVAILABILITY_USED_FOR_SORTING,
813 
814     /** Completely discard an operation if a required grid is missing. */
815     PROJ_GRID_AVAILABILITY_DISCARD_OPERATION_IF_MISSING_GRID,
816 
817     /** Ignore grid availability at all. Results will be presented as if
818         * all grids were available. */
819     PROJ_GRID_AVAILABILITY_IGNORED,
820 
821     /** Results will be presented as if grids known to PROJ (that is
822     * registered in the grid_alternatives table of its database) were
823     * available. Used typically when networking is enabled.
824     */
825     PROJ_GRID_AVAILABILITY_KNOWN_AVAILABLE,
826 } PROJ_GRID_AVAILABILITY_USE;
827 
828 /** \brief PROJ string version. */
829 typedef enum
830 {
831     /** cf osgeo::proj::io::PROJStringFormatter::Convention::PROJ_5 */
832     PJ_PROJ_5,
833     /** cf osgeo::proj::io::PROJStringFormatter::Convention::PROJ_4 */
834     PJ_PROJ_4
835 } PJ_PROJ_STRING_TYPE;
836 
837 /** Spatial criterion to restrict candidate operations. */
838 typedef enum {
839     /** The area of validity of transforms should strictly contain the
840         * are of interest. */
841     PROJ_SPATIAL_CRITERION_STRICT_CONTAINMENT,
842 
843     /** The area of validity of transforms should at least intersect the
844         * area of interest. */
845     PROJ_SPATIAL_CRITERION_PARTIAL_INTERSECTION
846 } PROJ_SPATIAL_CRITERION;
847 
848     /** Describe if and how intermediate CRS should be used */
849 typedef enum {
850     /** Always search for intermediate CRS. */
851     PROJ_INTERMEDIATE_CRS_USE_ALWAYS,
852 
853     /** Only attempt looking for intermediate CRS if there is no direct
854         * transformation available. */
855     PROJ_INTERMEDIATE_CRS_USE_IF_NO_DIRECT_TRANSFORMATION,
856 
857     /* Do not attempt looking for intermediate CRS. */
858     PROJ_INTERMEDIATE_CRS_USE_NEVER,
859 } PROJ_INTERMEDIATE_CRS_USE;
860 
861 /** Type of coordinate system. */
862 typedef enum
863 {
864     PJ_CS_TYPE_UNKNOWN,
865 
866     PJ_CS_TYPE_CARTESIAN,
867     PJ_CS_TYPE_ELLIPSOIDAL,
868     PJ_CS_TYPE_VERTICAL,
869     PJ_CS_TYPE_SPHERICAL,
870     PJ_CS_TYPE_ORDINAL,
871     PJ_CS_TYPE_PARAMETRIC,
872     PJ_CS_TYPE_DATETIMETEMPORAL,
873     PJ_CS_TYPE_TEMPORALCOUNT,
874     PJ_CS_TYPE_TEMPORALMEASURE
875 } PJ_COORDINATE_SYSTEM_TYPE;
876 
877 /** \brief Structure given overall description of a CRS.
878  *
879  * This structure may grow over time, and should not be directly allocated by
880  * client code.
881  */
882 typedef struct
883 {
884     /** Authority name. */
885     char* auth_name;
886     /** Object code. */
887     char* code;
888     /** Object name. */
889     char* name;
890     /** Object type. */
891     PJ_TYPE type;
892     /** Whether the object is deprecated */
893     int deprecated;
894     /** Whereas the west_lon_degree, south_lat_degree, east_lon_degree and
895      * north_lat_degree fields are valid. */
896     int bbox_valid;
897     /** Western-most longitude of the area of use, in degrees. */
898     double west_lon_degree;
899     /** Southern-most latitude of the area of use, in degrees. */
900     double south_lat_degree;
901     /** Eastern-most longitude of the area of use, in degrees. */
902     double east_lon_degree;
903     /** Northern-most latitude of the area of use, in degrees. */
904     double north_lat_degree;
905     /** Name of the area of use. */
906     char* area_name;
907     /** Name of the projection method for a projected CRS. Might be NULL even
908      *for projected CRS in some cases. */
909     char* projection_method_name;
910 } PROJ_CRS_INFO;
911 
912 /** \brief Structure describing optional parameters for proj_get_crs_list();
913  *
914  * This structure may grow over time, and should not be directly allocated by
915  * client code.
916  */
917 typedef struct
918 {
919     /** Array of allowed object types. Should be NULL if all types are allowed*/
920     const PJ_TYPE* types;
921     /** Size of types. Should be 0 if all types are allowed*/
922     size_t typesCount;
923 
924     /** If TRUE and bbox_valid == TRUE, then only CRS whose area of use
925      * entirely contains the specified bounding box will be returned.
926      * If FALSE and bbox_valid == TRUE, then only CRS whose area of use
927      * intersects the specified bounding box will be returned.
928      */
929     int crs_area_of_use_contains_bbox;
930     /** To set to TRUE so that west_lon_degree, south_lat_degree,
931      * east_lon_degree and north_lat_degree fields are taken into account. */
932     int bbox_valid;
933     /** Western-most longitude of the area of use, in degrees. */
934     double west_lon_degree;
935     /** Southern-most latitude of the area of use, in degrees. */
936     double south_lat_degree;
937     /** Eastern-most longitude of the area of use, in degrees. */
938     double east_lon_degree;
939     /** Northern-most latitude of the area of use, in degrees. */
940     double north_lat_degree;
941 
942     /** Whether deprecated objects are allowed. Default to FALSE. */
943     int allow_deprecated;
944 } PROJ_CRS_LIST_PARAMETERS;
945 
946 /** \brief Structure given description of a unit.
947  *
948  * This structure may grow over time, and should not be directly allocated by
949  * client code.
950  * @since 7.1
951  */
952 typedef struct
953 {
954     /** Authority name. */
955     char* auth_name;
956 
957     /** Object code. */
958     char* code;
959 
960     /** Object name. For example "metre", "US survey foot", etc. */
961     char* name;
962 
963     /** Category of the unit: one of "linear", "linear_per_time", "angular",
964      * "angular_per_time", "scale", "scale_per_time" or "time" */
965     char* category;
966 
967     /** Conversion factor to apply to transform from that unit to the
968      * corresponding SI unit (metre for "linear", radian for "angular", etc.).
969      * It might be 0 in some cases to indicate no known conversion factor. */
970     double conv_factor;
971 
972     /** PROJ short name, like "m", "ft", "us-ft", etc... Might be NULL */
973     char* proj_short_name;
974 
975     /** Whether the object is deprecated */
976     int deprecated;
977 } PROJ_UNIT_INFO;
978 
979 
980 /**@}*/
981 
982 /**
983  * \defgroup iso19111_functions Binding in C of basic methods from the C++ API
984  *  Functions for ISO19111 C API
985  *
986  * The PJ* objects returned by proj_create_from_wkt(),
987  * proj_create_from_database() and other functions in that section
988  * will have generally minimal interaction with the functions declared in the
989  * upper section of this header file (calling those functions on those objects
990  * will either return an error or default/non-sensical values). The exception is
991  * for ISO19111 objects of type CoordinateOperation that can be exported as a
992  * valid PROJ pipeline. In this case, the PJ objects will work for example with
993  * proj_trans_generic().
994  * Conversely, objects returned by proj_create() and proj_create_argv(), which
995  * are not of type CRS, will return an error when used with functions of this section.
996  * @{
997  */
998 
999 /*! @cond Doxygen_Suppress */
1000 typedef struct PJ_OBJ_LIST PJ_OBJ_LIST;
1001 /*! @endcond */
1002 
1003 void PROJ_DLL proj_string_list_destroy(PROJ_STRING_LIST list);
1004 
1005 void PROJ_DLL proj_context_set_autoclose_database(PJ_CONTEXT *ctx,
1006                                                   int autoclose);
1007 
1008 int PROJ_DLL proj_context_set_database_path(PJ_CONTEXT *ctx,
1009                                             const char *dbPath,
1010                                             const char *const *auxDbPaths,
1011                                             const char* const *options);
1012 
1013 const char PROJ_DLL *proj_context_get_database_path(PJ_CONTEXT *ctx);
1014 
1015 const char PROJ_DLL *proj_context_get_database_metadata(PJ_CONTEXT* ctx,
1016                                                         const char* key);
1017 
1018 
1019 PJ_GUESSED_WKT_DIALECT PROJ_DLL proj_context_guess_wkt_dialect(PJ_CONTEXT *ctx,
1020                                                                const char *wkt);
1021 
1022 PJ PROJ_DLL *proj_create_from_wkt(PJ_CONTEXT *ctx, const char *wkt,
1023                                           const char* const *options,
1024                                           PROJ_STRING_LIST *out_warnings,
1025                                           PROJ_STRING_LIST *out_grammar_errors);
1026 
1027 PJ PROJ_DLL *proj_create_from_database(PJ_CONTEXT *ctx,
1028                                                const char *auth_name,
1029                                                const char *code,
1030                                                PJ_CATEGORY category,
1031                                                int usePROJAlternativeGridNames,
1032                                                const char* const *options);
1033 
1034 int PROJ_DLL proj_uom_get_info_from_database(PJ_CONTEXT *ctx,
1035                                const char *auth_name,
1036                                const char *code,
1037                                const char **out_name,
1038                                double *out_conv_factor,
1039                                const char **out_category);
1040 
1041 int PROJ_DLL proj_grid_get_info_from_database(PJ_CONTEXT *ctx,
1042                                const char *grid_name,
1043                                const char **out_full_name,
1044                                const char **out_package_name,
1045                                const char **out_url,
1046                                int *out_direct_download,
1047                                int *out_open_license,
1048                                int *out_available);
1049 
1050 PJ PROJ_DLL *proj_clone(PJ_CONTEXT *ctx, const PJ *obj);
1051 
1052 PJ_OBJ_LIST PROJ_DLL *proj_create_from_name(PJ_CONTEXT *ctx,
1053                                                 const char *auth_name,
1054                                                 const char *searchedName,
1055                                                 const PJ_TYPE* types,
1056                                                 size_t typesCount,
1057                                                 int approximateMatch,
1058                                                 size_t limitResultCount,
1059                                                 const char* const *options);
1060 
1061 PJ_TYPE PROJ_DLL proj_get_type(const PJ *obj);
1062 
1063 int PROJ_DLL proj_is_deprecated(const PJ *obj);
1064 
1065 PJ_OBJ_LIST PROJ_DLL *proj_get_non_deprecated(PJ_CONTEXT *ctx,
1066                                                   const PJ *obj);
1067 
1068 int PROJ_DLL proj_is_equivalent_to(const PJ *obj, const PJ *other,
1069                                        PJ_COMPARISON_CRITERION criterion);
1070 
1071 int PROJ_DLL proj_is_equivalent_to_with_ctx(PJ_CONTEXT *ctx,
1072                                             const PJ *obj, const PJ *other,
1073                                             PJ_COMPARISON_CRITERION criterion);
1074 
1075 int PROJ_DLL proj_is_crs(const PJ *obj);
1076 
1077 const char PROJ_DLL* proj_get_name(const PJ *obj);
1078 
1079 const char PROJ_DLL* proj_get_id_auth_name(const PJ *obj, int index);
1080 
1081 const char PROJ_DLL* proj_get_id_code(const PJ *obj, int index);
1082 
1083 const char PROJ_DLL* proj_get_remarks(const PJ *obj);
1084 
1085 const char PROJ_DLL* proj_get_scope(const PJ *obj);
1086 
1087 int PROJ_DLL proj_get_area_of_use(PJ_CONTEXT *ctx,
1088                                       const PJ *obj,
1089                                       double* out_west_lon_degree,
1090                                       double* out_south_lat_degree,
1091                                       double* out_east_lon_degree,
1092                                       double* out_north_lat_degree,
1093                                       const char **out_area_name);
1094 
1095 const char PROJ_DLL* proj_as_wkt(PJ_CONTEXT *ctx,
1096                                      const PJ *obj, PJ_WKT_TYPE type,
1097                                      const char* const *options);
1098 
1099 const char PROJ_DLL* proj_as_proj_string(PJ_CONTEXT *ctx,
1100                                              const PJ *obj,
1101                                              PJ_PROJ_STRING_TYPE type,
1102                                              const char* const *options);
1103 
1104 const char PROJ_DLL* proj_as_projjson(PJ_CONTEXT *ctx,
1105                                       const PJ *obj,
1106                                       const char* const *options);
1107 
1108 PJ PROJ_DLL *proj_get_source_crs(PJ_CONTEXT *ctx,
1109                                          const PJ *obj);
1110 
1111 PJ PROJ_DLL *proj_get_target_crs(PJ_CONTEXT *ctx,
1112                                          const PJ *obj);
1113 
1114 PJ_OBJ_LIST PROJ_DLL *proj_identify(PJ_CONTEXT *ctx,
1115                                         const PJ *obj,
1116                                         const char *auth_name,
1117                                         const char* const *options,
1118                                         int **out_confidence);
1119 
1120 void PROJ_DLL proj_int_list_destroy(int* list);
1121 
1122 /* ------------------------------------------------------------------------- */
1123 
1124 PROJ_STRING_LIST PROJ_DLL proj_get_authorities_from_database(PJ_CONTEXT *ctx);
1125 
1126 PROJ_STRING_LIST PROJ_DLL proj_get_codes_from_database(PJ_CONTEXT *ctx,
1127                                              const char *auth_name,
1128                                              PJ_TYPE type,
1129                                              int allow_deprecated);
1130 
1131 PROJ_CRS_LIST_PARAMETERS PROJ_DLL *proj_get_crs_list_parameters_create(void);
1132 
1133 void PROJ_DLL proj_get_crs_list_parameters_destroy(
1134                                         PROJ_CRS_LIST_PARAMETERS* params);
1135 
1136 PROJ_CRS_INFO PROJ_DLL **proj_get_crs_info_list_from_database(
1137                                       PJ_CONTEXT *ctx,
1138                                       const char *auth_name,
1139                                       const PROJ_CRS_LIST_PARAMETERS* params,
1140                                       int *out_result_count);
1141 
1142 void PROJ_DLL proj_crs_info_list_destroy(PROJ_CRS_INFO** list);
1143 
1144 PROJ_UNIT_INFO PROJ_DLL **proj_get_units_from_database(
1145                                             PJ_CONTEXT *ctx,
1146                                             const char *auth_name,
1147                                             const char *category,
1148                                             int allow_deprecated,
1149                                             int *out_result_count);
1150 
1151 void PROJ_DLL proj_unit_list_destroy(PROJ_UNIT_INFO** list);
1152 
1153 /* ------------------------------------------------------------------------- */
1154 
1155 
1156 /*! @cond Doxygen_Suppress */
1157 typedef struct PJ_OPERATION_FACTORY_CONTEXT PJ_OPERATION_FACTORY_CONTEXT;
1158 /*! @endcond */
1159 
1160 PJ_OPERATION_FACTORY_CONTEXT PROJ_DLL *proj_create_operation_factory_context(
1161                                             PJ_CONTEXT *ctx,
1162                                             const char *authority);
1163 
1164 void PROJ_DLL proj_operation_factory_context_destroy(
1165                                             PJ_OPERATION_FACTORY_CONTEXT *ctx);
1166 
1167 void PROJ_DLL proj_operation_factory_context_set_desired_accuracy(
1168                                             PJ_CONTEXT *ctx,
1169                                             PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
1170                                             double accuracy);
1171 
1172 void PROJ_DLL proj_operation_factory_context_set_area_of_interest(
1173                                             PJ_CONTEXT *ctx,
1174                                             PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
1175                                             double west_lon_degree,
1176                                             double south_lat_degree,
1177                                             double east_lon_degree,
1178                                             double north_lat_degree);
1179 
1180 void PROJ_DLL proj_operation_factory_context_set_crs_extent_use(
1181                                             PJ_CONTEXT *ctx,
1182                                             PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
1183                                             PROJ_CRS_EXTENT_USE use);
1184 
1185 void PROJ_DLL proj_operation_factory_context_set_spatial_criterion(
1186                                             PJ_CONTEXT *ctx,
1187                                             PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
1188                                             PROJ_SPATIAL_CRITERION criterion);
1189 
1190 
1191 void PROJ_DLL proj_operation_factory_context_set_grid_availability_use(
1192                                             PJ_CONTEXT *ctx,
1193                                             PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
1194                                             PROJ_GRID_AVAILABILITY_USE use);
1195 
1196 void PROJ_DLL proj_operation_factory_context_set_use_proj_alternative_grid_names(
1197     PJ_CONTEXT *ctx,
1198     PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
1199     int usePROJNames);
1200 
1201 void PROJ_DLL proj_operation_factory_context_set_allow_use_intermediate_crs(
1202     PJ_CONTEXT *ctx,
1203     PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
1204     PROJ_INTERMEDIATE_CRS_USE use);
1205 
1206 void PROJ_DLL proj_operation_factory_context_set_allowed_intermediate_crs(
1207     PJ_CONTEXT *ctx,
1208     PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
1209     const char* const *list_of_auth_name_codes);
1210 
1211 void PROJ_DLL proj_operation_factory_context_set_discard_superseded(
1212     PJ_CONTEXT *ctx,
1213     PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
1214     int discard);
1215 
1216 void PROJ_DLL proj_operation_factory_context_set_allow_ballpark_transformations(
1217     PJ_CONTEXT *ctx,
1218     PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
1219     int allow);
1220 
1221 /* ------------------------------------------------------------------------- */
1222 
1223 
1224 PJ_OBJ_LIST PROJ_DLL *proj_create_operations(
1225                             PJ_CONTEXT *ctx,
1226                             const PJ *source_crs,
1227                             const PJ *target_crs,
1228                             const PJ_OPERATION_FACTORY_CONTEXT *operationContext);
1229 
1230 int PROJ_DLL proj_list_get_count(const PJ_OBJ_LIST *result);
1231 
1232 PJ PROJ_DLL *proj_list_get(PJ_CONTEXT *ctx,
1233                                    const PJ_OBJ_LIST *result,
1234                                    int index);
1235 
1236 void PROJ_DLL proj_list_destroy(PJ_OBJ_LIST *result);
1237 
1238 int PROJ_DLL proj_get_suggested_operation(PJ_CONTEXT *ctx,
1239                                           PJ_OBJ_LIST *operations,
1240                                           PJ_DIRECTION direction,
1241                                           PJ_COORD coord);
1242 
1243 /* ------------------------------------------------------------------------- */
1244 
1245 PJ PROJ_DLL *proj_crs_get_geodetic_crs(PJ_CONTEXT *ctx, const PJ *crs);
1246 
1247 PJ PROJ_DLL *proj_crs_get_horizontal_datum(PJ_CONTEXT *ctx, const PJ *crs);
1248 
1249 PJ PROJ_DLL *proj_crs_get_sub_crs(PJ_CONTEXT *ctx, const PJ *crs, int index);
1250 
1251 PJ PROJ_DLL *proj_crs_get_datum(PJ_CONTEXT *ctx, const PJ *crs);
1252 
1253 PJ PROJ_DLL *proj_crs_get_datum_ensemble(PJ_CONTEXT *ctx, const PJ *crs);
1254 
1255 PJ PROJ_DLL *proj_crs_get_datum_forced(PJ_CONTEXT *ctx, const PJ *crs);
1256 
1257 int PROJ_DLL proj_datum_ensemble_get_member_count(PJ_CONTEXT *ctx,
1258                                                   const PJ *datum_ensemble);
1259 
1260 double PROJ_DLL proj_datum_ensemble_get_accuracy(PJ_CONTEXT *ctx,
1261                                                  const PJ *datum_ensemble);
1262 
1263 PJ PROJ_DLL *proj_datum_ensemble_get_member(PJ_CONTEXT *ctx,
1264                                             const PJ *datum_ensemble,
1265                                             int member_index);
1266 
1267 double PROJ_DLL proj_dynamic_datum_get_frame_reference_epoch(PJ_CONTEXT *ctx,
1268                                                      const PJ *datum);
1269 
1270 PJ PROJ_DLL *proj_crs_get_coordinate_system(PJ_CONTEXT *ctx, const PJ *crs);
1271 
1272 PJ_COORDINATE_SYSTEM_TYPE PROJ_DLL proj_cs_get_type(PJ_CONTEXT *ctx,
1273                                                         const PJ *cs);
1274 
1275 int PROJ_DLL proj_cs_get_axis_count(PJ_CONTEXT *ctx,
1276                                         const PJ *cs);
1277 
1278 int PROJ_DLL proj_cs_get_axis_info(PJ_CONTEXT *ctx,
1279                                        const PJ *cs, int index,
1280                                        const char **out_name,
1281                                        const char **out_abbrev,
1282                                        const char **out_direction,
1283                                        double *out_unit_conv_factor,
1284                                        const char **out_unit_name,
1285                                        const char **out_unit_auth_name,
1286                                        const char **out_unit_code);
1287 
1288 PJ PROJ_DLL *proj_get_ellipsoid(PJ_CONTEXT *ctx,
1289                                         const PJ *obj);
1290 
1291 int PROJ_DLL proj_ellipsoid_get_parameters(PJ_CONTEXT *ctx,
1292                                                const PJ *ellipsoid,
1293                                             double *out_semi_major_metre,
1294                                             double *out_semi_minor_metre,
1295                                             int    *out_is_semi_minor_computed,
1296                                             double *out_inv_flattening);
1297 
1298 PJ PROJ_DLL *proj_get_prime_meridian(PJ_CONTEXT *ctx,
1299                                              const PJ *obj);
1300 
1301 int PROJ_DLL proj_prime_meridian_get_parameters(PJ_CONTEXT *ctx,
1302                                                     const PJ *prime_meridian,
1303                                                double *out_longitude,
1304                                                double *out_unit_conv_factor,
1305                                                const char **out_unit_name);
1306 
1307 PJ PROJ_DLL *proj_crs_get_coordoperation(PJ_CONTEXT *ctx,
1308                                                  const PJ *crs);
1309 
1310 int PROJ_DLL proj_coordoperation_get_method_info(PJ_CONTEXT *ctx,
1311                                                  const PJ *coordoperation,
1312                                                  const char **out_method_name,
1313                                                  const char **out_method_auth_name,
1314                                                  const char **out_method_code);
1315 
1316 int PROJ_DLL proj_coordoperation_is_instantiable(PJ_CONTEXT *ctx,
1317                                                  const PJ *coordoperation);
1318 
1319 int PROJ_DLL proj_coordoperation_has_ballpark_transformation(PJ_CONTEXT *ctx,
1320                                                  const PJ *coordoperation);
1321 
1322 int PROJ_DLL proj_coordoperation_get_param_count(PJ_CONTEXT *ctx,
1323                                                  const PJ *coordoperation);
1324 
1325 int PROJ_DLL proj_coordoperation_get_param_index(PJ_CONTEXT *ctx,
1326                                                  const PJ *coordoperation,
1327                                                  const char *name);
1328 
1329 int PROJ_DLL proj_coordoperation_get_param(PJ_CONTEXT *ctx,
1330                                            const PJ *coordoperation,
1331                                            int index,
1332                                            const char **out_name,
1333                                            const char **out_auth_name,
1334                                            const char **out_code,
1335                                            double *out_value,
1336                                            const char **out_value_string,
1337                                            double *out_unit_conv_factor,
1338                                            const char **out_unit_name,
1339                                            const char **out_unit_auth_name,
1340                                            const char **out_unit_code,
1341                                            const char **out_unit_category);
1342 
1343 int PROJ_DLL proj_coordoperation_get_grid_used_count(PJ_CONTEXT *ctx,
1344                                                      const PJ *coordoperation);
1345 
1346 int PROJ_DLL proj_coordoperation_get_grid_used(PJ_CONTEXT *ctx,
1347                                                const PJ *coordoperation,
1348                                                int index,
1349                                                const char **out_short_name,
1350                                                const char **out_full_name,
1351                                                const char **out_package_name,
1352                                                const char **out_url,
1353                                                int *out_direct_download,
1354                                                int *out_open_license,
1355                                                int *out_available);
1356 
1357 double PROJ_DLL proj_coordoperation_get_accuracy(PJ_CONTEXT *ctx,
1358                                                  const PJ *obj);
1359 
1360 int PROJ_DLL proj_coordoperation_get_towgs84_values(PJ_CONTEXT *ctx,
1361                                                     const PJ *coordoperation,
1362                                                     double *out_values,
1363                                                     int value_count,
1364                                                     int emit_error_if_incompatible);
1365 
1366 PJ PROJ_DLL *proj_coordoperation_create_inverse(PJ_CONTEXT *ctx, const PJ *obj);
1367 
1368 
1369 int PROJ_DLL proj_concatoperation_get_step_count(PJ_CONTEXT *ctx,
1370                                                  const PJ *concatoperation);
1371 
1372 PJ PROJ_DLL *proj_concatoperation_get_step(PJ_CONTEXT *ctx,
1373                                            const PJ *concatoperation,
1374                                            int i_step);
1375 
1376 /**@}*/
1377 
1378 #ifdef __cplusplus
1379 }
1380 #endif
1381 
1382 #endif /* ndef PROJ_H */
1383