1 /****************************************************************************** 2 * 3 * Project: PROJ 4 * Purpose: ISO19111:2019 implementation 5 * Author: Even Rouault <even dot rouault at spatialys dot com> 6 * 7 ****************************************************************************** 8 * Copyright (c) 2018, Even Rouault <even dot rouault at spatialys dot com> 9 * 10 * Permission is hereby granted, free of charge, to any person obtaining a 11 * copy of this software and associated documentation files (the "Software"), 12 * to deal in the Software without restriction, including without limitation 13 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 14 * and/or sell copies of the Software, and to permit persons to whom the 15 * Software is furnished to do so, subject to the following conditions: 16 * 17 * The above copyright notice and this permission notice shall be included 18 * in all copies or substantial portions of the Software. 19 * 20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 26 * DEALINGS IN THE SOFTWARE. 27 ****************************************************************************/ 28 29 #ifndef FROM_PROJ_CPP 30 #error This file should only be included from a PROJ cpp file 31 #endif 32 33 #ifndef IO_INTERNAL_HH_INCLUDED 34 #define IO_INTERNAL_HH_INCLUDED 35 36 #include <string> 37 #include <vector> 38 39 #include "proj/io.hpp" 40 #include "proj/util.hpp" 41 42 //! @cond Doxygen_Suppress 43 44 NS_PROJ_START 45 46 namespace io { 47 48 // --------------------------------------------------------------------------- 49 50 class WKTConstants { 51 public: 52 // WKT1 53 static const std::string GEOCCS; 54 static const std::string GEOGCS; 55 static const std::string DATUM; // WKT2 preferred too 56 static const std::string UNIT; 57 static const std::string SPHEROID; 58 static const std::string AXIS; // WKT2 too 59 static const std::string PRIMEM; // WKT2 too 60 static const std::string AUTHORITY; 61 static const std::string PROJCS; 62 static const std::string PROJECTION; 63 static const std::string PARAMETER; // WKT2 too 64 static const std::string VERT_CS; 65 static const std::string VERTCS; // WKT1 ESRI 66 static const std::string VERT_DATUM; 67 static const std::string COMPD_CS; 68 static const std::string TOWGS84; // WKT1 only 69 static const std::string EXTENSION; // WKT1 only - GDAL specific 70 static const std::string LOCAL_CS; // WKT1 only 71 static const std::string LOCAL_DATUM; // WKT1 only 72 73 // WKT2 preferred 74 static const std::string GEODCRS; 75 static const std::string LENGTHUNIT; 76 static const std::string ANGLEUNIT; 77 static const std::string SCALEUNIT; 78 static const std::string TIMEUNIT; 79 static const std::string ELLIPSOID; 80 // underscore, since there is a CS macro in Solaris system headers 81 static const std::string CS_; 82 static const std::string ID; 83 static const std::string PROJCRS; 84 static const std::string BASEGEODCRS; 85 static const std::string MERIDIAN; 86 static const std::string ORDER; 87 static const std::string ANCHOR; 88 static const std::string CONVERSION; 89 static const std::string METHOD; 90 static const std::string REMARK; 91 static const std::string GEOGCRS; // WKT2-2019 92 static const std::string BASEGEOGCRS; // WKT2-2019 93 static const std::string SCOPE; 94 static const std::string AREA; 95 static const std::string BBOX; 96 static const std::string CITATION; 97 static const std::string URI; 98 static const std::string VERTCRS; 99 static const std::string VDATUM; // WKT2 and WKT1 ESRI 100 static const std::string COMPOUNDCRS; 101 static const std::string PARAMETERFILE; 102 static const std::string COORDINATEOPERATION; 103 static const std::string SOURCECRS; 104 static const std::string TARGETCRS; 105 static const std::string INTERPOLATIONCRS; 106 static const std::string OPERATIONACCURACY; 107 static const std::string CONCATENATEDOPERATION; // WKT2-2019 108 static const std::string STEP; // WKT2-2019 109 static const std::string BOUNDCRS; 110 static const std::string ABRIDGEDTRANSFORMATION; 111 static const std::string DERIVINGCONVERSION; 112 static const std::string TDATUM; 113 static const std::string CALENDAR; // WKT2-2019 114 static const std::string TIMEORIGIN; 115 static const std::string TIMECRS; 116 static const std::string VERTICALEXTENT; 117 static const std::string TIMEEXTENT; 118 static const std::string USAGE; // WKT2-2019 119 static const std::string DYNAMIC; // WKT2-2019 120 static const std::string FRAMEEPOCH; // WKT2-2019 121 static const std::string MODEL; // WKT2-2019 122 static const std::string VELOCITYGRID; // WKT2-2019 123 static const std::string ENSEMBLE; // WKT2-2019 124 static const std::string MEMBER; // WKT2-2019 125 static const std::string ENSEMBLEACCURACY; // WKT2-2019 126 static const std::string DERIVEDPROJCRS; // WKT2-2019 127 static const std::string BASEPROJCRS; // WKT2-2019 128 static const std::string EDATUM; 129 static const std::string ENGCRS; 130 static const std::string PDATUM; 131 static const std::string PARAMETRICCRS; 132 static const std::string PARAMETRICUNIT; 133 static const std::string BASEVERTCRS; 134 static const std::string BASEENGCRS; 135 static const std::string BASEPARAMCRS; 136 static const std::string BASETIMECRS; 137 static const std::string VERSION; 138 static const std::string GEOIDMODEL; // WKT2-2019 139 140 // WKT2 alternate (longer or shorter) 141 static const std::string GEODETICCRS; 142 static const std::string GEODETICDATUM; 143 static const std::string PROJECTEDCRS; 144 static const std::string PRIMEMERIDIAN; 145 static const std::string GEOGRAPHICCRS; // WKT2-2019 146 static const std::string TRF; // WKT2-2019 147 static const std::string VERTICALCRS; 148 static const std::string VERTICALDATUM; 149 static const std::string VRF; // WKT2-2019 150 static const std::string TIMEDATUM; 151 static const std::string TEMPORALQUANTITY; 152 static const std::string ENGINEERINGDATUM; 153 static const std::string ENGINEERINGCRS; 154 static const std::string PARAMETRICDATUM; 155 constants()156 static const std::vector<std::string> &constants() { return constants_; } 157 158 private: 159 static std::vector<std::string> constants_; 160 static const char *createAndAddToConstantList(const char *text); 161 }; 162 163 } // namespace io 164 165 NS_PROJ_END 166 167 // --------------------------------------------------------------------------- 168 169 /** Auxiliary structure to PJ_CONTEXT storing C++ context stuff. */ 170 struct projCppContext { 171 private: 172 NS_PROJ::io::DatabaseContextPtr databaseContext_{}; 173 PJ_CONTEXT *ctx_ = nullptr; 174 std::string dbPath_{}; 175 std::vector<std::string> auxDbPaths_{}; 176 bool autoCloseDb_ = false; 177 178 projCppContext(const projCppContext &) = delete; 179 projCppContext &operator=(const projCppContext &) = delete; 180 181 public: 182 std::string lastDbPath_{}; 183 std::string lastDbMetadataItem_{}; 184 std::string lastUOMName_{}; 185 std::string lastGridFullName_{}; 186 std::string lastGridPackageName_{}; 187 std::string lastGridUrl_{}; 188 189 static std::vector<std::string> toVector(const char *const *auxDbPaths); 190 191 explicit projCppContext(PJ_CONTEXT *ctx, const char *dbPath = nullptr, 192 const std::vector<std::string> &auxDbPaths = {}); 193 194 projCppContext *clone(PJ_CONTEXT *ctx) const; 195 196 // cppcheck-suppress functionStatic getDbPathprojCppContext197 inline const std::string &getDbPath() const { return dbPath_; } 198 199 // cppcheck-suppress functionStatic getAuxDbPathsprojCppContext200 inline const std::vector<std::string> &getAuxDbPaths() const { 201 return auxDbPaths_; 202 } 203 setAutoCloseDbprojCppContext204 void setAutoCloseDb(bool autoClose) { autoCloseDb_ = autoClose; } getAutoCloseDbprojCppContext205 inline bool getAutoCloseDb() const { return autoCloseDb_; } 206 207 // cppcheck-suppress functionStatic 208 void closeDb(); 209 210 void autoCloseDbIfNeeded(); 211 212 NS_PROJ::io::DatabaseContextNNPtr getDatabaseContext(); 213 }; 214 215 //! @endcond 216 217 #endif // IO_INTERNAL_HH_INCLUDED 218