00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "geotiff.h"
00021 #include "geo_tiffp.h"
00022 #include "geo_keyp.h"
00023
00024
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';
00174
00175 return count;
00176 }