# $Id: drn2gen.awk,v 1.1 2002-04-12 16:39:57 jan Exp $ # # Copyright (C) 1999, 2001 by Jan-Oliver Wagner # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # DESCRIPTION: # This script reads in a GREAT-ER '.drn' file # and converts the coordinates to a # ArcInfo 'generate' format for lines. BEGIN { if (LOG == "") { # check for logfile print "Panic: No log-file specified" > "/dev/stderr" exit 1 } FS = "," # set field separator countIgnored = countEmpty = countComment = countID = countCoords = 0 } /^#/ { comments[countComment] = $0 ; countComment ++ ; next } # skip comments /^$/ { countEmpty ++ ; next } # skip empty lines NF == 1 { if (countID > 0) { print "end" } countID ++ printf("%d\n", $1) # print StretchID next } NF == 2 { printf("%f,%f\n", $1,$2) # print coords countCoords ++ next } { ignored[countIgnored] = $0 ; countIgnored ++ } END { print "end\nend" # append two "end" tokens # some log-info and statistics printf("File %s processed by %s via $Id: drn2gen.awk,v 1.1 2002-04-12 16:39:57 jan Exp $ at %s:\n", FILENAME == "-" ? "" : FILENAME, ENVIRON["LOGNAME"], strftime()) >> LOG printf("\tNumber of stretches: %d\n", countID) >> LOG printf("\tTotal number of Coordinates: %d\n", countCoords) >> LOG printf("\tAverage stretch length: %d\n", countCoords / countID) >> LOG printf("\tNumber of empty lines: %d\n", countEmpty) >> LOG printf("\tNumber of comment lines: %d\n", countComment) >> LOG if (countComment > 0) { printf("\tList of comment lines:\n") >> LOG for (i = 0;i < countComment;i ++) { printf("%s\n", comments[i]) >> LOG } printf("\tEnd of comment list\n") >> LOG } printf("\tNumber of ignored lines: %d\n", countIgnored) >> LOG if (countIgnored > 0) { printf("\tList of ignored lines:\n") >> LOG for (i = 0;i < countIgnored;i ++) printf("%s\n", ignored[i]) >> LOG printf("\tEnd of ignore list\n") >> LOG } printf("\n") >> LOG }