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

Add correctly named createTunisiaMiningGrid() / proj_create_conversion_tunisia_mining_grid()… #3559

Merged
merged 1 commit into from
Jan 16, 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
5 changes: 5 additions & 0 deletions include/proj/coordinateoperation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,11 @@ class PROJ_GCC_DLL Conversion : public SingleOperation {
const common::Angle &centerLong, const common::Length &falseEasting,
const common::Length &falseNorthing);

PROJ_DLL static ConversionNNPtr createTunisiaMiningGrid(
const util::PropertyMap &properties, const common::Angle &centerLat,
const common::Angle &centerLong, const common::Length &falseEasting,
const common::Length &falseNorthing);

PROJ_DLL static ConversionNNPtr
createAlbersEqualArea(const util::PropertyMap &properties,
const common::Angle &latitudeFalseOrigin,
Expand Down
2 changes: 2 additions & 0 deletions scripts/reference_exported_symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ osgeo::proj::operation::Conversion::createStereographic(osgeo::proj::util::Prope
osgeo::proj::operation::Conversion::createTransverseMercator(osgeo::proj::util::PropertyMap const&, osgeo::proj::common::Angle const&, osgeo::proj::common::Angle const&, osgeo::proj::common::Scale const&, osgeo::proj::common::Length const&, osgeo::proj::common::Length const&)
osgeo::proj::operation::Conversion::createTransverseMercatorSouthOriented(osgeo::proj::util::PropertyMap const&, osgeo::proj::common::Angle const&, osgeo::proj::common::Angle const&, osgeo::proj::common::Scale const&, osgeo::proj::common::Length const&, osgeo::proj::common::Length const&)
osgeo::proj::operation::Conversion::createTunisiaMappingGrid(osgeo::proj::util::PropertyMap const&, osgeo::proj::common::Angle const&, osgeo::proj::common::Angle const&, osgeo::proj::common::Length const&, osgeo::proj::common::Length const&)
osgeo::proj::operation::Conversion::createTunisiaMiningGrid(osgeo::proj::util::PropertyMap const&, osgeo::proj::common::Angle const&, osgeo::proj::common::Angle const&, osgeo::proj::common::Length const&, osgeo::proj::common::Length const&)
osgeo::proj::operation::Conversion::createTwoPointEquidistant(osgeo::proj::util::PropertyMap const&, osgeo::proj::common::Angle const&, osgeo::proj::common::Angle const&, osgeo::proj::common::Angle const&, osgeo::proj::common::Angle const&, osgeo::proj::common::Length const&, osgeo::proj::common::Length const&)
osgeo::proj::operation::Conversion::createUTM(osgeo::proj::util::PropertyMap const&, int, bool)
osgeo::proj::operation::Conversion::createVanDerGrinten(osgeo::proj::util::PropertyMap const&, osgeo::proj::common::Angle const&, osgeo::proj::common::Length const&, osgeo::proj::common::Length const&)
Expand Down Expand Up @@ -910,6 +911,7 @@ proj_create_conversion_stereographic
proj_create_conversion_transverse_mercator
proj_create_conversion_transverse_mercator_south_oriented
proj_create_conversion_tunisia_mapping_grid
proj_create_conversion_tunisia_mining_grid
proj_create_conversion_two_point_equidistant
proj_create_conversion_utm
proj_create_conversion_van_der_grinten
Expand Down
42 changes: 39 additions & 3 deletions src/iso19111/c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5046,13 +5046,49 @@ PJ *proj_create_conversion_two_point_equidistant(
// ---------------------------------------------------------------------------

/** \brief Instantiate a ProjectedCRS with a conversion based on the Tunisia
* Mapping Grid projection method.
* Mining Grid projection method.
*
* See osgeo::proj::operation::Conversion::createTunisiaMappingGrid().
* See osgeo::proj::operation::Conversion::createTunisiaMiningGrid().
*
* Linear parameters are expressed in (linear_unit_name,
* linear_unit_conv_factor).
* Angular parameters are expressed in (ang_unit_name, ang_unit_conv_factor).
*
* @deprecated. Replaced by proj_create_conversion_tunisia_mining_grid
*/
PJ *proj_create_conversion_tunisia_mining_grid(
PJ_CONTEXT *ctx, double center_lat, double center_long,
double false_easting, double false_northing, const char *ang_unit_name,
double ang_unit_conv_factor, const char *linear_unit_name,
double linear_unit_conv_factor) {
SANITIZE_CTX(ctx);
try {
UnitOfMeasure linearUnit(
createLinearUnit(linear_unit_name, linear_unit_conv_factor));
UnitOfMeasure angUnit(
createAngularUnit(ang_unit_name, ang_unit_conv_factor));
auto conv = Conversion::createTunisiaMiningGrid(
PropertyMap(), Angle(center_lat, angUnit),
Angle(center_long, angUnit), Length(false_easting, linearUnit),
Length(false_northing, linearUnit));
return proj_create_conversion(ctx, conv);
} catch (const std::exception &e) {
proj_log_error(ctx, __FUNCTION__, e.what());
}
return nullptr;
}
// ---------------------------------------------------------------------------

/** \brief Instantiate a ProjectedCRS with a conversion based on the Tunisia
* Mining Grid projection method.
*
* See osgeo::proj::operation::Conversion::createTunisiaMiningGrid().
*
* Linear parameters are expressed in (linear_unit_name,
* linear_unit_conv_factor).
* Angular parameters are expressed in (ang_unit_name, ang_unit_conv_factor).
*
* @since 9.2
*/
PJ *proj_create_conversion_tunisia_mapping_grid(
PJ_CONTEXT *ctx, double center_lat, double center_long,
Expand All @@ -5065,7 +5101,7 @@ PJ *proj_create_conversion_tunisia_mapping_grid(
createLinearUnit(linear_unit_name, linear_unit_conv_factor));
UnitOfMeasure angUnit(
createAngularUnit(ang_unit_name, ang_unit_conv_factor));
auto conv = Conversion::createTunisiaMappingGrid(
auto conv = Conversion::createTunisiaMiningGrid(
PropertyMap(), Angle(center_lat, angUnit),
Angle(center_long, angUnit), Length(false_easting, linearUnit),
Length(false_northing, linearUnit));
Expand Down
39 changes: 35 additions & 4 deletions src/iso19111/operation/conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,13 +484,43 @@ Conversion::createTwoPointEquidistant(const util::PropertyMap &properties,
* @param falseEasting See \ref false_easting
* @param falseNorthing See \ref false_northing
* @return a new Conversion.
* @deprecated. Use createTunisiaMiningGrid() instead
*/
ConversionNNPtr Conversion::createTunisiaMappingGrid(
const util::PropertyMap &properties, const common::Angle &centerLat,
const common::Angle &centerLong, const common::Length &falseEasting,
const common::Length &falseNorthing) {
return create(
properties, EPSG_CODE_METHOD_TUNISIA_MAPPING_GRID,
properties, EPSG_CODE_METHOD_TUNISIA_MINING_GRID,
createParams(centerLat, centerLong, falseEasting, falseNorthing));
}

// ---------------------------------------------------------------------------

/** \brief Instantiate a conversion based on the Tunisia Mining Grid projection
* method.
*
* This method is defined as
* <a href="https://epsg.org/coord-operation-method_9816/index.html">
* EPSG:9816</a>.
*
* \note There is currently no implementation of the method formulas in PROJ.
*
* @param properties See \ref general_properties of the conversion. If the name
* is not provided, it is automatically set.
* @param centerLat See \ref center_latitude
* @param centerLong See \ref center_longitude
* @param falseEasting See \ref false_easting
* @param falseNorthing See \ref false_northing
* @return a new Conversion.
* @since 9.2
*/
ConversionNNPtr Conversion::createTunisiaMiningGrid(
const util::PropertyMap &properties, const common::Angle &centerLat,
const common::Angle &centerLong, const common::Length &falseEasting,
const common::Length &falseNorthing) {
return create(
properties, EPSG_CODE_METHOD_TUNISIA_MINING_GRID,
createParams(centerLat, centerLong, falseEasting, falseNorthing));
}

Expand Down Expand Up @@ -1629,9 +1659,10 @@ ConversionNNPtr Conversion::createMercatorVariantA(
* <a href="../../../operations/projections/merc.html">
* Mercator (variant B)</a> projection method.
*
* This is the B variant, also known as Mercator (2SP), defined with the latitude
* of the first standard parallel (the second standard parallel is implicitly
* the opposite value). The latitude of natural origin is fixed to zero.
* This is the B variant, also known as Mercator (2SP), defined with the
* latitude of the first standard parallel (the second standard parallel is
* implicitly the opposite value). The latitude of natural origin is fixed to
* zero.
*
* This method is defined as
* <a href="https://epsg.org/coord-operation-method_9805/index.html">
Expand Down
8 changes: 7 additions & 1 deletion src/iso19111/operation/parammappings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,12 @@ static const MethodMapping projectionMethodMappings[] = {
{PROJ_WKT2_NAME_METHOD_TWO_POINT_EQUIDISTANT, 0, "Two_Point_Equidistant",
"tpeqd", nullptr, paramsTPEQD},

{EPSG_NAME_METHOD_TUNISIA_MINING_GRID, EPSG_CODE_METHOD_TUNISIA_MINING_GRID,
"Tunisia_Mining_Grid", nullptr,
nullptr, // no proj equivalent
paramsTMG},

// Deprecated. Use EPSG_NAME_METHOD_TUNISIA_MINING_GRID instead
{EPSG_NAME_METHOD_TUNISIA_MAPPING_GRID,
EPSG_CODE_METHOD_TUNISIA_MAPPING_GRID, "Tunisia_Mapping_Grid", nullptr,
nullptr, // no proj equivalent
Expand Down Expand Up @@ -898,7 +904,7 @@ const struct MethodNameCode methodNameCodes[] = {
METHOD_NAME_CODE(TRANSVERSE_MERCATOR_SOUTH_ORIENTATED),
METHOD_NAME_CODE(LAMBERT_CONIC_CONFORMAL_1SP),
METHOD_NAME_CODE(NZMG),
METHOD_NAME_CODE(TUNISIA_MAPPING_GRID),
METHOD_NAME_CODE(TUNISIA_MINING_GRID),
METHOD_NAME_CODE(ALBERS_EQUAL_AREA),
METHOD_NAME_CODE(LAMBERT_CONIC_CONFORMAL_2SP),
METHOD_NAME_CODE(LAMBERT_CONIC_CONFORMAL_2SP_BELGIUM),
Expand Down
4 changes: 4 additions & 0 deletions src/proj_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@
#define EPSG_NAME_METHOD_NZMG "New Zealand Map Grid"
#define EPSG_CODE_METHOD_NZMG 9811

/* Deprecated because of wrong name. Use EPSG_xxx_METHOD_TUNISIA_MINING_GRID instead */
#define EPSG_NAME_METHOD_TUNISIA_MAPPING_GRID "Tunisia Mapping Grid"
#define EPSG_CODE_METHOD_TUNISIA_MAPPING_GRID 9816

#define EPSG_NAME_METHOD_TUNISIA_MINING_GRID "Tunisia Mining Grid"
#define EPSG_CODE_METHOD_TUNISIA_MINING_GRID 9816

#define EPSG_NAME_METHOD_ALBERS_EQUAL_AREA "Albers Equal Area"
#define EPSG_CODE_METHOD_ALBERS_EQUAL_AREA 9822

Expand Down
9 changes: 9 additions & 0 deletions src/proj_experimental.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,15 @@ PJ PROJ_DLL *proj_create_conversion_tunisia_mapping_grid(
const char* ang_unit_name, double ang_unit_conv_factor,
const char* linear_unit_name, double linear_unit_conv_factor);

PJ PROJ_DLL *proj_create_conversion_tunisia_mining_grid(
PJ_CONTEXT *ctx,
double center_lat,
double center_long,
double false_easting,
double false_northing,
const char* ang_unit_name, double ang_unit_conv_factor,
const char* linear_unit_name, double linear_unit_conv_factor);

PJ PROJ_DLL *proj_create_conversion_albers_equal_area(
PJ_CONTEXT *ctx,
double latitude_false_origin,
Expand Down
1 change: 1 addition & 0 deletions src/proj_symbol_rename.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
#define proj_create_conversion_transverse_mercator internal_proj_create_conversion_transverse_mercator
#define proj_create_conversion_transverse_mercator_south_oriented internal_proj_create_conversion_transverse_mercator_south_oriented
#define proj_create_conversion_tunisia_mapping_grid internal_proj_create_conversion_tunisia_mapping_grid
#define proj_create_conversion_tunisia_mining_grid internal_proj_create_conversion_tunisia_mining_grid
#define proj_create_conversion_two_point_equidistant internal_proj_create_conversion_two_point_equidistant
#define proj_create_conversion_utm internal_proj_create_conversion_utm
#define proj_create_conversion_van_der_grinten internal_proj_create_conversion_van_der_grinten
Expand Down
2 changes: 1 addition & 1 deletion test/unit/test_c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2648,7 +2648,7 @@ TEST_F(CApi, proj_create_projections) {
ASSERT_NE(projCRS, nullptr);
}
{
auto projCRS = proj_create_conversion_tunisia_mapping_grid(
auto projCRS = proj_create_conversion_tunisia_mining_grid(
m_ctxt, 0, 0, 0, 0, "Degree", 0.0174532925199433, "Metre", 1.0);
ObjectKeeper keeper_projCRS(projCRS);
ASSERT_NE(projCRS, nullptr);
Expand Down
8 changes: 4 additions & 4 deletions test/unit/test_operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1455,16 +1455,16 @@ TEST(operation, tped_export) {
// ---------------------------------------------------------------------------

TEST(operation, tmg_export) {
auto conv = Conversion::createTunisiaMappingGrid(
auto conv = Conversion::createTunisiaMiningGrid(
PropertyMap(), Angle(1), Angle(2), Length(3), Length(4));
EXPECT_TRUE(conv->validateParameters().empty());

EXPECT_THROW(conv->exportToPROJString(PROJStringFormatter::create().get()),
FormattingException);

EXPECT_EQ(conv->exportToWKT(WKTFormatter::create().get()),
"CONVERSION[\"Tunisia Mapping Grid\",\n"
" METHOD[\"Tunisia Mapping Grid\",\n"
"CONVERSION[\"Tunisia Mining Grid\",\n"
" METHOD[\"Tunisia Mining Grid\",\n"
" ID[\"EPSG\",9816]],\n"
" PARAMETER[\"Latitude of false origin\",1,\n"
" ANGLEUNIT[\"degree\",0.0174532925199433],\n"
Expand All @@ -1482,7 +1482,7 @@ TEST(operation, tmg_export) {
EXPECT_EQ(
conv->exportToWKT(
WKTFormatter::create(WKTFormatter::Convention::WKT1_GDAL).get()),
"PROJECTION[\"Tunisia_Mapping_Grid\"],\n"
"PROJECTION[\"Tunisia_Mining_Grid\"],\n"
"PARAMETER[\"latitude_of_origin\",1],\n"
"PARAMETER[\"central_meridian\",2],\n"
"PARAMETER[\"false_easting\",3],\n"
Expand Down