aboutsummaryrefslogtreecommitdiff
path: root/src/proj_internal.h
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-03-12 23:10:20 +0100
committerEven Rouault <even.rouault@spatialys.com>2020-03-13 08:45:56 +0100
commitf0d6b64fee8b796ec038929187b7b725f62a5ba8 (patch)
treeb32badffae5470b2f318d4a0a98cc27443bbd75a /src/proj_internal.h
parentca3caf0e976e95a739963567057654cb8909bfb9 (diff)
downloadPROJ-f0d6b64fee8b796ec038929187b7b725f62a5ba8.tar.gz
PROJ-f0d6b64fee8b796ec038929187b7b725f62a5ba8.zip
Add proj_get_suggested_operation()
Return the index of the operation that would be the most appropriate to transform the specified coordinates. This operation may use resources that are not locally available, depending on the search criteria used by proj_create_operations(). This could be done by using proj_create_operations() with a punctual bounding box, but this function is faster when one needs to evaluate on many points with the same (source_crs, target_crs) tuple.
Diffstat (limited to 'src/proj_internal.h')
-rw-r--r--src/proj_internal.h105
1 files changed, 59 insertions, 46 deletions
diff --git a/src/proj_internal.h b/src/proj_internal.h
index 8f73200d..f3e1e2e8 100644
--- a/src/proj_internal.h
+++ b/src/proj_internal.h
@@ -287,6 +287,55 @@ typedef PJ_COORD (* PJ_OPERATOR) (PJ_COORD, PJ *);
#define PJD_GRIDSHIFT 3
#define PJD_WGS84 4 /* WGS84 (or anything considered equivalent) */
+struct CoordOperation
+{
+ int idxInOriginalList;
+ double minxSrc = 0.0;
+ double minySrc = 0.0;
+ double maxxSrc = 0.0;
+ double maxySrc = 0.0;
+ double minxDst = 0.0;
+ double minyDst = 0.0;
+ double maxxDst = 0.0;
+ double maxyDst = 0.0;
+ PJ* pj = nullptr;
+ std::string name{};
+ double accuracy = -1.0;
+ bool isOffshore = false;
+
+ CoordOperation(int idxInOriginalListIn,
+ double minxSrcIn, double minySrcIn, double maxxSrcIn, double maxySrcIn,
+ double minxDstIn, double minyDstIn, double maxxDstIn, double maxyDstIn,
+ PJ* pjIn, const std::string& nameIn, double accuracyIn, bool isOffshoreIn):
+ idxInOriginalList(idxInOriginalListIn),
+ minxSrc(minxSrcIn), minySrc(minySrcIn), maxxSrc(maxxSrcIn), maxySrc(maxySrcIn),
+ minxDst(minxDstIn), minyDst(minyDstIn), maxxDst(maxxDstIn), maxyDst(maxyDstIn),
+ pj(pjIn), name(nameIn),
+ accuracy(accuracyIn),
+ isOffshore(isOffshoreIn)
+ {
+ }
+
+ CoordOperation(const CoordOperation&) = delete;
+
+ CoordOperation(CoordOperation&& other):
+ idxInOriginalList(other.idxInOriginalList),
+ minxSrc(other.minxSrc), minySrc(other.minySrc), maxxSrc(other.maxxSrc), maxySrc(other.maxySrc),
+ minxDst(other.minxDst), minyDst(other.minyDst), maxxDst(other.maxxDst), maxyDst(other.maxyDst),
+ name(std::move(other.name)),
+ accuracy(other.accuracy),
+ isOffshore(other.isOffshore) {
+ pj = other.pj;
+ other.pj = nullptr;
+ }
+
+ CoordOperation& operator=(const CoordOperation&) = delete;
+
+ ~CoordOperation()
+ {
+ proj_destroy(pj);
+ }
+};
/* base projection data structure */
struct PJconsts {
@@ -493,52 +542,6 @@ struct PJconsts {
/*************************************************************************************
proj_create_crs_to_crs() alternative coordinate operations
**************************************************************************************/
-
- struct CoordOperation
- {
- double minxSrc = 0.0;
- double minySrc = 0.0;
- double maxxSrc = 0.0;
- double maxySrc = 0.0;
- double minxDst = 0.0;
- double minyDst = 0.0;
- double maxxDst = 0.0;
- double maxyDst = 0.0;
- PJ* pj = nullptr;
- std::string name{};
- double accuracy = -1.0;
- bool isOffshore = false;
-
- CoordOperation(double minxSrcIn, double minySrcIn, double maxxSrcIn, double maxySrcIn,
- double minxDstIn, double minyDstIn, double maxxDstIn, double maxyDstIn,
- PJ* pjIn, const std::string& nameIn, double accuracyIn, bool isOffshoreIn):
- minxSrc(minxSrcIn), minySrc(minySrcIn), maxxSrc(maxxSrcIn), maxySrc(maxySrcIn),
- minxDst(minxDstIn), minyDst(minyDstIn), maxxDst(maxxDstIn), maxyDst(maxyDstIn),
- pj(pjIn), name(nameIn),
- accuracy(accuracyIn),
- isOffshore(isOffshoreIn)
- {
- }
-
- CoordOperation(const CoordOperation&) = delete;
-
- CoordOperation(CoordOperation&& other):
- minxSrc(other.minxSrc), minySrc(other.minySrc), maxxSrc(other.maxxSrc), maxySrc(other.maxySrc),
- minxDst(other.minxDst), minyDst(other.minyDst), maxxDst(other.maxxDst), maxyDst(other.maxyDst),
- name(std::move(other.name)),
- accuracy(other.accuracy),
- isOffshore(other.isOffshore) {
- pj = other.pj;
- other.pj = nullptr;
- }
-
- CoordOperation& operator=(const CoordOperation&) = delete;
-
- ~CoordOperation()
- {
- proj_destroy(pj);
- }
- };
std::vector<CoordOperation> alternativeCoordinateOperations{};
int iCurCoordOp = -1;
@@ -873,6 +876,16 @@ std::string PROJ_DLL pj_context_get_user_writable_directory(PJ_CONTEXT *ctx, boo
void PROJ_DLL pj_context_set_user_writable_directory(PJ_CONTEXT* ctx, const std::string& path);
std::string PROJ_DLL pj_get_relative_share_proj(PJ_CONTEXT *ctx);
+std::vector<CoordOperation> pj_create_prepared_operations(PJ_CONTEXT *ctx,
+ const PJ *source_crs,
+ const PJ *target_crs,
+ PJ_OBJ_LIST* op_list);
+int pj_get_suggested_operation(PJ_CONTEXT *ctx,
+ const std::vector<CoordOperation>& opList,
+ const int iExcluded[2],
+ PJ_DIRECTION direction,
+ PJ_COORD coord);
+
/* classic public API */
#include "proj_api.h"