[PLUG] Xconq GIS Help Wanted

D. Cooper Stevenson cooper at cooper.stevenson.name
Tue Oct 19 22:41:02 UTC 2004


Dear All,

A few weeks ago I came up with what I thought was a great idea. I thought, 
"what would happen if people could play a strategy game with real-world 
terrain? What would happen if you could run military campaigns in the 
Columbia Gorge?

I first embarked to see if I could create maps with actual GIS data. Sure 
enough, you can! I wrote a HOWTO (with screenshots) here:

  http://wiki.xconqgis.org/index.php?UsgsMapImportHowto

Yeah, I know it's cool.

Here's a screenshot of what a GIS game map might look like sans units:

  http://wiki.xconqgis.org/index.php?WhatGisImageMightLookLike

Then I started looking around for a mature strategy game platform that I could 
incorporate the GIS data in. I found Xconq. Xconq is well known by many 
strategy gamers as it's been actively developed for years. I liked the 
project so much I developed a new website for it:

  http://www.xconq.org

Note: There's also a generic strategy game framework here:

  http://regcom.sourceforge.net/index.html

The best way to incorporate GIS data into Xconq is by converting an ASCII GIS 
output file to an Xconq input file. Don't worry, you don't have to understand 
the ins-and-outs of Xconq to see what needs to happen.

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.


Thanks,


Cooper




More information about the PLUG mailing list