-
- All Implemented Interfaces:
-
it.unibo.alchemist.model.interfaces.BenchmarkableEnvironment,it.unibo.alchemist.model.interfaces.Environment,it.unibo.alchemist.model.interfaces.MapEnvironment,java.io.Serializable,java.lang.Iterable
public final class OSMEnvironment<T> extends Abstract2DEnvironment<T, GeoPosition> implements MapEnvironment<T, GraphHopperOptions, GraphHopperRoutingService>
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_STREETS
-
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.implementations.environments.Abstract2DEnvironment
getDimensions, getOffset, getSize, moveNodeToPosition -
Methods inherited from class it.unibo.alchemist.model.implementations.environments.AbstractEnvironment
addLayer, addNode, addTerminator, forEach, getDistanceBetweenNodes, getIncarnation, getLayer, getLayers, getLinkingRule, getNeighborhood, getNodeByID, getNodeCount, getNodes, getNodesWithinRange, getPosition, getSimulation, isTerminated, iterator, removeNode, setLinkingRule, setSimulation, spliterator, toString -
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 it.unibo.alchemist.model.interfaces.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 it.unibo.alchemist.model.interfaces.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 it.unibo.alchemist.model.interfaces.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 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
-
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 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.
-
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 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
-
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 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
-
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 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
-
enableBenchmark
void enableBenchmark()
-
getBenchmarkResult
double getBenchmarkResult()
-
getRoutingService
GraphHopperRoutingService getRoutingService()
-
getSizeInDistanceUnits
Array<double> getSizeInDistanceUnits()
-
makePosition
GeoPosition makePosition(Array<Number> coordinates)
-
-
-
-