Examples of GlobalPosition


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

  public GlobalPosition reproject(Point2D point) {
    Point2D.Double cart = new Point2D.Double(point.getX() - xOff, point.getY() - yOff);
    Point2D.Double geo = new Point2D.Double();
    geo = this.proj.inverseTransform(cart, geo);

    return new GlobalPosition(-geo.y, geo.x);
  }
View Full Code Here

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

      if (environmentEvent.getLocation() instanceof CircleLocationModel) {
        log.debug("environmentEvent is CircleLocationModel");
        CircleLocationModel circleLoc =
          (CircleLocationModel) environmentEvent.getLocation();

        GlobalPosition center = circleLoc.getCenter();

        //WARNING: GLobalPosition require a latLong format
        GlobalPosition myPos = new GlobalPosition(longLat.y, longLat.x);

        double distanceTo = center.distanceTo(myPos);
        log.debug("distanceTo: "+distanceTo);
        log.debug("circleLoc.getRadius(): "+circleLoc.getRadius());
View Full Code Here

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

    }

    // calculate position of start edge
    NodeModel startFromNode = startEdge.getFromNode();
    NodeModel startToNode = startEdge.getToNode();
    GlobalPosition startPosition = new GlobalPosition((startFromNode.getLatitude() + startToNode.getLatitude()) / 2.0,
        (startFromNode.getLongitude() + startToNode.getLongitude()) / 2.0);

    // calculate position of end edge
    NodeModel destinationFromNode = destinationEdge.getFromNode();
    NodeModel destinationToNode = destinationEdge.getToNode();

    GlobalPosition destinationPosition = new GlobalPosition((destinationFromNode.getLatitude() + destinationToNode
        .getLatitude()) / 2.0, (destinationFromNode.getLongitude() + destinationToNode.getLongitude()) / 2.0);

    // calculate distance from start edge to destination edge
    double distanceInMeters = startPosition.distanceTo(destinationPosition);
View Full Code Here

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

      stringBuffer.append(TEXT_2);
      stringBuffer.append(id);
      stringBuffer.append(TEXT_3);
     
      // Perform projection of coordinates
      GlobalPosition g = node.getPosition();
      Projection p = ProjectionFactory.getInstance().getProjection(g.getLatitude(), g.getLongitude());
      double[] projected = p.projectToSUMO(g.getLongitude(), g.getLatitude());
      stringBuffer.append(projected[0]);
      stringBuffer.append(TEXT_4);
      stringBuffer.append(projected[1]);
      stringBuffer.append(TEXT_5);
      stringBuffer.append(type);
View Full Code Here

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

    // create environment events
    EnvironmentEventModel[] ee = new EnvironmentEventModel[2];

    CircleLocationModel cl = new CircleLocationModel();
    cl.setCenter(new GlobalPosition(3.0, 4.0));
    cl.setRadius(2.0);
    cl.setCirclePoint(new GlobalPosition(3.0, 2.0));
    List<EdgeModel> underlyingEdges = calculateUnderlyingEdges(3.0, 4.0, 2.0, Arrays.asList(e));
    for (EdgeModel underlyingEdge : underlyingEdges) {
      cl.addEdge(underlyingEdge);
    }
    ee[0] = new EnvironmentEventModel(EnvironmentEventModel.Type.Fog, 2, cl);
    ee[0].setStartTime(0);
    ee[0].setEndTime(5000);

    cl = new CircleLocationModel();
    cl.setCenter(new GlobalPosition(3.0, 3.0));
    cl.setRadius(3.0);
    cl.setCirclePoint(new GlobalPosition(3.0, 2.0));
    underlyingEdges = calculateUnderlyingEdges(3.0, 3.0, 3.0, Arrays.asList(e));
    for (EdgeModel underlyingEdge : underlyingEdges) {
      cl.addEdge(underlyingEdge);
    }
    ee[1] = new EnvironmentEventModel(EnvironmentEventModel.Type.Rain, 2, cl);
View Full Code Here

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

  @Test
  public void testCircleLocation () {
    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));
   
   
    Assert.assertEquals(centerPosition.getLatitude(), cl.getCenter().getLatitude());
    Assert.assertEquals(centerPosition.getLongitude(), cl.getCenter().getLongitude());
    Assert.assertEquals(centerPosition.getAltitude(), cl.getCenter().getAltitude());
   
    Assert.assertEquals(circlePosition.getLatitude(), cl.getCirclePoint().getLatitude());
    Assert.assertEquals(circlePosition.getLongitude(), cl.getCirclePoint().getLongitude());
    Assert.assertEquals(circlePosition.getAltitude(), cl.getCirclePoint().getAltitude());
   
    Assert.assertEquals(centerPosition.distanceTo(circlePosition), cl.getRadius());
  }
View Full Code Here

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

    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);
   
   
    Assert.assertEquals(5, pl.getPoints().size());
   
    pl.removePointAt(5);
    Assert.assertEquals(5, pl.getPoints().size());
   
    pl.removePointAt(-12);
    Assert.assertEquals(5, pl.getPoints().size());
   
    pl.removePointAt(3);
    Assert.assertEquals(4, pl.getPoints().size());
   
    pl.removePoint(gp1);
    Assert.assertEquals(3, pl.getPoints().size());
    Assert.assertNotSame(gp1, pl.getPoints().get(0));
    Assert.assertEquals(gp2, pl.getPoints().get(0));
   
    Point2D p6 = new Point2D.Double(33,16);
    GlobalPosition gp6 = GlobalPosition.from(p6);
    pl.addPoint(gp6);
    Assert.assertEquals(4, pl.getPoints().size());
   
    Point2D p7 = new Point2D.Double(33,16);
    GlobalPosition gp7 = GlobalPosition.from(p7);
    pl.addPointAt(2, gp7);
    Assert.assertEquals(gp7, pl.getPoints().get(2));
  }
View Full Code Here

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

    // set up 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));
   
   
    ///////////////////////////////////
    // set up PolygonLocation
   
    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);
   
   
View Full Code Here

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

  @Test
  public void testProjectReProject() throws Exception {
    de.hpi.eworld.util.Projection proj = new de.hpi.eworld.util.Projection(
        "+proj=utm +zone=33 +ellps=bessel +units=m", 0, 0);
    double[] latlon = new double[] { 13.295053, 52.499847 };
    GlobalPosition gp = new GlobalPosition(latlon[1],latlon[0]);
    Point2D projected = proj.project(gp);

    double[] geo = proj.projectToSUMO(latlon[0], latlon[1]);
    Double geox = new Double(geo[0]);
    Double geoy = new Double(geo[1]);
    Double projectedx = new Double(projected.getX());
    Double projectedy = new Double(-projected.getY());

    assertEquals(projectedx, geox);
    assertEquals(projectedy, geoy);
    GlobalPosition gp2 = proj.reproject(projected);
    double[] latlon2 = proj.reprojectFromSumo(geo[0], geo[1]);

    // double errors force us to test with relative precision
    System.out.println("Original values lat: " + gp.getLatitude() + " lon:" + gp.getLongitude());
    System.out.println("Reprojected values lat: " + gp2.getLatitude() + " lon:" + gp2.getLongitude());
    assertEquals(true, Math.abs(gp.getLatitude()-gp2.getLatitude())<0.0001f);
    assertEquals(true, Math.abs(gp.getLongitude()-gp2.getLongitude())<0.0001f);
    assertEquals(true, Math.abs(latlon[0]-latlon2[0])<0.0001f);
    assertEquals(true, Math.abs(latlon[1]-latlon2[1])<0.0001f);
  }
View Full Code Here

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

   * @return The created area.
   */
  private AreaModel createStartArea(double latitude, double longitude, double radius, int simulationTime, int vehicleCount,
      int vehicleEmitInterval, List<AreaModel> destinationAreas) {
    CircleLocationModel startLocation = new CircleLocationModel();
    startLocation.setCenter(new GlobalPosition(latitude, longitude));
    startLocation.setRadius(radius);

    List<EdgeModel> underlyingEdges = TestCaseUtil.calculateUnderlyingEdges(latitude, longitude, radius, edges);
    for (EdgeModel underlyingEdge : underlyingEdges) {
      startLocation.addEdge(underlyingEdge);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.