|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object vanetsim.map.Map
public final class Map
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 Region
s 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.
Field Summary | |
---|---|
static int |
LANE_WIDTH
The width of a single lane (3m). |
Method Summary | |
---|---|
void |
addMixZone(Node node,
int radius)
Add a new mix zone to the correct region. |
Node |
addNode(Node node)
Add a new node to the correct region. |
void |
addRSU(RSU rsu)
Add a new Road-Side-Unit to the correct region. |
void |
addStreet(Street street)
Add a new street to the correct region(s). |
void |
addVehicle(Vehicle vehicle)
Add a new vehicle to the correct start region. |
void |
autoTrimMap(int minX,
int minY,
int maxX,
int maxY)
Function to trim a map. |
void |
clearMixZones()
Delete every Mix Zone on this map |
void |
clearRSUs()
Delete every RSU on this map |
void |
clearTrafficLights()
Delete every turn-off lane on this map |
void |
clearVehicles()
Delete every Vehicle on this map |
void |
deleteMixZone(Node node)
Delete a mix zone in the correct region. |
void |
delNode(Node node)
Delete a node from it's region. |
void |
delRSU(int x,
int y)
Delete a Road-Side-Unit from it's region. |
void |
delStreet(Street street)
Delete a street from all region(s) it's in. |
void |
delVehicle(Vehicle vehicle)
Deletes a vehicle from it's region. |
static Map |
getInstance()
Gets the single instance of this map. |
int |
getMapHeight()
Gets the map height. |
int |
getMapWidth()
Gets the map width. |
boolean |
getReadyState()
Returns if a map is currently in the process of being loaded. |
int |
getRegionCountX()
Gets the amount of regions in x direction. |
int |
getRegionCountY()
Gets the amount of regions in y direction. |
Region |
getRegionOfPoint(int x,
int y)
Calculates the Region of a point. |
Region[][] |
getRegions()
Gets all regions. |
void |
initNewMap(int width,
int height,
int regionWidth,
int regionHeight)
Initializes a new map. |
void |
load(java.io.File file,
boolean zip)
Load a map. |
void |
save(java.io.File file,
boolean zip)
Save the map. |
void |
saveReloadMap()
Helper function to save and reload a map after editing |
void |
signalMapLoaded()
This function needs to be called to signal that the loading process of the map has finished. |
int |
trimStreet(int streetXInside,
int streetYInside,
int streetXOutside,
int streetYOutside,
int border)
|
void |
writeSilentPeriodHeader()
write silent period header to log file |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int LANE_WIDTH
Method Detail |
---|
public static Map getInstance()
public void initNewMap(int width, int height, int regionWidth, int regionHeight)
width
- the widthheight
- the heightregionWidth
- the width of a regionregionHeight
- the height of a regionpublic void signalMapLoaded()
public void load(java.io.File file, boolean zip)
file
- the file to loadzip
- true
if the file given is zipped, else false
public void save(java.io.File file, boolean zip)
file
- the file in which to savezip
- if true
, file is saved in a compressed zip file (extension .zip is added to file
!). If false
, no compression is made.public Node addNode(Node node)
node
- the node to add
public void delNode(Node node)
node
- the node to removepublic void addRSU(RSU rsu)
rsu
- the RSU to addpublic void delRSU(int x, int y)
x
- the x coordinate of the rsuy
- the y coordinate of the rsupublic void addVehicle(Vehicle vehicle)
vehicle
- the vehicle to addpublic void delVehicle(Vehicle vehicle)
vehicle
- the vehicle to deletepublic void addStreet(Street street)
street
- the street to addpublic void delStreet(Street street)
street
- the street to deletepublic void addMixZone(Node node, int radius)
node
- the mix zone node to addradius
- the mix zone radiuspublic void deleteMixZone(Node node)
public void clearMixZones()
public void clearRSUs()
public void clearVehicles()
public void autoTrimMap(int minX, int minY, int maxX, int maxY)
minX
- the minimum x coordinatemaxX
- the maximum x coordinateminY
- the minimum y coordinatemaxY
- the maximum y coordinatepublic int trimStreet(int streetXInside, int streetYInside, int streetXOutside, int streetYOutside, int border)
public void saveReloadMap()
public void clearTrafficLights()
public int getMapWidth()
public int getMapHeight()
public Region getRegionOfPoint(int x, int y)
Region
of a point.
x
- the x coordinate of the pointy
- the y coordinate of the point
null
if there was a problempublic void writeSilentPeriodHeader()
public Region[][] getRegions()
public int getRegionCountX()
public int getRegionCountY()
public boolean getReadyState()
true
if loading has finished, else false
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |