GPXRouteExtensions.java

  1. /*
  2.  * This file is part of Openrouteservice.
  3.  *
  4.  * Openrouteservice is free software; you can redistribute it and/or modify it under the terms of the
  5.  * GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1
  6.  * of the License, or (at your option) any later version.
  7.  *
  8.  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  9.  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10.  * See the GNU Lesser General Public License for more details.
  11.  *
  12.  * You should have received a copy of the GNU Lesser General Public License along with this library;
  13.  * if not, see <https://www.gnu.org/licenses/>.
  14.  */

  15. package org.heigit.ors.api.responses.routing.gpx;

  16. import jakarta.xml.bind.annotation.XmlElement;
  17. import jakarta.xml.bind.annotation.XmlRootElement;
  18. import org.heigit.ors.routing.RouteResult;
  19. import org.heigit.ors.routing.RouteSummary;

  20. @XmlRootElement(name = "extensions")
  21. public class GPXRouteExtensions {
  22.     @XmlElement(name = "distance")
  23.     private double distance;
  24.     @XmlElement(name = "duration")
  25.     private double duration;
  26.     @XmlElement(name = "ascent")
  27.     private double ascent;
  28.     @XmlElement(name = "descent")
  29.     private double descent;
  30.     @XmlElement(name = "avgspeed")
  31.     private double avgSpeed;
  32.     @XmlElement(name = "bounds")
  33.     private GPXBounds bounds;

  34.     public GPXRouteExtensions() {
  35.     }

  36.     public GPXRouteExtensions(RouteResult result) {
  37.         RouteSummary summary = result.getSummary();
  38.         this.distance = summary.getDistance();
  39.         this.duration = summary.getDuration();
  40.         this.ascent = summary.getAscent();
  41.         this.descent = summary.getDescent();
  42.         this.avgSpeed = summary.getAverageSpeed();
  43.         this.bounds = new GPXBounds(result.getSummary().getBBox());
  44.     }
  45. }