Search in sources :

Example 16 with MapNode

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

the class BoundingBox method adjust.

/**
	 * Makes sure, that all given nodes are within the box and extends the
	 * bounds if necessary.
	 */
public void adjust(Collection<MapNode> nodes) {
    for (MapNode node : nodes) {
        if (Float.isNaN(latMin)) {
            latMin = latMax = node.getLat();
            lonMin = lonMax = node.getLon();
        } else if (node.hasPosition()) {
            if (node.getLat() < latMin)
                latMin = node.getLat();
            else if (node.getLat() > latMax)
                latMax = node.getLat();
            if (node.getLon() < lonMin)
                lonMin = node.getLon();
            else if (node.getLon() > lonMax)
                lonMax = node.getLon();
        }
    }
}
Also used : MapNode(aimax.osm.data.entities.MapNode)

Example 17 with MapNode

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

the class Position method selectNearest.

/**
	 * Returns the node from <code>nodes</code> which is nearest to this
	 * position. If a filter is given, only those nodes are inspected, which are
	 * part of a way accepted by the filter.
	 * 
	 * @param nodes
	 * @param filter
	 *            possibly null
	 * @return A node or null
	 */
public MapNode selectNearest(Collection<MapNode> nodes, MapWayFilter filter) {
    MapNode result = null;
    double dist = Double.MAX_VALUE;
    double newDist;
    for (MapNode node : nodes) {
        newDist = getDistKM(node);
        boolean found = (newDist < dist);
        if (found && filter != null) {
            found = false;
            for (WayRef ref : node.getWayRefs()) {
                if (filter.isAccepted(ref.getWay()))
                    found = true;
            }
        }
        if (found) {
            result = node;
            dist = newDist;
        }
    }
    return result;
}
Also used : WayRef(aimax.osm.data.entities.WayRef) MapNode(aimax.osm.data.entities.MapNode)

Example 18 with MapNode

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

the class Position method getTrackLengthKM.

/** Computes the total length of a track in kilometers. */
public static double getTrackLengthKM(List<MapNode> nodes) {
    double result = 0.0;
    for (int i = 1; i < nodes.size(); i++) {
        MapNode n1 = nodes.get(i - 1);
        MapNode n2 = nodes.get(i);
        result += getDistKM(n1.getLat(), n1.getLon(), n2.getLat(), n2.getLon());
    }
    return result;
}
Also used : MapNode(aimax.osm.data.entities.MapNode)

Example 19 with MapNode

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

the class DefaultMap method getPlaces.

/** {@inheritDoc} */
@Override
public List<MapNode> getPlaces(String name) {
    String pattern = name.toLowerCase();
    List<MapNode> results = new ArrayList<MapNode>();
    for (MapNode node : pois) {
        if (node.getAttributeValue("place") != null && node.getName() != null && node.getName().toLowerCase().startsWith(pattern))
            results.add(node);
    }
    return results;
}
Also used : ArrayList(java.util.ArrayList) MapNode(aimax.osm.data.entities.MapNode)

Example 20 with MapNode

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

the class DefaultMap method addMarker.

/** {@inheritDoc} */
@Override
public MapNode addMarker(float lat, float lon) {
    long id = 1;
    for (MapNode node : markers) if (node.getId() >= id)
        id = node.getId() + 1;
    MapNode node = new DefaultMapNode(id);
    node.setName(Long.toString(id));
    List<EntityAttribute> atts = new ArrayList<EntityAttribute>(1);
    atts.add(new EntityAttribute("marker", "yes"));
    node.setAttributes(atts);
    node.setPosition(lat, lon);
    updateEntityViewInfo(node, false);
    markers.add(node);
    fireMapDataEvent(new MapEvent(this, MapEvent.Type.MARKER_ADDED, node.getId()));
    return node;
}
Also used : EntityAttribute(aimax.osm.data.entities.EntityAttribute) MapEvent(aimax.osm.data.MapEvent) ArrayList(java.util.ArrayList) MapNode(aimax.osm.data.entities.MapNode)

Aggregations

MapNode (aimax.osm.data.entities.MapNode)37 ArrayList (java.util.ArrayList)13 Position (aimax.osm.data.Position)12 MapWay (aimax.osm.data.entities.MapWay)6 MapEntity (aimax.osm.data.entities.MapEntity)5 BoundingBox (aimax.osm.data.BoundingBox)4 WayRef (aimax.osm.data.entities.WayRef)4 MapAdapter (aimax.osm.routing.MapAdapter)4 Point2D (aima.core.util.math.geom.shapes.Point2D)3 MapEvent (aimax.osm.data.MapEvent)3 EntityAttribute (aimax.osm.data.entities.EntityAttribute)3 Node (aima.core.search.framework.Node)2 LRTAStarAgent (aima.core.search.online.LRTAStarAgent)2 IOException (java.io.IOException)2 DecimalFormat (java.text.DecimalFormat)2 HashSet (java.util.HashSet)2 Agent (aima.core.agent.Agent)1 aima.core.environment.map (aima.core.environment.map)1 MapAgent (aima.core.environment.map.MapAgent)1 MapEnvironment (aima.core.environment.map.MapEnvironment)1