use of aimax.osm.routing.MapAdapter in project aima-java by aimacode.
the class OsmAgentApp method readMap.
/** Reads a map from the specified stream and stores it in {@link #map}. */
public void readMap(InputStream stream) {
if (stream != null) {
MapReader mapReader = new Bz2OsmReader();
MapBuilder mapBuilder = new DefaultMapBuilder();
mapReader.readMap(stream, mapBuilder);
map = new MapAdapter(mapBuilder.buildMap());
} else
LOG.warning("Map reading failed because input stream does not exist.");
}
use of aimax.osm.routing.MapAdapter in project aima-java by aimacode.
the class OsmAgentBaseApp method initialize.
/**
* Is called after each parameter selection change. This implementation
* prepares the map for different kinds of vehicles and clears the currently
* displayed track.
*/
@Override
public void initialize() {
map = new MapAdapter(mapPaneCtrl.getMap());
switch(simPaneCtrl.getParamValueIndex(PARAM_WAY_SELECTION)) {
case 0:
map.setMapWayFilter(MapWayAttFilter.createAnyWayFilter());
map.ignoreOneways(true);
break;
case 1:
map.setMapWayFilter(MapWayAttFilter.createCarWayFilter());
map.ignoreOneways(false);
break;
case 2:
map.setMapWayFilter(MapWayAttFilter.createBicycleWayFilter());
map.ignoreOneways(false);
break;
}
map.getOsmMap().clearTrack(TRACK_NAME);
}
use of aimax.osm.routing.MapAdapter in project aima-java by aimacode.
the class OsmLRTAStarAgentApp method initialize.
/**
* Is called after each parameter selection change. This implementation
* prepares the map for different kinds of vehicles and clears the currently
* displayed track.
*/
@Override
public void initialize() {
map = new MapAdapter(mapPaneCtrl.getMap());
switch(simPaneCtrl.getParamValueIndex(PARAM_WAY_SELECTION)) {
case 0:
map.setMapWayFilter(MapWayAttFilter.createAnyWayFilter());
map.ignoreOneways(true);
break;
case 1:
map.setMapWayFilter(MapWayAttFilter.createCarWayFilter());
map.ignoreOneways(false);
break;
case 2:
map.setMapWayFilter(MapWayAttFilter.createBicycleWayFilter());
map.ignoreOneways(false);
break;
}
map.getOsmMap().clearTrack(TRACK_NAME);
}
use of aimax.osm.routing.MapAdapter in project aima-java by aimacode.
the class OsmLRTAStarAgentApp 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());
}
use of aimax.osm.routing.MapAdapter in project aima-java by aimacode.
the class OsmAgentApp method readMap.
/** Reads a map from the specified file and stores it in {@link #map}. */
public void readMap(File file) {
MapReader mapReader = new Bz2OsmReader();
MapBuilder mapBuilder = new DefaultMapBuilder();
mapReader.readMap(file, mapBuilder);
map = new MapAdapter(mapBuilder.buildMap());
}
Aggregations