Main Page   Compound List   File List   Compound Members   File Members   Related Pages  

geo_get.c

00001 /**********************************************************************
00002  *
00003  *  geo_get.c  -- Public routines for GEOTIFF GeoKey access.
00004  *
00005  *    Written By: Niles D. Ritter.
00006  *
00007  *  copyright (c) 1995   Niles D. Ritter
00008  *
00009  *  Permission granted to use this software, so long as this copyright
00010  *  notice accompanies any products derived therefrom.
00011  *
00012  *  Revision History;
00013  *
00014  *    20 June, 1995      Niles D. Ritter         New
00015  *    3 July,  1995      Greg Martin             Fix strings and index
00016  *    6 July,  1995      Niles D. Ritter         Unfix indexing.
00017  *
00018  **********************************************************************/
00019 
00020 #include "geotiff.h"   /* public interface        */
00021 #include "geo_tiffp.h" /* external TIFF interface */
00022 #include "geo_keyp.h"  /* private interface       */
00023 
00024 /* return the Header info of this geotiff file */
00025 
00026 void GTIFDirectoryInfo(GTIF *gtif, int version[3], int *keycount)
00027 {
00028         if (version)
00029         {
00030                 version[0]  = gtif->gt_version;
00031                 version[1]  = gtif->gt_rev_major;
00032                 version[2]  = gtif->gt_rev_minor;
00033         }
00034         if (keycount) *keycount = gtif->gt_num_keys;
00035 }
00036 
00037 
00038 int GTIFKeyInfo(GTIF *gtif, geokey_t key, int *size, tagtype_t* type)
00039 {
00040         int index = gtif->gt_keyindex[ key ];
00041         GeoKey *keyptr;
00042 
00043         if (!index) return 0;
00044 
00045         keyptr = gtif->gt_keys + index;
00046         if (size) *size = (int) keyptr->gk_size;
00047         if (type) *type = keyptr->gk_type;
00048 
00049         return keyptr->gk_count;
00050 }
00051 
00150 int GTIFKeyGet(GTIF *gtif, geokey_t thekey, void *val, int index, int count)
00151 {
00152         int kindex = gtif->gt_keyindex[ thekey ];
00153         GeoKey *key;
00154         gsize_t size;
00155         char *data;
00156         tagtype_t type;
00157 
00158         if (!kindex) return 0;
00159 
00160         key = gtif->gt_keys+kindex;
00161         if (!count) count = key->gk_count - index;
00162         if (count <=0) return 0;
00163         if (count > key->gk_count) count = key->gk_count;
00164         size = key->gk_size;
00165         type = key->gk_type;
00166 
00167         if (count==1 && type==TYPE_SHORT) data = (char *)&key->gk_data;
00168         else data = key->gk_data;
00169 
00170         _GTIFmemcpy( val, data + index*size, count*size );
00171 
00172         if (type==TYPE_ASCII)
00173            ((char *)val)[count-1] = '\0'; /* replace last char with NULL */
00174 
00175         return count;
00176 }

Generated at Sun Mar 4 23:32:44 2001 for libgeotiff by doxygen1.2.3-20001105 written by Dimitri van Heesch, © 1997-2000