-
Notifications
You must be signed in to change notification settings - Fork 4
Map
4ND4 edited this page Mar 25, 2016
·
1 revision
Map
It consists in a mixture of Roads and Intersections and it is the graph structure that our map holds. In this class there are substantial functions that allow us to communicate with the different components. After accesing the Roads that reside in the map we can also access Lanes, Cells, etc. In this class there are two important functions which give us the capability of loading and saving maps. For the latter it would save the serialized map object to the Map directory; for the former it would load a saved map model with it's composite components.
public void saveMap(String fileName)
{
try
{
File directory = new File(MAP_DIR);
if(!directory.exists()) {
directory.mkdir();
}
String path = MAP_DIR + fileName;
File file = new File(path);
if(!file.exists()) {
file.createNewFile();
}
// save the map
FileOutputStream fileOut = new FileOutputStream(path);
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(this);
out.close();
fileOut.close();
}catch(IOException i)
{
i.printStackTrace();
}
}