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

org.opentripplanner.apis.transmodel.mapping.GeometryMapper Maven / Gradle / Ivy

The newest version!
package org.opentripplanner.apis.transmodel.mapping;

import java.util.ArrayList;
import java.util.List;
import org.opentripplanner.apis.transmodel.model.framework.EncodedPolylineBeanWithStops;
import org.opentripplanner.framework.geometry.EncodedPolyline;
import org.opentripplanner.transit.model.network.TripPattern;

public class GeometryMapper {

  /**
   * Based Trip Pattern, create a list of geometries for each stop-to-stop section in the pattern
   */
  public static List mapStopToStopGeometries(
    TripPattern tripPattern
  ) {
    var stopToStopGeometries = new ArrayList();

    for (int i = 0; i < tripPattern.numberOfStops() - 1; i++) {
      var startLocation = tripPattern.getStop(i);
      var endLocation = tripPattern.getStop(i + 1);
      var geometry = EncodedPolyline.encode(tripPattern.getHopGeometry(i));

      var stopToStopGeometry = new EncodedPolylineBeanWithStops(
        startLocation,
        endLocation,
        geometry
      );

      stopToStopGeometries.add(stopToStopGeometry);
    }

    return stopToStopGeometries;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy