1010import com .conveyal .gtfs .model .Stop ;
1111import com .conveyal .gtfs .model .StopTime ;
1212import com .conveyal .gtfs .model .Trip ;
13+ import com .conveyal .r5 .analyst .cluster .TransportNetworkConfig ;
1314import com .conveyal .r5 .api .util .TransitModes ;
1415import com .conveyal .r5 .common .GeometryUtils ;
1516import com .conveyal .r5 .streets .EdgeStore ;
@@ -66,8 +67,6 @@ public class TransitLayer implements Serializable, Cloneable {
6667 /** Maximum distance to record in distance tables, in meters. */
6768 public static final int WALK_DISTANCE_LIMIT_METERS = 2000 ;
6869
69- public static final boolean SAVE_SHAPES = false ;
70-
7170 /**
7271 * Distance limit for transfers, meters. Set to 1km which is slightly above OTP's 600m (which was specified as
7372 * 1 m/s with 600s max time, which is actually somewhat less than 600m due to extra costs due to steps etc.
@@ -166,6 +165,11 @@ public class TransitLayer implements Serializable, Cloneable {
166165
167166 public Map <String , Fare > fares ;
168167
168+ /** Whether to save detailed trip shapes from GTFS (e.g., for Conveyal Taui sites). Unless the default false
169+ * value is overwritten by a transportNetworkConfig file, straight line segments between stops will be used in
170+ * visualiations.*/
171+ public boolean saveShapes = false ;
172+
169173 /** Map from feed ID to feed CRC32 to ensure that we can't apply scenarios to the wrong feeds */
170174 public Map <String , Long > feedChecksums = new HashMap <>();
171175
@@ -179,6 +183,17 @@ public class TransitLayer implements Serializable, Cloneable {
179183 */
180184 public String scenarioId ;
181185
186+ public TransitLayer () {
187+ // Default constructor. Does not exist implicitly when one-arg constructor is present.
188+ // Necessary to ensure fields with initializer expressions are initialized upon deserialization.
189+ }
190+
191+ public TransitLayer (TransportNetworkConfig config ) {
192+ if (config != null ) {
193+ saveShapes = config .saveShapes ;
194+ }
195+ }
196+
182197 /**
183198 * Load a GTFS feed with full load level. The feed is not closed after being loaded.
184199 * TODO eliminate "load levels"
@@ -307,7 +322,7 @@ public void loadFromGtfs (GTFSFeed gtfs, LoadLevel level) throws DuplicateFeedEx
307322
308323 tripPattern .routeIndex = routeIndexForRoute .get (trip .route_id );
309324
310- if (trip .shape_id != null && SAVE_SHAPES ) {
325+ if (trip .shape_id != null && saveShapes ) {
311326 Shape shape = gtfs .getShape (trip .shape_id );
312327 if (shape == null ) LOG .warn ("Shape {} for trip {} was missing" , trip .shape_id , trip .trip_id );
313328 else {
0 commit comments