Package aimax.osm.data.entities

Examples of aimax.osm.data.entities.MapNode


    return osmMap;
  }

  @Override
  public Double getDistance(String fromLocation, String toLocation) {
    MapNode node1 = getWayNode(fromLocation);
    MapNode node2 = getWayNode(toLocation);
    if (node1 != null && node2 != null
        && getLocationsLinkedTo(fromLocation).contains(toLocation))
      return new Position(node1).getDistKM(node2);
    else
      return null;
View Full Code Here


  }

  @Override
  public List<String> getLocationsLinkedTo(String fromLocation) {
    List<String> result = new ArrayList<String>();
    MapNode node = getWayNode(fromLocation);
    if (node != null) {
      for (WayRef wref : node.getWayRefs()) {
        if (filter == null || filter.isAccepted(wref.getWay())) {
          MapWay way = wref.getWay();
          int nodeIdx = wref.getNodeIdx();
          List<MapNode> wayNodes = way.getNodes();
          MapNode next;
          if (wayNodes.size() > nodeIdx + 1) {
            next = wayNodes.get(nodeIdx + 1);
            result.add(Long.toString(next.getId()));
          }
          if (nodeIdx > 0 && (!way.isOneway() || ignoreOneways)) {
            next = wayNodes.get(nodeIdx - 1);
            result.add(Long.toString(next.getId()));
          }
        }
      }
    }
    return result;
View Full Code Here

  }

  /** Returns a <code>PointLatLon</code> instance. */
  @Override
  public Point2D getPosition(String loc) {
    MapNode node = getWayNode(loc);
    if (node != null)
      return new PointLatLon(node.getLat(), node.getLon());
    else
      return null;
  }
View Full Code Here

   * with respect to the specified coordinates and additionally passes the
   * filter.
   */
  public String getNearestLocation(Point2D pt) {
    Position pos = new Position((float) pt.getY(), (float) pt.getX());
    MapNode node = osmMap.getNearestWayNode(pos, filter);
    return (node != null) ? Long.toString(node.getId()) : null;
  }
View Full Code Here

    return (node != null) ? Long.toString(node.getId()) : null;
  }

  /** Returns the OSM way node corresponding to the given location string. */
  public MapNode getWayNode(String id) {
    MapNode result = null;
    try {
      result = osmMap.getNode(Long.parseLong(id));
    } catch (NumberFormatException e) {
      // node not found, indicated by return value null.
    }
View Full Code Here

    @Override
    public void positionUpdated(GpsFix pos) {
      if (pos.isPosOk()) {
        OsmMap mapData = frame.getMap();
        Track track = mapData.getTrack(GPS_TRACK_NAME);
        MapNode node = null;
        if (track != null)
          node = track.getLastNode();
        if (node == null || pos.getDistKM(node) > 0.01) {
          mapData.addToTrack(GPS_TRACK_NAME, pos);
          if (gpsCombo.getSelectedIndex() == 2
View Full Code Here

   */
  public void removeNearestMarker(int x, int y) {
    List<MapNode> marks = map.getMarkers();
    float lat = getTransformer().lat(y);
    float lon = getTransformer().lon(x);
    MapNode mark = new Position(lat, lon).selectNearest(marks, null);
    if (mark != null)
      marks.remove(mark);
    map.fireMapDataEvent(new MapEvent(map,
        MapEvent.Type.MAP_MODIFIED));
    fireMapViewEvent(new MapViewEvent(this,
View Full Code Here

    List<MapEntity> entities = new ArrayList<MapEntity>();
    if (entity.getName() != null || entity.getAttributes().length > 0
        || debug)
      entities.add(entity);
    if (entity instanceof MapNode) {
      MapNode mNode = (MapNode) entity;
      for (WayRef ref : mNode.getWayRefs()) {
        MapEntity me = ref.getWay();
        if (me.getName() != null || me.getAttributes().length > 0
            || debug)
          entities.add(me);
      }
View Full Code Here

          mark = map.addMarker(lat, lon);
          fireMapViewEvent(new MapViewEvent(MapViewPane.this,
              MapViewEvent.Type.MARKER_ADDED));
        } else { // double click
          map.removeMarker(mark);
          MapNode mNode = getRenderer().getNextNode(e.getX(), e.getY());
          if (mNode != null)
            showMapEntityInfoDialog(mNode, renderer.isDebugModeEnabled());
        }
      } else if (popup != null) {
        popup.show(MapViewPane.this, e.getX(), e.getY());
View Full Code Here

   * @param filter
   *            possibly null
   * @return A node or null
   */
  public MapNode selectNearest(Collection<MapNode> nodes, MapWayFilter filter) {
    MapNode result = null;
    double dist = Double.MAX_VALUE;
    double newDist;
    for (MapNode node : nodes) {
      newDist = getDistKM(node);
      boolean found = (newDist < dist);
View Full Code Here

TOP

Related Classes of aimax.osm.data.entities.MapNode

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.