Search in sources :

Example 11 with Position

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

the class RouteCalculator method subdivideProblem.

/**
	 * Factory method, responsible for subdividing the overall problem which is
	 * specified by a list of marker nodes. It returns arrays of way nodes.
	 * The arrays will be used to define problems to be solved one after
	 * another. This implementation returns pairs of from and to way nodes.
	 */
protected List<MapNode[]> subdivideProblem(List<MapNode> markers, OsmMap map, MapWayFilter wayFilter) {
    List<MapNode[]> result = new ArrayList<>();
    MapNode fromNode = map.getNearestWayNode(new Position(markers.get(0)), wayFilter);
    for (int i = 1; i < markers.size(); i++) {
        MapNode toNode = map.getNearestWayNode(new Position(markers.get(i)), wayFilter);
        result.add(new MapNode[] { fromNode, toNode });
        fromNode = toNode;
    }
    return result;
}
Also used : Position(aimax.osm.data.Position) ArrayList(java.util.ArrayList) MapNode(aimax.osm.data.entities.MapNode)

Example 12 with Position

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

the class MapViewPane method removeNearestMarker.

/**
	 * Removes the mark which is the nearest with respect to the given view
	 * coordinates.
	 */
public void removeNearestMarker(int x, int y) {
    List<MapNode> markers = getMap().getMarkers();
    float lat = getTransformer().lat(y);
    float lon = getTransformer().lon(x);
    MapNode marker = new Position(lat, lon).selectNearest(markers, null);
    if (marker != null)
        markers.remove(marker);
    getMap().fireMapDataEvent(new MapEvent(getMap(), MapEvent.Type.MAP_MODIFIED));
}
Also used : Position(aimax.osm.data.Position) MapEvent(aimax.osm.data.MapEvent) MapNode(aimax.osm.data.entities.MapNode)

Example 13 with Position

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

the class RoutePlannerApp method actionPerformed.

/** Starts route generation after the calculate button has been pressed. */
public void actionPerformed(ActionEvent e) {
    if (e.getSource() == calcButton) {
        OsmMap map = frame.getMap();
        List<Position> positions = routeCalculator.calculateRoute(map.getMarkers(), map, taskSelection.getSelectedIndex());
        frame.getMap().createTrack(ROUTE_TRACK_NAME, positions);
    }
}
Also used : OsmMap(aimax.osm.data.OsmMap) Position(aimax.osm.data.Position)

Example 14 with Position

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

the class FindPanel method valueChanged.

/** Creates markers for selected result items. */
@Override
public void valueChanged(ListSelectionEvent event) {
    clearMarkers(false);
    for (MapEntity entity : getSelectedEntities()) {
        Position pos = getPosition(entity);
        if (pos != null) {
            currMarkers.add(view.getMap().addMarker(pos.getLat(), pos.getLon()));
            view.adjustToCenter(pos.getLat(), pos.getLon());
        }
    }
    updateEnabledState();
}
Also used : Position(aimax.osm.data.Position) MapEntity(aimax.osm.data.entities.MapEntity)

Example 15 with Position

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

the class OsmAgentBaseApp method updateTrack.

/** Visualizes agent positions. Call from simulation thread. */
private void updateTrack(Agent agent, Metrics metrics) {
    MapAdapter map = (MapAdapter) env.getMap();
    MapNode node = map.getWayNode(env.getAgentLocation(agent));
    if (node != null) {
        Platform.runLater(() -> map.getOsmMap().addToTrack(TRACK_NAME, new Position(node.getLat(), node.getLon())));
    }
    simPaneCtrl.setStatus(metrics.toString());
}
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