-
Notifications
You must be signed in to change notification settings - Fork 807
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dispatch content of 4D_api.cpp into multiple .cpp files, and rename t…
…he remainder as misc.cpp No functional change, just moving code around. 4D_api.cpp has become quite large and a set of 'random' things, that didn't correlate well with the '4D' naming. Some re-organization was needed. Create following files: - src/area.cpp: PJ_AREA related code - src/coord_operation.cpp: PJCoordOperation methods - src/create.cpp: pj_create_internal() related stuff - src/crs_to_crs.cpp: proj_create_crs_to_crs() and the like - src/dist.cpp: distance related functions - src/info.cpp: proj_info() and proj_pj_info() - src/trans.cpp: proj_trans(), proj_trans_array(), proj_trans_generic(), proj_roundtrip() - src/trans_bounds.cpp: proj_trans_bounds() Some other functions also moved to more relevant existing source files.
- Loading branch information
Showing
17 changed files
with
3,378 additions
and
3,108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/****************************************************************************** | ||
* Project: PROJ | ||
* Purpose: PJ_AREA related code | ||
* | ||
* Author: Thomas Knudsen, thokn@sdfe.dk, 2016-06-09/2016-11-06 | ||
* | ||
****************************************************************************** | ||
* Copyright (c) 2016, 2017 Thomas Knudsen/SDFE | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a | ||
* copy of this software and associated documentation files (the "Software"), | ||
* to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
* and/or sell copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
* DEALINGS IN THE SOFTWARE. | ||
*****************************************************************************/ | ||
|
||
#define FROM_PROJ_CPP | ||
|
||
#include "proj.h" | ||
#include "proj_internal.h" | ||
|
||
/** Create an area of use */ | ||
PJ_AREA *proj_area_create(void) { return new PJ_AREA(); } | ||
|
||
/** Assign a bounding box to an area of use. */ | ||
void proj_area_set_bbox(PJ_AREA *area, double west_lon_degree, | ||
double south_lat_degree, double east_lon_degree, | ||
double north_lat_degree) { | ||
area->bbox_set = TRUE; | ||
area->west_lon_degree = west_lon_degree; | ||
area->south_lat_degree = south_lat_degree; | ||
area->east_lon_degree = east_lon_degree; | ||
area->north_lat_degree = north_lat_degree; | ||
} | ||
|
||
/** Assign the name of an area of use. */ | ||
void proj_area_set_name(PJ_AREA *area, const char *name) { area->name = name; } | ||
|
||
/** Free an area of use */ | ||
void proj_area_destroy(PJ_AREA *area) { delete area; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/****************************************************************************** | ||
* Project: PROJ | ||
* Purpose: PJCoordOperation methods | ||
* | ||
* Author: Even Rouault, <even.rouault at spatialys.com> | ||
* | ||
****************************************************************************** | ||
* Copyright (c) 2018-2024, Even Rouault, <even.rouault at spatialys.com> | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a | ||
* copy of this software and associated documentation files (the "Software"), | ||
* to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
* and/or sell copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included | ||
* in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
* DEALINGS IN THE SOFTWARE. | ||
*****************************************************************************/ | ||
|
||
#define FROM_PROJ_CPP | ||
|
||
#include "proj.h" | ||
#include "proj_internal.h" | ||
#include <math.h> | ||
|
||
#include "proj/internal/internal.hpp" | ||
|
||
using namespace NS_PROJ::internal; | ||
|
||
//! @cond Doxygen_Suppress | ||
/**************************************************************************************/ | ||
PJCoordOperation::~PJCoordOperation() { | ||
/**************************************************************************************/ | ||
proj_destroy(pj); | ||
proj_destroy(pjSrcGeocentricToLonLat); | ||
proj_destroy(pjDstGeocentricToLonLat); | ||
} | ||
|
||
/**************************************************************************************/ | ||
bool PJCoordOperation::isInstantiable() const { | ||
/**************************************************************************************/ | ||
if (isInstantiableCached == INSTANTIABLE_STATUS_UNKNOWN) | ||
isInstantiableCached = proj_coordoperation_is_instantiable(pj->ctx, pj); | ||
return (isInstantiableCached == 1); | ||
} | ||
|
||
// Returns true if the passed operation uses NADCON5 grids for NAD83 to | ||
// NAD83(HARN) | ||
static bool isSpecialCaseForNAD83_to_NAD83HARN(const std::string &opName) { | ||
return opName.find("NAD83 to NAD83(HARN) (47)") != std::string::npos || | ||
opName.find("NAD83 to NAD83(HARN) (48)") != std::string::npos || | ||
opName.find("NAD83 to NAD83(HARN) (49)") != std::string::npos || | ||
opName.find("NAD83 to NAD83(HARN) (50)") != std::string::npos; | ||
} | ||
|
||
// Returns true if the passed operation uses "GDA94 to WGS 84 (1)", which | ||
// is the null transformation | ||
static bool isSpecialCaseForGDA94_to_WGS84(const std::string &opName) { | ||
return opName.find("GDA94 to WGS 84 (1)") != std::string::npos; | ||
} | ||
|
||
// Returns true if the passed operation uses "GDA2020 to WGS 84 (2)", which | ||
// is the null transformation | ||
static bool isSpecialCaseForWGS84_to_GDA2020(const std::string &opName) { | ||
return opName.find("GDA2020 to WGS 84 (2)") != std::string::npos; | ||
} | ||
|
||
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, 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), 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)), | ||
pjSrcGeocentricToLonLat(pjSrcGeocentricToLonLatIn | ||
? proj_clone(pjSrcGeocentricToLonLatIn->ctx, | ||
pjSrcGeocentricToLonLatIn) | ||
: nullptr), | ||
pjDstGeocentricToLonLat(pjDstGeocentricToLonLatIn | ||
? proj_clone(pjDstGeocentricToLonLatIn->ctx, | ||
pjDstGeocentricToLonLatIn) | ||
: nullptr) { | ||
const auto IsLonLatOrLatLon = [](const PJ *crs, bool &isLonLatDegreeOut, | ||
bool &isLatLonDegreeOut) { | ||
const auto eType = proj_get_type(crs); | ||
if (eType == PJ_TYPE_GEOGRAPHIC_2D_CRS || | ||
eType == PJ_TYPE_GEOGRAPHIC_3D_CRS) { | ||
const auto cs = proj_crs_get_coordinate_system(crs->ctx, crs); | ||
const char *direction = ""; | ||
double conv_factor = 0; | ||
constexpr double EPS = 1e-14; | ||
if (proj_cs_get_axis_info(crs->ctx, cs, 0, nullptr, nullptr, | ||
&direction, &conv_factor, nullptr, | ||
nullptr, nullptr) && | ||
ci_equal(direction, "East")) { | ||
isLonLatDegreeOut = fabs(conv_factor - M_PI / 180) < EPS; | ||
} else if (proj_cs_get_axis_info(crs->ctx, cs, 1, nullptr, nullptr, | ||
&direction, &conv_factor, nullptr, | ||
nullptr, nullptr) && | ||
ci_equal(direction, "East")) { | ||
isLatLonDegreeOut = fabs(conv_factor - M_PI / 180) < EPS; | ||
} | ||
proj_destroy(cs); | ||
} | ||
}; | ||
|
||
const auto source = proj_get_source_crs(pj->ctx, pj); | ||
if (source) { | ||
IsLonLatOrLatLon(source, srcIsLonLatDegree, srcIsLatLonDegree); | ||
proj_destroy(source); | ||
} | ||
|
||
const auto target = proj_get_target_crs(pj->ctx, pj); | ||
if (target) { | ||
IsLonLatOrLatLon(target, dstIsLonLatDegree, dstIsLatLonDegree); | ||
proj_destroy(target); | ||
} | ||
} | ||
|
||
//! @endcond |
Oops, something went wrong.