MATSIM
TransitScheduleUtils.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * TransitScheduleUtils
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2019 by the members listed in the COPYING, *
8  * LICENSE and WARRANTY file. *
9  * email : info at matsim dot org *
10  * *
11  * *********************************************************************** *
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * See also COPYING, LICENSE and WARRANTY file *
18  * *
19  * *********************************************************************** */
20 
21 package org.matsim.pt.transitSchedule;
22 
23 import java.util.Collection;
24 
28 
35 public final class TransitScheduleUtils {
36 
37  public final static String ACCESSTIME_ATTRIBUTE = "accessTime";
38  public final static String EGRESSTIME_ATTRIBUTE = "egressTime";
40  }
41 
42  public static double getStopAccessTime(TransitStopFacility stopFacility){
43  Object accessTime = stopFacility.getAttributes().getAttribute(ACCESSTIME_ATTRIBUTE);
44  return accessTime!=null?(double) accessTime:0.0;
45  }
46 
47  public static void setStopAccessTime(TransitStopFacility stopFacility, double stopAccessTime){
48  stopFacility.getAttributes().putAttribute(ACCESSTIME_ATTRIBUTE,stopAccessTime);
49  }
50 
51  public static double getStopEgressTime(TransitStopFacility stopFacility){
52  Object egressTime = stopFacility.getAttributes().getAttribute(EGRESSTIME_ATTRIBUTE);
53  return egressTime!=null?(double) egressTime:0.0;
54  }
55  public static void setStopEgressTime(TransitStopFacility stopFacility, double stopEgressTime){
56  stopFacility.getAttributes().putAttribute(EGRESSTIME_ATTRIBUTE,stopEgressTime);
57  }
58 
59  public static void setSymmetricStopAccessEgressTime(TransitStopFacility stopFacility, double stopAccessEgressTime){
60  setStopAccessTime(stopFacility,stopAccessEgressTime);
61  setStopEgressTime(stopFacility,stopAccessEgressTime);
62  }
63 
65  return createQuadTreeOfTransitStopFacilities(transitSchedule.getFacilities().values());
66  }
67 
68  public static QuadTree<TransitStopFacility> createQuadTreeOfTransitStopFacilities(Collection<TransitStopFacility> transitStopFacilities) {
69  double minX = Double.POSITIVE_INFINITY;
70  double minY = Double.POSITIVE_INFINITY;
71  double maxX = Double.NEGATIVE_INFINITY;
72  double maxY = Double.NEGATIVE_INFINITY;
73  for (TransitStopFacility stopFacility : transitStopFacilities) {
74  double x = stopFacility.getCoord().getX();
75  double y = stopFacility.getCoord().getY();
76 
77  if (x < minX)
78  minX = x;
79  if (y < minY)
80  minY = y;
81  if (x > maxX)
82  maxX = x;
83  if (y > maxY)
84  maxY = y;
85  }
86  QuadTree<TransitStopFacility> stopsQT = new QuadTree<>(minX, minY, maxX, maxY);
87  for (TransitStopFacility stopFacility : transitStopFacilities) {
88  double x = stopFacility.getCoord().getX();
89  double y = stopFacility.getCoord().getY();
90  stopsQT.put(x, y, stopFacility);
91  }
92  return stopsQT;
93  }
94 }
static void setStopAccessTime(TransitStopFacility stopFacility, double stopAccessTime)
Map< Id< TransitStopFacility >, TransitStopFacility > getFacilities()
static void setSymmetricStopAccessEgressTime(TransitStopFacility stopFacility, double stopAccessEgressTime)
static QuadTree< TransitStopFacility > createQuadTreeOfTransitStopFacilities(TransitSchedule transitSchedule)
static double getStopAccessTime(TransitStopFacility stopFacility)
boolean put(final double x, final double y, final T value)
Definition: QuadTree.java:86
Object putAttribute(final String attribute, final Object value)
static QuadTree< TransitStopFacility > createQuadTreeOfTransitStopFacilities(Collection< TransitStopFacility > transitStopFacilities)
static void setStopEgressTime(TransitStopFacility stopFacility, double stopEgressTime)
static double getStopEgressTime(TransitStopFacility stopFacility)