proj_api.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /******************************************************************************
  2. * $Id: proj_api.h 2610 2015-02-17 21:52:14Z hobu $
  3. *
  4. * Project: PROJ.4
  5. * Purpose: Public (application) include file for PROJ.4 API, and constants.
  6. * Author: Frank Warmerdam, <warmerdam@pobox.com>
  7. *
  8. ******************************************************************************
  9. * Copyright (c) 2001, Frank Warmerdam <warmerdam@pobox.com>
  10. *
  11. * Permission is hereby granted, free of charge, to any person obtaining a
  12. * copy of this software and associated documentation files (the "Software"),
  13. * to deal in the Software without restriction, including without limitation
  14. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  15. * and/or sell copies of the Software, and to permit persons to whom the
  16. * Software is furnished to do so, subject to the following conditions:
  17. *
  18. * The above copyright notice and this permission notice shall be included
  19. * in all copies or substantial portions of the Software.
  20. *
  21. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  22. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  24. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  26. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  27. * DEALINGS IN THE SOFTWARE.
  28. *****************************************************************************/
  29. /* General projections header file */
  30. #ifndef PROJ_API_H
  31. #define PROJ_API_H
  32. /* standard inclusions */
  33. #include <math.h>
  34. #include <stdlib.h>
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /* Try to update this every version! */
  39. #define PJ_VERSION 491
  40. extern char const pj_release[]; /* global release id string */
  41. #define RAD_TO_DEG 57.29577951308232
  42. #define DEG_TO_RAD .0174532925199432958
  43. extern int pj_errno; /* global error return code */
  44. #if !defined(PROJECTS_H)
  45. typedef struct { double u, v; } projUV;
  46. typedef void *projPJ;
  47. #define projXY projUV
  48. #define projLP projUV
  49. typedef void *projCtx;
  50. #else
  51. typedef PJ *projPJ;
  52. typedef projCtx_t *projCtx;
  53. # define projXY XY
  54. # define projLP LP
  55. #endif
  56. /* file reading api, like stdio */
  57. typedef int *PAFile;
  58. typedef struct projFileAPI_t {
  59. PAFile (*FOpen)(projCtx ctx, const char *filename, const char *access);
  60. size_t (*FRead)(void *buffer, size_t size, size_t nmemb, PAFile file);
  61. int (*FSeek)(PAFile file, long offset, int whence);
  62. long (*FTell)(PAFile file);
  63. void (*FClose)(PAFile);
  64. } projFileAPI;
  65. /* procedure prototypes */
  66. projXY pj_fwd(projLP, projPJ);
  67. projLP pj_inv(projXY, projPJ);
  68. int pj_transform( projPJ src, projPJ dst, long point_count, int point_offset,
  69. double *x, double *y, double *z );
  70. int pj_datum_transform( projPJ src, projPJ dst, long point_count, int point_offset,
  71. double *x, double *y, double *z );
  72. int pj_geocentric_to_geodetic( double a, double es,
  73. long point_count, int point_offset,
  74. double *x, double *y, double *z );
  75. int pj_geodetic_to_geocentric( double a, double es,
  76. long point_count, int point_offset,
  77. double *x, double *y, double *z );
  78. int pj_compare_datums( projPJ srcdefn, projPJ dstdefn );
  79. int pj_apply_gridshift( projCtx, const char *, int,
  80. long point_count, int point_offset,
  81. double *x, double *y, double *z );
  82. void pj_deallocate_grids(void);
  83. void pj_clear_initcache(void);
  84. int pj_is_latlong(projPJ);
  85. int pj_is_geocent(projPJ);
  86. void pj_get_spheroid_defn(projPJ defn, double *major_axis, double *eccentricity_squared);
  87. void pj_pr_list(projPJ);
  88. void pj_free(projPJ);
  89. void pj_set_finder( const char *(*)(const char *) );
  90. void pj_set_searchpath ( int count, const char **path );
  91. projPJ pj_init(int, char **);
  92. projPJ pj_init_plus(const char *);
  93. projPJ pj_init_ctx( projCtx, int, char ** );
  94. projPJ pj_init_plus_ctx( projCtx, const char * );
  95. char *pj_get_def(projPJ, int);
  96. projPJ pj_latlong_from_proj( projPJ );
  97. void *pj_malloc(size_t);
  98. void pj_dalloc(void *);
  99. char *pj_strerrno(int);
  100. int *pj_get_errno_ref(void);
  101. const char *pj_get_release(void);
  102. void pj_acquire_lock(void);
  103. void pj_release_lock(void);
  104. void pj_cleanup_lock(void);
  105. projCtx pj_get_default_ctx(void);
  106. projCtx pj_get_ctx( projPJ );
  107. void pj_set_ctx( projPJ, projCtx );
  108. projCtx pj_ctx_alloc(void);
  109. void pj_ctx_free( projCtx );
  110. int pj_ctx_get_errno( projCtx );
  111. void pj_ctx_set_errno( projCtx, int );
  112. void pj_ctx_set_debug( projCtx, int );
  113. void pj_ctx_set_logger( projCtx, void (*)(void *, int, const char *) );
  114. void pj_ctx_set_app_data( projCtx, void * );
  115. void *pj_ctx_get_app_data( projCtx );
  116. void pj_ctx_set_fileapi( projCtx, projFileAPI *);
  117. projFileAPI *pj_ctx_get_fileapi( projCtx );
  118. void pj_log( projCtx ctx, int level, const char *fmt, ... );
  119. void pj_stderr_logger( void *, int, const char * );
  120. /* file api */
  121. projFileAPI *pj_get_default_fileapi();
  122. PAFile pj_ctx_fopen(projCtx ctx, const char *filename, const char *access);
  123. size_t pj_ctx_fread(projCtx ctx, void *buffer, size_t size, size_t nmemb, PAFile file);
  124. int pj_ctx_fseek(projCtx ctx, PAFile file, long offset, int whence);
  125. long pj_ctx_ftell(projCtx ctx, PAFile file);
  126. void pj_ctx_fclose(projCtx ctx, PAFile file);
  127. char *pj_ctx_fgets(projCtx ctx, char *line, int size, PAFile file);
  128. PAFile pj_open_lib(projCtx, const char *, const char *);
  129. #define PJ_LOG_NONE 0
  130. #define PJ_LOG_ERROR 1
  131. #define PJ_LOG_DEBUG_MAJOR 2
  132. #define PJ_LOG_DEBUG_MINOR 3
  133. #ifdef __cplusplus
  134. }
  135. #endif
  136. #endif /* ndef PROJ_API_H */