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

org.opentripplanner.ext.transferanalyzer.annotations.TransferCouldNotBeRouted Maven / Gradle / Ivy

The newest version!
package org.opentripplanner.ext.transferanalyzer.annotations;

import java.util.List;
import org.locationtech.jts.geom.Geometry;
import org.opentripplanner.framework.geometry.GeometryUtils;
import org.opentripplanner.graph_builder.issue.api.DataImportIssue;
import org.opentripplanner.transit.model.site.RegularStop;

/**
 * Represents two stops that are close to each other where no route is found between them using OSM
 * data
 */
public class TransferCouldNotBeRouted implements DataImportIssue {

  private static final String FMT =
    "Connection between stop %s and stop %s could not be routed. " + "Euclidean distance is %.0f.";

  private static final String HTMLFMT =
    "Connection between stop " +
    "\"%s\" (%s) and stop " +
    "\"%s\" (%s) could not be routed. " +
    "Euclidean distance is %.0f.";

  private final RegularStop origin;
  private final RegularStop destination;
  private final double directDistance;

  public TransferCouldNotBeRouted(
    RegularStop origin,
    RegularStop destination,
    double directDistance
  ) {
    this.origin = origin;
    this.destination = destination;
    this.directDistance = directDistance;
  }

  @Override
  public String getMessage() {
    return String.format(FMT, origin, destination, directDistance);
  }

  @Override
  public String getHTMLMessage() {
    return String.format(
      HTMLFMT,
      origin.getLat(),
      origin.getLon(),
      origin.getName(),
      origin.getId(),
      destination.getLat(),
      destination.getLon(),
      destination.getName(),
      destination.getId(),
      directDistance
    );
  }

  @Override
  public int getPriority() {
    return (int) -directDistance;
  }

  @Override
  public Geometry getGeometry() {
    return GeometryUtils.makeLineString(
      List.of(
        origin.getCoordinate().asJtsCoordinate(),
        destination.getCoordinate().asJtsCoordinate()
      )
    );
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy