1 /****************************************************************************** 2 * $Id$ 3 * 4 * Project: MapServer 5 * Purpose: Declarations of the projectionObj and related functions. 6 * Author: Steve Lime and the MapServer team. 7 * 8 ****************************************************************************** 9 * Copyright (c) 1996-2005 Regents of the University of Minnesota. 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 in 19 * all copies of this Software or works derived from this 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 30 #ifndef MAPPROJECT_H 31 #define MAPPROJECT_H 32 33 #include "mapprimitive.h" 34 #include "maphash.h" 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 #if PROJ_VERSION_MAJOR >= 6 41 # include <proj.h> 42 #if PROJ_VERSION_MAJOR == 6 && PROJ_VERSION_MINOR == 0 43 #error "PROJ 6.0 is not supported. Use PROJ 6.1 or later" 44 #endif 45 #else 46 # include <proj_api.h> 47 #if PJ_VERSION >= 470 && PJ_VERSION < 480 48 void pj_clear_initcache(); 49 #endif 50 #endif 51 52 #define wkp_none 0 53 #define wkp_lonlat 1 54 #define wkp_gmerc 2 55 56 typedef struct projectionContext projectionContext; 57 58 typedef struct { 59 #ifdef SWIG 60 %immutable; 61 #endif 62 int numargs; /* actual number of projection args */ 63 int automatic; /* projection object was to fetched from the layer */ 64 #ifdef SWIG 65 %mutable; 66 #endif 67 #ifndef SWIG 68 char **args; /* variable number of projection args */ 69 #if PROJ_VERSION_MAJOR >= 6 70 PJ* proj; 71 projectionContext* proj_ctx; 72 #else 73 projPJ proj; /* a projection structure for the PROJ package */ 74 #if PJ_VERSION >= 480 75 projCtx proj_ctx; 76 #endif 77 #endif 78 geotransformObj gt; /* extra transformation to apply */ 79 #endif 80 int wellknownprojection; 81 } projectionObj; 82 83 #ifndef SWIG 84 85 typedef struct reprojectionObj reprojectionObj; 86 MS_DLL_EXPORT reprojectionObj* msProjectCreateReprojector(projectionObj* in, projectionObj* out); 87 MS_DLL_EXPORT void msProjectDestroyReprojector(reprojectionObj* reprojector); 88 89 MS_DLL_EXPORT projectionContext* msProjectionContextGetFromPool(void); 90 MS_DLL_EXPORT void msProjectionContextReleaseToPool(projectionContext* ctx); 91 MS_DLL_EXPORT void msProjectionContextPoolCleanup(void); 92 93 MS_DLL_EXPORT int msIsAxisInverted(int epsg_code); 94 MS_DLL_EXPORT int msProjectPoint(projectionObj *in, projectionObj *out, pointObj *point); /* legacy interface */ 95 MS_DLL_EXPORT int msProjectPointEx(reprojectionObj* reprojector, pointObj *point); 96 MS_DLL_EXPORT int msProjectShape(projectionObj *in, projectionObj *out, shapeObj *shape); /* legacy interface */ 97 MS_DLL_EXPORT int msProjectShapeEx(reprojectionObj* reprojector, shapeObj *shape); 98 MS_DLL_EXPORT int msProjectLine(projectionObj *in, projectionObj *out, lineObj *line); /* legacy interface */ 99 MS_DLL_EXPORT int msProjectLineEx(reprojectionObj* reprojector, lineObj *line); 100 MS_DLL_EXPORT int msProjectRect(projectionObj *in, projectionObj *out, rectObj *rect); 101 MS_DLL_EXPORT int msProjectionsDiffer(projectionObj *, projectionObj *); 102 MS_DLL_EXPORT int msOGCWKT2ProjectionObj( const char *pszWKT, projectionObj *proj, int 103 debug_flag ); 104 MS_DLL_EXPORT char *msProjectionObj2OGCWKT( projectionObj *proj ); 105 106 MS_DLL_EXPORT void msFreeProjection(projectionObj *p); 107 MS_DLL_EXPORT void msFreeProjectionExceptContext(projectionObj *p); 108 MS_DLL_EXPORT int msInitProjection(projectionObj *p); 109 MS_DLL_EXPORT void msProjectionInheritContextFrom(projectionObj *pDst, projectionObj* pSrc); 110 MS_DLL_EXPORT void msProjectionSetContext(projectionObj *p, projectionContext* ctx); 111 MS_DLL_EXPORT int msProcessProjection(projectionObj *p); 112 MS_DLL_EXPORT int msLoadProjectionString(projectionObj *p, const char *value); 113 MS_DLL_EXPORT int msLoadProjectionStringEPSG(projectionObj *p, const char *value); 114 MS_DLL_EXPORT char *msGetProjectionString(projectionObj *proj); 115 int msIsAxisInvertedProj( projectionObj *proj ); 116 void msAxisSwapShape(shapeObj *shape); 117 MS_DLL_EXPORT void msAxisNormalizePoints( projectionObj *proj, int count, 118 double *x, double *y ); 119 MS_DLL_EXPORT void msAxisDenormalizePoints( projectionObj *proj, int count, 120 double *x, double *y ); 121 122 MS_DLL_EXPORT void msSetPROJ_LIB( const char *, const char * ); 123 MS_DLL_EXPORT void msProjLibInitFromEnv(); 124 125 int msProjIsGeographicCRS(projectionObj* proj); 126 #if PROJ_VERSION_MAJOR >= 6 127 int msProjectTransformPoints( reprojectionObj* reprojector, 128 int npoints, double* x, double* y ); 129 #endif 130 131 /*utility functions */ 132 MS_DLL_EXPORT int GetMapserverUnitUsingProj(projectionObj *psProj); 133 134 int msProjectHasLonWrap(projectionObj *in, double* pdfLonWrap); 135 #endif 136 137 #ifdef __cplusplus 138 } 139 #endif 140 141 #endif /* MAPPROJECT_H */ 142