org.openlr.encoder.MaxDistanceProcessor Maven / Gradle / Ivy
The newest version!
package org.openlr.encoder;
import org.openlr.map.Line;
import org.openlr.map.Path;
import java.util.OptionalDouble;
class MaxDistanceProcessor implements IntermediateProcessor {
private final double maxDistance;
MaxDistanceProcessor(double maxDistance) {
this.maxDistance = maxDistance;
}
@Override
public > OptionalDouble getDistanceToNext(Path path) {
if (path.getLength() > maxDistance) {
return OptionalDouble.of(maxDistance);
}
else {
return OptionalDouble.empty();
}
}
}