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;
}
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));
}
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);
}
}
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();
}
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());
}
Aggregations