Class OSMEnvironment

  • All Implemented Interfaces:
    it.unibo.alchemist.model.BenchmarkableEnvironment , it.unibo.alchemist.model.Environment , it.unibo.alchemist.model.maps.MapEnvironment , java.io.Serializable , java.lang.Iterable

    
    public final class OSMEnvironment<T>
    extends Abstract2DEnvironment<T, P> implements MapEnvironment<T, O, S>
                        

    This class serves as template for more specific implementations of environments using a map. It encloses the navigation logic, but leaves the subclasses to decide how to provide map data (e.g. loading from disk or rely on online services). The data is then stored in-memory for performance reasons.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      Route<GeoPosition> computeRoute(GeoPosition p1, GeoPosition p2) This method relies on the map data, and computes a route towards some absolute coordinate solving a TSP problem.
      Route<GeoPosition> computeRoute(GeoPosition from, GeoPosition to, GraphHopperOptions options) This method relies on the map data, and computes a route towards some absolute coordinate solving a TSP problem.
      Route<GeoPosition> computeRoute(Node<T> node, GeoPosition coord) This method relies on the map data, and computes a route towards some absolute coordinate solving a TSP problem.
      Route<GeoPosition> computeRoute(Node<T> node, GeoPosition coord, GraphHopperOptions options) This method relies on the map data, and computes a route towards some absolute coordinate solving a TSP problem.
      Route<GeoPosition> computeRoute(Node<T> node, Node<T> node2) This method relies on the map data, and computes a route towards some absolute coordinate solving a TSP problem.
      void enableBenchmark()
      double getBenchmarkResult()
      GraphHopperRoutingService getRoutingService()
      Array<double> getSizeInDistanceUnits()
      GeoPosition makePosition(Array<Number> coordinates)
      • Methods inherited from class it.unibo.alchemist.model.environments.AbstractEnvironment

        addGlobalReaction, addLayer, addNode, addTerminator, forEach, getDistanceBetweenNodes, getGlobalReactions, getIncarnation, getLayer, getLayers, getLinkingRule, getNeighborhood, getNodeByID, getNodeCount, getNodes, getNodesWithinRange, getPosition, getSimulation, isTerminated, iterator, removeGlobalReaction, removeNode, setLinkingRule, setSimulation, spliterator, toString
      • Methods inherited from class it.unibo.alchemist.model.environments.Abstract2DEnvironment

        getDimensions, getOffset, getSize, moveNodeToPosition
      • Methods inherited from class java.lang.Iterable

        iterator, spliterator
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • OSMEnvironment

        OSMEnvironment(Incarnation<T, GeoPosition> incarnation)
        Builds a new OSMEnvironment without an actual backing map.
        Parameters:
        incarnation - the incarnation to be used.
      • OSMEnvironment

        OSMEnvironment(Incarnation<T, GeoPosition> incarnation, String file)
        Builds a new OSMEnvironment, with nodes not forced on streets.
        Parameters:
        incarnation - the incarnation to be used.
        file - the file path where the map data is stored
      • OSMEnvironment

        OSMEnvironment(Incarnation<T, GeoPosition> incarnation, String file, boolean onStreets)
        Parameters:
        incarnation - the incarnation to be used.
        file - the file path where the map data is stored
        onStreets - if true, the nodes will be placed on the street nearest to the desired Position.
      • OSMEnvironment

        OSMEnvironment(Incarnation<T, GeoPosition> incarnation, String file, boolean onStreets, boolean onlyOnStreets)
        Parameters:
        incarnation - the incarnation to be used.
        file - the file path where the map data is stored
        onStreets - if true, the nodes will be placed on the street nearest to the desired Position.
        onlyOnStreets - if true, the nodes which are too far from a street will be simply discarded.
      • OSMEnvironment

        OSMEnvironment(Incarnation<T, GeoPosition> incarnation, String file, int approximation)
        Parameters:
        incarnation - the incarnation to be used.
        file - the file path where the map data is stored.
        approximation - the amount of ciphers of the IEEE 754 encoded position that may be discarded when comparing two positions, allowing a quicker retrieval of the route between two position, since the cache may already contain a similar route which can be considered to be the same route, according to the level of precision determined by this value
      • OSMEnvironment

        OSMEnvironment(Incarnation<T, GeoPosition> incarnation, String file, int approximation, boolean onStreets, boolean onlyOnStreets)
        Parameters:
        incarnation - the incarnation to be used.
        file - the file path where the map data is stored.
        approximation - the amount of ciphers of the IEEE 754 encoded position that may be discarded when comparing two positions, allowing a quicker retrieval of the route between two position, since the cache may already contain a similar route which can be considered to be the same route, according to the level of precision determined by this value
        onStreets - if true, the nodes will be placed on the street nearest to the desired Position.
        onlyOnStreets - if true, the nodes which are too far from a street will be simply discarded.
    • Method Detail

      • computeRoute

         Route<GeoPosition> computeRoute(GeoPosition p1, GeoPosition p2)

        This method relies on the map data, and computes a route towards some absolute coordinate solving a TSP problem. It's up to the specific it.unibo.alchemist.model.Action calling this method to effectively move nodes along the path.

        Parameters:
        p1 - start position
        p2 - end position The absolute coordinate where this node wants to move to
        Returns:

        A Route object describing the path the node should follow

      • computeRoute

         Route<GeoPosition> computeRoute(GeoPosition from, GeoPosition to, GraphHopperOptions options)

        This method relies on the map data, and computes a route towards some absolute coordinate solving a TSP problem. It's up to the specific it.unibo.alchemist.model.Action calling this method to effectively move nodes along the path.

        Parameters:
        from - start position
        to - end position The absolute coordinate where this node wants to move to
        options - options to use.
        Returns:

        A Route object describing the path the node should follow

      • computeRoute

         Route<GeoPosition> computeRoute(Node<T> node, GeoPosition coord)

        This method relies on the map data, and computes a route towards some absolute coordinate solving a TSP problem. It's up to the specific it.unibo.alchemist.model.Action calling this method to effectively move nodes along the path.

        Parameters:
        node - The Node to move
        coord - The absolute coordinate where this node wants to move to
        Returns:

        A Route object describing the path the node should follow

      • computeRoute

         Route<GeoPosition> computeRoute(Node<T> node, GeoPosition coord, GraphHopperOptions options)

        This method relies on the map data, and computes a route towards some absolute coordinate solving a TSP problem. It's up to the specific it.unibo.alchemist.model.Action calling this method to effectively move nodes along the path.

        Parameters:
        node - The Node to move
        coord - The absolute coordinate where this node wants to move to
        options - The options tipe for this route
        Returns:

        A Route object describing the path the node should follow

      • computeRoute

         Route<GeoPosition> computeRoute(Node<T> node, Node<T> node2)

        This method relies on the map data, and computes a route towards some absolute coordinate solving a TSP problem. It's up to the specific it.unibo.alchemist.model.Action calling this method to effectively move nodes along the path. It uses the fastest path as metric.

        Parameters:
        node - The start node
        node2 - the second node's position will be used as destination
        Returns:

        A Route object describing the path the node should follow