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.
-
-
Field Summary
Fields Modifier and Type Field Description public final static intDEFAULT_APPROXIMATIONpublic final static booleanDEFAULT_ON_STREETSpublic final static booleanDEFAULT_FORCE_STREETSpublic final ListSet<GlobalReaction<T>>globalReactionspublic final ListSet<Node<T>>nodespublic transient Incarnation<T, P>incarnationpublic transient Simulation<T, P>simulation
-
Constructor Summary
Constructors Constructor Description OSMEnvironment(Incarnation<T, GeoPosition> incarnation)Builds a new OSMEnvironment without an actual backing map. OSMEnvironment(Incarnation<T, GeoPosition> incarnation, String file)Builds a new OSMEnvironment, with nodes not forced on streets. OSMEnvironment(Incarnation<T, GeoPosition> incarnation, String file, boolean onStreets)OSMEnvironment(Incarnation<T, GeoPosition> incarnation, String file, boolean onStreets, boolean onlyOnStreets)OSMEnvironment(Incarnation<T, GeoPosition> incarnation, String file, int approximation)OSMEnvironment(Incarnation<T, GeoPosition> incarnation, String file, int approximation, boolean onStreets, boolean onlyOnStreets)
-
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. voidenableBenchmark()doublegetBenchmarkResult()GraphHopperRoutingServicegetRoutingService()Array<double>getSizeInDistanceUnits()GeoPositionmakePosition(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 storedonStreets- 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 storedonStreets- 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 valueonStreets- 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 positionp2- 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 positionto- end position The absolute coordinate where this node wants to move tooptions- 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 movecoord- 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 movecoord- The absolute coordinate where this node wants to move tooptions- 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 nodenode2- the second node's position will be used as destination- Returns:
A Route object describing the path the node should follow
-
enableBenchmark
void enableBenchmark()
-
getBenchmarkResult
double getBenchmarkResult()
-
getRoutingService
GraphHopperRoutingService getRoutingService()
- Returns:
the RoutingService for this environment
-
getSizeInDistanceUnits
Array<double> getSizeInDistanceUnits()
-
makePosition
GeoPosition makePosition(Array<Number> coordinates)
-
-
-
-