From ed462b39fb7d9b92a75a069da707f2b7921b2820 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 21 Jan 2019 19:31:02 +0100 Subject: proj_create_crs_to_crs(): defer selection of actual coordinate operation until proj_trans() is called (fixes #1229) --- src/proj_internal.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'src/proj_internal.h') diff --git a/src/proj_internal.h b/src/proj_internal.h index b97afdec..f5196939 100644 --- a/src/proj_internal.h +++ b/src/proj_internal.h @@ -60,6 +60,7 @@ #include "proj/common.hpp" #include "proj/coordinateoperation.hpp" + #include #include @@ -518,6 +519,50 @@ struct PJconsts { mutable bool gridsNeededAsked = false; mutable std::vector gridsNeeded{}; + /************************************************************************************* + 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{}; + + CoordOperation(double minxSrcIn, double minySrcIn, double maxxSrcIn, double maxySrcIn, + double minxDstIn, double minyDstIn, double maxxDstIn, double maxyDstIn, + PJ* pjIn, const std::string& nameIn): + minxSrc(minxSrcIn), minySrc(minySrcIn), maxxSrc(maxxSrcIn), maxySrc(maxySrcIn), + minxDst(minxDstIn), minyDst(minyDstIn), maxxDst(maxxDstIn), maxyDst(maxyDstIn), + pj(pjIn), name(nameIn) {} + + 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)) { + pj = other.pj; + other.pj = nullptr; + } + + CoordOperation& operator=(const CoordOperation&) = delete; + + ~CoordOperation() + { + proj_destroy(pj); + } + }; + std::vector alternativeCoordinateOperations{}; + int iCurCoordOp = -1; + /************************************************************************************* E N D O F G E N E R A L P A R A M E T E R S T R U C T -- cgit v1.2.3