Search in sources :

Example 1 with MapEvent

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

the class DefaultMap method addToTrack.

/** {@inheritDoc} */
@Override
public void addToTrack(String trackName, Position pos) {
    Track track = getTrack(trackName);
    if (track == null) {
        track = new DefaultTrack(nextTrackId++, trackName, trackName);
        updateEntityViewInfo(track, false);
        tracks.add(track);
    }
    track.addNode(pos);
    fireMapDataEvent(new MapEvent(this, MapEvent.Type.TRACK_MODIFIED, track.getId()));
}
Also used : MapEvent(aimax.osm.data.MapEvent) Track(aimax.osm.data.entities.Track)

Example 2 with MapEvent

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

the class DefaultMap method compile.

/**
	 * Separates way nodes from points of interests, cleans up useless garbage
	 * and creates a kd-tree for the remaining entities. Always call this method
	 * before using using the container for viewing.
	 */
public void compile() {
    ArrayList<Long> toDelete = new ArrayList<Long>();
    for (MapNode node : nodes.values()) {
        if (node.hasPosition()) {
            if (node.getName() != null || node.getAttributes().length > 0)
                pois.add(node);
            else if (node.getWayRefs().isEmpty())
                toDelete.add(node.getId());
        } else {
            LOG.warning("No definition found for referenced node " + node.getId() + ".");
            toDelete.add(node.getId());
        }
    }
    for (long id : toDelete) {
        nodes.remove(id);
    }
    BoundingBox bbAllNodes = new BoundingBox();
    bbAllNodes.adjust(nodes.values());
    bbAllNodes.adjust(pois);
    if (boundingBox == null)
        boundingBox = bbAllNodes;
    else
        boundingBox.intersectWith(bbAllNodes);
    applyClassifierAndUpdateTree(bbAllNodes);
    fireMapDataEvent(new MapEvent(this, MapEvent.Type.MAP_NEW));
}
Also used : BoundingBox(aimax.osm.data.BoundingBox) MapEvent(aimax.osm.data.MapEvent) ArrayList(java.util.ArrayList) MapNode(aimax.osm.data.entities.MapNode)

Example 3 with MapEvent

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

the class DefaultMap method clearMarkersAndTracks.

/** {@inheritDoc} */
@Override
public void clearMarkersAndTracks() {
    markers.clear();
    tracks.clear();
    fireMapDataEvent(new MapEvent(this, MapEvent.Type.MAP_MODIFIED));
}
Also used : MapEvent(aimax.osm.data.MapEvent)

Example 4 with MapEvent

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

the class DefaultMap method clear.

/** No data available after this reset. */
protected void clear() {
    EntityAttributeManager.instance().clearHash();
    nodes.clear();
    ways.clear();
    pois.clear();
    markers.clear();
    tracks.clear();
    entityTree = null;
    boundingBox = null;
    fireMapDataEvent(new MapEvent(this, MapEvent.Type.MAP_CLEARED));
}
Also used : MapEvent(aimax.osm.data.MapEvent)

Example 5 with MapEvent

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

the class DefaultMap method createTrack.

/** {@inheritDoc} */
@Override
public void createTrack(String trackName, List<Position> positions) {
    clearTrack(trackName);
    Track track = new DefaultTrack(nextTrackId++, trackName, trackName);
    updateEntityViewInfo(track, false);
    tracks.add(track);
    for (Position pos : positions) track.addNode(pos);
    fireMapDataEvent(new MapEvent(this, MapEvent.Type.TRACK_MODIFIED, track.getId()));
}
Also used : Position(aimax.osm.data.Position) MapEvent(aimax.osm.data.MapEvent) Track(aimax.osm.data.entities.Track)

Aggregations

MapEvent (aimax.osm.data.MapEvent)10 MapNode (aimax.osm.data.entities.MapNode)3 Track (aimax.osm.data.entities.Track)3 Position (aimax.osm.data.Position)2 ArrayList (java.util.ArrayList)2 BoundingBox (aimax.osm.data.BoundingBox)1 EntityAttribute (aimax.osm.data.entities.EntityAttribute)1