X-Git-Url: https://git.gag.com/?p=debian%2Fsplat;a=blobdiff_plain;f=utils%2Fusgs2sdf.c;fp=utils%2Fusgs2sdf.c;h=422ea855dd34ebf713cd40550ecc79bb9610b3d4;hp=acfb7f887e87e421750ccc54ebba2d89e87484b7;hb=68a3cad00312b42922f10cc4822349802f50ed20;hpb=0fe7930a10436ce250cae6daf2077415f8727af6 diff --git a/utils/usgs2sdf.c b/utils/usgs2sdf.c index acfb7f8..422ea85 100644 --- a/utils/usgs2sdf.c +++ b/utils/usgs2sdf.c @@ -1,10 +1,7 @@ -/***************************************************************************\ +/**************************************************************************** * USGS2SDF: USGS to SPLAT Data File Converter Utility * -* Copyright John A. Magliacane, KD2BD 1997-2001 * -* Last update: 05-Sep-2005 * -***************************************************************************** -* Updated July 2005 by John Gabrysch (jgabby@gmail.com) to properly handle * -* the updated USGS DEM file format and to properly scale Alaska tiles. * +* Copyright John A. Magliacane, KD2BD 1997-2009 * +* Last update: 14-Mar-2009 * ***************************************************************************** * * * This program reads files containing delimited US Geological Survey * @@ -26,7 +23,7 @@ * they represent (ie: min_north:max_north:min_west:max_west.sdf). * * * ***************************************************************************** -* To compile: gcc -Wall -O3 -s usgs2sdf.c -o usgs2sdf * +* To compile: gcc -Wall -O6 -s splat2sdf.c -o splat2sdf * ***************************************************************************** * * * This program is free software; you can redistribute it and/or modify it * @@ -39,7 +36,7 @@ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * * for more details. * * * -\***************************************************************************/ +*****************************************************************************/ #include #include @@ -64,12 +61,11 @@ int argc; char *argv[]; { unsigned char minimum[30], maximum[30], swlong[30], swlat[30], - nwlong[30], nwlat[30], nelong[30], nelat[30], - selong[30], selat[30]; + nwlong[30], nwlat[30], nelong[30], nelat[30], selong[30], + selat[30]; char string[40]; - double max_el, min_el, max_west, min_west, max_north, min_north; + double max_el, min_el, max_west, min_west, max_north, min_north; int x, y, z, c, array[1202][1202]; - int arc_mod=0; char splatfile[25]; FILE *fd; @@ -97,7 +93,6 @@ char *argv[]; for (x=0; x<22; x++) swlong[x]=getc(fd); - swlong[x]=0; /* Skip 2 bytes */ @@ -109,7 +104,6 @@ char *argv[]; for (x=0; x<22; x++) swlat[x]=getc(fd); - swlat[x]=0; /* Skip 2 bytes */ @@ -121,7 +115,6 @@ char *argv[]; for (x=0; x<22; x++) nwlong[x]=getc(fd); - nwlong[x]=0; /* Skip 2 bytes */ @@ -133,7 +126,6 @@ char *argv[]; for (x=0; x<22; x++) nwlat[x]=getc(fd); - nwlat[x]=0; /* Skip 2 bytes */ @@ -145,7 +137,6 @@ char *argv[]; for (x=0; x<22; x++) nelong[x]=getc(fd); - nelong[x]=0; /* Skip 2 bytes */ @@ -157,7 +148,6 @@ char *argv[]; for (x=0; x<22; x++) nelat[x]=getc(fd); - nelat[x]=0; /* Skip 2 bytes */ @@ -169,7 +159,6 @@ char *argv[]; for (x=0; x<22; x++) selong[x]=getc(fd); - selong[x]=0; /* Skip 2 bytes */ @@ -181,7 +170,6 @@ char *argv[]; for (x=0; x<22; x++) selat[x]=getc(fd); - selat[x]=0; /* Skip 2 bytes */ @@ -193,7 +181,6 @@ char *argv[]; for (x=0; x<22; x++) minimum[x]=getc(fd); - minimum[x]=0; /* Skip 2 bytes */ @@ -222,20 +209,9 @@ char *argv[]; max_north/=3600.0; min_west/=-3600.0; - /* If the latitude is between 50 and 70, there are only 600 vertical lines of data. - If the latitude is greater than 70, there are only 400. arc_mod is the flag for - use later */ - - if (min_north >= 50.0) - arc_mod++; - - if (min_north >= 70.0) - arc_mod++; + /* Skip 84 Bytes */ - - /* Skip 84 Bytes - Modified to 238 by jgabby 07/05 */ - - for (x=0; x<238; x++) + for (x=0; x<84; x++) getc(fd); /* Read elevation data... */ @@ -299,26 +275,9 @@ char *argv[]; c=getc(fd); } - string[z]=0; - + string[z]=0; sscanf(string,"%d",&array[y][x]); - - /* The next few lines either duplicate or triplicate the lines to - ensure a 1200x1200 result, depending on how arc_mod was set earlier */ - - if (arc_mod > 0) - sscanf(string,"%d",&array[y][x-1]); - - if (arc_mod > 1) - sscanf(string,"%d",&array[y][x-2]); } - - if (arc_mod > 0) - x--; - - - if (arc_mod > 1) - x--; } fclose(fd); @@ -348,8 +307,6 @@ char *argv[]; fprintf(stderr,"*** %c%s%c: File Not Found!\n",34,argv[1],34); exit(-1); } - else exit(0); } -