Exemplo n.º 1
0
 private Set<Link> getLinksWithinSearchRadius(Coord centralCoords) {
   Set<Link> linksWithinRadius = new HashSet<>();
   for (Link link : this.network.getLinks().values()) {
     if (NetworkUtils.getEuclidianDistance(centralCoords, link.getToNode().getCoord())
         < SEARCH_RADIUS) {
       linksWithinRadius.add(link);
     }
   }
   return linksWithinRadius;
 }
Exemplo n.º 2
0
 /**
  * Within search radius search for the closest link that has the current mode as allowed travel
  * mode and return this link.
  *
  * @param stopFacility Stop facility to search a link for.
  * @return Null if no such link could be found.
  */
 private Id<Link> findClosestLink(TransitStopFacility stopFacility) {
   Link nearestLink = NetworkUtils.getNearestLink(this.network, stopFacility.getCoord());
   if (NetworkUtils.getEuclidianDistance(
           stopFacility.getCoord(), nearestLink.getToNode().getCoord())
       <= SEARCH_RADIUS) {
     // If nearest link is within search radius, return it.
     return nearestLink.getId();
   } else {
     return null;
   }
 }
  private void assignProps(Collection<Link> links, Link link) {
    double capacity = 0;
    double freespeed = 0;
    double lanes = 0;
    for (Link origLink : links) {
      capacity += origLink.getCapacity();
      freespeed = Math.max(freespeed, origLink.getFreespeed());
      lanes += origLink.getNumberOfLanes();
    }

    link.setCapacity(capacity);
    link.setFreespeed(freespeed);
    link.setNumberOfLanes(lanes);
    link.setLength(
        NetworkUtils.getEuclidianDistance(
            link.getFromNode().getCoord(), link.getToNode().getCoord()));
  }