Search in sources :

Example 16 with Position

use of aimax.osm.data.Position in project aima-java by aimacode.

the class MapAdapter method getNearestLocation.

/**
	 * 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;
}
Also used : Position(aimax.osm.data.Position) MapNode(aimax.osm.data.entities.MapNode)

Example 17 with Position

use of aimax.osm.data.Position in project aima-java by aimacode.

the class OsmAgentView method updateTrack.

private void updateTrack(Agent agent, String location) {
    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()));
    }
}
Also used : Position(aimax.osm.data.Position) MapNode(aimax.osm.data.entities.MapNode) MapAdapter(aimax.osm.routing.MapAdapter)

Aggregations

Position (aimax.osm.data.Position)17 MapNode (aimax.osm.data.entities.MapNode)12 MapEntity (aimax.osm.data.entities.MapEntity)3 MapAdapter (aimax.osm.routing.MapAdapter)3 ArrayList (java.util.ArrayList)3 MapEvent (aimax.osm.data.MapEvent)2 OsmMap (aimax.osm.data.OsmMap)2 MapWay (aimax.osm.data.entities.MapWay)2 Node (aima.core.search.framework.Node)1 BoundingBox (aimax.osm.data.BoundingBox)1 MapWayFilter (aimax.osm.data.MapWayFilter)1 Track (aimax.osm.data.entities.Track)1 DecimalFormat (java.text.DecimalFormat)1 List (java.util.List)1 StringTokenizer (java.util.StringTokenizer)1