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

org.opentripplanner.routing.location.TemporaryStreetLocation Maven / Gradle / Ivy

There is a newer version: 2.6.0
Show newest version
package org.opentripplanner.routing.location;

import org.locationtech.jts.geom.Coordinate;
import org.opentripplanner.routing.edgetype.TemporaryEdge;
import org.opentripplanner.routing.graph.Edge;
import org.opentripplanner.routing.vertextype.TemporaryVertex;
import org.opentripplanner.transit.model.basic.I18NString;

public final class TemporaryStreetLocation extends StreetLocation implements TemporaryVertex {

  private final boolean endVertex;

  public TemporaryStreetLocation(
    String id,
    Coordinate nearestPoint,
    I18NString name,
    boolean endVertex
  ) {
    super(id, nearestPoint, name);
    this.endVertex = endVertex;
  }

  @Override
  public void addOutgoing(Edge edge) {
    if (edge instanceof TemporaryEdge) {
      if (endVertex) {
        throw new UnsupportedOperationException("Can't add outgoing edge to end vertex");
      } else {
        super.addOutgoing(edge);
      }
    } else {
      throw new UnsupportedOperationException("Can't add permanent edge to temporary vertex");
    }
  }

  @Override
  public void addIncoming(Edge edge) {
    if (edge instanceof TemporaryEdge) {
      if (endVertex) {
        super.addIncoming(edge);
      } else {
        throw new UnsupportedOperationException("Can't add incoming edge to start vertex");
      }
    } else {
      throw new UnsupportedOperationException("Can't add permanent edge to temporary vertex");
    }
  }

  @Override
  public boolean isEndVertex() {
    return endVertex;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy