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

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


  @Override
  protected List<GraphicsView<EventModel>> provideAnnotationItems() {
    List list = Arrays.asList(
      new RoadEventView(new RoadEventModel(RoadEventModel.Type.Accident)),
      new RoadEventView(new RoadEventModel(RoadEventModel.Type.Roadwork)),
      new PointOfInterestView(new PointOfInterest(0, 0, "<<new point of interest>>")),
      new CircleEventView(new CircleEventModel(CircleEventModel.Type.Fog, 1, null)),
      new CircleEventView(new CircleEventModel(CircleEventModel.Type.Rain, 1, null)),
      new CircleEventView(new CircleEventModel(CircleEventModel.Type.Snow, 1, null)),
      new CircleEventView(new CircleEventModel(CircleEventModel.Type.Ice, 1, null)),
      new PolygonEventView(new PolygonEventModel(PolygonEventModel.Type.Fog, 1, null)),
View Full Code Here


import de.hpi.eworld.networkview.objects.AbstractViewFactory;

public class AbstractViewFactoryTest extends EWorldTest {
  @Test
  public void testCreatePOI() {
    Assert.assertNotNull(AbstractViewFactory.createView(new PointOfInterest(0, 0, "")));
  }
View Full Code Here

    networkView.onModelElementAdded(to);
    networkView.onModelElementAdded(way);
    Assert.assertEquals(3, networkView.getGraphModel().items().length);

    // adding a point of interest
    poi = new PointOfInterest(0, 0, 0, "PoI");
    networkView.onModelElementAdded(poi);
    Assert.assertEquals(4, networkView.getGraphModel().items().length);

    // adding a traffic light
    trafficLight = new TrafficLightModel(new NodeModel(0,0));
View Full Code Here

        } else if ( ( at != null ) && (at.equals( "bus_stop" ) )) {
          node = new RoadSpotModel(lat, lon, RoadSpotModel.Type.Busstop);
          modelManager.addModelElement(node);
        } else if ( ( at != null ) && (at.equals( "stop" ) )) {
         
          PointOfInterest poi = new PointOfInterest(lat, lon, "stop_sign");
          imported = true;
         
          // this means that POIs are added to the model in any case
          // and the node is added an other time if it is referenced
          // by an edge
          modelManager.addModelElement(poi);
         
          node = new NodeModel( lat, lon );

        } else if ( ( at != null ) && (at.equals( "crossing" ) )) {
//          node = new TrafficLightModel(lat, lon, TrafficLightModel.Crossing);
          node = new NodeModel(lat,lon);
          modelManager.addModelElement(new TrafficLightModel(node,TrafficLightModel.Type.Crossing));
        } else {
       
          at = currentAttributes.get( "name" );
          if( at != null ) {
           
            String label = at;
            if( currentAttributes.get( "railway" ) != null ) {
              label = "Railway Station: " + label;
              node = new NodeModel( lat, lon );
            } else {
              PointOfInterest poi = new PointOfInterest( lat, lon, label );
              imported = true;
             
              // this means that POIs are added to the model in any case
              // and the node is added an other time if it is referenced
              // by an edge
              modelManager.addModelElement(poi);
             
              node = new NodeModel( lat, lon );
            }
           
          } else {
           
            at = currentAttributes.get( "barrier");
            if( ( at != null ) && ( at.equals( "lift_gate" ) ) ) {
//              node = new TrafficLightModel(lat,lon, TrafficLightModel.Lift_Gate);
              node = new NodeModel(lat,lon);
              modelManager.addModelElement(new TrafficLightModel(node,TrafficLightModel.Type.Lift_Gate));
            }
            else if ( ( at != null ) && (at.equals( "gate" ) )) {
              PointOfInterest poi = new PointOfInterest(lat, lon, "gate");
              modelManager.addModelElement(poi);
              node = new NodeModel(lat,lon);
            }
            else if (at != null) {
              PointOfInterest poi = new PointOfInterest(lat, lon, "unknown_barrier_type");
              modelManager.addModelElement(poi);
              node = new NodeModel(lat,lon);
            }
            else {
              // just a node, nothing more
View Full Code Here

      edge.addLane(new LaneModel(10, 70));
    }

    // create point of interests
    PointOfInterest[] poi = new PointOfInterest[2];
    poi[0] = new PointOfInterest(1.0, 2.0, "Point of interest 1");
    poi[1] = new PointOfInterest(5.0, 3.0, "Point of interest 2");

    // create road events
    RoadEventModel[] re = new RoadEventModel[2];

    EdgeLocationModel el = new EdgeLocationModel(e[4], 0.25, 0.5);
View Full Code Here

      * Generated using the JET engine and the according template
      */
     List<?> elementList = (List<?>) argument;
    stringBuffer.append(TEXT_1);
    String type = "point_of_interest";
     PointOfInterest poi;
      for (Iterator<?> i = elementList.iterator(); i.hasNext(); ) {
     poi = (PointOfInterest) i.next();
    stringBuffer.append(TEXT_2);
    stringBuffer.append(poi.getInternalID());
    stringBuffer.append(TEXT_3);
    stringBuffer.append(poi.getPosition().projected().getX());
    stringBuffer.append(TEXT_4);
    stringBuffer.append(-poi.getPosition().projected().getY());
    stringBuffer.append(TEXT_5);
    stringBuffer.append(type);
    stringBuffer.append(TEXT_6);
    stringBuffer.append(poi.getDescription());
    stringBuffer.append(TEXT_7);
     }
    stringBuffer.append(TEXT_8);
    return stringBuffer.toString();
  }
View Full Code Here

    Assert.assertSame(way, viewObject.getModelElement());
  }

  @Test
  public void testPoIItem() {
    PointOfInterest poi = new PointOfInterest(0, 0, 0, "PoI");
    AbstractView<Observable> viewObject = AbstractViewFactory.createView(poi);
    Assert.assertNotNull(viewObject);
    Assert.assertTrue(viewObject instanceof AbstractView<?>);   
    Assert.assertSame(poi, viewObject.getModelElement());
  }
View Full Code Here

      // check whether the model element is a point of interest and
      // the poi is of type crossing, gate or stop_sign
      if(!(element instanceof PointOfInterest))
        continue;
     
      PointOfInterest poi = (PointOfInterest) element;
     
      if(!(poi.getDescription().equals("crossing") || poi.getDescription().equals("gate") || poi.getDescription().equals("stop_sign")) )
        continue;
       
      lat = poi.getLatitude();
      lon = poi.getLongitude();
      String poi_lat = Double.toString(lat);
      String poi_long = Double.toString(lon);     
      double key_lat = Double.parseDouble(poi_lat.substring(0,(poi_lat.split("\\.")[0].length()) + 1 + MapSegmentationPrecission));
      double key_lon = Double.parseDouble(poi_long.substring(0, (poi_long.split("\\.")[0].length()) + 1 + MapSegmentationPrecission));
     
      // create a cluster around poi
      double[] keys_lat = new double[(LatitudeDifference * 2) + 1];
      keys_lat[0] = key_lat;
      int index_lat = 1;
     
      for (int i = 1; i < LatitudeDifference + 1; i++) {
        keys_lat[index_lat] = key_lat- i / Math.pow(10, (MapSegmentationPrecission));
        index_lat++;
        keys_lat[index_lat] = key_lat+ i / Math.pow(10, (MapSegmentationPrecission));
        index_lat++;
      }

      double[] keys_lon = new double[(LongitudeDifference * 2) + 1];
      keys_lon[0] = key_lon;
      int index_lon = 1;

      for (int j = 1; j < LongitudeDifference + 1; j++) {
        keys_lon[index_lon] = key_lon- j / Math.pow(10, (MapSegmentationPrecission));
        index_lon++;
        keys_lon[index_lon] = key_lon+ j / Math.pow(10, (MapSegmentationPrecission));
        index_lon++;
      }

      // search for all ways in the cluster and calculate the distance for each edge to poi
      for(double lati : keys_lat) {
        for(double longi : keys_lon) {
          String key1="";
          String lat_key = Double.toString(lati);
          String key2="";
          String long_key = Double.toString(longi);

          try{
            key1 = lat_key.substring(0, lat_key.split("\\.")[0].length() + 1 + MapSegmentationPrecission);
          } catch(Exception e) {
            while(key1.length()< lat_key.split("\\.")[0].length() + 1 + MapSegmentationPrecission-1)
              key1 =key1+"0";
          }

          try{
            key2 = long_key.substring(0, long_key.split("\\.")[0].length() + 1 + MapSegmentationPrecission);
          } catch(Exception e) {
            while(key2.length()< long_key.split("\\.")[0].length() + 1 + MapSegmentationPrecission-1)
              key2 =key2+"0";
          }

          key =key1+":" +key2;

          if(clusteredWays.containsKey(key)) {
            for(String wayId: clusteredWays.get(key)) {
              WayModel way =(WayModel)modelElements.get(wayId);
              if(way!=null) {
                for(EdgeModel edge:way.getForwardEdges()) {
                  double dist = Line2D.ptSegDist(
                    edge.getFromNode().getLatitude(),
                    edge.getFromNode().getLongitude(),
                    edge.getToNode().getLatitude(),
                    edge.getToNode().getLongitude(),
                    lat,
                    lon
                  );

                  if(dist < min_dist) {
                    min_dist = dist;
                    min_edge = edge;
                    min_way = way;
                  }
                }
              }
            }
          }
        }
      }

      if(min_dist > MinDistanceToPOI) {
        continue;
      }

      // check whether start or end point of an edge is the poi
      if(
          min_edge.getFromNode().getLatitude() == poi.getLatitude()
        &&  min_edge.getFromNode().getLongitude() == poi.getLongitude()
      ) {
        continue;
      }

      if(
          min_edge.getToNode().getLatitude() == poi.getLatitude()
        &&  min_edge.getToNode().getLongitude() == poi.getLongitude()
      ) {
        continue;
      }

      //create new Node on POI
      NodeModel new_Node=new NodeModel(poi.getLatitude(),poi.getLongitude());

      //create new Edges with remaining attributes
      EdgeModel firstForwardEdge = (EdgeModel) min_edge.clone();
      firstForwardEdge.setFromNode(min_edge.getFromNode());
      firstForwardEdge.setToNode(new_Node);
View Full Code Here

   * @return adjusted ModelElement attribute
   * @author 'Martin Horst Boissier'
   */
  @Override
  public ModelElement getAdjustedAssociatedElement(Point2D scrolledPoint, GraphController graphModel) {
    PointOfInterest model = (PointOfInterest) getModelElement().clone();
    final GlobalPosition globalPosition = GlobalPosition.from(scrolledPoint);
    model.setLatitude(globalPosition.getLatitude());
    model.setLongitude(globalPosition.getLongitude());

    return model;
  }
View Full Code Here

TOP

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

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.