Skip to content

Commit

Permalink
Remove +scale parameter in favour of good old +k_0
Browse files Browse the repository at this point in the history
  • Loading branch information
sphynx committed Oct 9, 2018
1 parent 11e52da commit 08f0548
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
8 changes: 3 additions & 5 deletions docs/source/operations/projections/lcc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ seven projections introduced by Johann Heinrich Lambert in 1772.
It has several different forms: with one and two standard parallels
(referred to as 1SP and 2SP in EPSG guidance notes). Additionally we
provide "2SP Michigan" form which is very similar to normal 2SP, but
with a scaling factor on the ellipsoid (given as `scale` parameter).
with a scaling factor on the ellipsoid (given as `k_0` parameter).
It is implemented as per EPSG Guidance Note 7-2 (version 54, August
2018, page 25). It is used in a few systems in the EPSG database which
justifies adding this otherwise non-standard projection.
Expand All @@ -23,7 +23,7 @@ justifies adding this otherwise non-standard projection.
| **Available forms** | Forward and inverse, spherical and elliptical projection.|
| | One or two standard parallels (1SP and 2SP). |
| | "LCC 2SP Michigan" form can be used by setting |
| | `+scale` parameter to specify elliposid scale. |
| | `+k_0` parameter to specify elliposid scale. |
+---------------------+----------------------------------------------------------+
| **Defined area** | Best for regions predominantly east–west in extent and |
| | located in the middle north or south latitudes. |
Expand Down Expand Up @@ -65,9 +65,7 @@ Parameters

.. include:: ../options/y_0.rst

.. include:: ../options/k_0.rst

.. option:: +scale=<value>
.. option:: +k_0=<value>

Ellipsoid Scale factor. Determines a scale factor used in LCC 2SP
Michigan variation of the projection.
Expand Down
13 changes: 4 additions & 9 deletions src/PJ_lcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "proj_math.h"

PROJ_HEAD(lcc, "Lambert Conformal Conic")
"\n\tConic, Sph&Ell\n\tlat_1= and lat_2= or lat_0, scale=";
"\n\tConic, Sph&Ell\n\tlat_1= and lat_2= or lat_0, k_0=";

#define EPS10 1.e-10

Expand All @@ -15,7 +15,6 @@ struct pj_opaque {
double n;
double rho0;
double c;
double scale;
};


Expand All @@ -32,7 +31,7 @@ static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */
rho = 0.;
} else {
rho = Q->c * (P->es != 0. ?
Q->scale * pow(pj_tsfn(lp.phi, sin(lp.phi), P->e), Q->n) :
pow(pj_tsfn(lp.phi, sin(lp.phi), P->e), Q->n) :
pow(tan(M_FORTPI + .5 * lp.phi), -Q->n));
}
lp.lam *= Q->n;
Expand All @@ -59,7 +58,7 @@ static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */
xy.y = -xy.y;
}
if (P->es != 0.) {
lp.phi = pj_phi2(P->ctx, pow(rho / (Q->scale * Q->c), 1./Q->n), P->e);
lp.phi = pj_phi2(P->ctx, pow(rho / Q->c, 1./Q->n), P->e);
if (lp.phi == HUGE_VAL) {
proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION);
return lp;
Expand All @@ -85,10 +84,6 @@ PJ *PROJECTION(lcc) {
return pj_default_destructor(P, ENOMEM);
P->opaque = Q;

Q->scale = 1.;
if (pj_param(P->ctx, P->params, "tscale").i)
Q->scale = pj_param(P->ctx, P->params, "dscale").f;

Q->phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
if (pj_param(P->ctx, P->params, "tlat_2").i)
Q->phi2 = pj_param(P->ctx, P->params, "rlat_2").f;
Expand All @@ -115,7 +110,7 @@ PJ *PROJECTION(lcc) {
}
Q->c = (Q->rho0 = m1 * pow(ml1, -Q->n) / Q->n);
Q->rho0 *= (fabs(fabs(P->phi0) - M_HALFPI) < EPS10) ? 0. :
Q->scale * pow(pj_tsfn(P->phi0, sin(P->phi0), P->e), Q->n);
pow(pj_tsfn(P->phi0, sin(P->phi0), P->e), Q->n);
} else {
if (secant)
Q->n = log(cosphi / cos(Q->phi2)) /
Expand Down
6 changes: 3 additions & 3 deletions test/gie/builtins.gie
Original file line number Diff line number Diff line change
Expand Up @@ -2535,9 +2535,9 @@ accept -200 -100
expect -0.001796358 -0.000904233

-------------------------------------------------------------------------------
Tests with +scale (Lambert Conformal Conic 2SP Michigan).
Tests with +k_0 (Lambert Conformal Conic 2SP Michigan).
-------------------------------------------------------------------------------
operation +proj=lcc +ellps=GRS80 +lat_1=0.5 +lat_2=2 +scale=1.0000382
operation +proj=lcc +ellps=GRS80 +lat_1=0.5 +lat_2=2 +k_0=1.0000382
-------------------------------------------------------------------------------
tolerance 0.1 mm
accept 2 1
Expand All @@ -2564,7 +2564,7 @@ expect -0.001796290 -0.000904199
Test various corner cases, spherical projection and one standard
parallel to improve test coverage.
-------------------------------------------------------------------------------
operation +proj=lcc +ellps=GRS80 +lat_1=0.5 +lat_2=2
operation +proj=lcc +ellps=GRS80 +lat_1=0.5 +lat_2=2
-------------------------------------------------------------------------------
tolerance 0.1 mm

Expand Down
2 changes: 1 addition & 1 deletion test/gie/more_builtins.gie
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ Tests for LCC 2SP Michigan (from PJ_lcc.c)
This test is taken from EPSG guidance note 7-2 (version 54, August 2018,
page 25)
-------------------------------------------------------------------------------
operation +proj=lcc +ellps=clrk66 +lat_1=44d11'N +lat_2=45d42'N +x_0=609601.2192 +lon_0=84d20'W +lat_0=43d19'N +scale=1.0000382 +units=us-ft
operation +proj=lcc +ellps=clrk66 +lat_1=44d11'N +lat_2=45d42'N +x_0=609601.2192 +lon_0=84d20'W +lat_0=43d19'N +k_0=1.0000382 +units=us-ft
-------------------------------------------------------------------------------
tolerance 5 mm
accept 83d10'W 43d45'N
Expand Down

0 comments on commit 08f0548

Please sign in to comment.