-
Notifications
You must be signed in to change notification settings - Fork 453
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DrtCompanion with PassengerGroupIdentifier (#3051)
* DrtCompanion with PassengerGroupIdentifier * Minor refactoring, red. public footprint
- Loading branch information
1 parent
5bab1fd
commit b236f2d
Showing
7 changed files
with
122 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...rc/main/java/org/matsim/contrib/drt/extension/companions/DrtCompanionGroupIdentifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* *********************************************************************** * | ||
* project: org.matsim.* | ||
* * | ||
* *********************************************************************** * | ||
* * | ||
* copyright : (C) 2024 by the members listed in the COPYING, * | ||
* LICENSE and WARRANTY file. * | ||
* email : info at matsim dot org * | ||
* * | ||
* *********************************************************************** * | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* See also COPYING, LICENSE and WARRANTY file * | ||
* * | ||
* *********************************************************************** */ | ||
|
||
package org.matsim.contrib.drt.extension.companions; | ||
|
||
import org.matsim.api.core.v01.Id; | ||
import org.matsim.api.core.v01.population.Person; | ||
import org.matsim.api.core.v01.population.Population; | ||
import org.matsim.contrib.dvrp.passenger.PassengerGroupIdentifier; | ||
import org.matsim.core.mobsim.framework.MobsimPassengerAgent; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* @author steffenaxer | ||
*/ | ||
class DrtCompanionGroupIdentifier implements PassengerGroupIdentifier { | ||
private final Population population; | ||
DrtCompanionGroupIdentifier(final Population population) | ||
{ | ||
this.population = population; | ||
} | ||
|
||
@Override | ||
public Optional<Id<PassengerGroup>> getGroupId(MobsimPassengerAgent agent) { | ||
Person person = wrapMobsimPassengerAgentToPerson(agent); | ||
return DrtCompanionUtils.getPassengerGroupIdentifier(person); | ||
} | ||
|
||
private Person wrapMobsimPassengerAgentToPerson(MobsimPassengerAgent agent) | ||
{ | ||
return this.population.getPersons().get(agent.getId()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters