Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pj_get_suggested_operation(): tune it to give correct result for RGAF09 to RRAF 1991 / UTM zone 20N + Guadeloupe 1988 height transformation #3952

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions cmake/ProjTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
#

function(proj_test_set_properties TESTNAME)
set_property(TEST ${TESTNAME}
PROPERTY ENVIRONMENT
"PROJ_SKIP_READ_USER_WRITABLE_DIRECTORY=YES"
set(_env "PROJ_SKIP_READ_USER_WRITABLE_DIRECTORY=YES"
"PROJ_DATA=${PROJ_BINARY_DIR}/data/for_tests")
if(TIFF_ENABLED)
set(_env ${_env} "TIFF_ENABLED=YES")
else()
set(_env ${_env} "TIFF_ENABLED=NO")
endif()
set_property(TEST ${TESTNAME}
PROPERTY ENVIRONMENT ${_env})
endfunction()

function(proj_add_test_script_sh SH_NAME BIN_USE)
Expand Down
Binary file added data/tests/fr_ign_RAGTBT2016.tif
Binary file not shown.
21 changes: 12 additions & 9 deletions src/4D_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ int pj_get_suggested_operation(PJ_CONTEXT *,
// the one that has the smallest area
(alt.accuracy == bestAccuracy &&
alt.pseudoArea < opList[iBest].pseudoArea &&
!(alt.isUnknownAreaName &&
!opList[iBest].isUnknownAreaName) &&
!opList[iBest].isPriorityOp)) &&
!alt.isOffshore)) {

Expand Down Expand Up @@ -1693,7 +1695,7 @@ static PJ *add_coord_op_to_list(
int idxInOriginalList, PJ *op, double west_lon, double south_lat,
double east_lon, double north_lat, PJ *pjGeogToSrc, PJ *pjGeogToDst,
const PJ *pjSrcGeocentricToLonLat, const PJ *pjDstGeocentricToLonLat,
bool isOffshore, std::vector<PJCoordOperation> &altCoordOps) {
const char *areaName, std::vector<PJCoordOperation> &altCoordOps) {
/*****************************************************************************/

double minxSrc;
Expand Down Expand Up @@ -1742,8 +1744,8 @@ static PJ *add_coord_op_to_list(
const double accuracy = proj_coordoperation_get_accuracy(op->ctx, op);
altCoordOps.emplace_back(
idxInOriginalList, minxSrc, minySrc, maxxSrc, maxySrc, minxDst,
minyDst, maxxDst, maxyDst, op, name, accuracy, pseudoArea,
isOffshore, pjSrcGeocentricToLonLat, pjDstGeocentricToLonLat);
minyDst, maxxDst, maxyDst, op, name, accuracy, pseudoArea, areaName,
pjSrcGeocentricToLonLat, pjDstGeocentricToLonLat);
op = nullptr;
}
return op;
Expand Down Expand Up @@ -2018,23 +2020,22 @@ pj_create_prepared_operations(PJ_CONTEXT *ctx, const PJ *source_crs,
north_lat = 90;
}

const bool isOffshore = areaName && strstr(areaName, "- offshore");
if (west_lon <= east_lon) {
op = add_coord_op_to_list(
i, op, west_lon, south_lat, east_lon, north_lat,
pjGeogToSrc, pjGeogToDst, pjSrcGeocentricToLonLat,
pjDstGeocentricToLonLat, isOffshore, preparedOpList);
pjDstGeocentricToLonLat, areaName, preparedOpList);
} else {
auto op_clone = proj_clone(ctx, op);

op = add_coord_op_to_list(
i, op, west_lon, south_lat, 180, north_lat, pjGeogToSrc,
pjGeogToDst, pjSrcGeocentricToLonLat,
pjDstGeocentricToLonLat, isOffshore, preparedOpList);
pjDstGeocentricToLonLat, areaName, preparedOpList);
op_clone = add_coord_op_to_list(
i, op_clone, -180, south_lat, east_lon, north_lat,
pjGeogToSrc, pjGeogToDst, pjSrcGeocentricToLonLat,
pjDstGeocentricToLonLat, isOffshore, preparedOpList);
pjDstGeocentricToLonLat, areaName, preparedOpList);
proj_destroy(op_clone);
}

Expand Down Expand Up @@ -3019,13 +3020,15 @@ PJCoordOperation::PJCoordOperation(
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, double pseudoAreaIn, bool isOffshoreIn,
double accuracyIn, double pseudoAreaIn, const char *areaNameIn,
const PJ *pjSrcGeocentricToLonLatIn, const PJ *pjDstGeocentricToLonLatIn)
: idxInOriginalList(idxInOriginalListIn), minxSrc(minxSrcIn),
minySrc(minySrcIn), maxxSrc(maxxSrcIn), maxySrc(maxySrcIn),
minxDst(minxDstIn), minyDst(minyDstIn), maxxDst(maxxDstIn),
maxyDst(maxyDstIn), pj(pjIn), name(nameIn), accuracy(accuracyIn),
pseudoArea(pseudoAreaIn), isOffshore(isOffshoreIn),
pseudoArea(pseudoAreaIn), areaName(areaNameIn ? areaNameIn : ""),
isOffshore(areaName.find("- offshore") != std::string::npos),
isUnknownAreaName(areaName.empty() || areaName == "unknown"),
isPriorityOp(isSpecialCaseForNAD83_to_NAD83HARN(name) ||
isSpecialCaseForGDA94_to_WGS84(name) ||
isSpecialCaseForWGS84_to_GDA2020(name)),
Expand Down
2 changes: 1 addition & 1 deletion src/iso19111/c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9135,7 +9135,7 @@ PJ *proj_normalize_for_visualization(PJ_CONTEXT *ctx, const PJ *obj) {
alt.idxInOriginalList, minxSrc, minySrc, maxxSrc,
maxySrc, minxDst, minyDst, maxxDst, maxyDst,
pjNormalized, co->nameStr(), alt.accuracy,
alt.pseudoArea, alt.isOffshore,
alt.pseudoArea, alt.areaName.c_str(),
alt.pjSrcGeocentricToLonLat,
alt.pjDstGeocentricToLonLat);
}
Expand Down
16 changes: 11 additions & 5 deletions src/proj_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,9 @@ struct PJCoordOperation {
std::string name{};
double accuracy = -1.0;
double pseudoArea = 0.0;
std::string areaName{};
bool isOffshore = false;
bool isUnknownAreaName = false;
bool isPriorityOp = false;
bool srcIsLonLatDegree = false;
bool srcIsLatLonDegree = false;
Expand All @@ -364,8 +366,8 @@ struct PJCoordOperation {
double minySrcIn, double maxxSrcIn, double maxySrcIn,
double minxDstIn, double minyDstIn, double maxxDstIn,
double maxyDstIn, PJ *pjIn, const std::string &nameIn,
double accuracyIn, double pseudoAreaIn, bool isOffshoreIn,
const PJ *pjSrcGeocentricToLonLatIn,
double accuracyIn, double pseudoAreaIn,
const char *areaName, const PJ *pjSrcGeocentricToLonLatIn,
const PJ *pjDstGeocentricToLonLatIn);

PJCoordOperation(const PJCoordOperation &) = delete;
Expand All @@ -377,7 +379,9 @@ struct PJCoordOperation {
minyDst(other.minyDst), maxxDst(other.maxxDst),
maxyDst(other.maxyDst), pj(proj_clone(ctx, other.pj)),
name(std::move(other.name)), accuracy(other.accuracy),
pseudoArea(other.pseudoArea), isOffshore(other.isOffshore),
pseudoArea(other.pseudoArea), areaName(other.areaName),
isOffshore(other.isOffshore),
isUnknownAreaName(other.isUnknownAreaName),
isPriorityOp(other.isPriorityOp),
srcIsLonLatDegree(other.srcIsLonLatDegree),
srcIsLatLonDegree(other.srcIsLatLonDegree),
Expand All @@ -399,7 +403,9 @@ struct PJCoordOperation {
minyDst(other.minyDst), maxxDst(other.maxxDst),
maxyDst(other.maxyDst), name(std::move(other.name)),
accuracy(other.accuracy), pseudoArea(other.pseudoArea),
isOffshore(other.isOffshore), isPriorityOp(other.isPriorityOp),
areaName(std::move(other.areaName)), isOffshore(other.isOffshore),
isUnknownAreaName(other.isUnknownAreaName),
isPriorityOp(other.isPriorityOp),
srcIsLonLatDegree(other.srcIsLonLatDegree),
srcIsLatLonDegree(other.srcIsLatLonDegree),
dstIsLonLatDegree(other.dstIsLonLatDegree),
Expand All @@ -422,7 +428,7 @@ struct PJCoordOperation {
maxxDst == other.maxxDst && maxyDst == other.maxyDst &&
name == other.name &&
proj_is_equivalent_to(pj, other.pj, PJ_COMP_STRICT) &&
accuracy == other.accuracy && isOffshore == other.isOffshore;
accuracy == other.accuracy && areaName == other.areaName;
}

bool operator!=(const PJCoordOperation &other) const {
Expand Down
12 changes: 12 additions & 0 deletions test/cli/testvarious
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,18 @@ $EXE -d 3 +proj=topocentric +datum=WGS84 +X_0=-3982059.42 +Y_0=3331314.88 +Z_0=3
0 0 0
EOF

echo "##############################################################" >> ${OUT}
echo "Test cs2cs EPSG:5488 (RGAF09) to EPSG:4559+5757 (RRAF 1991 / UTM zone 20N + Guadeloupe 1988 height)" >> ${OUT}
echo "Check that we use the horizontal transformation for Guadeloupe (RRAF 1991 to RGAF09 (2)), and not the one for Martinique" >> ${OUT}
#
if test "${TIFF_ENABLED}" = "yes"; then
PROJ_DATA=${PROJ_DATA}:${PROJ_DATA}/tests $EXE -d 3 EPSG:5488 EPSG:4559+5757 >> ${OUT} <<EOF
16.248285304 -61.484212843 53.073
EOF
else
printf "661991.318\t1796999.201 93.846" >> ${OUT}
fi


# Done!
# do 'diff' with distribution results
Expand Down
4 changes: 4 additions & 0 deletions test/cli/tv_out.dist
Original file line number Diff line number Diff line change
Expand Up @@ -649,3 +649,7 @@ Test --t_epoch
##############################################################
Test +proj=topocentric +datum=WGS84 +X_0=-3982059.42 +Y_0=3331314.88 +Z_0=3692463.58 +no_defs +type=crs +to EPSG:4978
0 0 0 -3982059.420 3331314.880 3692463.580
##############################################################
Test cs2cs EPSG:5488 (RGAF09) to EPSG:4559+5757 (RRAF 1991 / UTM zone 20N + Guadeloupe 1988 height)
Check that we use the horizontal transformation for Guadeloupe (RRAF 1991 to RGAF09 (2)), and not the one for Martinique
661991.318 1796999.201 93.846
Loading