Skip to content

Commit

Permalink
Merge pull request #1210 from rouault/remove_proj_defs_dat
Browse files Browse the repository at this point in the history
Remove proj_def.dat (#201)
  • Loading branch information
kbevers committed Dec 27, 2018
2 parents 81ec8c0 + 6bb14fa commit 1230114
Show file tree
Hide file tree
Showing 31 changed files with 128 additions and 195 deletions.
1 change: 0 additions & 1 deletion data/CMakeLists.txt
Expand Up @@ -8,7 +8,6 @@ set(PROJ_DICTIONARY world
GL27
nad83
nad.lst
proj_def.dat
CH
ITRF2000
ITRF2008
Expand Down
4 changes: 2 additions & 2 deletions data/Makefile.am
@@ -1,6 +1,6 @@
DATAPATH = $(top_srcdir)/data

pkgdata_DATA = GL27 nad.lst proj_def.dat nad27 nad83 world other.extra \
pkgdata_DATA = GL27 nad.lst nad27 nad83 world other.extra \
CH \
ITRF2000 ITRF2008 ITRF2014 proj.db

Expand Down Expand Up @@ -36,7 +36,7 @@ SQL_ORDERED_LIST = sql/begin.sql \
sql/customizations.sql \
sql/commit.sql

EXTRA_DIST = GL27 nad.lst proj_def.dat nad27 nad83 \
EXTRA_DIST = GL27 nad.lst nad27 nad83 \
world other.extra \
CH \
ITRF2000 ITRF2008 ITRF2014 \
Expand Down
2 changes: 0 additions & 2 deletions data/README
Expand Up @@ -5,8 +5,6 @@ File Contents:

README --- This file

proj_def.dat --- basic default file used by proj.

epsg --- Translation of EPSG GCS/PCS codes into PROJ via init= mechanism.

epsg-deprecated --- EPSG definitions that have been deprecated. They are
Expand Down
17 changes: 0 additions & 17 deletions data/proj_def.dat

This file was deleted.

2 changes: 1 addition & 1 deletion docs/source/operations/options/ellps.rst
Expand Up @@ -2,4 +2,4 @@

See :option:`proj -le` for a list of available ellipsoids.

*Defaults to "WGS84".*
*Defaults to "GRS80".*
15 changes: 3 additions & 12 deletions docs/source/resource_files.rst
Expand Up @@ -393,15 +393,6 @@ Below is a list of the init files that are packaged with PROJ.
The defaults file
-------------------------------------------------------------------------------

The ``proj_def.dat`` file supplies default parameters for PROJ. It uses the same
syntax as the init files described above. The identifiers in the defaults file
describe to what the parameters should apply. If the ``<general>`` identifier is
used, then all parameters in that section applies for all proj-strings. Otherwise
the identifier is connected to a specific projection. With the defaults file
supplied with PROJ the default ellipsoid is set to WGS84 (for all proj-strings).
Apart from that only the Albers Equal Area,
:doc:`Lambert Conic Conformal<operations/projections/lcc>` and the
:doc:`Lagrange<operations/projections/lagrng>` projections have default parameters.
Defaults can be ignored by adding the ``+no_def`` parameter to a proj-string.


Before PROJ 6.0, a ``proj_def.dat`` file could be used to supply default
parameters to PROJ. It has been removed due to the confusion and errors it
caused.
11 changes: 11 additions & 0 deletions docs/source/usage/differences.rst
Expand Up @@ -58,3 +58,14 @@ should return the same output for both.

Adding the ``+over`` flag to the projection definition provides
the old behaviour.

Version 6.0.0
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Removal of proj_def.dat
-----------------------

Before PROJ 6, the proj_def.dat was used to provide general and per-projection
parameters, when +no_defs was not specified. It has now been removed. In case,
no ellipsoid or datum specification is provided in the PROJ string, the
default ellipsoid is GRS80 (was WGS84 in previous PROJ versions).
1 change: 0 additions & 1 deletion docs/source/usage/projections.rst
Expand Up @@ -26,7 +26,6 @@ documenting the individual :doc:`projections<../operations/projections/index>`.
+lat_0 Latitude of origin
+lon_0 Central meridian
+lon_wrap Center longitude to use for wrapping (see below)
+no_defs Don't use the /usr/share/proj/proj_def.dat defaults file
+over Allow longitude output outside -180 to 180 range, disables
wrapping (see below)
+pm Alternate prime meridian (typically a city name, see below)
Expand Down
81 changes: 22 additions & 59 deletions src/init.cpp
Expand Up @@ -332,74 +332,41 @@ Expand key from buffer or (if not in buffer) from init file



static paralist *append_defaults_to_paralist (PJ_CONTEXT *ctx, paralist *start, const char *key, int allow_init_epsg) {
paralist *defaults, *last = nullptr;
char keystring[ID_TAG_MAX + 20];
paralist *next, *proj;
int err;

static void append_default_ellipsoid_to_paralist (paralist *start) {
if (nullptr==start)
return nullptr;

if (strlen(key) > ID_TAG_MAX)
return nullptr;
return;

/* Set defaults, unless inhibited (either explicitly through a "no_defs" token */
/* or implicitly, because we are initializing a pipeline) */
if (pj_param_exists (start, "no_defs"))
return start;
proj = pj_param_exists (start, "proj");
return;
auto proj = pj_param_exists (start, "proj");
if (nullptr==proj)
return start;
return;
if (strlen (proj->param) < 6)
return start;
return;
if (0==strcmp ("pipeline", proj->param + 5))
return start;

err = pj_ctx_get_errno (ctx);
pj_ctx_set_errno (ctx, 0);
return;

/* Don't default ellipse if datum, ellps or any ellipsoid information is set */
if (pj_param_exists (start, "datum")) return;
if (pj_param_exists (start, "ellps")) return;
if (pj_param_exists (start, "a")) return;
if (pj_param_exists (start, "b")) return;
if (pj_param_exists (start, "rf")) return;
if (pj_param_exists (start, "f")) return;
if (pj_param_exists (start, "e")) return;
if (pj_param_exists (start, "es")) return;

/* Locate end of start-list */
paralist *last = nullptr;
for (last = start; last->next; last = last->next);

strcpy (keystring, "proj_def.dat:");
strcat (keystring, key);
defaults = get_init (ctx, keystring, allow_init_epsg);

/* Defaults are optional - so we don't care if we cannot open the file */
pj_ctx_set_errno (ctx, err);

if (!defaults)
return last;

/* Loop over all default items */
for (next = defaults; next; next = next->next) {

/* Don't override existing parameter value of same name */
if (pj_param_exists (start, next->param))
continue;

/* Don't default ellipse if datum, ellps or any ellipsoid information is set */
if (0==strncmp(next->param,"ellps=", 6)) {
if (pj_param_exists (start, "datum")) continue;
if (pj_param_exists (start, "ellps")) continue;
if (pj_param_exists (start, "a")) continue;
if (pj_param_exists (start, "b")) continue;
if (pj_param_exists (start, "rf")) continue;
if (pj_param_exists (start, "f")) continue;
if (pj_param_exists (start, "e")) continue;
if (pj_param_exists (start, "es")) continue;
}

/* If we're here, it's OK to append the current default item */
last = last->next = pj_mkparam(next->param);
}
last->next = nullptr;

pj_dealloc_params (ctx, defaults, 0);
return last;
/* If we're here, it's OK to append the current default item */
last->next = pj_mkparam("ellps=GRS80");
}


/*****************************************************************************/
static paralist *pj_expand_init_internal(PJ_CONTEXT *ctx, paralist *init, int allow_init_epsg) {
/******************************************************************************
Expand Down Expand Up @@ -664,11 +631,7 @@ pj_init_ctx_with_allow_init_epsg(projCtx ctx, int argc, char **argv, int allow_i
return nullptr;
}


/* Append general and projection specific defaults to the definition list */
append_defaults_to_paralist (ctx, start, "general", allow_init_epsg);
append_defaults_to_paralist (ctx, start, name, allow_init_epsg);

append_default_ellipsoid_to_paralist (start);

/* Allocate projection structure */
PIN = proj(nullptr);
Expand Down
5 changes: 4 additions & 1 deletion src/projections/lagrng.cpp
Expand Up @@ -76,7 +76,10 @@ PJ *PROJECTION(lagrng) {
return pj_default_destructor (P, ENOMEM);
P->opaque = Q;

Q->w = pj_param(P->ctx, P->params, "dW").f;
if( pj_param(P->ctx, P->params, "tW").i )
Q->w = pj_param(P->ctx, P->params, "dW").f;
else
Q->w = 2;
if (Q->w <= 0)
return pj_default_destructor(P, PJD_ERR_W_OR_M_ZERO_OR_LESS);
Q->hw = 0.5 * Q->w;
Expand Down
13 changes: 1 addition & 12 deletions src/tests/multistresstest.cpp
Expand Up @@ -46,7 +46,6 @@
#define num_threads 10
static int num_iterations = 1000000;
static int reinit_every_iteration=0;
static int add_no_defs = 0;

typedef struct {
const char *src_def;
Expand Down Expand Up @@ -179,15 +178,7 @@ static volatile int active_thread_count = 0;

static projPJ custom_pj_init_plus_ctx(projCtx ctx, const char* def)
{
if( add_no_defs )
{
char szBuffer[256];
strcpy(szBuffer, def);
strcat(szBuffer, " +no_defs");
return pj_init_plus_ctx(ctx, szBuffer);
}
else
return pj_init_plus_ctx(ctx, def);
return pj_init_plus_ctx(ctx, def);
}

/************************************************************************/
Expand Down Expand Up @@ -462,8 +453,6 @@ int main( int argc, char **argv )
{
if( strcmp(argv[i], "-reinit") == 0 )
reinit_every_iteration = 1;
else if( strcmp(argv[i], "-add_no_defs") == 0 )
add_no_defs = 1;
else if( strcmp(argv[i], "-num_iterations") == 0 && i+1 < argc )
{
num_iterations = atoi(argv[i+1]);
Expand Down
5 changes: 2 additions & 3 deletions src/tests/test228.cpp
Expand Up @@ -36,10 +36,9 @@ static void* thread_main(void* unused)

p_proj_ctxt=pj_ctx_alloc();
p_WGS84_proj=pj_init_plus_ctx(p_proj_ctxt,"+proj=longlat "
"+ellps=WGS84 +datum=WGS84 +no_defs");
"+ellps=WGS84 +datum=WGS84");
p_OSGB36_proj=pj_init_plus_ctx(p_proj_ctxt,
"+proj=longlat +ellps=airy +datum=OSGB36 +nadgrids=OSTN02_NTv2.gsb "
"+no_defs");
"+proj=longlat +ellps=airy +datum=OSGB36 +nadgrids=OSTN02_NTv2.gsb");

while(run)
{
Expand Down
3 changes: 2 additions & 1 deletion src/transformations/deformation.cpp
Expand Up @@ -269,7 +269,8 @@ PJ *TRANSFORMATION(deformation,1) {
return destructor(P, ENOMEM);
P->opaque = (void *) Q;

Q->cart = proj_create(P->ctx, "+proj=cart");
// Pass a dummy ellipsoid definition that will be overridden just afterwards
Q->cart = proj_create(P->ctx, "+proj=cart +a=1");
if (Q->cart == nullptr)
return destructor(P, ENOMEM);

Expand Down
24 changes: 12 additions & 12 deletions test/cli/proj_outIGNF.dist
@@ -1,22 +1,22 @@
+init=IGNF:NTFG +to +init=IGNF:RGF93G
3.300866856 43.4477976569 0.0000 3d18'0.915"E 43d26'52.077"N 0.000
+init=IGNF:LAMBE +to +init=IGNF:LAMB93
600000.0000 2600545.4523 0.0000 652759.036 7033588.609 0.000
135638.3592 2418760.4094 0.0000 187444.148 6856142.911 0.000
998137.3947 2413822.2844 0.0000 1048843.997 6843923.913 0.000
600000.0000 2600545.4523 0.0000 652760.737 7033791.243 0.000
135638.3592 2418760.4094 0.0000 187194.062 6855928.882 0.000
998137.3947 2413822.2844 0.0000 1049052.258 6843776.562 0.000
600000.0000 2200000.0000 0.0000 649398.872 6633524.191 0.000
311552.5340 1906457.4840 0.0000 358593.374 6342647.465 0.000
960488.4138 1910172.8812 0.0000 1007324.119 6340956.093 0.000
600000.0000 1699510.8340 0.0000 645201.753 6133255.515 0.000
311552.5340 1906457.4840 0.0000 358799.172 6342652.486 0.000
960488.4138 1910172.8812 0.0000 1007068.686 6340907.237 0.000
600000.0000 1699510.8340 0.0000 645204.279 6133556.746 0.000
1203792.5981 626873.17210 0.0000 * * inf
+init=IGNF:LAMBE +to +init=IGNF:GEOPORTALFXX
600000.0000 2600545.4523 0.0000 179040.150 5610292.766 0.000
135638.3592 2418760.4094 0.0000 -303490.059 5410353.890 0.000
998137.3947 2413822.2844 0.0000 592635.926 5410280.335 0.000
600000.0000 2600545.4523 0.0000 179040.148 5610495.275 0.000
135638.3592 2418760.4094 0.0000 -303729.363 5410118.356 0.000
998137.3947 2413822.2844 0.0000 592842.792 5410120.554 0.000
600000.0000 2200000.0000 0.0000 179041.670 5209746.080 0.000
311552.5340 1906457.4840 0.0000 -97021.878 4909167.981 0.000
960488.4138 1910172.8812 0.0000 524126.466 4909227.598 0.000
600000.0000 1699510.8340 0.0000 179047.637 4708515.623 0.000
311552.5340 1906457.4840 0.0000 -96825.465 4909184.136 0.000
960488.4138 1910172.8812 0.0000 523880.019 4909191.141 0.000
600000.0000 1699510.8340 0.0000 179047.633 4708817.007 0.000
1203792.5981 626873.17210 0.0000 * * inf
+init=IGNF:RGF93G +to +init=IGNF:GEOPORTALFXX
2d20'11.4239243" 50d23'59.7718445" 0.0 179040.151 5610495.281 0.000
Expand Down

0 comments on commit 1230114

Please sign in to comment.