#include <map.h>
Public Methods | |
Map (void) | |
~Map () | |
bool | load_map (char *) |
void | show_map (void) |
int | max_x (void) |
int | max_y (void) |
int | x (int node) |
int | y (int node) |
int | first_node (void) |
int | num_nodes (void) |
int | connected_to (int, int, int=-1) |
int | num_connections (int, int=-1) |
char * | get_name (int node) |
int | next_short (int, int, bool, bool, bool) |
bool | taxi (int node) |
bool | bus (int node) |
bool | subway (int node) |
bool | taxi (int fromNode, int toNode) |
bool | bus (int fromNode, int toNode) |
bool | subway (int fromNode, int toNode) |
vect | vehicle (int fromNode, int toNode) |
Private Methods | |
void | initialize (int *array, int size) |
void | get_field (int, mode) |
Private Attributes | |
int | numNodes |
int | maxX |
int | maxY |
MapNode * | nodes |
ifstream | mapFile |
|
Definition at line 42 of file map.h. References maxX, maxY, and numNodes.
|
|
Definition at line 43 of file map.h.
00043 { delete [] nodes; } |
|
Definition at line 71 of file map.h. References Bus, and MapNode::is_link().
|
|
Definition at line 65 of file map.h. References Bus, and MapNode::is_link().
|
|
Definition at line 113 of file map.c. References between(), MapNode::find_join(), MapNode::find_link(), FIRST, nodes, and numNodes.
00113 { 00114 00115 if ( between(node, FIRST, numNodes) ) 00116 if ( join > -1 ) 00117 return nodes[node].find_join(link, join); 00118 else { 00119 return nodes[node].find_link(link); 00120 } 00121 00122 else { 00123 cerr << "Node " << node << " out of range (" 00124 << FIRST << ".." << numNodes << ")\n"; 00125 return 0; // node 0 points to NULL 00126 } 00127 } |
|
Definition at line 54 of file map.h. References FIRST.
00054 { return FIRST; } |
|
Definition at line 23 of file map.c. References FIELD, MapNode::get_join(), MapNode::get_link(), mapFile, mode, nodes, SUB1, and SUB2. Referenced by load_map().
00023 { 00024 // Input a transportation field from the map file. 00025 00026 char ch; 00027 int link; 00028 00029 mapFile >> ch; 00030 if ( ch != FIELD ) { 00031 mapFile.putback(ch); 00032 while ( ch != FIELD ) { 00033 mapFile >> link >> ch; 00034 nodes[node].get_link(link, transportation); 00035 if ( ch == SUB1 ) { // if a subfield is found... 00036 while ( ch != SUB2 ) { // ...loop through the subfield until end 00037 mapFile >> link >> ch; 00038 nodes[node].get_join(link); 00039 } 00040 mapFile >> ch; // pattern always ")," or ");" 00041 } 00042 } 00043 } 00044 } |
|
Definition at line 60 of file map.h. References MapNode::find_name().
|
|
Definition at line 18 of file map.c.
00019 { for (int i= 0; i < size; i++) array[i]= 0; } |
|
Definition at line 67 of file map.c. References Bus, EOLN, FIRST, get_field(), MapNode::get_name(), mapFile, maxX, maxY, nodes, numNodes, Subway, Taxi, MapNode::x, and MapNode::y. Referenced by main().
00067 { 00068 // Read in a map and construct a data representation 00069 00070 const int BUFFER= 40; // size of the "node name" input buffer 00071 const char COMMENT= '/'; // lines beginning with COMMENT are ignored 00072 00073 char text[BUFFER], ch; 00074 int nodeNum= 0; 00075 00076 mapFile.open(mapName, ios::in); 00077 00078 if ( !mapFile.fail() ) { 00079 mapFile >> numNodes; 00080 00081 nodes= new MapNode[numNodes + FIRST]; // store the adjacency list here 00082 assert (nodes != 0); 00083 00084 while ( nodeNum < numNodes ) { 00085 // ignore lines commented with COMMENT 00086 if (mapFile.peek() == COMMENT) while (mapFile.get() != EOLN) ; 00087 mapFile >> nodeNum >> ch; 00088 00089 get_field(nodeNum, Taxi); 00090 get_field(nodeNum, Bus); 00091 get_field(nodeNum, Subway); 00092 00093 mapFile >> nodes[nodeNum].x >> ch; 00094 if (nodes[nodeNum].x > maxX) maxX= nodes[nodeNum].x; 00095 mapFile >> nodes[nodeNum].y >> ch; 00096 if (nodes[nodeNum].y > maxY) maxY= nodes[nodeNum].y; 00097 00098 ch= mapFile.get(); 00099 while (ch == ' ') ch= mapFile.get(); // ignore whitespace 00100 mapFile.putback(ch); // put the last read character back into the buffer 00101 mapFile.getline(text, BUFFER, EOLN); // input node name and... 00102 // ...store name in adjacency list 00103 nodes[nodeNum].get_name(text, mapFile.gcount()); 00104 } 00105 } 00106 00107 mapFile.close(); 00108 return (bool) mapFile.good(); // return true if all file operations went well 00109 } |
|
Definition at line 48 of file map.h. References maxX.
00048 { return maxX; } |
|
Definition at line 49 of file map.h. References maxY.
00049 { return maxY; } |
|
Definition at line 147 of file map.c.
00147 { 00148 // This would have been a function to return the next nearest 00149 // link in a path using Dijkstra's shortest path algorithm. 00150 // Design changes, however, have made this function obsolete. 00151 // A nearest-neighbor algorithm is used instead. We have 00152 // decided to implement this algorithm outside of the map 00153 // module. 00154 00155 return 0; 00156 } |
|
Definition at line 131 of file map.c. References between(), FIRST, nodes, MapNode::num_joins(), MapNode::numLinks, and numNodes.
00131 { 00132 00133 if ( between(node, FIRST, numNodes) ) 00134 if ( join > -1 ) 00135 return nodes[node].num_joins(join); 00136 else 00137 return nodes[node].numLinks; 00138 else { 00139 cerr << "Node " << node << " out of range (" 00140 << FIRST << ".." << numNodes << ")\n"; 00141 return 0; // node 0 points to NULL 00142 } 00143 } |
|
Definition at line 55 of file map.h. References numNodes.
00055 { return numNodes; } |
|
Definition at line 54 of file map.c. References EOLN, FIRST, maxX, maxY, nodes, numNodes, and MapNode::show_node().
|
|
Definition at line 74 of file map.h. References MapNode::is_link(), and Subway.
|
|
Definition at line 66 of file map.h. References MapNode::is_link(), and Subway.
|
|
Definition at line 68 of file map.h. References MapNode::is_link(), and Taxi.
|
|
Definition at line 64 of file map.h. References MapNode::is_link(), and Taxi.
|
|
Definition at line 77 of file map.h. References MapNode::find_vector(), and vect.
00078 { return nodes[fromNode].find_vector(toNode); } |
|
Definition at line 51 of file map.h. References MapNode::x.
|
|
Definition at line 52 of file map.h. References MapNode::y.
|
|
|
|
|
|
|
|
Definition at line 35 of file map.h. Referenced by connected_to(), get_field(), load_map(), num_connections(), and show_map(). |
|
Definition at line 31 of file map.h. Referenced by connected_to(), load_map(), Map(), num_connections(), num_nodes(), and show_map(). |