gooderp18绿色标准版
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

1100 lines
43KB

  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. #ifndef PROJ_H
  117. #define PROJ_H
  118. #include <stddef.h> /* For size_t */
  119. #ifdef PROJ_API_H
  120. #error proj.h must be included before proj_api.h
  121. #endif
  122. #ifdef PROJ_RENAME_SYMBOLS
  123. #include "proj_symbol_rename.h"
  124. #endif
  125. #ifdef __cplusplus
  126. extern "C" {
  127. #endif
  128. /**
  129. * \file proj.h
  130. *
  131. * C API new generation
  132. */
  133. /*! @cond Doxygen_Suppress */
  134. #ifndef PROJ_DLL
  135. #ifdef PROJ_MSVC_DLL_EXPORT
  136. #define PROJ_DLL __declspec(dllexport)
  137. #elif defined(PROJ_MSVC_DLL_IMPORT)
  138. #define PROJ_DLL __declspec(dllimport)
  139. #elif defined(__GNUC__)
  140. #define PROJ_DLL __attribute__ ((visibility("default")))
  141. #else
  142. #define PROJ_DLL
  143. #endif
  144. #endif
  145. /* The version numbers should be updated with every release! **/
  146. #define PROJ_VERSION_MAJOR 6
  147. #define PROJ_VERSION_MINOR 2
  148. #define PROJ_VERSION_PATCH 0
  149. extern char const PROJ_DLL pj_release[]; /* global release id string */
  150. /* first forward declare everything needed */
  151. /* Data type for generic geodetic 3D data plus epoch information */
  152. union PJ_COORD;
  153. typedef union PJ_COORD PJ_COORD;
  154. struct PJ_AREA;
  155. typedef struct PJ_AREA PJ_AREA;
  156. struct P5_FACTORS { /* Common designation */
  157. double meridional_scale; /* h */
  158. double parallel_scale; /* k */
  159. double areal_scale; /* s */
  160. double angular_distortion; /* omega */
  161. double meridian_parallel_angle; /* theta-prime */
  162. double meridian_convergence; /* alpha */
  163. double tissot_semimajor; /* a */
  164. double tissot_semiminor; /* b */
  165. double dx_dlam, dx_dphi;
  166. double dy_dlam, dy_dphi;
  167. };
  168. typedef struct P5_FACTORS PJ_FACTORS;
  169. /* Data type for projection/transformation information */
  170. struct PJconsts;
  171. typedef struct PJconsts PJ; /* the PJ object herself */
  172. /* Data type for library level information */
  173. struct PJ_INFO;
  174. typedef struct PJ_INFO PJ_INFO;
  175. struct PJ_PROJ_INFO;
  176. typedef struct PJ_PROJ_INFO PJ_PROJ_INFO;
  177. struct PJ_GRID_INFO;
  178. typedef struct PJ_GRID_INFO PJ_GRID_INFO;
  179. struct PJ_INIT_INFO;
  180. typedef struct PJ_INIT_INFO PJ_INIT_INFO;
  181. /* Data types for list of operations, ellipsoids, datums and units used in PROJ.4 */
  182. struct PJ_LIST {
  183. const char *id; /* projection keyword */
  184. PJ *(*proj)(PJ *); /* projection entry point */
  185. const char * const *descr; /* description text */
  186. };
  187. typedef struct PJ_LIST PJ_OPERATIONS;
  188. struct PJ_ELLPS {
  189. const char *id; /* ellipse keyword name */
  190. const char *major; /* a= value */
  191. const char *ell; /* elliptical parameter */
  192. const char *name; /* comments */
  193. };
  194. typedef struct PJ_ELLPS PJ_ELLPS;
  195. struct PJ_UNITS {
  196. const char *id; /* units keyword */
  197. const char *to_meter; /* multiply by value to get meters */
  198. const char *name; /* comments */
  199. double factor; /* to_meter factor in actual numbers */
  200. };
  201. typedef struct PJ_UNITS PJ_UNITS;
  202. struct PJ_PRIME_MERIDIANS {
  203. const char *id; /* prime meridian keyword */
  204. const char *defn; /* offset from greenwich in DMS format. */
  205. };
  206. typedef struct PJ_PRIME_MERIDIANS PJ_PRIME_MERIDIANS;
  207. /* Geodetic, mostly spatiotemporal coordinate types */
  208. typedef struct { double x, y, z, t; } PJ_XYZT;
  209. typedef struct { double u, v, w, t; } PJ_UVWT;
  210. typedef struct { double lam, phi, z, t; } PJ_LPZT;
  211. typedef struct { double o, p, k; } PJ_OPK; /* Rotations: omega, phi, kappa */
  212. typedef struct { double e, n, u; } PJ_ENU; /* East, North, Up */
  213. typedef struct { double s, a1, a2; } PJ_GEOD; /* Geodesic length, fwd azi, rev azi */
  214. /* Classic proj.4 pair/triplet types - moved into the PJ_ name space */
  215. typedef struct { double u, v; } PJ_UV;
  216. typedef struct { double x, y; } PJ_XY;
  217. typedef struct { double lam, phi; } PJ_LP;
  218. typedef struct { double x, y, z; } PJ_XYZ;
  219. typedef struct { double u, v, w; } PJ_UVW;
  220. typedef struct { double lam, phi, z; } PJ_LPZ;
  221. /* Avoid preprocessor renaming and implicit type-punning: Use a union to make it explicit */
  222. union PJ_COORD {
  223. double v[4]; /* First and foremost, it really is "just 4 numbers in a vector" */
  224. PJ_XYZT xyzt;
  225. PJ_UVWT uvwt;
  226. PJ_LPZT lpzt;
  227. PJ_GEOD geod;
  228. PJ_OPK opk;
  229. PJ_ENU enu;
  230. PJ_XYZ xyz;
  231. PJ_UVW uvw;
  232. PJ_LPZ lpz;
  233. PJ_XY xy;
  234. PJ_UV uv;
  235. PJ_LP lp;
  236. };
  237. struct PJ_INFO {
  238. int major; /* Major release number */
  239. int minor; /* Minor release number */
  240. int patch; /* Patch level */
  241. const char *release; /* Release info. Version + date */
  242. const char *version; /* Full version number */
  243. const char *searchpath; /* Paths where init and grid files are */
  244. /* looked for. Paths are separated by */
  245. /* semi-colons on Windows, and colons */
  246. /* on non-Windows platforms. */
  247. const char * const *paths;
  248. size_t path_count;
  249. };
  250. struct PJ_PROJ_INFO {
  251. const char *id; /* Name of the projection in question */
  252. const char *description; /* Description of the projection */
  253. const char *definition; /* Projection definition */
  254. int has_inverse; /* 1 if an inverse mapping exists, 0 otherwise */
  255. double accuracy; /* Expected accuracy of the transformation. -1 if unknown. */
  256. };
  257. struct PJ_GRID_INFO {
  258. char gridname[32]; /* name of grid */
  259. char filename[260]; /* full path to grid */
  260. char format[8]; /* file format of grid */
  261. PJ_LP lowerleft; /* Coordinates of lower left corner */
  262. PJ_LP upperright; /* Coordinates of upper right corner */
  263. int n_lon, n_lat; /* Grid size */
  264. double cs_lon, cs_lat; /* Cell size of grid */
  265. };
  266. struct PJ_INIT_INFO {
  267. char name[32]; /* name of init file */
  268. char filename[260]; /* full path to the init file. */
  269. char version[32]; /* version of the init file */
  270. char origin[32]; /* origin of the file, e.g. EPSG */
  271. char lastupdate[16]; /* Date of last update in YYYY-MM-DD format */
  272. };
  273. typedef enum PJ_LOG_LEVEL {
  274. PJ_LOG_NONE = 0,
  275. PJ_LOG_ERROR = 1,
  276. PJ_LOG_DEBUG = 2,
  277. PJ_LOG_TRACE = 3,
  278. PJ_LOG_TELL = 4,
  279. PJ_LOG_DEBUG_MAJOR = 2, /* for proj_api.h compatibility */
  280. PJ_LOG_DEBUG_MINOR = 3 /* for proj_api.h compatibility */
  281. } PJ_LOG_LEVEL;
  282. typedef void (*PJ_LOG_FUNCTION)(void *, int, const char *);
  283. /* The context type - properly namespaced synonym for projCtx */
  284. struct projCtx_t;
  285. typedef struct projCtx_t PJ_CONTEXT;
  286. /* A P I */
  287. /**
  288. * The objects returned by the functions defined in this section have minimal
  289. * interaction with the functions of the
  290. * \ref iso19111_functions section, and vice versa. See its introduction
  291. * paragraph for more details.
  292. */
  293. /* Functionality for handling thread contexts */
  294. #ifdef __cplusplus
  295. #define PJ_DEFAULT_CTX nullptr
  296. #else
  297. #define PJ_DEFAULT_CTX 0
  298. #endif
  299. PJ_CONTEXT PROJ_DLL *proj_context_create (void);
  300. PJ_CONTEXT PROJ_DLL *proj_context_destroy (PJ_CONTEXT *ctx);
  301. /** Callback to resolve a filename to a full path */
  302. typedef const char* (*proj_file_finder) (PJ_CONTEXT *ctx, const char*, void* user_data);
  303. void PROJ_DLL proj_context_set_file_finder(PJ_CONTEXT *ctx, proj_file_finder finder, void* user_data);
  304. void PROJ_DLL proj_context_set_search_paths(PJ_CONTEXT *ctx, int count_paths, const char* const* paths);
  305. void PROJ_DLL proj_context_use_proj4_init_rules(PJ_CONTEXT *ctx, int enable);
  306. int PROJ_DLL proj_context_get_use_proj4_init_rules(PJ_CONTEXT *ctx, int from_legacy_code_path);
  307. /* Manage the transformation definition object PJ */
  308. PJ PROJ_DLL *proj_create (PJ_CONTEXT *ctx, const char *definition);
  309. PJ PROJ_DLL *proj_create_argv (PJ_CONTEXT *ctx, int argc, char **argv);
  310. PJ PROJ_DLL *proj_create_crs_to_crs(PJ_CONTEXT *ctx, const char *source_crs, const char *target_crs, PJ_AREA *area);
  311. PJ PROJ_DLL *proj_create_crs_to_crs_from_pj(PJ_CONTEXT *ctx,
  312. PJ *source_crs,
  313. PJ *target_crs,
  314. PJ_AREA *area,
  315. const char* const *options);
  316. PJ PROJ_DLL *proj_normalize_for_visualization(PJ_CONTEXT *ctx, const PJ* obj);
  317. PJ PROJ_DLL *proj_destroy (PJ *P);
  318. PJ_AREA PROJ_DLL *proj_area_create(void);
  319. void PROJ_DLL proj_area_set_bbox(PJ_AREA *area,
  320. double west_lon_degree,
  321. double south_lat_degree,
  322. double east_lon_degree,
  323. double north_lat_degree);
  324. void PROJ_DLL proj_area_destroy(PJ_AREA* area);
  325. /* Apply transformation to observation - in forward or inverse direction */
  326. enum PJ_DIRECTION {
  327. PJ_FWD = 1, /* Forward */
  328. PJ_IDENT = 0, /* Do nothing */
  329. PJ_INV = -1 /* Inverse */
  330. };
  331. typedef enum PJ_DIRECTION PJ_DIRECTION;
  332. int PROJ_DLL proj_angular_input (PJ *P, enum PJ_DIRECTION dir);
  333. int PROJ_DLL proj_angular_output (PJ *P, enum PJ_DIRECTION dir);
  334. PJ_COORD PROJ_DLL proj_trans (PJ *P, PJ_DIRECTION direction, PJ_COORD coord);
  335. int PROJ_DLL proj_trans_array (PJ *P, PJ_DIRECTION direction, size_t n, PJ_COORD *coord);
  336. size_t PROJ_DLL proj_trans_generic (
  337. PJ *P,
  338. PJ_DIRECTION direction,
  339. double *x, size_t sx, size_t nx,
  340. double *y, size_t sy, size_t ny,
  341. double *z, size_t sz, size_t nz,
  342. double *t, size_t st, size_t nt
  343. );
  344. /* Initializers */
  345. PJ_COORD PROJ_DLL proj_coord (double x, double y, double z, double t);
  346. /* Measure internal consistency - in forward or inverse direction */
  347. double PROJ_DLL proj_roundtrip (PJ *P, PJ_DIRECTION direction, int n, PJ_COORD *coord);
  348. /* Geodesic distance between two points with angular 2D coordinates */
  349. double PROJ_DLL proj_lp_dist (const PJ *P, PJ_COORD a, PJ_COORD b);
  350. /* The geodesic distance AND the vertical offset */
  351. double PROJ_DLL proj_lpz_dist (const PJ *P, PJ_COORD a, PJ_COORD b);
  352. /* Euclidean distance between two points with linear 2D coordinates */
  353. double PROJ_DLL proj_xy_dist (PJ_COORD a, PJ_COORD b);
  354. /* Euclidean distance between two points with linear 3D coordinates */
  355. double PROJ_DLL proj_xyz_dist (PJ_COORD a, PJ_COORD b);
  356. /* Geodesic distance (in meter) + fwd and rev azimuth between two points on the ellipsoid */
  357. PJ_COORD PROJ_DLL proj_geod (const PJ *P, PJ_COORD a, PJ_COORD b);
  358. /* Set or read error level */
  359. int PROJ_DLL proj_context_errno (PJ_CONTEXT *ctx);
  360. int PROJ_DLL proj_errno (const PJ *P);
  361. int PROJ_DLL proj_errno_set (const PJ *P, int err);
  362. int PROJ_DLL proj_errno_reset (const PJ *P);
  363. int PROJ_DLL proj_errno_restore (const PJ *P, int err);
  364. const char PROJ_DLL * proj_errno_string (int err);
  365. PJ_LOG_LEVEL PROJ_DLL proj_log_level (PJ_CONTEXT *ctx, PJ_LOG_LEVEL log_level);
  366. void PROJ_DLL proj_log_func (PJ_CONTEXT *ctx, void *app_data, PJ_LOG_FUNCTION logf);
  367. /* Scaling and angular distortion factors */
  368. PJ_FACTORS PROJ_DLL proj_factors(PJ *P, PJ_COORD lp);
  369. /* Info functions - get information about various PROJ.4 entities */
  370. PJ_INFO PROJ_DLL proj_info(void);
  371. PJ_PROJ_INFO PROJ_DLL proj_pj_info(PJ *P);
  372. PJ_GRID_INFO PROJ_DLL proj_grid_info(const char *gridname);
  373. PJ_INIT_INFO PROJ_DLL proj_init_info(const char *initname);
  374. /* List functions: */
  375. /* Get lists of operations, ellipsoids, units and prime meridians. */
  376. const PJ_OPERATIONS PROJ_DLL *proj_list_operations(void);
  377. const PJ_ELLPS PROJ_DLL *proj_list_ellps(void);
  378. const PJ_UNITS PROJ_DLL *proj_list_units(void);
  379. const PJ_UNITS PROJ_DLL *proj_list_angular_units(void);
  380. const PJ_PRIME_MERIDIANS PROJ_DLL *proj_list_prime_meridians(void);
  381. /* These are trivial, and while occasionally useful in real code, primarily here to */
  382. /* simplify demo code, and in acknowledgement of the proj-internal discrepancy between */
  383. /* angular units expected by classical proj, and by Charles Karney's geodesics subsystem */
  384. double PROJ_DLL proj_torad (double angle_in_degrees);
  385. double PROJ_DLL proj_todeg (double angle_in_radians);
  386. double PROJ_DLL proj_dmstor(const char *is, char **rs);
  387. char PROJ_DLL * proj_rtodms(char *s, double r, int pos, int neg);
  388. void PROJ_DLL proj_cleanup(void);
  389. /*! @endcond */
  390. /* ------------------------------------------------------------------------- */
  391. /* Binding in C of C++ API */
  392. /* ------------------------------------------------------------------------- */
  393. /** @defgroup iso19111_types Data types for ISO19111 C API
  394. * Data types for ISO19111 C API
  395. * @{
  396. */
  397. /** \brief Type representing a NULL terminated list of NULL-terminate strings. */
  398. typedef char **PROJ_STRING_LIST;
  399. /** \brief Guessed WKT "dialect". */
  400. typedef enum
  401. {
  402. /** \ref WKT2_2018 */
  403. PJ_GUESSED_WKT2_2018,
  404. /** \ref WKT2_2015 */
  405. PJ_GUESSED_WKT2_2015,
  406. /** \ref WKT1 */
  407. PJ_GUESSED_WKT1_GDAL,
  408. /** ESRI variant of WKT1 */
  409. PJ_GUESSED_WKT1_ESRI,
  410. /** Not WKT / unrecognized */
  411. PJ_GUESSED_NOT_WKT
  412. } PJ_GUESSED_WKT_DIALECT;
  413. /** \brief Object category. */
  414. typedef enum
  415. {
  416. PJ_CATEGORY_ELLIPSOID,
  417. PJ_CATEGORY_PRIME_MERIDIAN,
  418. PJ_CATEGORY_DATUM,
  419. PJ_CATEGORY_CRS,
  420. PJ_CATEGORY_COORDINATE_OPERATION
  421. } PJ_CATEGORY;
  422. /** \brief Object type. */
  423. typedef enum
  424. {
  425. PJ_TYPE_UNKNOWN,
  426. PJ_TYPE_ELLIPSOID,
  427. PJ_TYPE_PRIME_MERIDIAN,
  428. PJ_TYPE_GEODETIC_REFERENCE_FRAME,
  429. PJ_TYPE_DYNAMIC_GEODETIC_REFERENCE_FRAME,
  430. PJ_TYPE_VERTICAL_REFERENCE_FRAME,
  431. PJ_TYPE_DYNAMIC_VERTICAL_REFERENCE_FRAME,
  432. PJ_TYPE_DATUM_ENSEMBLE,
  433. /** Abstract type, not returned by proj_get_type() */
  434. PJ_TYPE_CRS,
  435. PJ_TYPE_GEODETIC_CRS,
  436. PJ_TYPE_GEOCENTRIC_CRS,
  437. /** proj_get_type() will never return that type, but
  438. * PJ_TYPE_GEOGRAPHIC_2D_CRS or PJ_TYPE_GEOGRAPHIC_3D_CRS. */
  439. PJ_TYPE_GEOGRAPHIC_CRS,
  440. PJ_TYPE_GEOGRAPHIC_2D_CRS,
  441. PJ_TYPE_GEOGRAPHIC_3D_CRS,
  442. PJ_TYPE_VERTICAL_CRS,
  443. PJ_TYPE_PROJECTED_CRS,
  444. PJ_TYPE_COMPOUND_CRS,
  445. PJ_TYPE_TEMPORAL_CRS,
  446. PJ_TYPE_ENGINEERING_CRS,
  447. PJ_TYPE_BOUND_CRS,
  448. PJ_TYPE_OTHER_CRS,
  449. PJ_TYPE_CONVERSION,
  450. PJ_TYPE_TRANSFORMATION,
  451. PJ_TYPE_CONCATENATED_OPERATION,
  452. PJ_TYPE_OTHER_COORDINATE_OPERATION,
  453. } PJ_TYPE;
  454. /** Comparison criterion. */
  455. typedef enum
  456. {
  457. /** All properties are identical. */
  458. PJ_COMP_STRICT,
  459. /** The objects are equivalent for the purpose of coordinate
  460. * operations. They can differ by the name of their objects,
  461. * identifiers, other metadata.
  462. * Parameters may be expressed in different units, provided that the
  463. * value is (with some tolerance) the same once expressed in a
  464. * common unit.
  465. */
  466. PJ_COMP_EQUIVALENT,
  467. /** Same as EQUIVALENT, relaxed with an exception that the axis order
  468. * of the base CRS of a DerivedCRS/ProjectedCRS or the axis order of
  469. * a GeographicCRS is ignored. Only to be used
  470. * with DerivedCRS/ProjectedCRS/GeographicCRS */
  471. PJ_COMP_EQUIVALENT_EXCEPT_AXIS_ORDER_GEOGCRS,
  472. } PJ_COMPARISON_CRITERION;
  473. /** \brief WKT version. */
  474. typedef enum
  475. {
  476. /** cf osgeo::proj::io::WKTFormatter::Convention::WKT2 */
  477. PJ_WKT2_2015,
  478. /** cf osgeo::proj::io::WKTFormatter::Convention::WKT2_SIMPLIFIED */
  479. PJ_WKT2_2015_SIMPLIFIED,
  480. /** cf osgeo::proj::io::WKTFormatter::Convention::WKT2_2018 */
  481. PJ_WKT2_2018,
  482. /** cf osgeo::proj::io::WKTFormatter::Convention::WKT2_2018_SIMPLIFIED */
  483. PJ_WKT2_2018_SIMPLIFIED,
  484. /** cf osgeo::proj::io::WKTFormatter::Convention::WKT1_GDAL */
  485. PJ_WKT1_GDAL,
  486. /** cf osgeo::proj::io::WKTFormatter::Convention::WKT1_ESRI */
  487. PJ_WKT1_ESRI
  488. } PJ_WKT_TYPE;
  489. /** Specify how source and target CRS extent should be used to restrict
  490. * candidate operations (only taken into account if no explicit area of
  491. * interest is specified. */
  492. typedef enum
  493. {
  494. /** Ignore CRS extent */
  495. PJ_CRS_EXTENT_NONE,
  496. /** Test coordinate operation extent against both CRS extent. */
  497. PJ_CRS_EXTENT_BOTH,
  498. /** Test coordinate operation extent against the intersection of both
  499. CRS extent. */
  500. PJ_CRS_EXTENT_INTERSECTION,
  501. /** Test coordinate operation against the smallest of both CRS extent. */
  502. PJ_CRS_EXTENT_SMALLEST
  503. } PROJ_CRS_EXTENT_USE;
  504. /** Describe how grid availability is used. */
  505. typedef enum {
  506. /** Grid availability is only used for sorting results. Operations
  507. * where some grids are missing will be sorted last. */
  508. PROJ_GRID_AVAILABILITY_USED_FOR_SORTING,
  509. /** Completely discard an operation if a required grid is missing. */
  510. PROJ_GRID_AVAILABILITY_DISCARD_OPERATION_IF_MISSING_GRID,
  511. /** Ignore grid availability at all. Results will be presented as if
  512. * all grids were available. */
  513. PROJ_GRID_AVAILABILITY_IGNORED,
  514. } PROJ_GRID_AVAILABILITY_USE;
  515. /** \brief PROJ string version. */
  516. typedef enum
  517. {
  518. /** cf osgeo::proj::io::PROJStringFormatter::Convention::PROJ_5 */
  519. PJ_PROJ_5,
  520. /** cf osgeo::proj::io::PROJStringFormatter::Convention::PROJ_4 */
  521. PJ_PROJ_4
  522. } PJ_PROJ_STRING_TYPE;
  523. /** Spatial criterion to restrict candidate operations. */
  524. typedef enum {
  525. /** The area of validity of transforms should strictly contain the
  526. * are of interest. */
  527. PROJ_SPATIAL_CRITERION_STRICT_CONTAINMENT,
  528. /** The area of validity of transforms should at least intersect the
  529. * area of interest. */
  530. PROJ_SPATIAL_CRITERION_PARTIAL_INTERSECTION
  531. } PROJ_SPATIAL_CRITERION;
  532. /** Describe if and how intermediate CRS should be used */
  533. typedef enum {
  534. /** Always search for intermediate CRS. */
  535. PROJ_INTERMEDIATE_CRS_USE_ALWAYS,
  536. /** Only attempt looking for intermediate CRS if there is no direct
  537. * transformation available. */
  538. PROJ_INTERMEDIATE_CRS_USE_IF_NO_DIRECT_TRANSFORMATION,
  539. /* Do not attempt looking for intermediate CRS. */
  540. PROJ_INTERMEDIATE_CRS_USE_NEVER,
  541. } PROJ_INTERMEDIATE_CRS_USE;
  542. /** Type of coordinate system. */
  543. typedef enum
  544. {
  545. PJ_CS_TYPE_UNKNOWN,
  546. PJ_CS_TYPE_CARTESIAN,
  547. PJ_CS_TYPE_ELLIPSOIDAL,
  548. PJ_CS_TYPE_VERTICAL,
  549. PJ_CS_TYPE_SPHERICAL,
  550. PJ_CS_TYPE_ORDINAL,
  551. PJ_CS_TYPE_PARAMETRIC,
  552. PJ_CS_TYPE_DATETIMETEMPORAL,
  553. PJ_CS_TYPE_TEMPORALCOUNT,
  554. PJ_CS_TYPE_TEMPORALMEASURE
  555. } PJ_COORDINATE_SYSTEM_TYPE;
  556. /** \brief Structure given overall description of a CRS.
  557. *
  558. * This structure may grow over time, and should not be directly allocated by
  559. * client code.
  560. */
  561. typedef struct
  562. {
  563. /** Authority name. */
  564. char* auth_name;
  565. /** Object code. */
  566. char* code;
  567. /** Object name. */
  568. char* name;
  569. /** Object type. */
  570. PJ_TYPE type;
  571. /** Whether the object is deprecated */
  572. int deprecated;
  573. /** Whereas the west_lon_degree, south_lat_degree, east_lon_degree and
  574. * north_lat_degree fields are valid. */
  575. int bbox_valid;
  576. /** Western-most longitude of the area of use, in degrees. */
  577. double west_lon_degree;
  578. /** Southern-most latitude of the area of use, in degrees. */
  579. double south_lat_degree;
  580. /** Eastern-most longitude of the area of use, in degrees. */
  581. double east_lon_degree;
  582. /** Northern-most latitude of the area of use, in degrees. */
  583. double north_lat_degree;
  584. /** Name of the area of use. */
  585. char* area_name;
  586. /** Name of the projection method for a projected CRS. Might be NULL even
  587. *for projected CRS in some cases. */
  588. char* projection_method_name;
  589. } PROJ_CRS_INFO;
  590. /** \brief Structure describing optional parameters for proj_get_crs_list();
  591. *
  592. * This structure may grow over time, and should not be directly allocated by
  593. * client code.
  594. */
  595. typedef struct
  596. {
  597. /** Array of allowed object types. Should be NULL if all types are allowed*/
  598. const PJ_TYPE* types;
  599. /** Size of types. Should be 0 if all types are allowed*/
  600. size_t typesCount;
  601. /** If TRUE and bbox_valid == TRUE, then only CRS whose area of use
  602. * entirely contains the specified bounding box will be returned.
  603. * If FALSE and bbox_valid == TRUE, then only CRS whose area of use
  604. * intersects the specified bounding box will be returned.
  605. */
  606. int crs_area_of_use_contains_bbox;
  607. /** To set to TRUE so that west_lon_degree, south_lat_degree,
  608. * east_lon_degree and north_lat_degree fields are taken into account. */
  609. int bbox_valid;
  610. /** Western-most longitude of the area of use, in degrees. */
  611. double west_lon_degree;
  612. /** Southern-most latitude of the area of use, in degrees. */
  613. double south_lat_degree;
  614. /** Eastern-most longitude of the area of use, in degrees. */
  615. double east_lon_degree;
  616. /** Northern-most latitude of the area of use, in degrees. */
  617. double north_lat_degree;
  618. /** Whether deprecated objects are allowed. Default to FALSE. */
  619. int allow_deprecated;
  620. } PROJ_CRS_LIST_PARAMETERS;
  621. /**@}*/
  622. /**
  623. * \defgroup iso19111_functions Binding in C of basic methods from the C++ API
  624. * Functions for ISO19111 C API
  625. *
  626. * The PJ* objects returned by proj_create_from_wkt(),
  627. * proj_create_from_database() and other functions in that section
  628. * will have generally minimal interaction with the functions declared in the
  629. * upper section of this header file (calling those functions on those objects
  630. * will either return an error or default/non-sensical values). The exception is
  631. * for ISO19111 objects of type CoordinateOperation that can be exported as a
  632. * valid PROJ pipeline. In this case, the PJ objects will work for example with
  633. * proj_trans_generic().
  634. * Conversely, objects returned by proj_create() and proj_create_argv(), which
  635. * are not of type CRS, will return an error when used with functions of this section.
  636. * @{
  637. */
  638. /*! @cond Doxygen_Suppress */
  639. typedef struct PJ_OBJ_LIST PJ_OBJ_LIST;
  640. /*! @endcond */
  641. void PROJ_DLL proj_string_list_destroy(PROJ_STRING_LIST list);
  642. void PROJ_DLL proj_context_set_autoclose_database(PJ_CONTEXT *ctx,
  643. int autoclose);
  644. int PROJ_DLL proj_context_set_database_path(PJ_CONTEXT *ctx,
  645. const char *dbPath,
  646. const char *const *auxDbPaths,
  647. const char* const *options);
  648. const char PROJ_DLL *proj_context_get_database_path(PJ_CONTEXT *ctx);
  649. const char PROJ_DLL *proj_context_get_database_metadata(PJ_CONTEXT* ctx,
  650. const char* key);
  651. PJ_GUESSED_WKT_DIALECT PROJ_DLL proj_context_guess_wkt_dialect(PJ_CONTEXT *ctx,
  652. const char *wkt);
  653. PJ PROJ_DLL *proj_create_from_wkt(PJ_CONTEXT *ctx, const char *wkt,
  654. const char* const *options,
  655. PROJ_STRING_LIST *out_warnings,
  656. PROJ_STRING_LIST *out_grammar_errors);
  657. PJ PROJ_DLL *proj_create_from_database(PJ_CONTEXT *ctx,
  658. const char *auth_name,
  659. const char *code,
  660. PJ_CATEGORY category,
  661. int usePROJAlternativeGridNames,
  662. const char* const *options);
  663. int PROJ_DLL proj_uom_get_info_from_database(PJ_CONTEXT *ctx,
  664. const char *auth_name,
  665. const char *code,
  666. const char **out_name,
  667. double *out_conv_factor,
  668. const char **out_category);
  669. int PROJ_DLL proj_grid_get_info_from_database(PJ_CONTEXT *ctx,
  670. const char *grid_name,
  671. const char **out_full_name,
  672. const char **out_package_name,
  673. const char **out_url,
  674. int *out_direct_download,
  675. int *out_open_license,
  676. int *out_available);
  677. PJ PROJ_DLL *proj_clone(PJ_CONTEXT *ctx, const PJ *obj);
  678. PJ_OBJ_LIST PROJ_DLL *proj_create_from_name(PJ_CONTEXT *ctx,
  679. const char *auth_name,
  680. const char *searchedName,
  681. const PJ_TYPE* types,
  682. size_t typesCount,
  683. int approximateMatch,
  684. size_t limitResultCount,
  685. const char* const *options);
  686. PJ_TYPE PROJ_DLL proj_get_type(const PJ *obj);
  687. int PROJ_DLL proj_is_deprecated(const PJ *obj);
  688. PJ_OBJ_LIST PROJ_DLL *proj_get_non_deprecated(PJ_CONTEXT *ctx,
  689. const PJ *obj);
  690. int PROJ_DLL proj_is_equivalent_to(const PJ *obj, const PJ *other,
  691. PJ_COMPARISON_CRITERION criterion);
  692. int PROJ_DLL proj_is_crs(const PJ *obj);
  693. const char PROJ_DLL* proj_get_name(const PJ *obj);
  694. const char PROJ_DLL* proj_get_id_auth_name(const PJ *obj, int index);
  695. const char PROJ_DLL* proj_get_id_code(const PJ *obj, int index);
  696. const char PROJ_DLL* proj_get_remarks(const PJ *obj);
  697. const char PROJ_DLL* proj_get_scope(const PJ *obj);
  698. int PROJ_DLL proj_get_area_of_use(PJ_CONTEXT *ctx,
  699. const PJ *obj,
  700. double* out_west_lon_degree,
  701. double* out_south_lat_degree,
  702. double* out_east_lon_degree,
  703. double* out_north_lat_degree,
  704. const char **out_area_name);
  705. const char PROJ_DLL* proj_as_wkt(PJ_CONTEXT *ctx,
  706. const PJ *obj, PJ_WKT_TYPE type,
  707. const char* const *options);
  708. const char PROJ_DLL* proj_as_proj_string(PJ_CONTEXT *ctx,
  709. const PJ *obj,
  710. PJ_PROJ_STRING_TYPE type,
  711. const char* const *options);
  712. const char PROJ_DLL* proj_as_projjson(PJ_CONTEXT *ctx,
  713. const PJ *obj,
  714. const char* const *options);
  715. PJ PROJ_DLL *proj_get_source_crs(PJ_CONTEXT *ctx,
  716. const PJ *obj);
  717. PJ PROJ_DLL *proj_get_target_crs(PJ_CONTEXT *ctx,
  718. const PJ *obj);
  719. PJ_OBJ_LIST PROJ_DLL *proj_identify(PJ_CONTEXT *ctx,
  720. const PJ *obj,
  721. const char *auth_name,
  722. const char* const *options,
  723. int **out_confidence);
  724. void PROJ_DLL proj_int_list_destroy(int* list);
  725. /* ------------------------------------------------------------------------- */
  726. PROJ_STRING_LIST PROJ_DLL proj_get_authorities_from_database(PJ_CONTEXT *ctx);
  727. PROJ_STRING_LIST PROJ_DLL proj_get_codes_from_database(PJ_CONTEXT *ctx,
  728. const char *auth_name,
  729. PJ_TYPE type,
  730. int allow_deprecated);
  731. PROJ_CRS_LIST_PARAMETERS PROJ_DLL *proj_get_crs_list_parameters_create(void);
  732. void PROJ_DLL proj_get_crs_list_parameters_destroy(
  733. PROJ_CRS_LIST_PARAMETERS* params);
  734. PROJ_CRS_INFO PROJ_DLL **proj_get_crs_info_list_from_database(
  735. PJ_CONTEXT *ctx,
  736. const char *auth_name,
  737. const PROJ_CRS_LIST_PARAMETERS* params,
  738. int *out_result_count);
  739. void PROJ_DLL proj_crs_info_list_destroy(PROJ_CRS_INFO** list);
  740. /* ------------------------------------------------------------------------- */
  741. /*! @cond Doxygen_Suppress */
  742. typedef struct PJ_OPERATION_FACTORY_CONTEXT PJ_OPERATION_FACTORY_CONTEXT;
  743. /*! @endcond */
  744. PJ_OPERATION_FACTORY_CONTEXT PROJ_DLL *proj_create_operation_factory_context(
  745. PJ_CONTEXT *ctx,
  746. const char *authority);
  747. void PROJ_DLL proj_operation_factory_context_destroy(
  748. PJ_OPERATION_FACTORY_CONTEXT *ctx);
  749. void PROJ_DLL proj_operation_factory_context_set_desired_accuracy(
  750. PJ_CONTEXT *ctx,
  751. PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
  752. double accuracy);
  753. void PROJ_DLL proj_operation_factory_context_set_area_of_interest(
  754. PJ_CONTEXT *ctx,
  755. PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
  756. double west_lon_degree,
  757. double south_lat_degree,
  758. double east_lon_degree,
  759. double north_lat_degree);
  760. void PROJ_DLL proj_operation_factory_context_set_crs_extent_use(
  761. PJ_CONTEXT *ctx,
  762. PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
  763. PROJ_CRS_EXTENT_USE use);
  764. void PROJ_DLL proj_operation_factory_context_set_spatial_criterion(
  765. PJ_CONTEXT *ctx,
  766. PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
  767. PROJ_SPATIAL_CRITERION criterion);
  768. void PROJ_DLL proj_operation_factory_context_set_grid_availability_use(
  769. PJ_CONTEXT *ctx,
  770. PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
  771. PROJ_GRID_AVAILABILITY_USE use);
  772. void PROJ_DLL proj_operation_factory_context_set_use_proj_alternative_grid_names(
  773. PJ_CONTEXT *ctx,
  774. PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
  775. int usePROJNames);
  776. void PROJ_DLL proj_operation_factory_context_set_allow_use_intermediate_crs(
  777. PJ_CONTEXT *ctx,
  778. PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
  779. PROJ_INTERMEDIATE_CRS_USE use);
  780. void PROJ_DLL proj_operation_factory_context_set_allowed_intermediate_crs(
  781. PJ_CONTEXT *ctx,
  782. PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
  783. const char* const *list_of_auth_name_codes);
  784. void PROJ_DLL proj_operation_factory_context_set_discard_superseded(
  785. PJ_CONTEXT *ctx,
  786. PJ_OPERATION_FACTORY_CONTEXT *factory_ctx,
  787. int discard);
  788. /* ------------------------------------------------------------------------- */
  789. PJ_OBJ_LIST PROJ_DLL *proj_create_operations(
  790. PJ_CONTEXT *ctx,
  791. const PJ *source_crs,
  792. const PJ *target_crs,
  793. const PJ_OPERATION_FACTORY_CONTEXT *operationContext);
  794. int PROJ_DLL proj_list_get_count(const PJ_OBJ_LIST *result);
  795. PJ PROJ_DLL *proj_list_get(PJ_CONTEXT *ctx,
  796. const PJ_OBJ_LIST *result,
  797. int index);
  798. void PROJ_DLL proj_list_destroy(PJ_OBJ_LIST *result);
  799. /* ------------------------------------------------------------------------- */
  800. PJ PROJ_DLL *proj_crs_get_geodetic_crs(PJ_CONTEXT *ctx, const PJ *crs);
  801. PJ PROJ_DLL *proj_crs_get_horizontal_datum(PJ_CONTEXT *ctx, const PJ *crs);
  802. PJ PROJ_DLL *proj_crs_get_sub_crs(PJ_CONTEXT *ctx, const PJ *crs, int index);
  803. PJ PROJ_DLL *proj_crs_get_datum(PJ_CONTEXT *ctx, const PJ *crs);
  804. PJ PROJ_DLL *proj_crs_get_coordinate_system(PJ_CONTEXT *ctx, const PJ *crs);
  805. PJ_COORDINATE_SYSTEM_TYPE PROJ_DLL proj_cs_get_type(PJ_CONTEXT *ctx,
  806. const PJ *cs);
  807. int PROJ_DLL proj_cs_get_axis_count(PJ_CONTEXT *ctx,
  808. const PJ *cs);
  809. int PROJ_DLL proj_cs_get_axis_info(PJ_CONTEXT *ctx,
  810. const PJ *cs, int index,
  811. const char **out_name,
  812. const char **out_abbrev,
  813. const char **out_direction,
  814. double *out_unit_conv_factor,
  815. const char **out_unit_name,
  816. const char **out_unit_auth_name,
  817. const char **out_unit_code);
  818. PJ PROJ_DLL *proj_get_ellipsoid(PJ_CONTEXT *ctx,
  819. const PJ *obj);
  820. int PROJ_DLL proj_ellipsoid_get_parameters(PJ_CONTEXT *ctx,
  821. const PJ *ellipsoid,
  822. double *out_semi_major_metre,
  823. double *out_semi_minor_metre,
  824. int *out_is_semi_minor_computed,
  825. double *out_inv_flattening);
  826. PJ PROJ_DLL *proj_get_prime_meridian(PJ_CONTEXT *ctx,
  827. const PJ *obj);
  828. int PROJ_DLL proj_prime_meridian_get_parameters(PJ_CONTEXT *ctx,
  829. const PJ *prime_meridian,
  830. double *out_longitude,
  831. double *out_unit_conv_factor,
  832. const char **out_unit_name);
  833. PJ PROJ_DLL *proj_crs_get_coordoperation(PJ_CONTEXT *ctx,
  834. const PJ *crs);
  835. int PROJ_DLL proj_coordoperation_get_method_info(PJ_CONTEXT *ctx,
  836. const PJ *coordoperation,
  837. const char **out_method_name,
  838. const char **out_method_auth_name,
  839. const char **out_method_code);
  840. int PROJ_DLL proj_coordoperation_is_instantiable(PJ_CONTEXT *ctx,
  841. const PJ *coordoperation);
  842. int PROJ_DLL proj_coordoperation_has_ballpark_transformation(PJ_CONTEXT *ctx,
  843. const PJ *coordoperation);
  844. int PROJ_DLL proj_coordoperation_get_param_count(PJ_CONTEXT *ctx,
  845. const PJ *coordoperation);
  846. int PROJ_DLL proj_coordoperation_get_param_index(PJ_CONTEXT *ctx,
  847. const PJ *coordoperation,
  848. const char *name);
  849. int PROJ_DLL proj_coordoperation_get_param(PJ_CONTEXT *ctx,
  850. const PJ *coordoperation,
  851. int index,
  852. const char **out_name,
  853. const char **out_auth_name,
  854. const char **out_code,
  855. double *out_value,
  856. const char **out_value_string,
  857. double *out_unit_conv_factor,
  858. const char **out_unit_name,
  859. const char **out_unit_auth_name,
  860. const char **out_unit_code,
  861. const char **out_unit_category);
  862. int PROJ_DLL proj_coordoperation_get_grid_used_count(PJ_CONTEXT *ctx,
  863. const PJ *coordoperation);
  864. int PROJ_DLL proj_coordoperation_get_grid_used(PJ_CONTEXT *ctx,
  865. const PJ *coordoperation,
  866. int index,
  867. const char **out_short_name,
  868. const char **out_full_name,
  869. const char **out_package_name,
  870. const char **out_url,
  871. int *out_direct_download,
  872. int *out_open_license,
  873. int *out_available);
  874. double PROJ_DLL proj_coordoperation_get_accuracy(PJ_CONTEXT *ctx,
  875. const PJ *obj);
  876. int PROJ_DLL proj_coordoperation_get_towgs84_values(PJ_CONTEXT *ctx,
  877. const PJ *coordoperation,
  878. double *out_values,
  879. int value_count,
  880. int emit_error_if_incompatible);
  881. int PROJ_DLL proj_concatoperation_get_step_count(PJ_CONTEXT *ctx,
  882. const PJ *concatoperation);
  883. PJ PROJ_DLL *proj_concatoperation_get_step(PJ_CONTEXT *ctx,
  884. const PJ *concatoperation,
  885. int i_step);
  886. /**@}*/
  887. #ifdef __cplusplus
  888. }
  889. #endif
  890. #endif /* ndef PROJ_H */
上海开阖软件有限公司 沪ICP备12045867号-1