VANET Simulator
 All Classes Functions Variables
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
vanetsim.map.Map Class Reference

Public Member Functions

void initNewMap (int width, int height, int regionWidth, int regionHeight)
 
void signalMapLoaded ()
 
void load (File file, boolean zip)
 
void save (File file, boolean zip)
 
Node addNode (Node node)
 
void delNode (Node node)
 
void addRSU (RSU rsu)
 
void delRSU (int x, int y)
 
void addVehicle (Vehicle vehicle)
 
void delVehicle (Vehicle vehicle)
 
void addStreet (Street street)
 
void delStreet (Street street)
 
void addMixZone (Node node, int radius)
 
void deleteMixZone (Node node)
 
void clearMixZones ()
 
void clearRSUs ()
 
void clearVehicles ()
 
void autoTrimMap (int minX, int minY, int maxX, int maxY)
 
int trimStreet (int streetXInside, int streetYInside, int streetXOutside, int streetYOutside, int border)
 
void saveReloadMap ()
 
void clearTrafficLights ()
 
int getMapWidth ()
 
int getMapHeight ()
 
Region getRegionOfPoint (int x, int y)
 
void writeSilentPeriodHeader ()
 
Region[][] getRegions ()
 
int getRegionCountX ()
 
int getRegionCountY ()
 
boolean getReadyState ()
 

Static Public Member Functions

static Map getInstance ()
 

Static Public Attributes

static final int LANE_WIDTH = 300
 

Detailed Description

The map. The coordinate system is 2-dimensional with each axis allowing values from 0 to Integer.MAXVALUE (2147483647). Negative values are not allowed. The scale is 1:1cm which means that about 21474km x 21474km is the maximum size of a map (should be more than enough for all cases). The map is divided into several rectangular Regions in order to improve performance. All vehicles, nodes and streets are stored in these regions. Because of the regions, for example rendering and distance calculations only need to be done on a limited amount of vehicles/streets/nodes which helps handling large maps a lot.

Member Function Documentation

void vanetsim.map.Map.addMixZone ( Node  node,
int  radius 
)
inline

Add a new mix zone to the correct region. A mix zone can only be in one region.

Parameters
nodethe mix zone node to add
radiusthe mix zone radius
Node vanetsim.map.Map.addNode ( Node  node)
inline

Add a new node to the correct region. A node can only be in one region.

Parameters
nodethe node to add
Returns
the added node (might be different if already existing!)
void vanetsim.map.Map.addRSU ( RSU  rsu)
inline

Add a new Road-Side-Unit to the correct region. A RSU can only be in one region.

Parameters
rsuthe RSU to add
void vanetsim.map.Map.addStreet ( Street  street)
inline

Add a new street to the correct region(s). Note that a street can be in multiple regions and so we must determine all here! This makes rendering and calculations a lot easier later!

Parameters
streetthe street to add
void vanetsim.map.Map.addVehicle ( Vehicle  vehicle)
inline

Add a new vehicle to the correct start region. A vehicle can only be in one region and may move to other regions during the simulation. Although a vehicle is part of a scenario, it's added here as the map knows everything about how to correctly put it into a region.

Parameters
vehiclethe vehicle to add
void vanetsim.map.Map.autoTrimMap ( int  minX,
int  minY,
int  maxX,
int  maxY 
)
inline

Function to trim a map. If no coordinates are chosen the map will be trimmed to its borders (Only empty space will be removed). Otherwise the map will be trimmed according to the coordinates.

Parameters
minXthe minimum x coordinate
maxXthe maximum x coordinate
minYthe minimum y coordinate
maxYthe maximum y coordinate
void vanetsim.map.Map.clearMixZones ( )
inline

Delete every Mix Zone on this map

void vanetsim.map.Map.clearRSUs ( )
inline

Delete every RSU on this map

void vanetsim.map.Map.clearTrafficLights ( )
inline

Delete every turn-off lane on this map

void vanetsim.map.Map.clearVehicles ( )
inline

Delete every Vehicle on this map

void vanetsim.map.Map.deleteMixZone ( Node  node)
inline

Delete a mix zone in the correct region.

void vanetsim.map.Map.delNode ( Node  node)
inline

Delete a node from it's region.

Parameters
nodethe node to remove
void vanetsim.map.Map.delRSU ( int  x,
int  y 
)
inline

Delete a Road-Side-Unit from it's region.

Parameters
xthe x coordinate of the rsu
ythe y coordinate of the rsu
void vanetsim.map.Map.delStreet ( Street  street)
inline

Delete a street from all region(s) it's in.

Parameters
streetthe street to delete
void vanetsim.map.Map.delVehicle ( Vehicle  vehicle)
inline

Deletes a vehicle from it's region.

Parameters
vehiclethe vehicle to delete
static Map vanetsim.map.Map.getInstance ( )
inlinestatic

Gets the single instance of this map.

Returns
single instance of this map
int vanetsim.map.Map.getMapHeight ( )
inline

Gets the map height.

Returns
the map height
int vanetsim.map.Map.getMapWidth ( )
inline

Gets the map width.

Returns
the map width
boolean vanetsim.map.Map.getReadyState ( )
inline

Returns if a map is currently in the process of being loaded. While loading, simulation and rendering should not be done because not all map elements are already existing!

Returns
true if loading has finished, else false
int vanetsim.map.Map.getRegionCountX ( )
inline

Gets the amount of regions in x direction.

Returns
the amount of regions in x direction
int vanetsim.map.Map.getRegionCountY ( )
inline

Gets the amount of regions in y direction.

Returns
the amount of regions in y direction
Region vanetsim.map.Map.getRegionOfPoint ( int  x,
int  y 
)
inline

Calculates the Region of a point.

Parameters
xthe x coordinate of the point
ythe y coordinate of the point
Returns
the region in which this point is located or null if there was a problem
Region [][] vanetsim.map.Map.getRegions ( )
inline

Gets all regions.

Returns
all regions
void vanetsim.map.Map.initNewMap ( int  width,
int  height,
int  regionWidth,
int  regionHeight 
)
inline

Initializes a new map.

Parameters
widththe width
heightthe height
regionWidththe width of a region
regionHeightthe height of a region
void vanetsim.map.Map.load ( File  file,
boolean  zip 
)
inline

Load a map.

Parameters
filethe file to load
ziptrue if the file given is zipped, else false
void vanetsim.map.Map.save ( File  file,
boolean  zip 
)
inline

Save the map.

Parameters
filethe file in which to save
zipif true, file is saved in a compressed zip file (extension .zip is added to file!). If false, no compression is made.
void vanetsim.map.Map.saveReloadMap ( )
inline

Helper function to save and reload a map after editing

void vanetsim.map.Map.signalMapLoaded ( )
inline

This function needs to be called to signal that the loading process of the map has finished.

void vanetsim.map.Map.writeSilentPeriodHeader ( )
inline

write silent period header to log file

Member Data Documentation

final int vanetsim.map.Map.LANE_WIDTH = 300
static

The width of a single lane (3m). Used in various other places in this program!


The documentation for this class was generated from the following file: