aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2020-01-25 20:50:01 +0100
committerGitHub <noreply@github.com>2020-01-25 20:50:01 +0100
commitf02d83434bd27b882824642f5d4639646e01f77a (patch)
tree5f78a72c911387f824eaa4e8777b8f27c195ea49 /src
parentd3e133b23fdb73a3f663f903fa8b8ca53cdf570e (diff)
parentf201a86386b9c8fa183b3f9855a4087a9a800f4e (diff)
downloadPROJ-f02d83434bd27b882824642f5d4639646e01f77a.tar.gz
PROJ-f02d83434bd27b882824642f5d4639646e01f77a.zip
Merge pull request #1884 from rouault/cea_k_0
Fix ingestion of +proj=cea with +k_0
Diffstat (limited to 'src')
-rw-r--r--src/iso19111/io.cpp51
1 files changed, 36 insertions, 15 deletions
diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp
index d88581b4..0fc11f6f 100644
--- a/src/iso19111/io.cpp
+++ b/src/iso19111/io.cpp
@@ -8736,22 +8736,43 @@ CRSNNPtr PROJStringParser::Private::buildProjectedCRS(
} else if (param->unit_type == UnitOfMeasure::Type::SCALE) {
value = 1;
- } else {
- // For omerc, if gamma is missing, the default value is
- // alpha
- if (step.name == "omerc" && proj_name == "gamma") {
- paramValue = &getParamValue(step, "alpha");
- if (!paramValue->empty()) {
- value = getAngularValue(*paramValue);
+ }
+ // For omerc, if gamma is missing, the default value is
+ // alpha
+ else if (step.name == "omerc" && proj_name == "gamma") {
+ paramValue = &getParamValue(step, "alpha");
+ if (!paramValue->empty()) {
+ value = getAngularValue(*paramValue);
+ }
+ } else if (step.name == "krovak") {
+ if (param->epsg_code ==
+ EPSG_CODE_PARAMETER_COLATITUDE_CONE_AXIS) {
+ value = 30.28813975277777776;
+ } else if (
+ param->epsg_code ==
+ EPSG_CODE_PARAMETER_LATITUDE_PSEUDO_STANDARD_PARALLEL) {
+ value = 78.5;
+ }
+ } else if (step.name == "cea" && proj_name == "lat_ts") {
+ paramValue = &getParamValueK(step);
+ if (!paramValue->empty()) {
+ bool hasError = false;
+ const double k = getNumericValue(*paramValue, &hasError);
+ if (hasError) {
+ throw ParsingException("invalid value for k/k_0");
}
- } else if (step.name == "krovak") {
- if (param->epsg_code ==
- EPSG_CODE_PARAMETER_COLATITUDE_CONE_AXIS) {
- value = 30.28813975277777776;
- } else if (
- param->epsg_code ==
- EPSG_CODE_PARAMETER_LATITUDE_PSEUDO_STANDARD_PARALLEL) {
- value = 78.5;
+ if (k >= 0 && k <= 1) {
+ const double es =
+ geogCRS->ellipsoid()->squaredEccentricity();
+ if (es < 0) {
+ throw ParsingException("Invalid flattening");
+ }
+ value =
+ Angle(acos(k * sqrt((1 - es) / (1 - k * k * es))),
+ UnitOfMeasure::RADIAN)
+ .convertToUnit(UnitOfMeasure::DEGREE);
+ } else {
+ throw ParsingException("k/k_0 should be in [0,1]");
}
}
}