/* This program is free software: you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package org.opentripplanner.routing.graph;
import org.opentripplanner.common.geometry.SphericalDistanceLibrary;
import org.opentripplanner.routing.core.State;
import org.opentripplanner.routing.core.StateEditor;
import org.opentripplanner.routing.core.TraverseMode;
import com.vividsolutions.jts.geom.LineString;
public class SimpleConcreteEdge extends Edge {
private static final long serialVersionUID = 1L;
/**
* Constructor without ID.
*
* @param v1
* @param v2
*/
public SimpleConcreteEdge(Vertex v1, Vertex v2) {
super(v1, v2);
}
@Override
public State traverse(State s0) {
double d = getDistance();
TraverseMode mode = s0.getNonTransitMode();
int t = (int) (d / s0.getOptions().getSpeed(mode));
StateEditor s1 = s0.edit(this);
s1.incrementTimeInSeconds(t);
s1.incrementWeight(d);
return s1.makeState();
}
@Override
public String getName() {
return null;
}
@Override
public LineString getGeometry() {
return null;
}
@Override
public double getDistance() {
return SphericalDistanceLibrary.getInstance().distance(getFromVertex().getCoordinate(), getToVertex()
.getCoordinate());
}
}