Homework 2

Short Description:

Perform simple map analysis.

This assignment is worth 20 points.

Goals

When you finish this homework, you should have:

Formal Description

The planet of WA-TOR is a toroidal planet described in A.K. Dewdney's Computer Recreations column in Scientific American, December 1984. This (mythical) planet is in the shape of a torus, where the east connects to the west, and the north connects to the south. It can be formed by connecting the top and bottom edges of a piece of paper to form a tube, then connecting the ends of the tube. (This planet is ideal for computer simulation, but not so good for realism.)

The government of WA-TOR has hired your company to conduct a geographical survey of the planet, and you are to write the software to support this survey. As there are several other planets in the area with the same shape, you have decided to write a generic program to perform this task.

Your company has a satellite that circles the planet taking photographs, which are then assembled into a map. These maps, stored in one bit per pixel, record land sectors as a 1 and water sectors as a 0. One of WA-TOR's moons, Chessious, has the following survey map.

16 16
0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0
0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0
0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0
0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0
1 0 0 0 0 0 1 1 1 0 0 0 0 0 0 1 
1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 
1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 
1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 
0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0
0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0
0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0
0 0 0 1 1 0 0 0 0 0 0 1 1 0 0 0
1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 
1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 
1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 
1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 
As you will notice, Chessious appears to have 8 land masses, each of area 12 square units. The government of WA-TOR has defined an land mass to be a collection of 8-connected land sectors. Note a land mass can extend across the edges of a map. (The moon Addor, below, has one land mass.)
5 5
0 0 1 0 0
0 0 1 0 0
1 1 0 1 1
0 0 1 0 0
0 0 1 0 0

To simplify the process of aligning a map with a planet, your company places a reference pin, called the "top pin", in the planet. This pin is the reference point for all maps, and is given the coordinate 0,0. For any survey map, this pin will be in the upper left hand corner of the map.

Finally the government has established the following naming scheme for land masses. Starting at the top pin and heading west, the first land mass encountered is called "A", the next "B", until Z. After land mass Z, the naming continues with AA, AB, ... AZ, BA, BB, .... When you reach the top pin, sail south for one sector and repeat the process. Therefore the moon Chessious would have land masses named as follows:

 AA  BB
 AA  BB
C  DD C
C  DD C
 EE  FF
 EE  FF
G  HH G
G  HH G

Your program is to read a map and compute the following information:

Furthermore you are to produce a colored map of the planet surveyed.

Input

Your program should ask for the name of a file containing a survey map. This map will be in the following format:

Output

Your program should output the following items:
  • A survey map of the planet in ppm format. In the maps, the water should be some shade of blue. For the colored map, you should assign one of six different colors to land masses as they are encountered. A color 1, B color 2, C-3, D-4, E-5, F-6, G-1, and so on.

    Files should be named as follows.

    Discussion

    You must use standard container vector class for the one dimensional arrays in this program.

    You must use the standard algorithm library function sort to perform your sorts.

    You must implement a matrix class to store the planetary data. I would make the dereference function "fix" any errors in indexing.

    Do not make any assumptions about the size of the files. A planet must have at least one sector, but may be very large.

    Required Files

    The source code.

    Extra Credit

    If you are interested in creating a gui for your program, talk to me.

    Submission

    Email the source code to dbennett@edinboro.edu by September 28 at class time..