public class NodeEdgeConnectorItem extends Object implements INodeConnectorItem
NodeEdgeConnnectorItem
holds the two Strings
of the start and the end location.
Each NodeEdgeConnnectorItem
is describing for example the time, distance etc. between two
Nodes
and is itself contained within a INodeEdgeConnector
The INodeConnectorItem
can be populated with realistic data on distance and time
needed between two locations. If not populated, air distance and average speed is being used.
The Nodes
are filtered before the INodeconnector
is being populated. If one
Node
is only accessible in December and another one only in January the Optimizer
never puts them in the same Route
which is more efficient and the specific data on the
distance between these Nodes
does not need to be acquired.
Implementation example:
List<INodeConnectorItem> connectionItems = new ArrayList<INodeConnectorItem>();
// Add connections from resources
INodeConnectorItem connectionJackHeilbronn = new NodeEdgeConnectorItem();
connectionJackHeilbronn.setFromOptimizationElement(resourceJackHeilbronn);
connectionJackHeilbronn.setToOptimizationElement(cityHeilbronn);
connectionJackHeilbronn.setDistance(Quantities.getQuantity(2, KILO(METRE)));
connectionJackHeilbronn.setDrivingTime(Duration.ofMinutes(10));
connectionItems.add(connectionJackHeilbronn);
// Add some connection items => The rest will be generated as fall back solution to bird
// distances.
INodeConnectorItem connectionKoelnOberhausen = new NodeEdgeConnectorItem();
connectionKoelnOberhausen.setFromOptimizationElement(cityKoeln);
connectionKoelnOberhausen.setToOptimizationElement(cityOberhausen);
connectionJackHeilbronn.setDistance(Quantities.getQuantity(20, KILO(METRE)));
connectionKoelnOberhausen.doAutoCalculateTime(true); // The time will be calculated based on the provided distance
connectionItems.add(connectionKoelnOberhausen);
INodeConnectorItem connectionOberhausenKoeln = new NodeEdgeConnectorItem();
connectionOberhausenKoeln.setFromOptimizationElement(cityOberhausen);
connectionOberhausenKoeln.setToOptimizationElement(cityKoeln);
connectionJackHeilbronn.setDistance(Quantities.getQuantity(20, KILO(METRE)));
connectionOberhausenKoeln.doAutoCalculateTime( true); // The time will be calculated based on the provided distance
connectionItems.add(connectionOberhausenKoeln);
INodeEdgeConnector myNodeConnector = new NodeEdgeConnector();
// Add items to connector
myNodeConnector.putNodeConnections(connectionItems);
// Set NodeEdgeConnector
setNodeConnector(this.myNodeConnector);
Constructor and Description |
---|
NodeEdgeConnectorItem() |
Modifier and Type | Method and Description |
---|---|
void |
doAutoCalculateTime(boolean isDoAutoCalculateTime)
In case only a distance is provided by a user, the missing driving time information can be calculated
on the fly.
|
long |
getBaseTimeMillis()
Gets the base traveling time in milliseconds.
|
long |
getBaseTimeMillis(Instant time)
Gets the driving time as function of time.
|
IConnectionByTimeStore |
getConnectionByTimeStore()
Gets the
IConnectionByTimeStore of a connection. |
double |
getDistanceMeter()
Gets the distance in meters.
|
double |
getDistanceMeter(Instant time)
Gets the distance as function of time.
|
IOptimizationElement |
getFromOptimizationElement()
Gets the
optimization element (usually a Node ) from which the connection starts. |
Optional<INodeConnectorItem> |
getShiftedCopy(INodeConnectorItem deltaItem) |
Optional<INodeConnectorItem> |
getShiftedCopy(ReducedNodeEdgeConnectorItem deltaItem) |
long |
getTimeMillis(IResource visitor)
Gets the traveling time in milliseconds correct for potential visitor modifications.
|
long |
getTimeMillis(IResource visitor,
Instant time)
Gets the driving time as function of time.
|
IOptimizationElement |
getToOptimizationElement()
Gets the
optimization element (usually a Node ) at which the connection ends. |
boolean |
isCreatedOnTheFly()
Checks if the
connection is created on the fly in case the connection is
not found in the INodeEdgeConnector which means it was created on the fly by its
IBackupElementConnector . |
boolean |
isDoAutoCalculateTime()
Checks if the driving time has to be approximated by calculation because only distance but no exact driving time has been provided
by the user.
|
void |
setConnectionByTimeStore(IConnectionByTimeStore connectionByTimeStore)
Sets the
connectionByTimeStore . |
void |
setDistance(javax.measure.Quantity<javax.measure.quantity.Length> distance)
Sets
distance of the specific connection . |
void |
setDistanceMeter(double distanceMeter)
Deprecated.
|
void |
setDrivingTime(Duration duration)
Sets the
driving time of that specific connection . |
void |
setFromOptimizationElement(IOptimizationElement fromOptimizationElement)
Sets the
optimization element (usually a Node ) from which the connection starts. |
void |
setIsCreatedOnTheFly(boolean isCreatedOnTheFly)
Marks the
connection as created on the fly in case the connection is not found
in the INodeEdgeConnector which means it was created on the fly by its IBackupElementConnector . |
void |
setTimeMillis(long timeMillis)
Deprecated.
|
void |
setToOptimizationElement(IOptimizationElement toOptimizationElement)
Sets the
optimization element (usually a Node ) at which the connection ends. |
String |
toString() |
public void doAutoCalculateTime(boolean isDoAutoCalculateTime)
INodeConnectorItem
doAutoCalculateTime
in interface INodeConnectorItem
isDoAutoCalculateTime
- the boolean to be setpublic boolean isDoAutoCalculateTime()
INodeConnectorItem
isDoAutoCalculateTime
in interface INodeConnectorItem
INodeConnectorItem.doAutoCalculateTime(boolean)
public double getDistanceMeter()
INodeConnectorItem
getDistanceMeter
in interface INodeConnectorItem
public long getBaseTimeMillis()
INodeConnectorItem
getBaseTimeMillis
in interface INodeConnectorItem
public long getTimeMillis(IResource visitor)
INodeConnectorItem
getTimeMillis
in interface INodeConnectorItem
visitor
- the visitorpublic double getDistanceMeter(Instant time)
INodeConnectorItem
IConnectionByTimeStore
is
present an input Instant will be used to extract the corresponding value. In case no
store is present, the instant time is ignored.
Internally, when the distance information of the connection is requested, the departure time of the from element is used as input.
getDistanceMeter
in interface INodeConnectorItem
time
- the instant timepublic long getTimeMillis(IResource visitor, Instant time)
INodeConnectorItem
IConnectionByTimeStore
is
present an input Instant will be used to extract the corresponding value. In case no
store is present, the instant time is ignored.
Internally, when the driving time information of the connection is requested, the departure time of the from element is used as input.
getTimeMillis
in interface INodeConnectorItem
visitor
- the visitortime
- the instant timepublic long getBaseTimeMillis(Instant time)
INodeConnectorItem
IConnectionByTimeStore
is
present an input Instant will be used to extract the corresponding value. In case no
store is present, the instant time is ignored.
Internally, when the driving time information of the connection is requested, the departure time of the from element is used as input.
getBaseTimeMillis
in interface INodeConnectorItem
time
- the instant timepublic void setDrivingTime(Duration duration)
INodeConnectorItem
driving time
of that specific connection
.
Please note that the same connection
in the other direction can have a different
driving time
.
setDrivingTime
in interface INodeConnectorItem
duration
- the duration of the driving timepublic void setDistance(javax.measure.Quantity<javax.measure.quantity.Length> distance)
INodeConnectorItem
distance
of the specific connection
.setDistance
in interface INodeConnectorItem
distance
- Quantity of the distance to be set@Deprecated public void setDistanceMeter(double distanceMeter)
INodeConnectorItem
Sets the distance
of a connection
in meters.
setDistanceMeter
in interface INodeConnectorItem
distanceMeter
- the double distance in meter to be set@Deprecated public void setTimeMillis(long timeMillis)
INodeConnectorItem
Sets the duration
of a connection
in milliseconds.
setTimeMillis
in interface INodeConnectorItem
timeMillis
- the long milliseconds to be setpublic IConnectionByTimeStore getConnectionByTimeStore()
INodeConnectorItem
IConnectionByTimeStore
of a connection. In case the driving
time is a function of the clock-time itself a connection store can be defined.
For example, using a certain connection during a rushhour at a Monday morning
takes longer compared to a Sunday afternoon.
Further, the distance can be also modeled as a function of time, for example if another path is taken depending on the time.
getConnectionByTimeStore
in interface INodeConnectorItem
public void setConnectionByTimeStore(IConnectionByTimeStore connectionByTimeStore)
INodeConnectorItem
connectionByTimeStore
. In case the driving
time is a function of the clock-time itself a connection store can be defined.
For example, using a certain connection during a rushhour at a Monday morning
takes longer compared to a Sunday afternoon.setConnectionByTimeStore
in interface INodeConnectorItem
connectionByTimeStore
- the iConnectionByTimeStorepublic IOptimizationElement getFromOptimizationElement()
INodeConnectorItem
optimization element
(usually a Node
) from which the connection
starts.getFromOptimizationElement
in interface INodeConnectorItem
public void setFromOptimizationElement(IOptimizationElement fromOptimizationElement)
INodeConnectorItem
optimization element
(usually a Node
) from which the connection
starts.setFromOptimizationElement
in interface INodeConnectorItem
fromOptimizationElement
- the iOptimizationElement to be setpublic IOptimizationElement getToOptimizationElement()
INodeConnectorItem
optimization element
(usually a Node
) at which the connection
ends.getToOptimizationElement
in interface INodeConnectorItem
public void setToOptimizationElement(IOptimizationElement toOptimizationElement)
INodeConnectorItem
optimization element
(usually a Node
) at which the connection
ends.setToOptimizationElement
in interface INodeConnectorItem
toOptimizationElement
- the iOptimizationElement to be setpublic void setIsCreatedOnTheFly(boolean isCreatedOnTheFly)
INodeConnectorItem
connection
as created on the fly
in case the connection
is not found
in the INodeEdgeConnector
which means it was created on the fly by its IBackupElementConnector
.setIsCreatedOnTheFly
in interface INodeConnectorItem
isCreatedOnTheFly
- the boolean to be setpublic boolean isCreatedOnTheFly()
INodeConnectorItem
connection
is created on the fly
in case the connection
is
not found in the INodeEdgeConnector
which means it was created on the fly by its
IBackupElementConnector
.isCreatedOnTheFly
in interface INodeConnectorItem
public Optional<INodeConnectorItem> getShiftedCopy(ReducedNodeEdgeConnectorItem deltaItem)
getShiftedCopy
in interface INodeConnectorItem
public Optional<INodeConnectorItem> getShiftedCopy(INodeConnectorItem deltaItem)
getShiftedCopy
in interface INodeConnectorItem
Copyright © 2017–2023 DNA Evolutions GmbH. All rights reserved.