Skip to content

Commit

Permalink
Merge bf3c8c9 into e65df1f
Browse files Browse the repository at this point in the history
  • Loading branch information
kbevers committed Feb 11, 2019
2 parents e65df1f + bf3c8c9 commit b15383c
Show file tree
Hide file tree
Showing 19 changed files with 491 additions and 486 deletions.
32 changes: 0 additions & 32 deletions docs/source/operations/projections/etmerc.rst

This file was deleted.

Binary file not shown.
1 change: 0 additions & 1 deletion docs/source/operations/projections/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ Projections map the spherical 3D space to a flat 2D space.
eqdc
eqearth
euler
etmerc
fahey
fouc
fouc_s
Expand Down
10 changes: 8 additions & 2 deletions docs/source/operations/projections/tmerc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The transverse Mercator projection in its various forms is the most widely used
| **Defined area** | Global, but reasonably accurate only within 15 degrees |
| | of the central meridian |
+---------------------+----------------------------------------------------------+
| **Alias** | tmerc |
| **Alias** | tmerc, etmerc |
+---------------------+----------------------------------------------------------+
| **Domain** | 2D |
+---------------------+----------------------------------------------------------+
Expand Down Expand Up @@ -68,13 +68,19 @@ Example using Gauss-Kruger on Germany area (aka EPSG:31467) ::
Example using Gauss Boaga on Italy area (EPSG:3004) ::

$ echo 15 42 | proj +proj=tmerc +lat_0=0 +lon_0=15 +k_0=0.9996 +x_0=2520000 +y_0=0 +ellps=intl +units=m +no_defs
2520000.00 4649858.60
2520000.00 4649858.60

Parameters
################################################################################

.. note:: All parameters for the projection are optional.

.. option:: +approx

.. versionadded:: 6.0.0

Use faster, less accurate algorithm for the Transverse Mercator.

.. include:: ../options/lon_0.rst

.. include:: ../options/lat_0.rst
Expand Down
6 changes: 6 additions & 0 deletions docs/source/operations/projections/utm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ Required

Add this flag when using the UTM on the southern hemisphere.

.. option:: +approx

.. versionadded:: 6.0.0

Use faster, less accurate algorithm for the Transverse Mercator.

