
org.opentripplanner.ext.restapi.mapping.ElevationMapper Maven / Gradle / Ivy
The newest version!
package org.opentripplanner.ext.restapi.mapping;
import org.opentripplanner.model.plan.ElevationProfile;
public class ElevationMapper {
public static String mapElevation(ElevationProfile p) {
if (p == null) {
return null;
}
StringBuilder str = new StringBuilder();
for (var step : p.steps()) {
str.append(Math.round(step.x()));
str.append(",");
if (step.isYUnknown()) {
str.append("NaN");
} else {
str.append(Math.round(step.y() * 10.0) / 10.0);
}
str.append(",");
}
if (str.length() > 0) {
str.setLength(str.length() - 1);
}
return str.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy