Skip to content

Commit

Permalink
Don't save elevation correction without approving
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-kutz committed Feb 13, 2025
1 parent 39cc4b0 commit dc82ed5
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,26 @@ class GpxFile : GpxExtensions {
}
}

constructor(other: GpxFile) {
this.author = other.author
this.metadata = Metadata(other.metadata)
this.tracks = other.tracks.map { Track(it) }.toMutableList()
this.routes = other.routes.map { Route(it) }.toMutableList()
this.points = other.points.map { WptPt(it) }.toMutableList()
this.pointsGroups = other.pointsGroups.mapValues { PointsGroup(it.value) }.toMutableMap()
this.networkRouteKeyTags.putAll(other.networkRouteKeyTags)

this.error = other.error
this.path = other.path
this.showCurrentTrack = other.showCurrentTrack
this.hasAltitude = other.hasAltitude
this.modifiedTime = other.modifiedTime
this.pointsModifiedTime = other.pointsModifiedTime

this.generalTrack = other.generalTrack?.let { Track(it) }
this.generalSegment = other.generalSegment?.let { TrkSegment(it) }
}

fun isShowCurrentTrack() = showCurrentTrack

fun hasAltitude() = hasAltitude
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,23 @@ object GpxUtilities {
var pointTypes: String? = null
var names: String? = null

constructor()

constructor(other: RouteSegment) {
this.id = other.id
this.length = other.length
this.startTrackPointIndex = other.startTrackPointIndex
this.segmentTime = other.segmentTime
this.speed = other.speed
this.turnType = other.turnType
this.turnLanes = other.turnLanes
this.turnAngle = other.turnAngle
this.skipTurn = other.skipTurn
this.types = other.types
this.pointTypes = other.pointTypes
this.names = other.names
}

companion object {
const val START_TRKPT_IDX_ATTR = "startTrkptIdx"

Expand Down Expand Up @@ -245,6 +262,13 @@ object GpxUtilities {
var tag: String? = null
var value: String? = null

constructor()

constructor(routeType: RouteType) {
this.tag = routeType.tag
this.value = routeType.value
}

companion object {
fun fromStringBundle(bundle: StringBundle): RouteType {
val t = RouteType()
Expand Down Expand Up @@ -283,6 +307,14 @@ object GpxUtilities {
backgroundType = point.getBackgroundType()
}

constructor(other: PointsGroup) : this(other.name) {
this.iconName = other.iconName
this.backgroundType = other.backgroundType
this.points = other.points.map { WptPt(it) }.toMutableList()
this.color = other.color
this.hidden = other.hidden
}

fun isHidden(): Boolean {
return hidden
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
package net.osmand.shared.gpx.primitives

class Route : GpxExtensions() {
class Route : GpxExtensions {
var name: String? = null
var desc: String? = null
var points = mutableListOf<WptPt>()

constructor()

constructor(other: Route) {
this.name = other.name
this.desc = other.desc
this.points = other.points.map { WptPt(it) }.toMutableList()
copyExtensions(other)
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
package net.osmand.shared.gpx.primitives

class Track : GpxExtensions() {
class Track : GpxExtensions {
var name: String? = null
var desc: String? = null
var segments = mutableListOf<TrkSegment>()
var generalTrack = false

constructor()

constructor(other: Track) : this() {
this.name = other.name
this.desc = other.desc
this.segments.addAll(other.segments.map { TrkSegment(it) })
this.generalTrack = other.generalTrack
}

fun isGeneralTrack() = generalTrack
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,25 @@ import net.osmand.shared.gpx.GpxUtilities
import net.osmand.shared.gpx.SplitMetric
import net.osmand.shared.gpx.SplitSegment

class TrkSegment : GpxExtensions() {
class TrkSegment : GpxExtensions {
var name: String? = null
var generalSegment = false
var points = mutableListOf<WptPt>()
var renderer: Any? = null
var routeSegments = mutableListOf<GpxUtilities.RouteSegment>()
var routeTypes = mutableListOf<GpxUtilities.RouteType>()

constructor()

constructor(segment: TrkSegment) {
this.name = segment.name
this.generalSegment = segment.generalSegment
this.renderer = segment.renderer
this.routeSegments.addAll(segment.routeSegments.map { GpxUtilities.RouteSegment(it) })
this.routeTypes.addAll(segment.routeTypes.map { GpxUtilities.RouteType(it) })
this.points.addAll(segment.points.map { WptPt(it) })
}

fun isGeneralSegment() = generalSegment

fun hasRoute(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
import net.osmand.shared.gpx.RouteActivityHelper;
import net.osmand.shared.gpx.primitives.Metadata;
import net.osmand.shared.gpx.primitives.RouteActivity;
import net.osmand.shared.gpx.primitives.Track;
import net.osmand.shared.gpx.primitives.TrkSegment;
import net.osmand.shared.gpx.primitives.WptPt;
import net.osmand.util.Algorithms;
Expand Down Expand Up @@ -402,6 +403,10 @@ public LatLon getLatLon() {
return latLon;
}

public GpxFile getGpxCopy() {
return new GpxFile(getGpx());
}

public GpxFile getGpx() {
return displayHelper.getGpx();
}
Expand Down Expand Up @@ -1644,7 +1649,7 @@ public void onRouteSelected(@NonNull GpxFile gpxFile, int selectedRoute) {
public void openPlanRoute(int segmentIndex, @MeasurementToolMode int mode) {
MapActivity activity = getMapActivity();
if (activity != null) {
GpxFile gpxFile = getGpx();
GpxFile gpxFile = getGpxCopy();
MeasurementToolFragment.showInstance(activity, gpxFile, segmentIndex, mode);
}
hide();
Expand Down

0 comments on commit dc82ed5

Please sign in to comment.