Search in sources :

Example 1 with MapAdapter

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.");
}
Also used : MapReader(aimax.osm.reader.MapReader) Bz2OsmReader(aimax.osm.reader.Bz2OsmReader) DefaultMapBuilder(aimax.osm.data.impl.DefaultMapBuilder) MapBuilder(aimax.osm.data.MapBuilder) DefaultMapBuilder(aimax.osm.data.impl.DefaultMapBuilder) MapAdapter(aimax.osm.routing.MapAdapter)

Example 2 with MapAdapter

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);
}
Also used : MapAdapter(aimax.osm.routing.MapAdapter)

Example 3 with MapAdapter

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);
}
Also used : MapAdapter(aimax.osm.routing.MapAdapter)

Example 4 with MapAdapter

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

Example 5 with MapAdapter

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());
}
Also used : MapReader(aimax.osm.reader.MapReader) Bz2OsmReader(aimax.osm.reader.Bz2OsmReader) DefaultMapBuilder(aimax.osm.data.impl.DefaultMapBuilder) MapBuilder(aimax.osm.data.MapBuilder) DefaultMapBuilder(aimax.osm.data.impl.DefaultMapBuilder) MapAdapter(aimax.osm.routing.MapAdapter)

Aggregations

MapAdapter (aimax.osm.routing.MapAdapter)7 Position (aimax.osm.data.Position)3 MapNode (aimax.osm.data.entities.MapNode)3 MapBuilder (aimax.osm.data.MapBuilder)2 DefaultMapBuilder (aimax.osm.data.impl.DefaultMapBuilder)2 Bz2OsmReader (aimax.osm.reader.Bz2OsmReader)2 MapReader (aimax.osm.reader.MapReader)2