aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2019-01-18 07:10:42 +0100
committerGitHub <noreply@github.com>2019-01-18 07:10:42 +0100
commit8584dcd50777355b460b38418cae0db05dcf91bc (patch)
treeb7335182c91737ceda8518a638ac5a79bd2bc5b2 /include
parent3fc48e6146e020b86a0ef87749cc645f9b4fa113 (diff)
parent25f8ad123dc5fb7de0ac2fb10b55ae9efd2723a3 (diff)
downloadPROJ-8584dcd50777355b460b38418cae0db05dcf91bc.tar.gz
PROJ-8584dcd50777355b460b38418cae0db05dcf91bc.zip
Merge pull request #1223 from rouault/unify_proj_create
Unify proj_create(), proj_create_from_user_input() and proj_create_from_proj_string() (fixes #1214)
Diffstat (limited to 'include')
-rw-r--r--include/proj/internal/io_internal.hpp22
-rw-r--r--include/proj/io.hpp12
2 files changed, 33 insertions, 1 deletions
diff --git a/include/proj/internal/io_internal.hpp b/include/proj/internal/io_internal.hpp
index 62196fef..be6a11bd 100644
--- a/include/proj/internal/io_internal.hpp
+++ b/include/proj/internal/io_internal.hpp
@@ -36,6 +36,7 @@
#include <string>
#include <vector>
+#include "proj/io.hpp"
#include "proj/util.hpp"
//! @cond Doxygen_Suppress
@@ -159,6 +160,27 @@ class WKTConstants {
NS_PROJ_END
+// ---------------------------------------------------------------------------
+
+/** Auxiliary structure to PJ_CONTEXT storing C++ context stuff. */
+struct projCppContext {
+ NS_PROJ::io::DatabaseContextNNPtr databaseContext;
+ std::string lastUOMName_{};
+
+ explicit projCppContext(PJ_CONTEXT *ctx, const char *dbPath = nullptr,
+ const char *const *auxDbPaths = nullptr)
+ : databaseContext(NS_PROJ::io::DatabaseContext::create(
+ dbPath ? dbPath : std::string(), toVector(auxDbPaths), ctx)) {}
+
+ static std::vector<std::string> toVector(const char *const *auxDbPaths) {
+ std::vector<std::string> res;
+ for (auto iter = auxDbPaths; iter && *iter; ++iter) {
+ res.emplace_back(std::string(*iter));
+ }
+ return res;
+ }
+};
+
//! @endcond
#endif // IO_INTERNAL_HH_INCLUDED
diff --git a/include/proj/io.hpp b/include/proj/io.hpp
index ac951233..825e8e44 100644
--- a/include/proj/io.hpp
+++ b/include/proj/io.hpp
@@ -526,7 +526,9 @@ class PROJ_GCC_DLL IPROJStringExportable {
*
* <li>For PROJStringFormatter::Convention::PROJ_4, format a string
* compatible with the OGRSpatialReference::exportToProj4() of GDAL
- * &lt;=2.3.
+ * &lt;=2.3. It is only compatible of a few CRS objects. The PROJ string
+ * will also contain a +type=crs parameter to disambiguish the nature of
+ * the string from a CoordinateOperation.
* <ul>
* <li>For a crs::GeographicCRS, returns a proj=longlat string, with
* ellipsoid / datum / prime meridian information, ignoring axis order
@@ -600,6 +602,9 @@ createFromUserInput(const std::string &text,
const DatabaseContextPtr &dbContext,
bool usePROJ4InitRules = false);
+PROJ_DLL util::BaseObjectNNPtr createFromUserInput(const std::string &text,
+ PJ_CONTEXT *ctx);
+
// ---------------------------------------------------------------------------
/** \brief Parse a WKT string into the appropriate suclass of util::BaseObject.
@@ -662,6 +667,11 @@ class PROJ_GCC_DLL PROJStringParser {
PROJ_DLL util::BaseObjectNNPtr createFromPROJString(
const std::string &projString); // throw(ParsingException)
+ PROJ_PRIVATE :
+ //! @cond Doxygen_Suppress
+ PROJStringParser &
+ attachContext(PJ_CONTEXT *ctx);
+ //! @endcond
private:
PROJ_OPAQUE_PRIVATE_DATA
};