Package aimax.osm.data

Examples of aimax.osm.data.Position


        }
        nextRadius = -1;
      }
      if (iResults.size() == 1 && wayName != null) {
        MapNode place = (MapNode) iResults.get(0);
        findWay(wayName, new Position(place.getLat(), place.getLon()),
            null);
      }
     
    } else {
      nextRadius *= 2;
View Full Code Here


    MapAdapter map = (MapAdapter) getMapEnv().getMap();
    MapNode node = map.getWayNode(location);
    if (node != null) {
      int aIdx = getMapEnv().getAgents().indexOf(agent);
      map.getOsmMap().addToTrack(TRACK_NAME + aIdx,
          new Position(node.getLat(), node.getLon()));
    }
  }
View Full Code Here

  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

   * Returns the ID of the way node in the underlying OSM map which is nearest
   * 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

   * Returns the world coordinates, which are currently shown in the center.
   */
  public Position getCenterPosition() {
    float lat = transformer.lat(getHeight() / 2);
    float lon = transformer.lon(getWidth() / 2);
    return new Position(lat, lon);
  }
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

        float lat = transformer.lat(e.getY());
        float lon = transformer.lon(e.getX());
        if ((e.getModifiers() & MouseEvent.CTRL_MASK) != 0) {
          // mouse left button + ctrl -> add track point
          map.addToTrack("Mouse Track",
              new Position(lat, lon));
          fireMapViewEvent(new MapViewEvent(MapViewPane.this,
              MapViewEvent.Type.TRK_PT_ADDED));
        } else if ((e.getModifiers() & MouseEvent.SHIFT_MASK) != 0) {
          // mouse left button + shift -> add track point
          removeNearestMarker(e.getX(), e.getY());
View Full Code Here

  /**
   * Returns the map node which is the nearest with respect to the specified
   * view coordinates among the currently displayed nodes.
   */
  public MapNode getNextNode(int x, int y) {
    Position pos = new Position(transformer.lat(y), transformer.lon(x));
    MapNode nextNode = null;
    MapNode tmp = null;
    for (int i = 0; i < 2; i++) {
      List<MapWay> ways = (i == 0) ? areaBuffer : wayBuffer;
      for (MapWay way : ways) {
        tmp = pos.selectNearest(way.getNodes(), null);
        if (nextNode == null
            || pos.getDistKM(tmp) < pos.getDistKM(nextNode)) {
          nextNode = tmp;
        }
      }
    }
    for (MapEntity node : nodeBuffer) {
      if (node instanceof MapNode) {
        tmp = (MapNode) node;
        if (tmp != null && tmp.getAttributeValue("marker") == null
            && (nextNode == null || pos.getDistKM(tmp) < pos
                .getDistKM(nextNode))) {
          nextNode = tmp;
        }
      }
    }
View Full Code Here

   * straight-line-distance to the goal in KM.
   */
  @Override
  public double h(Object s) {
    MapNode currState = (MapNode) s;
    return (new Position(currState)).getDistKM(goalState);
  }
View Full Code Here

      int waySelection) {
    List<Position> result = new ArrayList<Position>();
    try {
      MapWayFilter wayFilter = createMapWayFilter(mapData, waySelection);
      boolean ignoreOneways = (waySelection == 0);
      MapNode fromRNode = mapData.getNearestWayNode(new Position(locs
          .get(0)), wayFilter);
      result.add(new Position(fromRNode.getLat(), fromRNode.getLon()));
      for (int i = 1; i < locs.size()
          && !CancelableThread.currIsCanceled(); i++) {
        MapNode toRNode = mapData.getNearestWayNode(new Position(locs
            .get(i)), wayFilter);
        HeuristicFunction hf = createHeuristicFunction(toRNode,
            waySelection);
        Problem problem = createProblem(fromRNode, toRNode, mapData,
            wayFilter, ignoreOneways, waySelection);
        Search search = new AStarSearch(new GraphSearch(), hf);
        List<Action> actions = search.search(problem);
        if (actions.isEmpty())
          break;
        for (Object action : actions) {
          if (action instanceof OsmMoveAction) {
            OsmMoveAction a = (OsmMoveAction) action;
            for (MapNode node : a.getNodes())
              if (!node.equals(a.getFrom()))
                result.add(new Position(node.getLat(), node
                    .getLon()));
          }
        }
        fromRNode = toRNode;
      }
View Full Code Here

TOP

Related Classes of aimax.osm.data.Position

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.