Class NodeEdgeConnectorItem
- All Implemented Interfaces:
INodeConnectorItem,Serializable,Cloneable
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);
- Since:
- 03/08/2019
- Version:
- 16/09/2019
- Author:
- DNA
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddoAutoCalculateTime(boolean isDoAutoCalculateTime) In case only a distance is provided by a user, the missing driving time information can be calculated on the fly.longGets the base traveling time in milliseconds.longgetBaseTimeMillis(Instant time) Gets the driving time as function of time.Gets theIConnectionByTimeStoreof a connection.doubleGets the distance in meters.doublegetDistanceMeter(Instant time) Gets the distance as function of time.Gets theoptimization element(usually aNode) from which theconnectionstarts.getShiftedCopy(INodeConnectorItem deltaItem) getShiftedCopy(ReducedNodeEdgeConnectorItem deltaItem) longgetTimeMillis(IResource visitor) Gets the traveling time in milliseconds correct for potential visitor modifications.longgetTimeMillis(IResource visitor, Instant time) Gets the driving time as function of time.Gets theoptimization element(usually aNode) at which theconnectionends.booleanChecks if theconnectioniscreated on the flyin case theconnectionis not found in theINodeEdgeConnectorwhich means it was created on the fly by itsIBackupElementConnector.booleanChecks if the driving time has to be approximated by calculation because only distance but no exact driving time has been provided by the user.voidsetConnectionByTimeStore(IConnectionByTimeStore connectionByTimeStore) Sets theconnectionByTimeStore.voidsetDistance(javax.measure.Quantity<javax.measure.quantity.Length> distance) Setsdistanceof the specificconnection.voidsetDistanceMeter(double distanceMeter) Deprecated.voidsetDrivingTime(Duration duration) Sets thedriving timeof that specificconnection.voidsetFromOptimizationElement(IOptimizationElement fromOptimizationElement) Sets theoptimization element(usually aNode) from which theconnectionstarts.voidsetIsCreatedOnTheFly(boolean isCreatedOnTheFly) Marks theconnectionascreated on the flyin case theconnectionis not found in theINodeEdgeConnectorwhich means it was created on the fly by itsIBackupElementConnector.voidsetTimeMillis(long timeMillis) Deprecated.voidsetToOptimizationElement(IOptimizationElement toOptimizationElement) Sets theoptimization element(usually aNode) at which theconnectionends.toString()
-
Constructor Details
-
NodeEdgeConnectorItem
public NodeEdgeConnectorItem()
-
-
Method Details
-
doAutoCalculateTime
public void doAutoCalculateTime(boolean isDoAutoCalculateTime) Description copied from interface:INodeConnectorItemIn case only a distance is provided by a user, the missing driving time information can be calculated on the fly.- Specified by:
doAutoCalculateTimein interfaceINodeConnectorItem- Parameters:
isDoAutoCalculateTime- the boolean to be set
-
isDoAutoCalculateTime
public boolean isDoAutoCalculateTime()Description copied from interface:INodeConnectorItemChecks if the driving time has to be approximated by calculation because only distance but no exact driving time has been provided by the user.- Specified by:
isDoAutoCalculateTimein interfaceINodeConnectorItem- Returns:
- the isDoAutoCalculateTime
- See Also:
-
getDistanceMeter
public double getDistanceMeter()Description copied from interface:INodeConnectorItemGets the distance in meters.- Specified by:
getDistanceMeterin interfaceINodeConnectorItem- Returns:
- the double distanceMeter
-
getBaseTimeMillis
public long getBaseTimeMillis()Description copied from interface:INodeConnectorItemGets the base traveling time in milliseconds.- Specified by:
getBaseTimeMillisin interfaceINodeConnectorItem- Returns:
- the base time millis
-
getTimeMillis
Description copied from interface:INodeConnectorItemGets the traveling time in milliseconds correct for potential visitor modifications.- Specified by:
getTimeMillisin interfaceINodeConnectorItem- Parameters:
visitor- the visitor- Returns:
- the long potentially modified timeMillis
-
getDistanceMeter
Description copied from interface:INodeConnectorItemGets the distance as function of time. If aIConnectionByTimeStoreis 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.
- Specified by:
getDistanceMeterin interfaceINodeConnectorItem- Parameters:
time- the instant time- Returns:
- the set distanceMeter or the distanceMeter of the localDateTime
-
getTimeMillis
Description copied from interface:INodeConnectorItemGets the driving time as function of time. Further, the driving time has potential modifications by the visitor assigned. If aIConnectionByTimeStoreis 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.
- Specified by:
getTimeMillisin interfaceINodeConnectorItem- Parameters:
visitor- the visitortime- the instant time- Returns:
- the set timeMillis or the timeMillis (modified by the visitor) for the LocalDateTime
-
getBaseTimeMillis
Description copied from interface:INodeConnectorItemGets the driving time as function of time. Further, the driving time has potential modifications by the visitor assigned. If aIConnectionByTimeStoreis 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.
- Specified by:
getBaseTimeMillisin interfaceINodeConnectorItem- Parameters:
time- the instant time- Returns:
- the set timeMillis or the timeMillis of the LocalDateTime
-
setDrivingTime
Description copied from interface:INodeConnectorItemSets thedriving timeof that specificconnection.Please note that the same
connectionin the other direction can have a differentdriving time.- Specified by:
setDrivingTimein interfaceINodeConnectorItem- Parameters:
duration- the duration of the driving time
-
setDistance
public void setDistance(javax.measure.Quantity<javax.measure.quantity.Length> distance) Description copied from interface:INodeConnectorItemSetsdistanceof the specificconnection.- Specified by:
setDistancein interfaceINodeConnectorItem- Parameters:
distance- Quantity of the distance to be set
-
setDistanceMeter
Deprecated.Description copied from interface:INodeConnectorItemDeprecated methodSets the
distanceof aconnectionin meters.- Specified by:
setDistanceMeterin interfaceINodeConnectorItem- Parameters:
distanceMeter- the double distance in meter to be set
-
setTimeMillis
Deprecated.Description copied from interface:INodeConnectorItemDeprecated methodSets the
durationof aconnectionin milliseconds.- Specified by:
setTimeMillisin interfaceINodeConnectorItem- Parameters:
timeMillis- the long milliseconds to be set
-
getConnectionByTimeStore
Description copied from interface:INodeConnectorItemGets theIConnectionByTimeStoreof 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.
- Specified by:
getConnectionByTimeStorein interfaceINodeConnectorItem- Returns:
- the connectionByTimeStore
-
setConnectionByTimeStore
Description copied from interface:INodeConnectorItemSets theconnectionByTimeStore. 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.- Specified by:
setConnectionByTimeStorein interfaceINodeConnectorItem- Parameters:
connectionByTimeStore- the iConnectionByTimeStore
-
getFromOptimizationElement
Description copied from interface:INodeConnectorItemGets theoptimization element(usually aNode) from which theconnectionstarts.- Specified by:
getFromOptimizationElementin interfaceINodeConnectorItem- Returns:
- the fromOptimizationElement
-
setFromOptimizationElement
Description copied from interface:INodeConnectorItemSets theoptimization element(usually aNode) from which theconnectionstarts.- Specified by:
setFromOptimizationElementin interfaceINodeConnectorItem- Parameters:
fromOptimizationElement- the iOptimizationElement to be set
-
getToOptimizationElement
Description copied from interface:INodeConnectorItemGets theoptimization element(usually aNode) at which theconnectionends.- Specified by:
getToOptimizationElementin interfaceINodeConnectorItem- Returns:
- the toOptimizationElement
-
setToOptimizationElement
Description copied from interface:INodeConnectorItemSets theoptimization element(usually aNode) at which theconnectionends.- Specified by:
setToOptimizationElementin interfaceINodeConnectorItem- Parameters:
toOptimizationElement- the iOptimizationElement to be set
-
setIsCreatedOnTheFly
public void setIsCreatedOnTheFly(boolean isCreatedOnTheFly) Description copied from interface:INodeConnectorItemMarks theconnectionascreated on the flyin case theconnectionis not found in theINodeEdgeConnectorwhich means it was created on the fly by itsIBackupElementConnector.- Specified by:
setIsCreatedOnTheFlyin interfaceINodeConnectorItem- Parameters:
isCreatedOnTheFly- the boolean to be set
-
isCreatedOnTheFly
public boolean isCreatedOnTheFly()Description copied from interface:INodeConnectorItemChecks if theconnectioniscreated on the flyin case theconnectionis not found in theINodeEdgeConnectorwhich means it was created on the fly by itsIBackupElementConnector.- Specified by:
isCreatedOnTheFlyin interfaceINodeConnectorItem- Returns:
- the set status of isCreatedOnTheFly
-
toString
-
getShiftedCopy
- Specified by:
getShiftedCopyin interfaceINodeConnectorItem
-
getShiftedCopy
- Specified by:
getShiftedCopyin interfaceINodeConnectorItem
-