* A Little Help
@ 2004-10-12 2:15 D. Cooper Stevenson
2004-10-12 2:36 ` Eric McDonald
0 siblings, 1 reply; 8+ messages in thread
From: D. Cooper Stevenson @ 2004-10-12 2:15 UTC (permalink / raw)
To: xconq7
Dear All,
I've worked hard on importing ASCII data from GIS. Here's the good news:
* Exporting GIS data into ASCII may be automated using just one command
* The ASCII file format is simple
Here's the bad news:
* 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
rows: 747
cols: 832
10 10 10 9 9 ...........
Each number represents a terrain type. Well, that's not exactly true, but it's
close. 1-3 say, is beach, 4-6 is plains and so on.
So if you want an area of 54 x 42 cells, you would want to sample a "box" of
13 x 20 cells.
In other words:
1) Sample the first 13 numbers across by 20 lines down. A "mode" calculation
(the number that shows up the most) is best. An average will do I think.
Export this number to a terrain file; this is the first cell type.
2) Jump to the next "box," i.e. column 14-27 while still on lines 1-20 and
output it to a file. This is the second cell type.
3) Repeat until the file is finished.
Here is my code so far:
http://www.xconq.org/ascii/parsegis.c
Here is the actual GIS file (Huge: 21M):
http://www.xconq.org/ascii/seattle.arx
If you can offer a little help I'd be greatfull.
-Coop
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: A Little Help
2004-10-12 2:15 A Little Help D. Cooper Stevenson
@ 2004-10-12 2:36 ` Eric McDonald
2004-10-13 2:38 ` Eric McDonald
2004-10-16 5:08 ` D. Cooper Stevenson
0 siblings, 2 replies; 8+ messages in thread
From: Eric McDonald @ 2004-10-12 2:36 UTC (permalink / raw)
To: cstevens; +Cc: xconq7
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 */
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: A Little Help
2004-10-12 2:36 ` Eric McDonald
@ 2004-10-13 2:38 ` Eric McDonald
2004-10-16 5:08 ` D. Cooper Stevenson
1 sibling, 0 replies; 8+ messages in thread
From: Eric McDonald @ 2004-10-13 2:38 UTC (permalink / raw)
To: cstevens; +Cc: xconq7
Let me clear out some vestigial junk and clarify a few things:
> elevbox = malloc(numcols * BOXHEIGHT * sizeof(int));
elevboxrow = malloc(numcols * BOXHEIGHT * sizeof(int));
> memset(elevrow, 0, numcols * sizeof(int));
Not necessary and certainly not in this form.
> /* You can use / and % (div and mod) to help determine which box to
> stuff things in. */
Probably not necessary. Just put directly into column and row. Reduction
to medians or means is the only place where the row of boxes truly matters.
Eric
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: A Little Help
2004-10-12 2:36 ` Eric McDonald
2004-10-13 2:38 ` Eric McDonald
@ 2004-10-16 5:08 ` D. Cooper Stevenson
2004-10-16 18:22 ` Website Update Request Elijah Meeks
1 sibling, 1 reply; 8+ messages in thread
From: D. Cooper Stevenson @ 2004-10-16 5:08 UTC (permalink / raw)
To: Eric McDonald; +Cc: xconq7
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 */
^ permalink raw reply [flat|nested] 8+ messages in thread
* Website Update Request
2004-10-16 5:08 ` D. Cooper Stevenson
@ 2004-10-16 18:22 ` Elijah Meeks
2004-10-17 14:45 ` Eric McDonald
0 siblings, 1 reply; 8+ messages in thread
From: Elijah Meeks @ 2004-10-16 18:22 UTC (permalink / raw)
To: xconq7
I love xconq.org, but...
The poll doesn't seem to work (At least for me).
Can we have pages for the individual xconq games?
That way we can explain storyline, strategy and put up
screenshots.
Thanks,
Elijah
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Website Update Request
2004-10-16 18:22 ` Website Update Request Elijah Meeks
@ 2004-10-17 14:45 ` Eric McDonald
2004-10-18 23:47 ` D. Cooper Stevenson
0 siblings, 1 reply; 8+ messages in thread
From: Eric McDonald @ 2004-10-17 14:45 UTC (permalink / raw)
To: Elijah Meeks; +Cc: xconq7
Elijah Meeks wrote:
> I love xconq.org, but...
>
> The poll doesn't seem to work (At least for me).
I reactivated the surveys module, so this might be fixed now.
> Can we have pages for the individual xconq games?
I don't see why not. If you make the pages, you might to create a master
index page so that we don't have dozens of links from the home page.
Eric
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Website Update Request
2004-10-17 14:45 ` Eric McDonald
@ 2004-10-18 23:47 ` D. Cooper Stevenson
2004-10-23 19:39 ` Elijah Meeks
0 siblings, 1 reply; 8+ messages in thread
From: D. Cooper Stevenson @ 2004-10-18 23:47 UTC (permalink / raw)
To: Eric McDonald; +Cc: Elijah Meeks, xconq7
On Sat, 2004-10-16 at 11:22, Eric McDonald wrote:
[snip]
>
> > Can we have pages for the individual xconq games?
I can give you "author" access, Elijah, so that you can create and post
the content yourself. When you're ready to post, we can link it to the
main page. I think Eric's plan to create a single "games link" is the
best way to go. Let me know if you're interested and would like a login.
-Coop
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Website Update Request
2004-10-18 23:47 ` D. Cooper Stevenson
@ 2004-10-23 19:39 ` Elijah Meeks
0 siblings, 0 replies; 8+ messages in thread
From: Elijah Meeks @ 2004-10-23 19:39 UTC (permalink / raw)
To: cooper, Eric McDonald; +Cc: Elijah Meeks, xconq7
> I can give you "author" access, Elijah, so that you
> can create and post
> the content yourself. When you're ready to post, we
> can link it to the
> main page. I think Eric's plan to create a single
> "games link" is the
> best way to go. Let me know if you're interested and
> would like a login.
That sounds fine, as long as I'm working with
templates. I have no artistic talent whatsoever.
None. Zero. Nada. Zilch.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2004-10-18 23:47 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-12 2:15 A Little Help D. Cooper Stevenson
2004-10-12 2:36 ` Eric McDonald
2004-10-13 2:38 ` Eric McDonald
2004-10-16 5:08 ` D. Cooper Stevenson
2004-10-16 18:22 ` Website Update Request Elijah Meeks
2004-10-17 14:45 ` Eric McDonald
2004-10-18 23:47 ` D. Cooper Stevenson
2004-10-23 19:39 ` Elijah Meeks
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).