PROJ C++ API
proj.h
Go to the documentation of this file.
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 in projects.h) has grown organically
7  * 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  *
97  * Permission is hereby granted, free of charge, to any person obtaining a
98  * copy of this software and associated documentation files (the "Software"),
99  * to deal in the Software without restriction, including without limitation
100  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
101  * and/or sell copies of the Software, and to permit persons to whom the
102  * Software is furnished to do so, subject to the following conditions:
103  *
104  * The above copyright notice and this permission notice shall be included
105  * in all copies or substantial portions of the Software.
106  *
107  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
108  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
109  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO COORD SHALL
110  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
111  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
112  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
113  * DEALINGS IN THE SOFTWARE.
114  *****************************************************************************/
115 
116 #include <stddef.h> /* For size_t */
117 
118 
119 #ifdef PROJECTS_H
120 #error proj.h must be included before projects.h
121 #endif
122 #ifdef PROJ_API_H
123 #error proj.h must be included before proj_api.h
124 #endif
125 
126 #ifndef PROJ_H
127 #define PROJ_H
128 #ifdef __cplusplus
129 extern "C" {
130 #endif
131 
140 #ifndef PROJ_DLL
141 #ifdef PROJ_MSVC_DLL_EXPORT
142 #define PROJ_DLL __declspec(dllexport)
143 #elif defined(PROJ_MSVC_DLL_IMPORT)
144 #define PROJ_DLL __declspec(dllimport)
145 #else
146 #define PROJ_DLL
147 #endif
148 #endif
149 
150 /* The version numbers should be updated with every release! **/
151 #define PROJ_VERSION_MAJOR 6
152 #define PROJ_VERSION_MINOR 0
153 #define PROJ_VERSION_PATCH 0
154 
155 extern char const pj_release[]; /* global release id string */
156 
157 /* first forward declare everything needed */
158 
159 /* Data type for generic geodetic 3D data plus epoch information */
160 union PJ_COORD;
161 typedef union PJ_COORD PJ_COORD;
162 
163 struct PJ_AREA;
164 typedef struct PJ_AREA PJ_AREA;
165 
166 struct P5_FACTORS { /* Common designation */
167  double meridional_scale; /* h */
168  double parallel_scale; /* k */
169  double areal_scale; /* s */
170 
171  double angular_distortion; /* omega */
172  double meridian_parallel_angle; /* theta-prime */
173  double meridian_convergence; /* alpha */
174 
175  double tissot_semimajor; /* a */
176  double tissot_semiminor; /* b */
177 
178  double dx_dlam, dx_dphi;
179  double dy_dlam, dy_dphi;
180 };
181 typedef struct P5_FACTORS PJ_FACTORS;
182 
183 /* Data type for projection/transformation information */
184 struct PJconsts;
185 typedef struct PJconsts PJ; /* the PJ object herself */
186 
187 /* Data type for library level information */
188 struct PJ_INFO;
189 typedef struct PJ_INFO PJ_INFO;
190 
191 struct PJ_PROJ_INFO;
192 typedef struct PJ_PROJ_INFO PJ_PROJ_INFO;
193 
194 struct PJ_GRID_INFO;
195 typedef struct PJ_GRID_INFO PJ_GRID_INFO;
196 
197 struct PJ_INIT_INFO;
198 typedef struct PJ_INIT_INFO PJ_INIT_INFO;
199 
200 /* Data types for list of operations, ellipsoids, datums and units used in PROJ.4 */
201 struct PJ_LIST {
202  const char *id; /* projection keyword */
203  PJ *(*proj)(PJ *); /* projection entry point */
204  const char * const *descr; /* description text */
205 };
206 
207 typedef struct PJ_LIST PJ_OPERATIONS;
208 
209 struct PJ_ELLPS {
210  const char *id; /* ellipse keyword name */
211  const char *major; /* a= value */
212  const char *ell; /* elliptical parameter */
213  const char *name; /* comments */
214 };
215 typedef struct PJ_ELLPS PJ_ELLPS;
216 
217 struct PJ_UNITS {
218  const char *id; /* units keyword */
219  const char *to_meter; /* multiply by value to get meters */
220  const char *name; /* comments */
221  double factor; /* to_meter factor in actual numbers */
222 };
223 typedef struct PJ_UNITS PJ_UNITS;
224 
225 struct PJ_PRIME_MERIDIANS {
226  const char *id; /* prime meridian keyword */
227  const char *defn; /* offset from greenwich in DMS format. */
228 };
229 typedef struct PJ_PRIME_MERIDIANS PJ_PRIME_MERIDIANS;
230 
231 
232 /* Geodetic, mostly spatiotemporal coordinate types */
233 typedef struct { double x, y, z, t; } PJ_XYZT;
234 typedef struct { double u, v, w, t; } PJ_UVWT;
235 typedef struct { double lam, phi, z, t; } PJ_LPZT;
236 typedef struct { double o, p, k; } PJ_OPK; /* Rotations: omega, phi, kappa */
237 typedef struct { double e, n, u; } PJ_ENU; /* East, North, Up */
238 typedef struct { double s, a1, a2; } PJ_GEOD; /* Geodesic length, fwd azi, rev azi */
239 
240 /* Classic proj.4 pair/triplet types - moved into the PJ_ name space */
241 typedef struct { double u, v; } PJ_UV;
242 typedef struct { double x, y; } PJ_XY;
243 typedef struct { double lam, phi; } PJ_LP;
244 
245 typedef struct { double x, y, z; } PJ_XYZ;
246 typedef struct { double u, v, w; } PJ_UVW;
247 typedef struct { double lam, phi, z; } PJ_LPZ;
248 
249 
250 /* Avoid preprocessor renaming and implicit type-punning: Use a union to make it explicit */
251 union PJ_COORD {
252  double v[4]; /* First and foremost, it really is "just 4 numbers in a vector" */
253  PJ_XYZT xyzt;
254  PJ_UVWT uvwt;
255  PJ_LPZT lpzt;
256  PJ_GEOD geod;
257  PJ_OPK opk;
258  PJ_ENU enu;
259  PJ_XYZ xyz;
260  PJ_UVW uvw;
261  PJ_LPZ lpz;
262  PJ_XY xy;
263  PJ_UV uv;
264  PJ_LP lp;
265 };
266 
267 
268 struct PJ_INFO {
269  int major; /* Major release number */
270  int minor; /* Minor release number */
271  int patch; /* Patch level */
272  const char *release; /* Release info. Version + date */
273  const char *version; /* Full version number */
274  const char *searchpath; /* Paths where init and grid files are */
275  /* looked for. Paths are separated by */
276  /* semi-colons. */
277  const char * const *paths;
278  size_t path_count;
279 };
280 
281 struct PJ_PROJ_INFO {
282  const char *id; /* Name of the projection in question */
283  const char *description; /* Description of the projection */
284  const char *definition; /* Projection definition */
285  int has_inverse; /* 1 if an inverse mapping exists, 0 otherwise */
286  double accuracy; /* Expected accuracy of the transformation. -1 if unknown. */
287 };
288 
289 struct PJ_GRID_INFO {
290  char gridname[32]; /* name of grid */
291  char filename[260]; /* full path to grid */
292  char format[8]; /* file format of grid */
293  PJ_LP lowerleft; /* Coordinates of lower left corner */
294  PJ_LP upperright; /* Coordinates of upper right corner */
295  int n_lon, n_lat; /* Grid size */
296  double cs_lon, cs_lat; /* Cell size of grid */
297 };
298 
299 struct PJ_INIT_INFO {
300  char name[32]; /* name of init file */
301  char filename[260]; /* full path to the init file. */
302  char version[32]; /* version of the init file */
303  char origin[32]; /* origin of the file, e.g. EPSG */
304  char lastupdate[16]; /* Date of last update in YYYY-MM-DD format */
305 };
306 
307 typedef enum PJ_LOG_LEVEL {
308  PJ_LOG_NONE = 0,
309  PJ_LOG_ERROR = 1,
310  PJ_LOG_DEBUG = 2,
311  PJ_LOG_TRACE = 3,
312  PJ_LOG_TELL = 4,
313  PJ_LOG_DEBUG_MAJOR = 2, /* for proj_api.h compatibility */
314  PJ_LOG_DEBUG_MINOR = 3 /* for proj_api.h compatibility */
315 } PJ_LOG_LEVEL;
316 
317 typedef void (*PJ_LOG_FUNCTION)(void *, int, const char *);
318 
319 
320 /* The context type - properly namespaced synonym for projCtx */
321 struct projCtx_t;
322 typedef struct projCtx_t PJ_CONTEXT;
323 
324 /* A P I */
325 
326 
327 /* Functionality for handling thread contexts */
328 #define PJ_DEFAULT_CTX 0
329 PJ_CONTEXT *proj_context_create (void);
330 PJ_CONTEXT *proj_context_destroy (PJ_CONTEXT *ctx);
331 
332 
333 /* Manage the transformation definition object PJ */
334 PJ *proj_create (PJ_CONTEXT *ctx, const char *definition);
335 PJ *proj_create_argv (PJ_CONTEXT *ctx, int argc, char **argv);
336 PJ *proj_create_crs_to_crs(PJ_CONTEXT *ctx, const char *srid_from, const char *srid_to, PJ_AREA *area);
337 PJ *proj_destroy (PJ *P);
338 
339 /* Setter-functions for the opaque PJ_AREA struct */
340 /* Uncomment these when implementing support for area-based transformations.
341 void proj_area_bbox(PJ_AREA *area, LP ll, LP ur);
342 void proj_area_description(PJ_AREA *area, const char *descr);
343 */
344 
345 /* Apply transformation to observation - in forward or inverse direction */
346 enum PJ_DIRECTION {
347  PJ_FWD = 1, /* Forward */
348  PJ_IDENT = 0, /* Do nothing */
349  PJ_INV = -1 /* Inverse */
350 };
351 typedef enum PJ_DIRECTION PJ_DIRECTION;
352 
353 
354 int proj_angular_input (PJ *P, enum PJ_DIRECTION dir);
355 int proj_angular_output (PJ *P, enum PJ_DIRECTION dir);
356 
357 
358 PJ_COORD proj_trans (PJ *P, PJ_DIRECTION direction, PJ_COORD coord);
359 int proj_trans_array (PJ *P, PJ_DIRECTION direction, size_t n, PJ_COORD *coord);
360 size_t proj_trans_generic (
361  PJ *P,
362  PJ_DIRECTION direction,
363  double *x, size_t sx, size_t nx,
364  double *y, size_t sy, size_t ny,
365  double *z, size_t sz, size_t nz,
366  double *t, size_t st, size_t nt
367 );
368 
369 
370 /* Initializers */
371 PJ_COORD proj_coord (double x, double y, double z, double t);
372 
373 /* Measure internal consistency - in forward or inverse direction */
374 double proj_roundtrip (PJ *P, PJ_DIRECTION direction, int n, PJ_COORD *coord);
375 
376 /* Geodesic distance between two points with angular 2D coordinates */
377 double proj_lp_dist (const PJ *P, PJ_COORD a, PJ_COORD b);
378 
379 /* The geodesic distance AND the vertical offset */
380 double proj_lpz_dist (const PJ *P, PJ_COORD a, PJ_COORD b);
381 
382 /* Euclidean distance between two points with linear 2D coordinates */
383 double proj_xy_dist (PJ_COORD a, PJ_COORD b);
384 
385 /* Euclidean distance between two points with linear 3D coordinates */
386 double proj_xyz_dist (PJ_COORD a, PJ_COORD b);
387 
388 /* Geodesic distance (in meter) + fwd and rev azimuth between two points on the ellipsoid */
389 PJ_COORD proj_geod (const PJ *P, PJ_COORD a, PJ_COORD b);
390 
391 
392 /* Set or read error level */
393 int proj_context_errno (PJ_CONTEXT *ctx);
394 int proj_errno (const PJ *P);
395 int proj_errno_set (const PJ *P, int err);
396 int proj_errno_reset (const PJ *P);
397 int proj_errno_restore (const PJ *P, int err);
398 const char* proj_errno_string (int err);
399 
400 PJ_LOG_LEVEL proj_log_level (PJ_CONTEXT *ctx, PJ_LOG_LEVEL log_level);
401 void proj_log_func (PJ_CONTEXT *ctx, void *app_data, PJ_LOG_FUNCTION logf);
402 
403 /* Scaling and angular distortion factors */
404 PJ_FACTORS proj_factors(PJ *P, PJ_COORD lp);
405 
406 /* Info functions - get information about various PROJ.4 entities */
407 PJ_INFO proj_info(void);
408 PJ_PROJ_INFO proj_pj_info(PJ *P);
409 PJ_GRID_INFO proj_grid_info(const char *gridname);
410 PJ_INIT_INFO proj_init_info(const char *initname);
411 
412 /* List functions: */
413 /* Get lists of operations, ellipsoids, units and prime meridians. */
414 const PJ_OPERATIONS *proj_list_operations(void);
415 const PJ_ELLPS *proj_list_ellps(void);
416 const PJ_UNITS *proj_list_units(void);
417 const PJ_UNITS *proj_list_angular_units(void);
418 const PJ_PRIME_MERIDIANS *proj_list_prime_meridians(void);
419 
420 /* These are trivial, and while occasionally useful in real code, primarily here to */
421 /* simplify demo code, and in acknowledgement of the proj-internal discrepancy between */
422 /* angular units expected by classical proj, and by Charles Karney's geodesics subsystem */
423 double proj_torad (double angle_in_degrees);
424 double proj_todeg (double angle_in_radians);
425 
426 /* Geographical to geocentric latitude - another of the "simple, but useful" */
427 PJ_COORD proj_geocentric_latitude (const PJ *P, PJ_DIRECTION direction, PJ_COORD coord);
428 
429 double proj_dmstor(const char *is, char **rs);
430 char* proj_rtodms(char *s, double r, int pos, int neg);
431 
434 /* ------------------------------------------------------------------------- */
435 /* Binding in C of C++ API */
436 /* ------------------------------------------------------------------------- */
437 
439 typedef struct PJ_OBJ PJ_OBJ;
442 int PROJ_DLL proj_context_set_database_path(PJ_CONTEXT *ctx,
443  const char *dbPath,
444  const char *const *auxDbPaths);
445 
446 const char PROJ_DLL *proj_context_get_database_path(PJ_CONTEXT *ctx);
447 
448 PJ_OBJ PROJ_DLL *proj_obj_create_from_user_input(PJ_CONTEXT *ctx,
449  const char *text);
450 
451 PJ_OBJ PROJ_DLL *proj_obj_create_from_wkt(PJ_CONTEXT *ctx, const char *wkt);
452 
453 PJ_OBJ PROJ_DLL *proj_obj_create_from_proj_string(PJ_CONTEXT *ctx,
454  const char *proj_string);
455 
457 typedef enum
458 {
459  PJ_OBJ_CATEGORY_ELLIPSOID,
460  PJ_OBJ_CATEGORY_DATUM,
461  PJ_OBJ_CATEGORY_CRS,
462  PJ_OBJ_CATEGORY_COORDINATE_OPERATION
464 
465 PJ_OBJ PROJ_DLL *proj_obj_create_from_database(PJ_CONTEXT *ctx,
466  const char *auth_name,
467  const char *code,
468  PJ_OBJ_CATEGORY category,
469  int usePROJAlternativeGridNames,
470  const char* const *options);
471 
472 void PROJ_DLL proj_obj_unref(PJ_OBJ *obj);
473 
475 typedef enum
476 {
477  PJ_OBJ_TYPE_ELLIPSOID,
478 
479  PJ_OBJ_TYPE_GEODETIC_REFERENCE_FRAME,
480  PJ_OBJ_TYPE_DYNAMIC_GEODETIC_REFERENCE_FRAME,
481  PJ_OBJ_TYPE_VERTICAL_REFERENCE_FRAME,
482  PJ_OBJ_TYPE_DYNAMIC_VERTICAL_REFERENCE_FRAME,
483  PJ_OBJ_TYPE_DATUM_ENSEMBLE,
484 
485  PJ_OBJ_TYPE_GEODETIC_CRS,
486  PJ_OBJ_TYPE_GEOGRAPHIC_CRS,
487  PJ_OBJ_TYPE_VERTICAL_CRS,
488  PJ_OBJ_TYPE_PROJECTED_CRS,
489  PJ_OBJ_TYPE_COMPOUND_CRS,
490  PJ_OBJ_TYPE_TEMPORAL_CRS,
491  PJ_OBJ_TYPE_BOUND_CRS,
492  PJ_OBJ_TYPE_OTHER_CRS,
493 
494  PJ_OBJ_TYPE_CONVERSION,
495  PJ_OBJ_TYPE_TRANSFORMATION,
496  PJ_OBJ_TYPE_CONCATENATED_OPERATION,
497  PJ_OBJ_TYPE_OTHER_COORDINATE_OPERATION,
498 
499  PJ_OBJ_TYPE_UNKNOWN
500 } PJ_OBJ_TYPE;
501 
502 PJ_OBJ_TYPE PROJ_DLL proj_obj_get_type(PJ_OBJ *obj);
503 
505 typedef char **PROJ_STRING_LIST;
506 
507 PROJ_STRING_LIST PROJ_DLL proj_get_authorities_from_database(PJ_CONTEXT *ctx);
508 
509 PROJ_STRING_LIST PROJ_DLL proj_get_codes_from_database(PJ_CONTEXT *ctx,
510  const char *auth_name,
511  PJ_OBJ_TYPE type,
512  int allow_deprecated);
513 
514 void PROJ_DLL proj_free_string_list(PROJ_STRING_LIST list);
515 
516 int PROJ_DLL proj_obj_is_crs(PJ_OBJ *obj);
517 
518 const char PROJ_DLL* proj_obj_get_name(PJ_OBJ *obj);
519 
520 const char PROJ_DLL* proj_obj_get_id_auth_name(PJ_OBJ *obj, int index);
521 
522 const char PROJ_DLL* proj_obj_get_id_code(PJ_OBJ *obj, int index);
523 
525 typedef enum
526 {
537 
539  PJ_WKT_TYPE_LAST = PJ_WKT1_GDAL /* developers: do not forget to update this */
541 } PJ_WKT_TYPE;
542 
543 const char PROJ_DLL* proj_obj_as_wkt(PJ_OBJ *obj, PJ_WKT_TYPE type,
544  const char* const *options);
545 
547 typedef enum
548 {
553 
555  PJ_PROJ_STRING_TYPE_LAST = PJ_PROJ_4 /* developers: do not forget to update this */
558 
559 const char PROJ_DLL* proj_obj_as_proj_string(PJ_OBJ *obj,
560  PJ_PROJ_STRING_TYPE type,
561  const char* const *options);
562 
563 PJ_OBJ PROJ_DLL *proj_obj_get_source_crs(PJ_OBJ *obj);
564 
565 PJ_OBJ PROJ_DLL *proj_obj_get_target_crs(PJ_OBJ *obj);
566 
567 /* ------------------------------------------------------------------------- */
568 
574  PJ_CONTEXT *ctx,
575  const char *authority);
576 
579 
582  double accuracy);
583 
586  double west_lon,
587  double south_lat,
588  double east_lon,
589  double north_lat);
590 
594 typedef enum
595 {
598 
601 
605 
609 
612  PROJ_CRS_EXTENT_USE use);
613 
615 typedef enum {
619 
624 
627  PROJ_SPATIAL_CRITERION criterion);
628 
629 
631 typedef enum {
635 
638 
643 
646  PROJ_GRID_AVAILABILITY_USE use);
647 
650  int usePROJNames);
651 
653  PJ_OPERATION_FACTORY_CONTEXT *ctxt, int allow);
654 
657  const char* const *list_of_auth_name_codes);
658 
659 /* ------------------------------------------------------------------------- */
660 
666  PJ_OBJ *source_crs,
667  PJ_OBJ *target_crs,
668  PJ_OPERATION_FACTORY_CONTEXT *operationContext);
669 
671 
673  int index);
674 
675 void PROJ_DLL proj_operation_result_unref(PJ_OPERATION_RESULT *result);
676 
677 /* ------------------------------------------------------------------------- */
678 
680 
682 
683 PJ_OBJ PROJ_DLL *proj_obj_crs_get_sub_crs(PJ_OBJ *crs, int index);
684 
686 
687 PJ_OBJ PROJ_DLL *proj_obj_get_ellipsoid(PJ_OBJ *obj);
688 
689 int PROJ_DLL proj_obj_ellipsoid_get_parameters(PJ_OBJ *ellipsoid,
690  double *pSemiMajorMetre,
691  double *pSemiMinorMetre,
692  int *pIsSemiMinorComputed,
693  double *pInverseFlattening);
694 
696 
697 int PROJ_DLL proj_obj_prime_meridian_get_parameters(PJ_OBJ *prime_meridian,
698  double *pLongitude,
699  double *pLongitudeUnitConvFactor,
700  const char **pLongitudeUnitName);
701 
703  const char **pMethodName,
704  const char **pMethodAuthorityName,
705  const char **pMethodCode);
706 
707 int PROJ_DLL proj_coordoperation_is_instanciable(PJ_OBJ *coordoperation);
708 
709 int PROJ_DLL proj_coordoperation_get_param_count(PJ_OBJ *coordoperation);
710 
711 int PROJ_DLL proj_coordoperation_get_param_index(PJ_OBJ *coordoperation,
712  const char *name);
713 
714 int PROJ_DLL proj_coordoperation_get_param(PJ_OBJ *coordoperation,
715  int index,
716  const char **pName,
717  const char **pNameAuthorityName,
718  const char **pNameCode,
719  double *pValue,
720  const char **pValueString,
721  double *pValueUnitConvFactor,
722  const char **pValueUnitName);
723 
724 int PROJ_DLL proj_coordoperation_get_grid_used_count(PJ_OBJ *coordoperation);
725 
726 int PROJ_DLL proj_coordoperation_get_grid_used(PJ_OBJ *coordoperation,
727  int index,
728  const char **pShortName,
729  const char **pFullName,
730  const char **pPackageName,
731  const char **pURL,
732  int *pDirectDownload,
733  int *pOpenLicense,
734  int *pAvailable);
735 
736 #ifdef __cplusplus
737 }
738 #endif
739 
740 #endif /* ndef PROJ_H */
int proj_coordoperation_get_grid_used_count(PJ_OBJ *coordoperation)
Return the number of grids used by a CoordinateOperation.
Definition: c_api.cpp:1410
PJ_OBJ * proj_obj_crs_get_coordoperation(PJ_OBJ *crs, const char **pMethodName, const char **pMethodAuthorityName, const char **pMethodCode)
Return the Conversion of a DerivedCRS (such as a ProjectedCRS), or the Transformation from the baseCR...
Definition: c_api.cpp:1170
const char * proj_obj_get_id_code(PJ_OBJ *obj, int index)
Get the code of an identifier of an object.
Definition: c_api.cpp:525
Definition: proj.h:597
Opaque object representing an operation factory context.
Definition: c_api.cpp:1506
Definition: proj.h:534
int proj_coordoperation_get_param_index(PJ_OBJ *coordoperation, const char *name)
Return the index of a parameter of a SingleOperation.
Definition: c_api.cpp:1269
void proj_operation_factory_context_set_area_of_interest(PJ_OPERATION_FACTORY_CONTEXT *ctxt, double west_lon, double south_lat, double east_lon, double north_lat)
Set the desired area of interest for the resulting coordinate transformations.
Definition: c_api.cpp:1601
PJ_OPERATION_RESULT * proj_obj_create_operations(PJ_OBJ *source_crs, PJ_OBJ *target_crs, PJ_OPERATION_FACTORY_CONTEXT *operationContext)
Find a list of CoordinateOperation from source_crs to target_crs.
Definition: c_api.cpp:1809
Definition: proj.h:641
PJ_OBJ * proj_obj_create_from_user_input(PJ_CONTEXT *ctx, const char *text)
Instanciate an object from a WKT string, PROJ string or object code (like "EPSG:4326", "urn:ogc:def:crs:EPSG::4326", "urn:ogc:def:coordinateOperation:EPSG::1671").
Definition: c_api.cpp:245
int proj_obj_is_crs(PJ_OBJ *obj)
Return whether an object is a CRS.
Definition: c_api.cpp:453
int proj_context_set_database_path(PJ_CONTEXT *ctx, const char *dbPath, const char *const *auxDbPaths)
Explicitly point to the main PROJ CRS and coordinate operation definition database ("proj...
Definition: c_api.cpp:195
PJ_OBJ_TYPE
Object type.
Definition: proj.h:475
PJ_OBJ * proj_obj_get_source_crs(PJ_OBJ *obj)
Return the base CRS of a BoundCRS or the source CRS of a CoordinateOperation.
Definition: c_api.cpp:944
int proj_obj_ellipsoid_get_parameters(PJ_OBJ *ellipsoid, double *pSemiMajorMetre, double *pSemiMinorMetre, int *pIsSemiMinorComputed, double *pInverseFlattening)
Return ellipsoid parameters.
Definition: c_api.cpp:833
PJ_OBJ * proj_obj_create_from_wkt(PJ_CONTEXT *ctx, const char *wkt)
Instanciate an object from a WKT string.
Definition: c_api.cpp:271
PJ_OPERATION_FACTORY_CONTEXT * proj_create_operation_factory_context(PJ_CONTEXT *ctx, const char *authority)
Instanciate a context for building coordinate operations between two CRS.
Definition: c_api.cpp:1537
PROJ_STRING_LIST proj_get_codes_from_database(PJ_CONTEXT *ctx, const char *auth_name, PJ_OBJ_TYPE type, int allow_deprecated)
Returns the set of authority codes of the given object type.
Definition: c_api.cpp:1048
const char * proj_obj_as_proj_string(PJ_OBJ *obj, PJ_PROJ_STRING_TYPE type, const char *const *options)
Get a PROJ string representation of an object.
Definition: c_api.cpp:620
PJ_OBJ * proj_obj_create_from_database(PJ_CONTEXT *ctx, const char *auth_name, const char *code, PJ_OBJ_CATEGORY category, int usePROJAlternativeGridNames, const char *const *options)
Instanciate an object from a database lookup.
Definition: c_api.cpp:327
PJ_OBJ * proj_obj_crs_get_horizontal_datum(PJ_OBJ *crs)
Get the horizontal datum from a CRS.
Definition: c_api.cpp:799
void proj_operation_factory_context_set_use_proj_alternative_grid_names(PJ_OPERATION_FACTORY_CONTEXT *ctxt, int usePROJNames)
Set whether PROJ alternative grid names should be substituted to the official authority names...
Definition: c_api.cpp:1716
Definition: proj.h:607
PJ_PROJ_STRING_TYPE
PROJ string version.
Definition: proj.h:547
PJ_OBJ_CATEGORY
Object category.
Definition: proj.h:457
const char * proj_obj_get_id_auth_name(PJ_OBJ *obj, int index)
Get the authority name / codespace of an identifier of an object.
Definition: c_api.cpp:494
void proj_operation_factory_context_set_desired_accuracy(PJ_OPERATION_FACTORY_CONTEXT *ctxt, double accuracy)
Set the desired accuracy of the resulting coordinate transformations.
Definition: c_api.cpp:1581
int proj_coordoperation_get_param(PJ_OBJ *coordoperation, int index, const char **pName, const char **pNameAuthorityName, const char **pNameCode, double *pValue, const char **pValueString, double *pValueUnitConvFactor, const char **pValueUnitName)
Return a parameter of a SingleOperation.
Definition: c_api.cpp:1314
PJ_WKT_TYPE
WKT version.
Definition: proj.h:525
void proj_operation_result_unref(PJ_OPERATION_RESULT *result)
Drops a reference on an object.
Definition: c_api.cpp:1884
PROJ_CRS_EXTENT_USE
Definition: proj.h:594
int proj_operation_result_get_count(PJ_OPERATION_RESULT *result)
Return the number of CoordinateOperation in the result set.
Definition: c_api.cpp:1847
int proj_coordoperation_is_instanciable(PJ_OBJ *coordoperation)
Return whether a coordinate operation can be instanciated as a PROJ pipeline, checking in particular ...
Definition: c_api.cpp:1223
int proj_obj_prime_meridian_get_parameters(PJ_OBJ *prime_meridian, double *pLongitude, double *pLongitudeUnitConvFactor, const char **pLongitudeUnitName)
Return prime meridian parameters.
Definition: c_api.cpp:906
Opaque object representing a set of operation results.
Definition: c_api.cpp:1775
Definition: proj.h:604
PJ_OBJ * proj_obj_get_prime_meridian(PJ_OBJ *obj)
Get the prime meridian of a CRS or a GeodeticReferenceFrame.
Definition: c_api.cpp:875
void proj_operation_factory_context_set_spatial_criterion(PJ_OPERATION_FACTORY_CONTEXT *ctxt, PROJ_SPATIAL_CRITERION criterion)
Set the spatial criterion to use when comparing the area of validity of coordinate operations with th...
Definition: c_api.cpp:1658
PJ_OBJ * proj_obj_crs_create_bound_crs_to_WGS84(PJ_OBJ *crs)
Returns potentially a BoundCRS, with a transformation to EPSG:4326, wrapping this CRS...
Definition: c_api.cpp:745
void proj_free_string_list(PROJ_STRING_LIST list)
Definition: c_api.cpp:1142
PROJ_GRID_AVAILABILITY_USE
Definition: proj.h:631
Definition: proj.h:600
Opaque object representing a Ellipsoid, Datum, CRS or Coordinate Operation. Should be used by at most...
Definition: c_api.cpp:90
PROJ_STRING_LIST proj_get_authorities_from_database(PJ_CONTEXT *ctx)
Return the list of authorities used in the database.
Definition: c_api.cpp:1023
Definition: proj.h:552
Definition: proj.h:550
void proj_operation_factory_context_set_allow_use_intermediate_crs(PJ_OPERATION_FACTORY_CONTEXT *ctxt, int allow)
Set whether an intermediate pivot CRS can be used for researching coordinate operations between a sou...
Definition: c_api.cpp:1744
void proj_operation_factory_context_set_grid_availability_use(PJ_OPERATION_FACTORY_CONTEXT *ctxt, PROJ_GRID_AVAILABILITY_USE use)
Set how grid availability is used.
Definition: c_api.cpp:1683
void proj_operation_factory_context_set_crs_extent_use(PJ_OPERATION_FACTORY_CONTEXT *ctxt, PROJ_CRS_EXTENT_USE use)
Set how source and target CRS extent should be used when considering if a transformation can be used ...
Definition: c_api.cpp:1620
PJ_OBJ_TYPE proj_obj_get_type(PJ_OBJ *obj)
Return the type of an object.
Definition: c_api.cpp:383
int proj_coordoperation_get_param_count(PJ_OBJ *coordoperation)
Return the number of parameters of a SingleOperation.
Definition: c_api.cpp:1248
PJ_OBJ * proj_obj_create_from_proj_string(PJ_CONTEXT *ctx, const char *proj_string)
Instanciate an object from a PROJ string.
Definition: c_api.cpp:296
int proj_coordoperation_get_grid_used(PJ_OBJ *coordoperation, int index, const char **pShortName, const char **pFullName, const char **pPackageName, const char **pURL, int *pDirectDownload, int *pOpenLicense, int *pAvailable)
Return a parameter of a SingleOperation.
Definition: c_api.cpp:1459
void proj_operation_factory_context_unref(PJ_OPERATION_FACTORY_CONTEXT *ctxt)
Drops a reference on an object.
Definition: c_api.cpp:1571
PJ_OBJ * proj_obj_crs_get_sub_crs(PJ_OBJ *crs, int index)
Get a CRS component from a CompoundCRS.
Definition: c_api.cpp:715
PJ_OBJ * proj_obj_get_target_crs(PJ_OBJ *obj)
Return the hub CRS of a BoundCRS or the target CRS of a CoordinateOperation.
Definition: c_api.cpp:977
Definition: proj.h:530
const char * proj_obj_get_name(PJ_OBJ *obj)
Get the name of an object.
Definition: c_api.cpp:467
PJ_OBJ * proj_obj_crs_get_geodetic_crs(PJ_OBJ *crs)
Get the geodeticCRS / geographicCRS from a CRS.
Definition: c_api.cpp:693
PROJ_SPATIAL_CRITERION
Definition: proj.h:615
void proj_obj_unref(PJ_OBJ *obj)
Drops a reference on an object.
Definition: c_api.cpp:374
PJ_OBJ * proj_obj_get_ellipsoid(PJ_OBJ *obj)
Get the ellipsoid from a CRS or a GeodeticReferenceFrame.
Definition: c_api.cpp:769
const char * proj_context_get_database_path(PJ_CONTEXT *ctx)
Returns the path to the database.
Definition: c_api.cpp:219
PJ_OBJ * proj_operation_result_get(PJ_OPERATION_RESULT *result, int index)
Return a CoordinateOperation in the result set.
Definition: c_api.cpp:1866
Definition: proj.h:532
Definition: proj.h:536
const char * proj_obj_as_wkt(PJ_OBJ *obj, PJ_WKT_TYPE type, const char *const *options)
Get a WKT representation of an object.
Definition: c_api.cpp:556
char ** PROJ_STRING_LIST
Type representing a NULL terminated list of NUL-terminate strings.
Definition: proj.h:505
Definition: proj.h:528
void proj_operation_factory_context_set_allowed_intermediate_crs(PJ_OPERATION_FACTORY_CONTEXT *ctxt, const char *const *list_of_auth_name_codes)
Restrict the potential pivot CRSs that can be used when trying to build a coordinate operation betwee...
Definition: c_api.cpp:1759