static void PrintGeoTags(GTIF gt, GTIFPrintMethod print, object aux) { TIFF tif = gt.gt_tif; if (tif == null) { return; } object data; int count; if (gt.gt_methods.get(tif, (ushort)GTIFF_TIEPOINTS, out count, out data)) { PrintTag((int)GTIFF_TIEPOINTS, count / 3, (double[])data, 3, print, aux); } if (gt.gt_methods.get(tif, (ushort)GTIFF_PIXELSCALE, out count, out data)) { PrintTag((int)GTIFF_PIXELSCALE, count / 3, (double[])data, 3, print, aux); } if (gt.gt_methods.get(tif, (ushort)GTIFF_TRANSMATRIX, out count, out data)) { PrintTag((int)GTIFF_TRANSMATRIX, count / 4, (double[])data, 4, print, aux); } }
public static void GTIFPrint(GTIF gtif, GTIFPrintMethod print, object aux) { if (print == null) { print = DefaultPrint; } if (aux == null) { aux = Console.Out; } string message = FMT_GEOTIFF + "\n"; print(message, aux); message = string.Format("\t" + FMT_VERSION + "\n", gtif.gt_version); print(message, aux); message = string.Format("\t" + FMT_REV + "\n", gtif.gt_rev_major, gtif.gt_rev_minor); print(message, aux); message = string.Format("\t{0}\n", FMT_TAGS); print(message, aux); PrintGeoTags(gtif, print, aux); message = string.Format("\t\t{0}\n", FMT_TAGEND); print(message, aux); message = string.Format("\t{0}\n", FMT_KEYS); print(message, aux); foreach (GeoKey key in gtif.gt_keys.Values) { PrintKey(key, print, aux); } message = string.Format("\t\t{0}\n", FMT_KEYEND); print(message, aux); message = string.Format("\t{0}\n", FMT_GEOEND); print(message, aux); }
static void PrintTag(int tag, int nrows, double[] data, int ncols, GTIFPrintMethod print, object aux) { print("\t\t", aux); print(GTIFTagName(tag), aux); string message = string.Format(" ({0},{1}):\n", nrows, ncols); print(message, aux); int ind = 0; for (int i = 0; i < nrows; i++) { print("\t\t\t", aux); for (int j = 0; j < ncols; j++) { message = string.Format(FMT_DOUBLE, data[ind++]); print(message, aux); if (j < ncols - 1) { print(" ", aux); } } print("\n", aux); } }
static void PrintGeoTags(GTIF gt, GTIFPrintMethod print, object aux) { TIFF tif=gt.gt_tif; if(tif==null) return; object data; int count; if(gt.gt_methods.get(tif, (ushort)GTIFF_TIEPOINTS, out count, out data)) PrintTag((int)GTIFF_TIEPOINTS, count/3, (double[])data, 3, print, aux); if(gt.gt_methods.get(tif, (ushort)GTIFF_PIXELSCALE, out count, out data)) PrintTag((int)GTIFF_PIXELSCALE, count/3, (double[])data, 3, print, aux); if(gt.gt_methods.get(tif, (ushort)GTIFF_TRANSMATRIX, out count, out data)) PrintTag((int)GTIFF_TRANSMATRIX, count/4, (double[])data, 4, print, aux); }
public static void GTIFPrint(GTIF gtif, GTIFPrintMethod print, object aux) { if(print==null) print=DefaultPrint; if(aux==null) aux=Console.Out; string message=FMT_GEOTIFF+"\n"; print(message, aux); message=string.Format("\t"+FMT_VERSION+"\n", gtif.gt_version); print(message, aux); message=string.Format("\t"+FMT_REV+"\n", gtif.gt_rev_major, gtif.gt_rev_minor); print(message, aux); message=string.Format("\t{0}\n", FMT_TAGS); print(message, aux); PrintGeoTags(gtif, print, aux); message=string.Format("\t\t{0}\n", FMT_TAGEND); print(message, aux); message=string.Format("\t{0}\n", FMT_KEYS); print(message, aux); foreach(GeoKey key in gtif.gt_keys.Values) PrintKey(key, print, aux); message=string.Format("\t\t{0}\n", FMT_KEYEND); print(message, aux); message=string.Format("\t{0}\n", FMT_GEOEND); print(message, aux); }
static void PrintTag(int tag, int nrows, double[] data, int ncols, GTIFPrintMethod print, object aux) { print("\t\t", aux); print(GTIFTagName(tag), aux); string message=string.Format(" ({0},{1}):\n", nrows, ncols); print(message, aux); int ind=0; for(int i=0; i<nrows; i++) { print("\t\t\t", aux); for(int j=0; j<ncols; j++) { message=string.Format(FMT_DOUBLE, data[ind++]); print(message, aux); if(j<ncols-1) print(" ", aux); } print("\n", aux); } }
static void PrintKey(GeoKey key, GTIFPrintMethod print, object aux) { print("\t\t", aux); geokey_t keyid=key.gk_key; print(GTIFKeyName(keyid), aux); int count=key.gk_count; string message=string.Format(" ({0},{1}): ", GTIFTypeName(key.gk_type), count); print(message, aux); object data=key.gk_data; switch(key.gk_type) { case tagtype_t.TYPE_ASCII: { string str=data as string; if(str==null) throw new Exception("string expected."); if(str.Length<count) throw new Exception("string too short."); message="\""; for(int i=0; i<count; i++) { char c=str[i]; if(c=='\n') message+="\\n"; else if(c=='\\') message+="\\\\"; else if(c=='\t') message+="\\t"; else if(c=='\b') message+="\\b"; else if(c=='\r') message+="\\r"; else if(c=='"') message+="\\\""; else if(c=='\0') message+="\\0"; else message+=c; } message+="\"\n"; print(message, aux); } break; case tagtype_t.TYPE_DOUBLE: double[] dptr=data as double[]; if(dptr==null) throw new Exception("double[] expected."); if(dptr.Length<count) throw new Exception("double[] too short."); for(int i=0; i<count; i+=3) { int done=Math.Min(i+3, count); for(int j=i; j<done; j++) { message=string.Format(FMT_DOUBLE, dptr[j]); print(message, aux); } print("\n", aux); } break; case tagtype_t.TYPE_SHORT: ushort[] sptr=data as ushort[]; if(sptr==null) throw new Exception("ushort[] expected."); if(sptr.Length<count) throw new Exception("ushort[] too short."); if(count==1) { print(GTIFValueName(keyid, sptr[0]), aux); print("\n", aux); } else { for(int i=0; i<count; i+=3) { int done=Math.Min(i+3, count); for(int j=i; j<done; j++) { message=string.Format(FMT_SHORT, sptr[j]); print(message, aux); } print("\n", aux); } } break; default: message=string.Format("Unknown Type ({0})\n", key.gk_type); print(message, aux); break; } }
static void PrintKey(GeoKey key, GTIFPrintMethod print, object aux) { print("\t\t", aux); geokey_t keyid = key.gk_key; print(GTIFKeyName(keyid), aux); int count = key.gk_count; string message = string.Format(" ({0},{1}): ", GTIFTypeName(key.gk_type), count); print(message, aux); object data = key.gk_data; switch (key.gk_type) { case tagtype_t.TYPE_ASCII: { string str = data as string; if (str == null) { throw new Exception("string expected."); } if (str.Length < count) { throw new Exception("string too short."); } message = "\""; for (int i = 0; i < count; i++) { char c = str[i]; if (c == '\n') { message += "\\n"; } else if (c == '\\') { message += "\\\\"; } else if (c == '\t') { message += "\\t"; } else if (c == '\b') { message += "\\b"; } else if (c == '\r') { message += "\\r"; } else if (c == '"') { message += "\\\""; } else if (c == '\0') { message += "\\0"; } else { message += c; } } message += "\"\n"; print(message, aux); } break; case tagtype_t.TYPE_DOUBLE: double[] dptr = data as double[]; if (dptr == null) { throw new Exception("double[] expected."); } if (dptr.Length < count) { throw new Exception("double[] too short."); } for (int i = 0; i < count; i += 3) { int done = Math.Min(i + 3, count); for (int j = i; j < done; j++) { message = string.Format(FMT_DOUBLE, dptr[j]); print(message, aux); } print("\n", aux); } break; case tagtype_t.TYPE_SHORT: ushort[] sptr = data as ushort[]; if (sptr == null) { throw new Exception("ushort[] expected."); } if (sptr.Length < count) { throw new Exception("ushort[] too short."); } if (count == 1) { print(GTIFValueName(keyid, sptr[0]), aux); print("\n", aux); } else { for (int i = 0; i < count; i += 3) { int done = Math.Min(i + 3, count); for (int j = i; j < done; j++) { message = string.Format(FMT_SHORT, sptr[j]); print(message, aux); } print("\n", aux); } } break; default: message = string.Format("Unknown Type ({0})\n", key.gk_type); print(message, aux); break; } }