vanetsim.map
Class Region

java.lang.Object
  extended by vanetsim.map.Region

public final class Region
extends java.lang.Object

A region stores all objects in a specific part of the map. It stores streets, nodes and vehicles.


Field Summary
 java.util.ArrayList<java.lang.String> nnn
           
 java.util.ArrayList<java.lang.String> xxx
           
 java.util.ArrayList<java.lang.String> yyy
           
 
Constructor Summary
Region(int x, int y, int leftBoundary, int rightBoundary, int upperBoundary, int lowerBoundary)
          Constructor for a region.
 
Method Summary
 void addMixZone(Node node, int radius)
          adds mix zone at the location of "node" if no mix zone on this location already exists
 Node addNode(Node node, boolean doCheck)
          Function to add a node to this region.
 void addRSU(RSU rsu)
          Function to add a Road-Side-Units to this region.
 void addStreet(Street street, boolean doCheck)
          Function to add a street to this region.
 void addVehicle(Vehicle vehicle, boolean doCheck)
          Function to add a vehicle to this region.
 void calculateJunctions()
          This function should be called before starting simulation.
 void checkStreetsForBridges()
          Checks all streets in this region for possible bridges.
 void cleanVehicles()
          This function should be called before initializing a new scenario to delete all vehicles.
 void clearMixZones()
          clear all mix zones from this region.
 void clearRSUs()
          clear all RSUs from this region.
 void clearTrafficLights()
          This function deletes all traffic lights in this region
 void createBacklink(WorkerThread thread, int numberinThread)
          Creates a backlink to the worker thread which computes this region.
 void deleteMixZone(Node node)
          deletes mix zone at the node
 void delNode(Node node)
          Delete a node.
 void delRSU(RSU rsu)
          Delete a Road-Side-Unit.
 void delStreet(Street street)
          Delete a street.
 void delVehicle(Vehicle vehicle)
          Function to delete a vehicle from this region.
 java.lang.String[] getIntersectionPoints(Node mixNode, Region region12)
          Gets intersection points between mix-zone and streets.
 int getLeftBoundary()
          Gets the coordinate of the left boundary of this region.
 int getLowerBoundary()
          Gets the coordinate of the lower boundary of this region.
 Node[] getMixZoneNodes()
          Returns all mix zone nodes in this region.
 Node[] getNodes()
          Returns all nodes in this region.
 int getRightBoundary()
          Gets the coordinate of the right boundary of this region.
 RSU[] getRSUs()
          Returns all Road-Side-Units in this region.
 Street[] getStreets()
          Returns all streets in this region.
 int getUpperBoundary()
          Gets the coordinate of the upper boundary of this region.
 Vehicle[] getVehicleArray()
          Creates an array as a copy of the vehicle ArrayList to prevent problems during simulation caused by changing the ArrayList while reading it in another thread.
 java.util.ArrayList<Vehicle> getVehicleArrayList()
          Used to return the ArrayList of all vehicles.
 int getX()
          Function to get the x axis position of this region.
 int getY()
          Function to get the y axis position of this region.
 void prepareLogs(Node[] nodes)
          Method to prepare the log files.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xxx

public java.util.ArrayList<java.lang.String> xxx

yyy

public java.util.ArrayList<java.lang.String> yyy

nnn

public java.util.ArrayList<java.lang.String> nnn
Constructor Detail

Region

public Region(int x,
              int y,
              int leftBoundary,
              int rightBoundary,
              int upperBoundary,
              int lowerBoundary)
Constructor for a region.

Parameters:
x - the position on the x axis of the new region
y - the position on the y axis of the new region
leftBoundary - the coordinate of the left boundary
rightBoundary - the coordinate of the right boundary
upperBoundary - the coordinate of the upper boundary
lowerBoundary - the coordinate of the lower boundary
Method Detail

addNode

public Node addNode(Node node,
                    boolean doCheck)
Function to add a node to this region.

Parameters:
node - the node to add
doCheck - true if a check should be made if this node already exists; else false to skip the test
Returns:
the node added (might be different from node if it already existed and check was true)

delNode

public void delNode(Node node)
Delete a node.

Parameters:
node - the node

addRSU

public void addRSU(RSU rsu)
Function to add a Road-Side-Units to this region.

