ns2::NetTranslater Class Reference


Detailed Description

class for translating sumo net needed for avoiding negative coordinates in ns2
Author:
Thimor Bohn <bohn@itm.uni-luebeck.de>

Definition at line 12 of file NetTranslater.java.


Static Public Member Functions

static void translate (List< Edge > edges, Map< String, Junction > junctions)

Member Function Documentation

static void ns2::NetTranslater::translate ( List< Edge edges,
Map< String, Junction junctions 
) [inline, static]

method fro translating sumo net needed for avoiding negative coordinates in ns2

Parameters:
edges contains sumo net

Definition at line 18 of file NetTranslater.java.

00018                                                                                     {
00019         // scan coordinates
00020         float xmin = 0;
00021         float ymin = 0;
00022         boolean first = true;
00023         for (Junction junction: junctions.values())
00024         {
00025             if (first)
00026             {
00027                 first = false;
00028                 xmin  = junction.x;
00029                 ymin  = junction.y;
00030             }
00031             else
00032             {
00033                 xmin = Math.min(xmin, junction.x);
00034                 ymin = Math.min(ymin, junction.y);
00035             }
00036         }
00037         // translate if needed
00038         if (xmin < 0 || ymin < 0) {
00039             for (Junction junction: junctions.values())
00040             {
00041                 junction.x -= xmin;
00042                 junction.y -= ymin;
00043             }
00044             for (Edge edge: edges) {
00045                 for (Lane lane: edge.lanes.values())
00046                 {
00047                     lane.xfrom -= xmin;
00048                     lane.xto   -= xmin;
00049                     lane.yfrom -= ymin;
00050                     lane.yto   -= ymin;
00051                 }
00052             }           
00053         }
00054     }


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

Generated on Wed May 5 00:07:02 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6