aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/iso19111/factory.cpp21
-rw-r--r--src/iso19111/io.cpp15
-rw-r--r--src/iso19111/operation/concatenatedoperation.cpp24
-rw-r--r--src/iso19111/operation/projbasedoperation.cpp16
-rw-r--r--src/projections/moll.cpp2
5 files changed, 49 insertions, 29 deletions
diff --git a/src/iso19111/factory.cpp b/src/iso19111/factory.cpp
index 52c3f82b..a5162ab2 100644
--- a/src/iso19111/factory.cpp
+++ b/src/iso19111/factory.cpp
@@ -252,7 +252,7 @@ class SQLiteHandle {
}
// cppcheck-suppress functionStatic
- void registerFunctions();
+ void initialize();
SQLResultSet run(const std::string &sql,
const ListOfParams &parameters = ListOfParams(),
@@ -344,7 +344,7 @@ std::shared_ptr<SQLiteHandle> SQLiteHandle::open(PJ_CONTEXT *ctx,
#ifdef ENABLE_CUSTOM_LOCKLESS_VFS
handle->vfs_ = std::move(vfs);
#endif
- handle->registerFunctions();
+ handle->initialize();
handle->checkDatabaseLayout(path, path, std::string());
return handle;
}
@@ -359,7 +359,7 @@ SQLiteHandle::initFromExisting(sqlite3 *sqlite_handle, bool close_handle,
new SQLiteHandle(sqlite_handle, close_handle));
handle->nLayoutVersionMajor_ = nLayoutVersionMajor;
handle->nLayoutVersionMinor_ = nLayoutVersionMinor;
- handle->registerFunctions();
+ handle->initialize();
return handle;
}
@@ -370,7 +370,7 @@ SQLiteHandle::initFromExistingUniquePtr(sqlite3 *sqlite_handle,
bool close_handle) {
auto handle = std::unique_ptr<SQLiteHandle>(
new SQLiteHandle(sqlite_handle, close_handle));
- handle->registerFunctions();
+ handle->initialize();
return handle;
}
@@ -547,7 +547,18 @@ void SQLiteHandle::checkDatabaseLayout(const std::string &mainDbPath,
#define SQLITE_DETERMINISTIC 0
#endif
-void SQLiteHandle::registerFunctions() {
+void SQLiteHandle::initialize() {
+
+ // There is a bug in sqlite 3.38.0 with some complex queries.
+ // Cf https://github.com/OSGeo/PROJ/issues/3077
+ // Disabling Bloom-filter pull-down optimization as suggested in
+ // https://sqlite.org/forum/forumpost/7d3a75438c
+ const int sqlite3VersionNumber = sqlite3_libversion_number();
+ if (sqlite3VersionNumber == 3 * 1000000 + 38 * 1000) {
+ sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, sqlite_handle_,
+ 0x100000);
+ }
+
sqlite3_create_function(sqlite_handle_, "pseudo_area_from_swne", 4,
SQLITE_UTF8 | SQLITE_DETERMINISTIC, nullptr,
PROJ_SQLITE_pseudo_area_from_swne, nullptr,
diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp
index b7f26fe5..d4c6aec1 100644
--- a/src/iso19111/io.cpp
+++ b/src/iso19111/io.cpp
@@ -4341,10 +4341,10 @@ createBoundCRSSourceTransformationCRS(const crs::CRSPtr &sourceCRS,
sourceCRS->extractGeographicCRS();
sourceTransformationCRS = sourceGeographicCRS;
if (sourceGeographicCRS) {
- if (sourceGeographicCRS->datum() != nullptr &&
- sourceGeographicCRS->primeMeridian()
- ->longitude()
- .getSIValue() != 0.0) {
+ const auto &sourceDatum = sourceGeographicCRS->datum();
+ if (sourceDatum != nullptr && sourceGeographicCRS->primeMeridian()
+ ->longitude()
+ .getSIValue() != 0.0) {
sourceTransformationCRS =
GeographicCRS::create(
util::PropertyMap().set(
@@ -4354,13 +4354,12 @@ createBoundCRSSourceTransformationCRS(const crs::CRSPtr &sourceCRS,
datum::GeodeticReferenceFrame::create(
util::PropertyMap().set(
common::IdentifiedObject::NAME_KEY,
- sourceGeographicCRS->datum()->nameStr() +
+ sourceDatum->nameStr() +
" (with Greenwich prime meridian)"),
- sourceGeographicCRS->datum()->ellipsoid(),
+ sourceDatum->ellipsoid(),
util::optional<std::string>(),
datum::PrimeMeridian::GREENWICH),
- cs::EllipsoidalCS::createLatitudeLongitude(
- common::UnitOfMeasure::DEGREE))
+ sourceGeographicCRS->coordinateSystem())
.as_nullable();
}
} else {
diff --git a/src/iso19111/operation/concatenatedoperation.cpp b/src/iso19111/operation/concatenatedoperation.cpp
index 7da561b4..e5728c4c 100644
--- a/src/iso19111/operation/concatenatedoperation.cpp
+++ b/src/iso19111/operation/concatenatedoperation.cpp
@@ -276,14 +276,28 @@ void ConcatenatedOperation::fixStepsDirection(
}
}
+ const auto extractDerivedCRS =
+ [](const crs::CRS *crs) -> const crs::DerivedCRS * {
+ auto derivedCRS = dynamic_cast<const crs::DerivedCRS *>(crs);
+ if (derivedCRS)
+ return derivedCRS;
+ auto compoundCRS = dynamic_cast<const crs::CompoundCRS *>(crs);
+ if (compoundCRS) {
+ derivedCRS = dynamic_cast<const crs::DerivedCRS *>(
+ compoundCRS->componentReferenceSystems().front().get());
+ if (derivedCRS)
+ return derivedCRS;
+ }
+ return nullptr;
+ };
+
for (size_t i = 0; i < operationsInOut.size(); ++i) {
auto &op = operationsInOut[i];
auto l_sourceCRS = op->sourceCRS();
auto l_targetCRS = op->targetCRS();
auto conv = dynamic_cast<const Conversion *>(op.get());
if (conv && i == 0 && !l_sourceCRS && !l_targetCRS) {
- if (auto derivedCRS = dynamic_cast<const crs::DerivedCRS *>(
- concatOpSourceCRS.get())) {
+ if (auto derivedCRS = extractDerivedCRS(concatOpSourceCRS.get())) {
if (i + 1 < operationsInOut.size()) {
// use the sourceCRS of the next operation as our target CRS
l_targetCRS = operationsInOut[i + 1]->sourceCRS();
@@ -323,8 +337,7 @@ void ConcatenatedOperation::fixStepsDirection(
}
} else if (conv && i + 1 == operationsInOut.size() && !l_sourceCRS &&
!l_targetCRS) {
- auto derivedCRS =
- dynamic_cast<const crs::DerivedCRS *>(concatOpTargetCRS.get());
+ auto derivedCRS = extractDerivedCRS(concatOpTargetCRS.get());
if (derivedCRS) {
if (i >= 1) {
// use the sourceCRS of the previous operation as our source
@@ -350,8 +363,7 @@ void ConcatenatedOperation::fixStepsDirection(
} else if (i >= 1) {
l_sourceCRS = operationsInOut[i - 1]->targetCRS();
if (l_sourceCRS) {
- derivedCRS = dynamic_cast<const crs::DerivedCRS *>(
- l_sourceCRS.get());
+ derivedCRS = extractDerivedCRS(l_sourceCRS.get());
if (derivedCRS &&
conv->isEquivalentTo(
derivedCRS->derivingConversion().get(),
diff --git a/src/iso19111/operation/projbasedoperation.cpp b/src/iso19111/operation/projbasedoperation.cpp
index 6e0fd109..fd03fc09 100644
--- a/src/iso19111/operation/projbasedoperation.cpp
+++ b/src/iso19111/operation/projbasedoperation.cpp
@@ -232,15 +232,13 @@ void PROJBasedOperation::_exportToJSON(
method()->_exportToJSON(formatter);
const auto &l_parameterValues = parameterValues();
- if (!l_parameterValues.empty()) {
- writer->AddObjKey("parameters");
- {
- auto parametersContext(writer->MakeArrayContext(false));
- for (const auto &genOpParamvalue : l_parameterValues) {
- formatter->setAllowIDInImmediateChild();
- formatter->setOmitTypeInImmediateChild();
- genOpParamvalue->_exportToJSON(formatter);
- }
+ writer->AddObjKey("parameters");
+ {
+ auto parametersContext(writer->MakeArrayContext(false));
+ for (const auto &genOpParamvalue : l_parameterValues) {
+ formatter->setAllowIDInImmediateChild();
+ formatter->setOmitTypeInImmediateChild();
+ genOpParamvalue->_exportToJSON(formatter);
}
}
}
diff --git a/src/projections/moll.cpp b/src/projections/moll.cpp
index 87b38336..f8b52a5f 100644
--- a/src/projections/moll.cpp
+++ b/src/projections/moll.cpp
@@ -10,7 +10,7 @@ PROJ_HEAD(moll, "Mollweide") "\n\tPCyl, Sph";
PROJ_HEAD(wag4, "Wagner IV") "\n\tPCyl, Sph";
PROJ_HEAD(wag5, "Wagner V") "\n\tPCyl, Sph";
-#define MAX_ITER 10
+#define MAX_ITER 30
#define LOOP_TOL 1e-7
namespace { // anonymous namespace