All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opentripplanner.ext.flex.flexpathcalculator.FlexPath Maven / Gradle / Ivy

There is a newer version: 2.6.0
Show newest version
package org.opentripplanner.ext.flex.flexpathcalculator;

import java.util.function.Supplier;
import org.locationtech.jts.geom.LineString;

/**
 * This class contains the results from a FlexPathCalculator.
 */
public class FlexPath {

  private final Supplier geometrySupplier;
  public int distanceMeters;
  public int durationSeconds;
  private LineString geometry;

  /**
   * @param geometrySupplier Computing a linestring from a GraphPath is a surprisingly expensive
   *                         operation and since there are very many instances of these for a flex
   *                         access/egress search the actual computation is delayed until the
   *                         linestring is actually needed. Most of them are _not_ needed so this
   *                         increases performance quite dramatically.
   */
  public FlexPath(int distanceMeters, int durationSeconds, Supplier geometrySupplier) {
    this.distanceMeters = distanceMeters;
    this.durationSeconds = durationSeconds;
    this.geometrySupplier = geometrySupplier;
  }

  public LineString getGeometry() {
    if (geometry == null) {
      geometry = geometrySupplier.get();
    }
    return geometry;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy