MATSIM
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
org.matsim.lanes.LanesConsistencyChecker Class Reference

Public Member Functions

 LanesConsistencyChecker (Network net, Lanes laneDefs)
 
void checkConsistency ()
 
boolean isRemoveMalformed ()
 
void setRemoveMalformed (boolean removeMalformed)
 

Private Member Functions

boolean isLaneOnLinkConsistent (LanesToLinkAssignment l2l)
 

Private Attributes

Network network
 
Lanes lanes
 
boolean removeMalformed = false
 

Static Private Attributes

static final Logger log = LogManager.getLogger(LanesConsistencyChecker.class)
 

Detailed Description

Author
dgrether, tthunig

Definition at line 36 of file LanesConsistencyChecker.java.

Constructor & Destructor Documentation

◆ LanesConsistencyChecker()

org.matsim.lanes.LanesConsistencyChecker.LanesConsistencyChecker ( Network  net,
Lanes  laneDefs 
)

Definition at line 43 of file LanesConsistencyChecker.java.

Member Function Documentation

◆ checkConsistency()

void org.matsim.lanes.LanesConsistencyChecker.checkConsistency ( )

Definition at line 48 of file LanesConsistencyChecker.java.

References org.matsim.lanes.Lanes.getLanesToLinkAssignments(), and org.matsim.lanes.LanesConsistencyChecker.isLaneOnLinkConsistent().

48  {
49  log.info("checking consistency...");
50  List<Id<Link>> linksWithMalformedLanes = new LinkedList<>();
51  for (LanesToLinkAssignment l2l : this.lanes.getLanesToLinkAssignments().values()){
52  if (!isLaneOnLinkConsistent(l2l)){
53  linksWithMalformedLanes.add(l2l.getLinkId());
54  }
55  }
56 
57  if (this.removeMalformed){
58  for (Id<Link> linkId : linksWithMalformedLanes) {
59  this.lanes.getLanesToLinkAssignments().remove(linkId);
60  log.info("remove lanes on link " + linkId);
61  }
62  }
63  log.info("checked consistency. Lanes on " + linksWithMalformedLanes.size() + " links have been removed.");
64  }
SortedMap< Id< Link >, LanesToLinkAssignment > getLanesToLinkAssignments()
boolean isLaneOnLinkConsistent(LanesToLinkAssignment l2l)
Here is the call graph for this function:

◆ isLaneOnLinkConsistent()

boolean org.matsim.lanes.LanesConsistencyChecker.isLaneOnLinkConsistent ( LanesToLinkAssignment  l2l)
private

Definition at line 66 of file LanesConsistencyChecker.java.

References org.matsim.api.core.v01.Identifiable< T >.getId(), org.matsim.lanes.LanesToLinkAssignment.getLanes(), org.matsim.api.core.v01.network.Link.getLength(), org.matsim.lanes.LanesToLinkAssignment.getLinkId(), org.matsim.api.core.v01.network.Network.getLinks(), org.matsim.api.core.v01.network.Node.getOutLinks(), and org.matsim.api.core.v01.network.Link.getToNode().

Referenced by org.matsim.lanes.LanesConsistencyChecker.checkConsistency().

66  {
67  //check if link exists for each assignment of one or more lanes to a link
68  if (!this.network.getLinks().containsKey(l2l.getLinkId())) {
69  log.error("No link found for lanesToLinkAssignment on link Id(linkIdRef): " + l2l.getLinkId());
70  return false;
71  }
72  //check length
73  else {
74  Link link = this.network.getLinks().get(l2l.getLinkId());
75  for (Lane l : l2l.getLanes().values()){
76  if (link.getLength() < l.getStartsAtMeterFromLinkEnd()) {
77  log.error("Link Id " + link.getId() + " is shorter than an assigned lane with id " + l.getId());
78  return false;
79  }
80  }
81  }
82 
83  //check toLinks or toLanes specified in the lanes
84  for (Lane lane : l2l.getLanes().values()) {
85  if (lane.getToLaneIds() != null) {
86  for (Id<Lane> toLaneId : lane.getToLaneIds()){
87  if (! l2l.getLanes().containsKey(toLaneId)){
88  log.error("Error: toLane not existing:");
89  log.error(" Lane Id: " + lane.getId() + " on Link Id: " + l2l.getLinkId() +
90  " leads to Lane Id: " + toLaneId + " that is not existing!");
91  return false;
92  // TODO just delete this toLane?
93  }
94  }
95  }
96  //check availability of toLink in network
97  else if (lane.getToLinkIds() != null){
98  for (Id<Link> toLinkId : lane.getToLinkIds()) {
99  if (! this.network.getLinks().containsKey(toLinkId)){
100  log.error("No link found in network for toLinkId " + toLinkId + " of laneId " + lane.getId() + " of link id " + l2l.getLinkId());
101  return false;
102  // TODO just delete this toLink?
103  } else {
104  Link link = this.network.getLinks().get(l2l.getLinkId());
105  if (! link.getToNode().getOutLinks().containsKey(toLinkId)){
106  log.error("The given toLink " + toLinkId + " is not reachable from lane " + lane.getId() + " on link " + link.getId());
107  return false;
108  // TODO just delete this toLink?
109  }
110  }
111  }
112  }
113  }
114 
115  // comment this out, because not every out-link of a node has to be reached by every in-link. theresa, aug'17
116 // //second check matching of link's outlinks and lane's toLinks
117 // Link link = this.network.getLinks().get(l2l.getLinkId());
118 // log.info("Link id: " + l2l.getLinkId());
119 // Set<Id<Link>> toLinksFromLanes = new HashSet<>();
120 // for (Lane lane : l2l.getLanes().values()){
121 // if (lane.getToLinkIds() != null){
122 // toLinksFromLanes.addAll(lane.getToLinkIds());
123 // }
124 // }
125 //
126 // for (Link nodeOutLink : link.getToNode().getOutLinks().values()){
127 // log.info("\t\thas outlink: " + nodeOutLink.getId());
128 // if (!toLinksFromLanes.contains(nodeOutLink.getId())){
129 // log.error("Error: Lane Outlink: ");
130 // log.error("\t\tThe lanes of link " + link.getId() + " do not lead to all of the outlinks of the links toNode " + link.getToNode().getId() + " . The outlink " + nodeOutLink.getId()
131 // + " is not reachable from the lanes of this link. ");
132 // for (Lane lane : l2l.getLanes().values()){
133 // log.error("\t\tLane id: " + lane.getId());
134 // if (lane.getToLinkIds() != null){
135 // for (Id<Link> id : lane.getToLinkIds()){
136 // log.error("\t\t\t\thas toLinkId: " + id);
137 // }
138 // }
139 // log.error("End: Lane Outlink Error Message");
140 // }
141 // return false;
142 // }
143 // }
144  return true;
145  }
Map< Id< Link >, ? extends Link > getLinks()
Here is the call graph for this function:

◆ isRemoveMalformed()

boolean org.matsim.lanes.LanesConsistencyChecker.isRemoveMalformed ( )

◆ setRemoveMalformed()

void org.matsim.lanes.LanesConsistencyChecker.setRemoveMalformed ( boolean  removeMalformed)

Member Data Documentation

◆ log

final Logger org.matsim.lanes.LanesConsistencyChecker.log = LogManager.getLogger(LanesConsistencyChecker.class)
staticprivate

Definition at line 38 of file LanesConsistencyChecker.java.

◆ network

Network org.matsim.lanes.LanesConsistencyChecker.network
private

Definition at line 39 of file LanesConsistencyChecker.java.

◆ lanes

Lanes org.matsim.lanes.LanesConsistencyChecker.lanes
private

Definition at line 40 of file LanesConsistencyChecker.java.

◆ removeMalformed

boolean org.matsim.lanes.LanesConsistencyChecker.removeMalformed = false
private

The documentation for this class was generated from the following file: