Package de.hpi.eworld.model.db.data

Examples of de.hpi.eworld.model.db.data.EdgeModel


   *            The position, to look for edges.
   * @return The Edge, which was nearest to the given position.
   * @author Frank Huxol
   */
  public static EdgeModel getNearestEdgeOutOf(Point2D position, List<EdgeModel> edges) {
    EdgeModel nearestEdges = null;
    double nearestDistance = Double.MAX_VALUE;
    for (EdgeModel edge : edges) {
      Point2D from = edge.getFromNode().getPosition().projected();
      Point2D to = edge.getToNode().getPosition().projected();
      if (Geometry.isPointNearLine(position, from, to, nearestDistance)){
View Full Code Here


    if (DATABASE_DISABLED)
      return;
   
   
    WayModel testWay = new WayModel("My way");
    EdgeModel testEdge = TestCaseUtil.createTestEdge();
    EdgeModel testEdge2 = TestCaseUtil.createTestEdge();
    testWay.addForwardEdge(testEdge);
    testWay.addBackwardEdge(testEdge2);
   
    boolean found = false;
    Collection<ModelElement> c = databaseSaveLoadGeneric(testWay);
View Full Code Here

  public void testRoadEvent () {
   
    NodeModel fromNode = new NodeModel(2.3, 45,6);
    NodeModel toNode = new NodeModel(45.22, 78.899);
   
    EdgeModel e = new EdgeModel("testModelID", fromNode, toNode);
    EdgeLocationModel el1 = new EdgeLocationModel(e, -12.3, -55.67);
    EdgeLocationModel el2 = new EdgeLocationModel(e, 12.3, 55.67);
   
    RoadEventModel re1 = new RoadEventModel(RoadEventModel.Type.Accident, el1);
    RoadEventModel re2 = new RoadEventModel(RoadEventModel.Type.Roadwork, el1);
View Full Code Here

    // set up ee3 with EdgeLocation
   
    NodeModel fromNode = new NodeModel(2.3, 45,6);
    NodeModel toNode = new NodeModel(45.22, 78.899);
   
    EdgeModel e = new EdgeModel("testModelID", fromNode, toNode);
    EdgeLocationModel el = new EdgeLocationModel(e, -12.3, -55.67);
   
    EnvironmentEventModel ee3 =
      new EnvironmentEventModel(EnvironmentEventModel.Type.Snow, 0, el);
   
View Full Code Here

    // set up RoadEvents
   
    NodeModel fromNode = new NodeModel(2.3, 45,6);
    NodeModel toNode = new NodeModel(45.22, 78.899);
   
    EdgeModel e = new EdgeModel("testModelID", fromNode, toNode);
    EdgeLocationModel el1 = new EdgeLocationModel(e, -12.3, -55.67);
    EdgeLocationModel el2 = new EdgeLocationModel(e, 12.3, 55.67);
   
    RoadEventModel re1 = new RoadEventModel(RoadEventModel.Type.Accident, el1);
    RoadEventModel re2 = new RoadEventModel(RoadEventModel.Type.Roadwork, el1);
   
    RoadEventModel re3 = new RoadEventModel(RoadEventModel.Type.Accident, el2);
    RoadEventModel re4 = new RoadEventModel(RoadEventModel.Type.Roadwork, el2);
   
    RoadEventModel re5 = new RoadEventModel(RoadEventModel.Type.Accident);
    RoadEventModel re6 = new RoadEventModel(RoadEventModel.Type.Roadwork);
   
    ///////////////////////////////////
    // set up ee1 with CircleLocation
   
    CircleLocationModel cl = new CircleLocationModel();
   
    Point2D positionOnScreen = new Point2D.Double(3,4);
    GlobalPosition centerPosition = GlobalPosition.from(positionOnScreen);
    cl.setCenter(centerPosition);
   
    Point2D circlePoint = new Point2D.Double(0, -25);
    GlobalPosition circlePosition = GlobalPosition.from(circlePoint);
    cl.setCirclePoint(circlePosition);
   
    cl.setRadius(centerPosition.distanceTo(circlePosition));
   
    EnvironmentEventModel ee1 =
      new EnvironmentEventModel(EnvironmentEventModel.Type.CO2, 12, cl);
   
    ///////////////////////////////////
    // set up ee2 with PloygonLocation
   
    PolygonLocationModel pl = new PolygonLocationModel();
   
    List<GlobalPosition> positions = new ArrayList<GlobalPosition>();
   
    Point2D p1 = new Point2D.Double(3,4);
    GlobalPosition gp1 = GlobalPosition.from(p1);
    positions.add(gp1);
   
    Point2D p2 = new Point2D.Double(13,14);
    GlobalPosition gp2 = GlobalPosition.from(p2);
    positions.add(gp2);
   
    Point2D p3 = new Point2D.Double(22,23);
    GlobalPosition gp3 = GlobalPosition.from(p3);
    positions.add(gp3);
   
    Point2D p4 = new Point2D.Double(12,9);
    GlobalPosition gp4 = GlobalPosition.from(p4);
    positions.add(gp4);
   
    Point2D p5 = new Point2D.Double(3,34);
    GlobalPosition gp5 = GlobalPosition.from(p5);
    positions.add(gp5);
   
    pl.setPoints(positions);
   
    EnvironmentEventModel ee2 =
      new EnvironmentEventModel(EnvironmentEventModel.Type.Fog, -23, pl);
   
    ///////////////////////////////////
    // set up ee3 with EdgeLocation
   
    NodeModel fromNode2 = new NodeModel(2.3, 45,6);
    NodeModel toNode2 = new NodeModel(45.22, 78.899);
   
    EdgeModel e2 = new EdgeModel("testModelID", fromNode2, toNode2);
    EdgeLocationModel el = new EdgeLocationModel(e2, -12.3, -55.67);
   
    EnvironmentEventModel ee3 =
      new EnvironmentEventModel(EnvironmentEventModel.Type.Snow, 0, el);
   
View Full Code Here

    ModelManager mm = ModelManager.getInstance();
    mm.clearModel();

    StatisticsDataManager smm = StatisticsDataManager.getInstance();
    smm.clear();
    EdgeModel testEdge = null;

    // create 2 dummy models
    StatDataset model1 = new StatDataset();
    model1.setBelongsToCurrentMap(true);
    StatInterval interval1 = new StatInterval("int1", 0, 100);
    model1.addInterval(interval1);
    StatDataset model2 = new StatDataset();
    model2.setBelongsToCurrentMap(true);
    StatInterval interval2 = new StatInterval("int2", 0, 100);
    model2.addInterval(interval2);

    for (ModelElement element : allElements) {
      if (element instanceof WayModel) {
        WayModel way = (WayModel) element;
        //add way to ModelManager
        mm.addModelElement(way);
       
        List<EdgeModel> edges = way.getBackwardEdges();
        edges.addAll(way.getForwardEdges());
        for (EdgeModel edge : edges) {
          // for each edge in the testcase add a StatEdge to the dummy
          // model...
          // with defaults for the values to be tested for (maxspeed, minspeed,
          // street name) and ...
          // ...without lanes (model1)
          StatEdge edge1 = TestCaseUtil.createTestStatEdge(true,
              false, 0, edge.getInternalID());
          edge1.setMaxSpeed(0);
          edge1.setMinSpeed(0);
          edge1.setStreetName(null);
          interval1.addStatEdge(edge1);

          // ...with same number of lanes as the edge has (model2)
          int lanes = edge.getNoOfLanes();
          //however, eWorlds edges have 1 lane by default, SUMOs do not
          lanes = (lanes == 1)? 0: lanes;
          StatEdge edge2 = TestCaseUtil.createTestStatEdge(true,
              true, lanes, edge.getInternalID());
          edge2.setMaxSpeed(0);
          edge2.setMinSpeed(0);
          edge2.setStreetName(null);
          interval2.addStatEdge(edge2);
         
         
          //System.out.println("Lanes   edge:" + edge.getNoOfLanes() +
          //    "statedge:" + edge2.numLanes());
          // also look for an edge, that has all attributes we want to
          // test for
          if (testEdge == null) {
            if ((edge.getMaxspeed() != 0)
                && (edge.getMinspeed() != 0)
                && (edge.getParentWay().getDescription() != null)) {
              testEdge = edge;
            }//end if
          }//end if
        }//end for edges
      }//end instanceof
    }//end for allElements

    // add models to statmodelmanager and test if testcase data was added to
    // them
    smm.addDataset(model1);
    StatEdge testStatEdge = model1.getInterval(0).getStatEdge(
        testEdge.getInternalID());
    Assert.assertFalse((testStatEdge.getValue(Value.MAXSPEED) == 0));
    Assert.assertFalse((testStatEdge.getValue(Value.MINSPEED) == 0));
    Assert.assertNotNull(testStatEdge.getStreetName());

    smm.clear();
    smm.addDataset(model2);
    testStatEdge = model2.getInterval(0).getStatEdge(
        testEdge.getInternalID());
    Assert.assertFalse((testStatEdge.getValue(Value.MAXSPEED) == 0));
    Assert.assertFalse((testStatEdge.getValue(Value.MINSPEED) == 0));
    Assert.assertNotNull(testStatEdge.getStreetName());
  }
View Full Code Here

          "priority").getTextContent()) : -42;

      if (!function.equals("internal")) {
        if (id != null && from != null && to != null && priority != -42) {

          EdgeModel newEdge = new EdgeModel(id, nodes.get(from), nodes.get(to));
          nodes.get(from).addUsedBy(newEdge);
          nodes.get(to).addUsedBy(newEdge);
          newEdge.setPriority(priority);

          // System.out.println(newEdge.toString());

          this.edges.put(id, newEdge);

          NodeList laneList = curNode.getChildNodes();
          int maxSpeed = 42;
          for (int j = 0; j < laneList.getLength(); j++) {
            if (laneList.item(j).getNodeName().equals("lane")) {
              LaneModel newLane = new LaneModel();
              maxSpeed = Math.round(Float.parseFloat(laneList.item(j).getAttributes()
                  .getNamedItem("speed").getTextContent()) * 3.6f);
              newLane.setMaxSpeed(maxSpeed);
              newEdge.addLane(newLane);
            }
          }
         
          newEdge.setMaxspeed(maxSpeed);
         
        } else {
          System.out.println("Netfile inconsistency found");
        }
      }
View Full Code Here

          SumoRoute curRoute = new SumoRoute("route_for_vehicle_nr_" + id + "_"
              + UUID.randomUUID().toString());

          for (String curEdgeLabel : edgeList) {
            EdgeModel edgeToAdd = edges.get(curEdgeLabel);
            curRoute.addEdge(edgeToAdd.getInternalID());
          }

          sumoMan.addRoute(curRoute);
          SumoVehicle newVehicle = new SumoVehicle(depart, id, sumoMan.getSumoRouteById(curRoute
              .getId()), vType);
View Full Code Here

   *
   * @param way
   *            The model object that contains the way data to display
   */
  private void displayWayInformation(final WayModel way) {
    EdgeModel edgeToDisplay = null;

    List<EdgeModel> edges = way.getForwardEdges();
    if (edges.size() > 0) {
      edgeToDisplay = edges.get(0);
    } else {
View Full Code Here

    if ((getModelElement() != null) && (getModelElement().getLocation() != null)) {
      final EdgeLocationModel edgeLocation = (EdgeLocationModel) getModelElement().getLocation();
      final List<EdgeModel> edgeList = edgeLocation.getEdges();
      if ((edgeList != null) && (edgeList.size() != 0)) {
       
        EdgeModel edge = edgeList.get(0);

        GlobalPosition edgeStartGlobal = edge.getFromNode().getPosition();
        GlobalPosition edgeEndGlobal = edge.getToNode().getPosition();
       
        double globalLenght = edgeEndGlobal.distanceTo(edgeStartGlobal);
        double distanceToStart = edgeLocation.getDistance();

        Point2D edgeStartLocal = edge.getFromNode().getPosition().projected();
        Point2D edgeEndLocal = edge.getToNode().getPosition().projected();
       
        double localLength = Point2DUtils.distance(edgeEndLocal, edgeStartLocal);
       
       
        //normalize the edgeVector
View Full Code Here

TOP

Related Classes of de.hpi.eworld.model.db.data.EdgeModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.