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

Examples of de.hpi.eworld.model.db.data.event.CircleLocationModel


    for (EnvironmentEventModel environmentEvent : events) {
      // if the location is a circle...
      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());

        if (distanceTo <= circleLoc.getRadius()) {
          log.debug("distanceTo <= circleLoc.getRadius()");
          results.add(environmentEvent);
        }

      }
View Full Code Here


    re[1].setEndTime(10000);

    // 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);
    ee[1].setStartTime(100);
    ee[1].setEndTime(2000);
View Full Code Here

   * Tests initialization and methods of
   * de.hpi.eworld.model.db.data.event.CircleLocation
   */
  @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

   
   
    ///////////////////////////////////
    // 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
   
View Full Code Here

   * @param destinationAreas The areas which are a destination for the created start area.
   * @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);
    }

    AreaModel area = new AreaModel(startLocation, AreaModel.AreaType.START);
    area.setSimulationTime(simulationTime);
    area.setVehicleCount(vehicleCount);
View Full Code Here

    Assert.assertSame(roadEvent, viewItem.getModelElement());
  }

  @Test
  public void testCircleEnvironmentEventItem() {
    CircleLocationModel circleLocation = new  CircleLocationModel();
    CircleEventModel circleEvent = new CircleEventModel(EnvironmentEventModel.Type.Fog, 1, circleLocation);
    AbstractView<Observable> viewItem = AbstractViewFactory.createView(circleEvent);
    Assert.assertNotNull(viewItem);
    Assert.assertTrue(viewItem instanceof AbstractView<?>);
//    CircleEventItem circleEventItem = (CircleEventItem) viewItem;
View Full Code Here

  @Override
  @SuppressWarnings({ "rawtypes", "unchecked" })
  protected List<GraphicsView<AreaModel>> provideAnnotationItems() {
    List list = Arrays.asList(new CircleScenarioView(new AreaModel(
        new CircleLocationModel(), AreaType.START),
        CircleScenarioView.DEFAULT_RADIUS), new CircleScenarioView(
        new AreaModel(new CircleLocationModel(), AreaType.DESTINATION),
        CircleScenarioView.DEFAULT_RADIUS));
    return (List<GraphicsView<AreaModel>>) list;
  }
View Full Code Here

   * @param vehicleEmitInterval The vehicle emit interval (specifies the interval between two emitted vehicles).
   * @return The created area.
   */
  private AreaModel createDestinationArea(double latitude, double longitude, double radius, int simulationTime, int vehicleCount,
      int vehicleEmitInterval) {
    CircleLocationModel destinationLocation = new CircleLocationModel();
    destinationLocation.setCenter(new GlobalPosition(latitude, longitude));
    destinationLocation.setRadius(radius);

    List<EdgeModel> underlyingEdges = TestCaseUtil.calculateUnderlyingEdges(latitude, longitude, radius, edges);
    for (EdgeModel underlyingEdge : underlyingEdges) {
      destinationLocation.addEdge(underlyingEdge);
    }

    AreaModel area = new AreaModel(destinationLocation, AreaModel.AreaType.DESTINATION);
    area.setSimulationTime(simulationTime);
    area.setVehicleCount(vehicleCount);
View Full Code Here

  public void testEnvironmentEvent () {
   
    ///////////////////////////////////
    // 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);
   
    ///////////////////////////////////
View Full Code Here

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

TOP

Related Classes of de.hpi.eworld.model.db.data.event.CircleLocationModel

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.