Parameters:
rsu - the RSU to add

delRSU

public void delRSU(RSU rsu)
Delete a Road-Side-Unit.

Parameters:
rsu - the RSU to delete

addStreet

public void addStreet(Street street,
                      boolean doCheck)
Function to add a street to this region. This also checks if it is intersecting with other streets in this region and sets the appropriate flag on the streets!

Parameters:
street - the street to add
doCheck - true if a check should be made if this street already exists; else false to skip the test

checkStreetsForBridges

public void checkStreetsForBridges()
Checks all streets in this region for possible bridges.


delStreet

public void delStreet(Street street)
Delete a street.

Parameters:
street - the street

addVehicle

public void addVehicle(Vehicle vehicle,
                       boolean doCheck)
Function to add a vehicle to this region.

Parameters:
vehicle - vehicle to add
doCheck - true if a check should be made if this vehicle already exists; else false to skip the test

delVehicle

public void delVehicle(Vehicle vehicle)
Function to delete a vehicle from this region.

Parameters:
vehicle - the vehicle to remove

getX

public int getX()
Function to get the x axis position of this region.

Returns:
x axis position

getY

public int getY()
Function to get the y axis position of this region.

Returns:
y axis position

calculateJunctions

public void calculateJunctions()
This function should be called before starting simulation. All nodes calculate if they are junctions and and what their priority streets are. Furthermore, mixing zones are generated.


addMixZone

public void addMixZone(Node node,
                       int radius)
adds mix zone at the location of "node" if no mix zone on this location already exists


deleteMixZone

public void deleteMixZone(Node node)
deletes mix zone at the node

Parameters:
node - Node where mix zone is placed on

prepareLogs

public void prepareLogs(Node[] nodes)
Method to prepare the log files. Calculates all intersections beetween streets and mix-zones


getIntersectionPoints

public java.lang.String[] getIntersectionPoints(Node mixNode,
                                                Region region12)
Gets intersection points between mix-zone and streets. Before evoking check if this node is a mix-zone. Note that the performance of this function is very bad. It has to be evoked before the start of the simulation!

Returns:
string array with to intersection String in form of "x1:x2:x3"

clearMixZones

public void clearMixZones()
clear all mix zones from this region.


clearRSUs

public void clearRSUs()
clear all RSUs from this region.


cleanVehicles

public void cleanVehicles()
This function should be called before initializing a new scenario to delete all vehicles.


clearTrafficLights

public void clearTrafficLights()
This function deletes all traffic lights in this region


getNodes

public Node[] getNodes()
Returns all nodes in this region.

Returns:
an array containing all nodes

getMixZoneNodes

public Node[] getMixZoneNodes()
Returns all mix zone nodes in this region.

Returns:
an array containing all nodes

getRSUs

public RSU[] getRSUs()
Returns all Road-Side-Units in this region.

Returns:
an array containing all RSUs

getStreets

public Street[] getStreets()
Returns all streets in this region.

Returns:
an array containing all streets

getVehicleArrayList

public java.util.ArrayList<Vehicle> getVehicleArrayList()
Used to return the ArrayList of all vehicles. Note that it can not guaranteed, that no changes are made after you received this.

Returns:
the ArrayList containing all vehicles

getVehicleArray

public Vehicle[] getVehicleArray()
Creates an array as a copy of the vehicle ArrayList to prevent problems during simulation caused by changing the ArrayList while reading it in another thread. The array is cached so that new ones are only created when needed.

Returns:
the array copy of all vehicles in this region or an empty array if there are no elements

createBacklink

public void createBacklink(WorkerThread thread,
                           int numberinThread)
Creates a backlink to the worker thread which computes this region.

Parameters:
thread - the thread
numberinThread - the number in the thread

getLeftBoundary

public int getLeftBoundary()
Gets the coordinate of the left boundary of this region.

Returns:
the coordinate

getRightBoundary

public int getRightBoundary()
Gets the coordinate of the right boundary of this region.

Returns:
the coordinate

getUpperBoundary

public int getUpperBoundary()
Gets the coordinate of the upper boundary of this region.

Returns:
the coordinate

getLowerBoundary

public int getLowerBoundary()
Gets the coordinate of the lower boundary of this region.

Returns:
the coordinate