From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5344 invoked by alias); 13 Oct 2004 02:38:07 -0000 Mailing-List: contact xconq7-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: xconq7-owner@sources.redhat.com Received: (qmail 5329 invoked from network); 13 Oct 2004 02:38:06 -0000 Received: from unknown (HELO gencom001.gencom.us) (208.45.97.129) by sourceware.org with SMTP; 13 Oct 2004 02:38:06 -0000 Received: from localhost (localhost [127.0.0.1]) by gencom001.gencom.us (Postfix) with ESMTP id B3C046DEF; Tue, 12 Oct 2004 19:56:50 -0700 (PDT) Received: from gencom001.gencom.us ([127.0.0.1]) by localhost (gencom001.gencom.us [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 10384-08; Tue, 12 Oct 2004 19:56:50 -0700 (PDT) Received: from [192.168.0.100] (home [67.171.201.213]) by gencom001.gencom.us (Postfix) with ESMTP id 1E7C1644D; Tue, 12 Oct 2004 19:56:50 -0700 (PDT) From: "D. Cooper Stevenson" Reply-To: cstevens@gencom.us Organization: GenCom To: Eric McDonald Subject: Re: A Little Help Date: Sat, 16 Oct 2004 05:08:00 -0000 User-Agent: KMail/1.6.2 Cc: xconq7 References: <200410102134.15234.cstevens@gencom.us> <416B3E1C.6050004@phy.cmich.edu> In-Reply-To: <416B3E1C.6050004@phy.cmich.edu> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200410121745.32401.cstevens@gencom.us> X-Virus-Scanned: by amavisd-new at gencom001 X-SW-Source: 2004/txt/msg01353.txt.bz2 Thanks for this help, Eric. I'll continue working on it keep you and this list abreast of progress. My goal is to have this done by the end of this weekend. -Coop On Monday 11 October 2004 19:14, Eric McDonald wrote: > D. Cooper Stevenson wrote: > > * I haven't written (but do respect) the C language in a long time and > > it shows; I've had a tough go of it getting the application to work. > > > > I think it's time to ask for help. > > > > As I mentioned above, the GIS ASCII file format is simple. Here's a > > description: > > > > The first 7 or so lines represent the header of the file. The most > > relevant numbers for our purposes are the "rows" and "cols" numbers. The > > last line is the actual elevation (or landcover) data. Here's an example: > > > > north: 3980319.16466812 > > south: 3978824.85093895 > > east: 443960 > > west: 442296 > > If you don't need these values, you might want to just toss them. That > way you wouldn't have to tell your parser to ignore them. > > > rows: 747 > > cols: 832 > > You'll probably want to keep this information. The number of rows is > probably a better termination condition than EOF. And the number of > columns is useful for determining how many times to call strtok(3), for > example. > > Here is a vague handwaving outline of how one might go about some of > this. This is not guaranteed to be the best way. Just some spewing off > the top of my head...: > > /* Some definitions earlier on. */ > #define BUFSIZE 256 > #define DATAWIDTH 5 > char data [BUFSIZE] > int numrows = numcols = 0; > > /* Some code.... */ > > /* Part of your parser. (One possible way; there are others. Assumes you > are inside some sort of loop.) */ > if (numrows && numcols) > break; > fgets(data, BUFSIZE, ifp); > if (!strncmp("rows: ", data, 6)) { > numrows = atoi(data+6); > continue; > } > else if (!strncmp("cols: ", data, 6)) { > numcols = atoi(data+6); > continue; > } > > /* Some code...? */ > > /* Another part of your parser. */ > data2 = malloc(numcols*DATAWIDTH); > boxrowsz = numcols / BOXWIDTH; > elevbox = malloc(numcols * BOXHEIGHT * sizeof(int)); > for (i = 0; i < numrows; ++i) { > fgets(data2, numcols * DATAWIDTH, ifp); > memset(elevrow, 0, numcols * sizeof(int)); > for (j = 0; j < numcols; ++j) { > if (!j) > nextdata = strtok(data2, " "); > else > nextdata = strtok(NULL, " "); > /* Stuff the data into the appropriate elev row box and slot(s) > within the box. */ > /* You can use / and % (div and mod) to help determine which box to > stuff things in. */ > } > if (i && (0 == (i % BOXHEIGHT))) > /* Take median, mean, or whatever. */ > } > > /* More code.... */ > > /* You can use existing functions in libconq.a or maybe even just > libconqlow.a to help in writing out Xconq-readable forms, including > layer data. */ > > /* Hope this helps, > Eric */