Optional
-------------------------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions include/proj/io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ class PROJ_GCC_DLL PROJStringFormatter {
PROJ_DLL ~PROJStringFormatter();
//! @endcond

PROJ_DLL void setUseETMercForTMerc(bool flag);
PROJ_DLL void setUseApproxTMerc(bool flag);

PROJ_DLL const std::string &toString() const;

Expand All @@ -378,7 +378,7 @@ class PROJ_GCC_DLL PROJStringFormatter {
PROJ_DLL void startInversion();
PROJ_DLL void stopInversion();
PROJ_INTERNAL bool isInverted() const;
PROJ_INTERNAL bool getUseETMercForTMerc(bool &settingSetOut) const;
PROJ_INTERNAL bool getUseApproxTMerc() const;
PROJ_INTERNAL void setCoordinateOperationOptimizations(bool enable);

PROJ_DLL void
Expand Down
1 change: 0 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ libproj_la_SOURCES = \
projections/wag7.cpp \
projections/lcca.cpp \
projections/geos.cpp \
projections/etmerc.cpp \
projections/boggs.cpp \
projections/collg.cpp \
projections/comill.cpp \
Expand Down
11 changes: 4 additions & 7 deletions src/iso19111/c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1205,9 +1205,8 @@ const char *proj_as_wkt(PJ_CONTEXT *ctx, const PJ *obj, PJ_WKT_TYPE type,
* @param type PROJ String version.
* @param options NULL-terminated list of strings with "KEY=VALUE" format. or
* NULL.
* The currently recognized option is USE_ETMERC=YES to use
* +proj=etmerc instead of +proj=tmerc (or USE_ETMERC=NO to disable implicit
* use of etmerc by utm conversions)
* The currently recognized option is USE_APPROX_TMERC=YES to add the +approx
* flag to +proj=tmerc or +proj=utm
* @return a string, or NULL in case of error.
*/
const char *proj_as_proj_string(PJ_CONTEXT *ctx, const PJ *obj,
Expand Down Expand Up @@ -1241,10 +1240,8 @@ const char *proj_as_proj_string(PJ_CONTEXT *ctx, const PJ *obj,
try {
auto formatter = PROJStringFormatter::create(convention, dbContext);
if (options != nullptr && options[0] != nullptr) {
if (ci_equal(options[0], "USE_ETMERC=YES")) {
formatter->setUseETMercForTMerc(true);
} else if (ci_equal(options[0], "USE_ETMERC=NO")) {
formatter->setUseETMercForTMerc(false);
if (ci_equal(options[0], "USE_APPROX_TMERC=YES")) {
formatter->setUseApproxTMerc(true);
}
}
obj->lastPROJString = exportable->exportToPROJString(formatter.get());
Expand Down
27 changes: 16 additions & 11 deletions src/iso19111/coordinateoperation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5381,13 +5381,11 @@ bool Conversion::addWKTExtensionNode(io::WKTFormatter *formatter) const {
const auto &l_method = method();
const auto &methodName = l_method->nameStr();
const int methodEPSGCode = l_method->getEPSGCode();
int zone = 0;
bool north = true;
if (l_method->getPrivate()->projMethodOverride_ == "etmerc" &&
!isUTM(zone, north)) {
if (l_method->getPrivate()->projMethodOverride_ == "tmerc approx" ||
l_method->getPrivate()->projMethodOverride_ == "utm approx") {
auto projFormatter = io::PROJStringFormatter::create();
projFormatter->setCRSExport(true);
projFormatter->setUseETMercForTMerc(true);
projFormatter->setUseApproxTMerc(true);
formatter->startNode(io::WKTConstants::EXTENSION, false);
formatter->addQuotedString("PROJ4");
_exportToPROJString(projFormatter.get());
Expand Down Expand Up @@ -5479,17 +5477,21 @@ void Conversion::_exportToPROJString(
const auto &convName = nameStr();
bool bConversionDone = false;
bool bEllipsoidParametersDone = false;
bool useETMerc = false;
bool useApprox = false;
if (methodEPSGCode == EPSG_CODE_METHOD_TRANSVERSE_MERCATOR) {
// Check for UTM
int zone = 0;
bool north = true;
bool etMercSettingSet = false;
useETMerc = formatter->getUseETMercForTMerc(etMercSettingSet) ||
l_method->getPrivate()->projMethodOverride_ == "etmerc";
if (isUTM(zone, north) && !(etMercSettingSet && !useETMerc)) {
useApprox =
formatter->getUseApproxTMerc() ||
l_method->getPrivate()->projMethodOverride_ == "tmerc approx" ||
l_method->getPrivate()->projMethodOverride_ == "utm approx";
if (isUTM(zone, north)) {
bConversionDone = true;
formatter->addStep("utm");
if( useApprox ) {
formatter->addParam("approx");
}
formatter->addParam("zone", zone);
if (!north) {
formatter->addParam("south");
Expand Down Expand Up @@ -5662,7 +5664,10 @@ void Conversion::_exportToPROJString(
if (!bConversionDone) {
const MethodMapping *mapping = getMapping(l_method.get());
if (mapping && mapping->proj_name_main) {
formatter->addStep(useETMerc ? "etmerc" : mapping->proj_name_main);
formatter->addStep(mapping->proj_name_main);
if (useApprox) {
formatter->addParam("approx");
}
if (mapping->proj_name_aux) {
if (internal::starts_with(mapping->proj_name_aux, "axis=")) {
bAxisSpecFound = true;
Expand Down
22 changes: 10 additions & 12 deletions src/iso19111/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4746,8 +4746,7 @@ struct PROJStringFormatter::Private {
bool omitProjLongLatIfPossible_ = false;
bool omitZUnitConversion_ = false;
DatabaseContextPtr dbContext_{};
bool useETMercForTMerc_ = false;
bool useETMercForTMercSet_ = false;
bool useApproxTMerc_ = false;
bool addNoDefs_ = true;
bool coordOperationOptimizations_ = false;
bool crsExport_ = false;
Expand Down Expand Up @@ -4803,11 +4802,9 @@ PROJStringFormatter::create(Convention conventionIn,

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

/** \brief Set whether Extended Transverse Mercator (etmerc) should be used
* instead of tmerc */
void PROJStringFormatter::setUseETMercForTMerc(bool flag) {
d->useETMercForTMerc_ = flag;
d->useETMercForTMercSet_ = true;
/** \brief Set whether approximate Transverse Mercator or UTM should be used */
void PROJStringFormatter::setUseApproxTMerc(bool flag) {
d->useApproxTMerc_ = flag;
}

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -5256,9 +5253,8 @@ PROJStringFormatter::Convention PROJStringFormatter::convention() const {

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

bool PROJStringFormatter::getUseETMercForTMerc(bool &settingSetOut) const {
settingSetOut = d->useETMercForTMercSet_;
return d->useETMercForTMerc_;
bool PROJStringFormatter::getUseApproxTMerc() const {
return d->useApproxTMerc_;
}

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -7081,8 +7077,10 @@ CRSNNPtr PROJStringParser::Private::buildProjectedCRS(
: UnitOfMeasure::NONE)));
}

if (step.name == "etmerc") {
methodMap.set("proj_method", "etmerc");
if (step.name == "tmerc" && hasParamValue(step, "approx")) {
methodMap.set("proj_method", "tmerc approx");
} else if (step.name == "utm" && hasParamValue(step, "approx")) {
methodMap.set("proj_method", "utm approx");
}

conv = Conversion::create(mapWithUnknownName, methodMap, parameters,
Expand Down
1 change: 0 additions & 1 deletion src/lib_proj.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ SET(SRC_LIBPROJ_PROJECTIONS
projections/wag7.cpp
projections/lcca.cpp
projections/geos.cpp
projections/etmerc.cpp
projections/boggs.cpp
projections/collg.cpp
projections/comill.cpp
Expand Down

0 comments on commit b15383c

Please sign in to comment.