"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "geo_names.c" between
libgeotiff-1.5.1.tar.gz and libgeotiff-1.6.0.tar.gz

About: libgeotiff is a library (built on top of libtiff) for reading and writing coordinate system information from and to GeoTIFF files (GeoTIFF establishes a TIFF based interchange format for georeferenced raster imagery).

geo_names.c  (libgeotiff-1.5.1):geo_names.c  (libgeotiff-1.6.0)
skipping to change at line 47 skipping to change at line 47
static const KeyInfo _tagInfo[] = { static const KeyInfo _tagInfo[] = {
{GTIFF_PIXELSCALE, "ModelPixelScaleTag"}, {GTIFF_PIXELSCALE, "ModelPixelScaleTag"},
{GTIFF_TRANSMATRIX, "ModelTransformationTag"}, {GTIFF_TRANSMATRIX, "ModelTransformationTag"},
{GTIFF_TIEPOINTS, "ModelTiepointTag"}, {GTIFF_TIEPOINTS, "ModelTiepointTag"},
/* This alias maps the Intergraph symbol to the current tag */ /* This alias maps the Intergraph symbol to the current tag */
{GTIFF_TRANSMATRIX, "IntergraphMatrixTag"}, {GTIFF_TRANSMATRIX, "IntergraphMatrixTag"},
END_LIST END_LIST
}; };
static char *FindName(const KeyInfo *info,int key) static const char *FindName(const KeyInfo *info,int key)
{ {
static char errmsg[80]; static char errmsg[80];
while (info->ki_key>=0 && info->ki_key != key) info++; while (info->ki_key>=0 && info->ki_key != key) info++;
if (info->ki_key<0) if (info->ki_key<0)
{ {
sprintf(errmsg,"Unknown-%d", key ); sprintf(errmsg,"Unknown-%d", key );
return errmsg; return errmsg;
} }
return info->ki_name; return info->ki_name;
} }
char *GTIFKeyName(geokey_t key) char *GTIFKeyName(geokey_t key)
{ {
return FindName( &_keyInfo[0],key); return (char*) FindName( &_keyInfo[0],key);
}
const char* GTIFKeyNameEx(GTIF* gtif, geokey_t key)
{
const KeyInfo *info;
if( gtif->gt_version == GEOTIFF_SPEC_1_0_VERSION &&
gtif->gt_rev_major == GEOTIFF_SPEC_1_0_KEY_REVISION &&
gtif->gt_rev_minor == GEOTIFF_SPEC_1_0_MINOR_REVISION )
{
info = &_keyInfo[0];
}
else
{
info = &_keyInfoV11[0];
}
while (info->ki_key>=0 && info->ki_key != (int)key) info++;
if (info->ki_key<0)
{
sprintf(gtif->szTmpBufferForGTIFValueNameEx,"Unknown-%d", key );
return gtif->szTmpBufferForGTIFValueNameEx;
}
return info->ki_name;
} }
char *GTIFTypeName(tagtype_t type) char *GTIFTypeName(tagtype_t type)
{ {
return FindName( &_formatInfo[0],type); return (char*) FindName( &_formatInfo[0],type);
} }
char *GTIFTagName(int tag) char *GTIFTagName(int tag)
{ {
return FindName( &_tagInfo[0],tag); return (char*) FindName( &_tagInfo[0],tag);
} }
static const KeyInfo* FindTable(geokey_t key) static const KeyInfo* FindTable(geokey_t key)
{ {
const KeyInfo *info; const KeyInfo *info;
switch (key) switch (key)
{ {
/* All codes using linear/angular/whatever units */ /* All codes using linear/angular/whatever units */
case GeogLinearUnitsGeoKey: case GeogLinearUnitsGeoKey:
skipping to change at line 113 skipping to change at line 135
/* And if all else fails... */ /* And if all else fails... */
default: info = _csdefaultValue;break; default: info = _csdefaultValue;break;
} }
return info; return info;
} }
char *GTIFValueName(geokey_t key, int value) char *GTIFValueName(geokey_t key, int value)
{ {
return FindName(FindTable(key), value); return (char*) FindName(FindTable(key), value);
} }
static void GetNameFromDatabase(GTIF* gtif, static void GetNameFromDatabase(GTIF* gtif,
const char* pszCode, const char* pszCode,
PJ_CATEGORY category, PJ_CATEGORY category,
char* pszOut, char* pszOut,
size_t nOutSize) size_t nOutSize)
{ {
PJ* obj = proj_create_from_database( PJ* obj = proj_create_from_database(
gtif->pj_context, "EPSG", pszCode, category, gtif->pj_context, "EPSG", pszCode, category,
FALSE, NULL); FALSE, NULL);
if( obj ) if( obj )
{ {
const char* pszName = proj_get_name(obj); const char* pszName = proj_get_name(obj);
if( pszName ) if( pszName )
{ {
strncpy(pszOut, pszName, nOutSize); size_t nToCopy = MIN(strlen(pszName), nOutSize - 1);
pszOut[nOutSize-1] = 0; memcpy(pszOut, pszName, nToCopy);
pszOut[nToCopy] = 0;
} }
proj_destroy(obj); proj_destroy(obj);
} }
else else
{ {
pszOut[0] = 0; pszOut[0] = 0;
} }
} }
const char *GTIFValueNameEx(GTIF* gtif, geokey_t key, int value) const char *GTIFValueNameEx(GTIF* gtif, geokey_t key, int value)
{ {
const KeyInfo *info = FindTable(key); const KeyInfo *info = FindTable(key);
int useHardcodedTables = 0;
while (info->ki_key>=0 && info->ki_key != value) info++; if( value == KvUndefined || value == KvUserDefined )
{
useHardcodedTables = 1;
}
else if( gtif->gt_version == GEOTIFF_SPEC_1_0_VERSION &&
gtif->gt_rev_major == GEOTIFF_SPEC_1_0_KEY_REVISION &&
gtif->gt_rev_minor == GEOTIFF_SPEC_1_0_MINOR_REVISION )
{
useHardcodedTables = 1;
}
else if( key == GTModelTypeGeoKey ||
key == GTRasterTypeGeoKey ||
key == ProjCoordTransGeoKey )
{
useHardcodedTables = 1;
}
else if( key == VerticalCSTypeGeoKey &&
value >= 5001 && value <= 5033 )
{
useHardcodedTables = 1;
}
if( useHardcodedTables )
{
while (info->ki_key>=0 && info->ki_key != value) info++;
}
if (info->ki_key<0) if ( !useHardcodedTables || info->ki_key<0 )
{ {
sprintf(gtif->szTmpBufferForGTIFValueNameEx,"Unknown-%d", value ); sprintf(gtif->szTmpBufferForGTIFValueNameEx,"Unknown-%d", value );
if( gtif->pj_context == NULL ) if( gtif->pj_context == NULL )
{ {
gtif->pj_context = proj_context_create(); gtif->pj_context = proj_context_create();
if( gtif->pj_context ) if( gtif->pj_context )
{ {
gtif->own_pj_context = TRUE; gtif->own_pj_context = TRUE;
} }
skipping to change at line 238 skipping to change at line 286
return gtif->szTmpBufferForGTIFValueNameEx; return gtif->szTmpBufferForGTIFValueNameEx;
} }
return info->ki_name; return info->ki_name;
} }
/* /*
* Inverse Utilities (name->code) * Inverse Utilities (name->code)
*/ */
static int FindCode(const KeyInfo *info,char *key) static int FindCode(const KeyInfo *info,const char *key)
{ {
while (info->ki_key>=0 && strcmp(info->ki_name,key) ) info++; while (info->ki_key>=0 && strcmp(info->ki_name,key) ) info++;
if (info->ki_key<0) if (info->ki_key<0)
{ {
/* not a registered key; might be generic code */ /* not a registered key; might be generic code */
if (!strncmp(key,"Unknown-",8)) if (!strncmp(key,"Unknown-",8))
{ {
int code=-1; int code=-1;
sscanf(key,"Unknown-%d",&code); sscanf(key,"Unknown-%d",&code);
skipping to change at line 261 skipping to change at line 309
{ {
int code=-1; int code=-1;
sscanf(key,"Code-%d",&code); sscanf(key,"Code-%d",&code);
return code; return code;
} }
else return -1; else return -1;
} }
return info->ki_key; return info->ki_key;
} }
int GTIFKeyCode(char *key) int GTIFKeyCode(const char *key)
{ {
return FindCode( &_keyInfo[0],key); int ret = FindCode( &_keyInfo[0],key);
if( ret < 0 )
ret = FindCode( &_keyInfoV11[0],key);
return ret;
} }
int GTIFTypeCode(char *type) int GTIFTypeCode(const char *type)
{ {
return FindCode( &_formatInfo[0],type); return FindCode( &_formatInfo[0],type);
} }
int GTIFTagCode(char *tag) int GTIFTagCode(const char *tag)
{ {
return FindCode( &_tagInfo[0],tag); return FindCode( &_tagInfo[0],tag);
} }
/* /*
* The key must be determined with GTIFKeyCode() before * The key must be determined with GTIFKeyCode() before
* the name can be encoded. * the name can be encoded.
*/ */
int GTIFValueCode(geokey_t key, char *name) int GTIFValueCode(geokey_t key, const char *name)
{ {
return FindCode(FindTable(key),name); return FindCode(FindTable(key),name);
} }
 End of changes. 15 change blocks. 
15 lines changed or deleted 66 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)