diff options
| author | Frank Warmerdam <warmerdam@pobox.com> | 2012-06-18 15:07:06 +0000 |
|---|---|---|
| committer | Frank Warmerdam <warmerdam@pobox.com> | 2012-06-18 15:07:06 +0000 |
| commit | fcb186942ec8532655ff6cf4cc990e5da669a3bc (patch) | |
| tree | e15cffe73f281721f816077a4818dbcff1f7cf65 /src | |
| parent | e6839e86a9010b35a5e92886fce55ee3685649cb (diff) | |
| download | PROJ-fcb186942ec8532655ff6cf4cc990e5da669a3bc.tar.gz PROJ-fcb186942ec8532655ff6cf4cc990e5da669a3bc.zip | |
preliminary work on grid catalogs
git-svn-id: http://svn.osgeo.org/metacrs/proj/trunk@2218 4e78687f-474d-0410-85f9-8d5e500ac6b2
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile.am | 1 | ||||
| -rw-r--r-- | src/Makefile.in | 18 | ||||
| -rw-r--r-- | src/pj_gc_reader.c | 203 | ||||
| -rw-r--r-- | src/pj_gridcatalog.c | 219 | ||||
| -rw-r--r-- | src/proj_newgrid.h | 85 | ||||
| -rw-r--r-- | src/projects.h | 62 |
6 files changed, 494 insertions, 94 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index d8d2718b..e44b0248 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -59,6 +59,7 @@ libproj_la_SOURCES = \ pj_zpoly1.c rtodms.c vector1.c pj_release.c pj_gauss.c \ PJ_healpix.c PJ_natearth.c \ \ + pj_gc_reader.c pj_gridcatalog.c \ nad_cvt.c nad_init.c nad_intr.c emess.c emess.h \ pj_apply_gridshift.c pj_datums.c pj_datum_set.c pj_transform.c \ geocent.c geocent.h pj_utils.c pj_gridinfo.c pj_gridlist.c \ diff --git a/src/Makefile.in b/src/Makefile.in index 04ef4b67..345147bf 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -102,11 +102,12 @@ am_libproj_la_OBJECTS = PJ_aeqd.lo PJ_gnom.lo PJ_laea.lo \ pj_open_lib.lo pj_param.lo pj_phi2.lo pj_pr_list.lo pj_qsfn.lo \ pj_strerrno.lo pj_tsfn.lo pj_units.lo pj_ctx.lo pj_log.lo \ pj_zpoly1.lo rtodms.lo vector1.lo pj_release.lo pj_gauss.lo \ - PJ_healpix.lo PJ_natearth.lo nad_cvt.lo nad_init.lo \ - nad_intr.lo emess.lo pj_apply_gridshift.lo pj_datums.lo \ - pj_datum_set.lo pj_transform.lo geocent.lo pj_utils.lo \ - pj_gridinfo.lo pj_gridlist.lo jniproj.lo pj_mutex.lo \ - pj_initcache.lo pj_apply_vgridshift.lo + PJ_healpix.lo PJ_natearth.lo pj_gc_reader.lo pj_gridcatalog.lo \ + nad_cvt.lo nad_init.lo nad_intr.lo emess.lo \ + pj_apply_gridshift.lo pj_datums.lo pj_datum_set.lo \ + pj_transform.lo geocent.lo pj_utils.lo pj_gridinfo.lo \ + pj_gridlist.lo jniproj.lo pj_mutex.lo pj_initcache.lo \ + pj_apply_vgridshift.lo libproj_la_OBJECTS = $(am_libproj_la_OBJECTS) libproj_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ @@ -165,7 +166,6 @@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ -DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ @@ -191,7 +191,6 @@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ -MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ MUTEX_SETTING = @MUTEX_SETTING@ NM = @NM@ @@ -218,7 +217,6 @@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ -ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ @@ -251,6 +249,7 @@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ +lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ @@ -318,6 +317,7 @@ libproj_la_SOURCES = \ pj_zpoly1.c rtodms.c vector1.c pj_release.c pj_gauss.c \ PJ_healpix.c PJ_natearth.c \ \ + pj_gc_reader.c pj_gridcatalog.c \ nad_cvt.c nad_init.c nad_intr.c emess.c emess.h \ pj_apply_gridshift.c pj_datums.c pj_datum_set.c pj_transform.c \ geocent.c geocent.h pj_utils.c pj_gridinfo.c pj_gridlist.c \ @@ -601,7 +601,9 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_factors.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_fwd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_gauss.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_gc_reader.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_geocent.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_gridcatalog.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_gridinfo.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_gridlist.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj_init.Plo@am__quote@ diff --git a/src/pj_gc_reader.c b/src/pj_gc_reader.c new file mode 100644 index 00000000..ef9479ff --- /dev/null +++ b/src/pj_gc_reader.c @@ -0,0 +1,203 @@ +/****************************************************************************** + * $Id$ + * + * Project: PROJ.4 + * Purpose: Code to read a grid catalog from a .cvs file. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2012, Frank Warmerdam <warmerdam@pobox.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 PJ_LIB__ + +#include <projects.h> +#include <string.h> + +static int pj_gc_readentry( projCtx ctx, FILE *fp, PJ_GridCatalogEntry *entry ); + + +/************************************************************************/ +/* pj_gc_readcatalog() */ +/* */ +/* Read a grid catalog from a .csv file. */ +/************************************************************************/ + +PJ_GridCatalog *pj_gc_readcatalog( projCtx ctx, const char *catalog_name ) +{ + FILE *fp; + PJ_GridCatalog *catalog; + int entry_max, err; + + fp = pj_open_lib( ctx, (char *) catalog_name, "r" ); + if (fp == NULL) + return NULL; + + catalog = (PJ_GridCatalog *) calloc(1,sizeof(PJ_GridCatalog)); + if( !catalog ) + return NULL; + + catalog->catalog_name = strdup(catalog_name); + + entry_max = 10; + catalog->entries = (PJ_GridCatalogEntry *) + malloc(entry_max * sizeof(PJ_GridCatalogEntry)); + + while( pj_gc_readentry( ctx, fp, + catalog->entries+catalog->entry_count) == 0) + { + catalog->entry_count++; + + if( catalog->entry_count == entry_max ) + { + entry_max = entry_max * 2; + catalog->entries = (PJ_GridCatalogEntry *) + realloc(catalog->entries, + entry_max * sizeof(PJ_GridCatalogEntry)); + if (catalog->entries == NULL ) + return NULL; + } + } + + return catalog; +} + + +/************************************************************************/ +/* pj_gc_read_csv_line() */ +/* */ +/* Simple csv line splitter with fixed maximum line size and */ +/* token count. */ +/************************************************************************/ + +static int pj_gc_read_csv_line( projCtx ctx, FILE *fp, + char **tokens, int max_tokens ) +{ + char line[302]; + + while( fgets(line, sizeof(line)-1, fp) != NULL ) + { + char *next = line; + int token_count = 0; + + while( isspace(*next) ) + next++; + + /* skip blank and comment lines */ + if( next[0] == '#' || next[0] == '\0' ) + continue; + + while( token_count < max_tokens && next != '\0' ) + { + const char *start = next; + + while( *next != '\0' && *next != ',' ) + next++; + + if( *next == ',' ) + { + *next = '\0'; + next++; + } + + tokens[token_count++] = strdup(start); + } + + return token_count; + } + + return 0; +} + +/************************************************************************/ +/* pj_gc_parsedate() */ +/* */ +/* Parse a date into a floating point year value. Acceptable */ +/* values are "yyyy.fraction" and "yyyy-mm-dd". Anything else */ +/* returns 0.0. */ +/************************************************************************/ + +double pj_gc_parsedate( projCtx ctx, const char *date_string ) +{ + if( strlen(date_string) == 10 + && date_string[4] == '-' && date_string[7] == '-' ) + { + int year = atoi(date_string); + int month = atoi(date_string+5); + int day = atoi(date_string+8); + + /* simplified calculation so we don't need to know all about months */ + return year + ((month-1) * 31 + (day-1)) / 372.0; + } + else + { + return atof(date_string); + } +} + + +/************************************************************************/ +/* pj_gc_readentry() */ +/* */ +/* Read one catalog entry from the file */ +/* */ +/* Format: */ +/* gridname,ll_long,ll_lat,ur_long,ur_lat,priority,date */ +/************************************************************************/ + +static int pj_gc_readentry( projCtx ctx, FILE *fp, PJ_GridCatalogEntry *entry ) +{ +#define MAX_TOKENS 30 + char *tokens[MAX_TOKENS]; + int token_count, i; + int error = 0; + + memset( entry, 0, sizeof(PJ_GridCatalogEntry) ); + + token_count = pj_gc_read_csv_line( ctx, fp, tokens, MAX_TOKENS ); + if( token_count < 5 ) + { + error = 1; /* TODO: need real error codes */ + pj_log( ctx, PJ_LOG_ERROR, "Short line in grid catalog." ); + } + else + { + memset( entry, 0, sizeof(PJ_GridCatalogEntry)); + + entry->definition = strdup( tokens[0] ); + entry->region.ll_long = dmstor_ctx( ctx, tokens[1], NULL ); + entry->region.ll_lat = dmstor_ctx( ctx, tokens[2], NULL ); + entry->region.ur_long = dmstor_ctx( ctx, tokens[3], NULL ); + entry->region.ur_lat = dmstor_ctx( ctx, tokens[4], NULL ); + if( token_count > 5 ) + entry->priority = atoi( tokens[5] ); /* defaults to zero */ + if( token_count > 6 ) + entry->date = pj_gc_parsedate( ctx, tokens[6] ); + } + + for( i = 0; i < token_count; i++ ) + free( tokens[i] ); + + return error; +} + + + diff --git a/src/pj_gridcatalog.c b/src/pj_gridcatalog.c new file mode 100644 index 00000000..48808368 --- /dev/null +++ b/src/pj_gridcatalog.c @@ -0,0 +1,219 @@ +/****************************************************************************** + * $Id$ + * + * Project: PROJ.4 + * Purpose: Code in support of grid catalogs + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 2012, Frank Warmerdam <warmerdam@pobox.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 PJ_LIB__ + +#include <projects.h> +#include <string.h> + +static PJ_GridCatalog *grid_catalog_list = NULL; + +/************************************************************************/ +/* pj_gc_unloadall() */ +/* */ +/* Deallocate all the grid catalogs (but not the referenced */ +/* grids). */ +/************************************************************************/ + +void pj_gc_unloadall( projCtx ctx ) + +{ + while( grid_catalog_list != NULL ) + { + int i; + PJ_GridCatalog *catalog = grid_catalog_list; + grid_catalog_list = grid_catalog_list->next; + + for( i = 0; i < catalog->entry_count; i++ ) + { + /* we don't own gridinfo - do not free here */ + free( catalog->entries[i].definition ); + } + free( catalog->entries ); + free( catalog ); + } +} + +/************************************************************************/ +/* pj_gc_findcatalog() */ +/************************************************************************/ + +PJ_GridCatalog *pj_gc_findcatalog( projCtx ctx, const char *name ) + +{ + PJ_GridCatalog *catalog; + + pj_acquire_lock(); + + for( catalog=grid_catalog_list; catalog != NULL; catalog = catalog->next ) + { + if( strcmp(catalog->catalog_name, name) == 0 ) + { + pj_release_lock(); + return catalog; + } + } + + pj_release_lock(); + + catalog = pj_gc_readcatalog( ctx, name ); + if( catalog == NULL ) + return NULL; + + pj_acquire_lock(); + catalog->next = grid_catalog_list; + grid_catalog_list = catalog; + pj_release_lock(); + + return catalog; +} + +/************************************************************************/ +/* pj_gc_apply_gridshift() */ +/************************************************************************/ + +int pj_gc_apply_gridshift( PJ *defn, int inverse, + long point_count, int point_offset, + double *x, double *y, double *z ) + +{ + int i; + + if( defn->catalog == NULL ) + { + defn->catalog = pj_gc_findcatalog( defn->ctx, defn->catalog_name ); + if( defn->catalog == NULL ) + return defn->ctx->last_errno; + } + + ctx->last_errno = 0; + + for( i = 0; i < point_count; i++ ) + { + long io = i * point_offset; + LP input, output; + int itable; + + input.phi = y[io]; + input.lam = x[io]; + output.phi = HUGE_VAL; + output.lam = HUGE_VAL; + + /* make sure we have appropriate "before" shift file available */ + if( defn->last_before_grid == NULL + || input.lam < defn->last_before_region.ll_long + || input.lam > defn->last_before_region.ur_long + || input.phi < defn->last_before_region.ll_lat + || input.phi > defn->last_before_region.ll_lat ) { + defn->last_before_grid = pj_gc_findgrid( + defn->ctx, defn->catalog, 0, ll, 0.0, + &(defn->last_before_region), NULL); + } + + PJ_GRIDINFO *gi = defn->last_before_grid; + struct CTABLE *ct = gi->ct; + double epsilon = (fabs(ct->del.phi)+fabs(ct->del.lam))/10000.0; + + /* If we have child nodes, check to see if any of them apply. */ + if( gi->child != NULL ) + { + PJ_GRIDINFO *child; + + for( child = gi->child; child != NULL; child = child->next ) + { + struct CTABLE *ct1 = child->ct; + double epsilon = + (fabs(ct1->del.phi)+fabs(ct1->del.lam))/10000.0; + + if( ct1->ll.phi - epsilon > input.phi + || ct1->ll.lam - epsilon > input.lam + || (ct1->ll.phi+(ct1->lim.phi-1)*ct1->del.phi + epsilon + < input.phi) + || (ct1->ll.lam+(ct1->lim.lam-1)*ct1->del.lam + epsilon + < input.lam) ) + continue; + + break; + } + + /* we found a more refined child node to use */ + if( child != NULL ) + { + gi = child; + ct = child->ct; + } + } + + /* load the grid shift info if we don't have it. */ + if( ct->cvs == NULL && !pj_gridinfo_load( ctx, gi ) ) + { + pj_ctx_set_errno( ctx, -38 ); + return -38; + } + + output = nad_cvt( input, inverse, ct ); + if( output.lam != HUGE_VAL ) + { + if( debug_count++ < 20 ) + pj_log( ctx, PJ_LOG_DEBUG_MINOR, + "pj_apply_gridshift(): used %s", ct->id ); + break; + } + + + if( output.lam == HUGE_VAL ) + { + if( ctx->debug_level >= PJ_LOG_DEBUG_MAJOR ) + { + pj_log( ctx, PJ_LOG_DEBUG_MAJOR, + "pj_apply_gridshift(): failed to find a grid shift table for\n" + " location (%.7fdW,%.7fdN)", + x[io] * RAD_TO_DEG, + y[io] * RAD_TO_DEG ); + for( itable = 0; itable < grid_count; itable++ ) + { + PJ_GRIDINFO *gi = tables[itable]; + if( itable == 0 ) + pj_log( ctx, PJ_LOG_DEBUG_MAJOR, + " tried: %s", gi->gridname ); + else + pj_log( ctx, PJ_LOG_DEBUG_MAJOR, + ",%s", gi->gridname ); + } + } + } + else + { + y[io] = output.phi; + x[io] = output.lam; + } + } + + return 0; +} diff --git a/src/proj_newgrid.h b/src/proj_newgrid.h deleted file mode 100644 index c8efb76c..00000000 --- a/src/proj_newgrid.h +++ /dev/null @@ -1,85 +0,0 @@ -/****************************************************************************** - * $Id$ - * - * Project: PROJ.4 - * Purpose: Definitions related to new datum shift grid (date aware) API. - * Author: Frank Warmerdam, <warmerdam@pobox.com> - * - ****************************************************************************** - * Copyright (c) 2012, Frank Warmerdam <warmerdam@pobox.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. - *****************************************************************************/ - -#ifndef PROJ_NEWGRID_H -#define PROJ_NEWGRID_H - -typedef struct { - LP ll; /* lower left corner coordinates */ - LP del; /* size of cells */ - ILP lim; /* width/height of grid (value count) */ - - double date; /* year.fraction */ - - const char *definition; /* usually the gridname */ - - PJ_GRIDINFO *gridinfo; - - int available; /* 0=unknown, 1=true, -1=false */ -} PJ_GridCatalogEntry; - -typedef struct { - char *catalog_name; - - LP last_grid_ll; /* maximum extent of catalog data */ - LP last_grid_ur; - - int entry_count; - PJ_GridCatalogEntry *entries; -} PJ_GridCatalog; - -typedef struct { - - PJ_GridCatalog *catalog; - - double datum_date; - - PJ_NGRIDINFO *last_before_grid; - PJ_NGRIDINFO *last_after_grid; - - LP last_grid_ll; /* region for which the last grid set is optimal */ - LP last_grid_ur; - -} PJ_GridEvalInfo; - -PJ_GridCatalog *pj_gc_findcatalog( const char * ); -void pj_gc_unloadall(); - -PJ_GRIDINFO *pj_gc_findgrid( PJ_GridCatalog *catalog, int after, - LP location, double date, - LP *optimal_ll, LP *optimal_ur, - double *grid_date ); - - -#ifdef __cplusplus -} -#endif - -#endif /* ndef PROJ_NEWGRID_H */ - diff --git a/src/projects.h b/src/projects.h index e282ecb5..a15ed596 100644 --- a/src/projects.h +++ b/src/projects.h @@ -144,6 +144,7 @@ typedef struct { #define PJD_ERR_GEOCENTRIC -45 #define PJD_ERR_AXIS -47 #define PJD_ERR_GRID_AREA -48 +#define PJD_ERR_CATALOG -49 #define USE_PROJUV @@ -190,6 +191,13 @@ struct PJ_PRIME_MERIDIANS { char *defn; /* offset from greenwich in DMS format. */ }; +typedef struct { + double ll_long; /* lower left corner coordinates (radians) */ + double ll_lat; + double ur_long; /* upper right corner coordinates (radians) */ + double ur_lat; +} PJ_Region; + struct DERIVS { double x_l, x_p; /* derivatives of x for lambda-phi */ double y_l, y_p; /* derivatives of y for lambda-phi */ @@ -256,7 +264,19 @@ typedef struct PJconsts { double long_wrap_center; /* 0.0 for -180 to 180, actually in radians*/ int is_long_wrap_set; char axis[4]; - + + /* New Datum Shift Grid Catalogs */ + char *catalog_name; + struct _PJ_GridCatalog *catalog; + + double datum_date; + + struct _pj_gi *last_before_grid; + PJ_Region last_before_region; + + struct _pj_gi *last_after_grid; + PJ_Region last_after_region; + #ifdef PROJ_PARMS__ PROJ_PARMS__ #endif /* end of optional extensions */ @@ -347,6 +367,28 @@ typedef struct _pj_gi { struct _pj_gi *child; } PJ_GRIDINFO; +typedef struct _PJ_GridCatalog { + PJ_Region region; + int priority; /* higher used before lower */ + double date; /* year.fraction */ + char *definition; /* usually the gridname */ + + PJ_GRIDINFO *gridinfo; + int available; /* 0=unknown, 1=true, -1=false */ +} PJ_GridCatalogEntry; + +typedef struct _pj_gc { + char *catalog_name; + + PJ_Region region; /* maximum extent of catalog data */ + + int entry_count; + PJ_GridCatalogEntry *entries; + + struct _pj_gc *next; +} PJ_GridCatalog; + + /* procedure prototypes */ double dmstor(const char *, char **); double dmstor_ctx(projCtx ctx, const char *, char **); @@ -437,6 +479,24 @@ PJ_GRIDINFO *pj_gridinfo_init( projCtx, const char * ); int pj_gridinfo_load( projCtx, PJ_GRIDINFO * ); void pj_gridinfo_free( projCtx, PJ_GRIDINFO * ); +PJ_GridCatalog *pj_gc_findcatalog( projCtx, const char * ); +PJ_GridCatalog *pj_gc_readcatalog( projCtx, const char * ); +void pj_gc_unloadall( projCtx ); +int pj_gc_apply_gridshift( PJ *defn, int inverse, + long point_count, int point_offset, + double *x, double *y, double *z ); +int pj_gc_apply_gridshift( PJ *defn, int inverse, + long point_count, int point_offset, + double *x, double *y, double *z ); + +PJ_GRIDINFO *pj_gc_findgrid( projCtx ctx, + PJ_GridCatalog *catalog, int after, + LP location, double date, + PJ_Region *optional_region, + double *grid_date ); + +double pj_gc_parsedate( projCtx, const char * ); + void *proj_mdist_ini(double); double proj_mdist(double, double, double, const void *); double proj_inv_mdist(projCtx ctx, double, const void *); |
