2
* Copyright 2008 Google Inc.
4
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5
* use this file except in compliance with the License. You may obtain a copy of
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
* License for the specific language governing permissions and limitations under
16
//TODO: Might not need mapID
17
package org.opensatnav.android.contribute.content;
19
import android.location.Location;
20
import android.os.Parcel;
21
import android.os.Parcelable;
23
import java.util.ArrayList;
26
* A class representing a (GPS) Track.
28
* @author Leif Hendrik Wilden
30
public class Track implements Parcelable {
33
* Creator for a Track object
35
public static class Creator implements Parcelable.Creator<Track> {
37
public Track createFromParcel(Parcel source) {
38
Track track = new Track();
39
track.id = source.readLong();
40
track.name = source.readString();
41
track.description = source.readString();
42
track.mapId = source.readString();
43
track.category = source.readString();
44
track.startId = source.readLong();
45
track.stopId = source.readLong();
46
track.startTime = source.readLong();
47
track.stopTime = source.readLong();
48
track.totalDistance = source.readDouble();
49
track.totalTime = source.readLong();
50
track.movingTime = source.readLong();
51
track.averageSpeed = source.readDouble();
52
track.averageMovingSpeed = source.readDouble();
53
track.maxSpeed = source.readDouble();
54
track.minElevation = source.readDouble();
55
track.maxElevation = source.readDouble();
56
track.totalElevationGain = source.readDouble();
57
track.minGrade = source.readDouble();
58
track.maxGrade = source.readDouble();
59
track.left = source.readInt();
60
track.top = source.readInt();
61
track.right = source.readInt();
62
track.bottom = source.readInt();
63
track.numberOfPoints = source.readInt();
64
for (int i = 0; i < track.numberOfPoints; ++i) {
65
Location loc = source.readParcelable(null);
66
track.locations.add(loc);
71
public Track[] newArray(int size) {
72
return new Track[size];
76
public static final Creator CREATOR = new Creator();
81
private ArrayList<Location> locations = new ArrayList<Location>();
84
private String name = "";
85
private String description = "";
86
private String mapId = "";
87
private long startId = -1;
88
private long stopId = -1;
89
private String category = "";
91
// Fields derived from locations. Use setDerivedFields() to set them:
92
//-------------------------------------------------------------------
94
private long startTime = -1;
95
private long stopTime = -1;
96
private int numberOfPoints = 0;
97
private double totalDistance = 0;
98
private long totalTime = 0;
99
private long movingTime = 0;
105
private double averageSpeed = 0;
106
private double averageMovingSpeed = 0;
107
private double maxSpeed = 0;
108
private double minElevation = 0;
109
private double maxElevation = 0;
110
private double totalElevationGain = 0;
111
private double minGrade = 0;
112
private double maxGrade = 0;
115
left = Integer.MAX_VALUE;
116
top = Integer.MIN_VALUE;
117
right = Integer.MIN_VALUE;
118
bottom = Integer.MAX_VALUE;
121
public void writeToParcel(Parcel dest, int flags) {
123
dest.writeString(name);
124
dest.writeString(description);
125
dest.writeString(mapId);
126
dest.writeString(category);
127
dest.writeLong(startId);
128
dest.writeLong(stopId);
129
dest.writeLong(startTime);
130
dest.writeLong(stopTime);
131
dest.writeDouble(totalDistance);
132
dest.writeLong(totalTime);
133
dest.writeLong(movingTime);
134
dest.writeDouble(averageSpeed);
135
dest.writeDouble(averageMovingSpeed);
136
dest.writeDouble(maxSpeed);
137
dest.writeDouble(minElevation);
138
dest.writeDouble(maxElevation);
139
dest.writeDouble(totalElevationGain);
140
dest.writeDouble(minGrade);
141
dest.writeDouble(maxGrade);
144
dest.writeInt(right);
145
dest.writeInt(bottom);
146
dest.writeInt(numberOfPoints);
147
for (int i = 0; i < numberOfPoints; ++i) {
148
dest.writeParcelable(locations.get(i), 0);
152
// Getters and setters:
153
//---------------------
155
public int getLeft() {
159
public int getTop() {
163
public int getRight() {
167
public int getBottom() {
171
public void setBounds(int aLeft, int aTop, int aRight, int aBottom) {
178
public int describeContents() {
182
public long getId() {
186
public void setId(long id) {
190
public double getTotalDistance() {
191
return totalDistance;
194
public void setTotalDistance(double totalDistance) {
195
this.totalDistance = totalDistance;
198
public long getTotalTime() {
202
public void setTotalTime(long totalTime) {
203
this.totalTime = totalTime;
206
public long getMovingTime() {
210
public void setMovingTime(long movingTime) {
211
this.movingTime = movingTime;
214
public long getStartTime() {
218
public void setStartTime(long startTime) {
219
this.startTime = startTime;
222
public long getStopTime() {
226
public void setStopTime(long stopTime) {
227
this.stopTime = stopTime;
230
public String getName() {
234
public void setName(String name) {
238
public long getStartId() {
242
public void setStartId(long startId) {
243
this.startId = startId;
246
public long getStopId() {
250
public void setStopId(long stopId) {
251
this.stopId = stopId;
254
public String getDescription() {
258
public void setDescription(String description) {
259
this.description = description;
262
public String getMapId() {
266
public void setMapId(String mapId) {
270
public String getCategory() {
274
public void setCategory(String category) {
275
this.category = category;
278
public double getAverageSpeed() {
282
public void setAverageSpeed(double averageSpeed) {
283
this.averageSpeed = averageSpeed;
286
public double getAverageMovingSpeed() {
287
return averageMovingSpeed;
290
public void setAverageMovingSpeed(double averageMovingSpeed) {
291
this.averageMovingSpeed = averageMovingSpeed;
294
public double getMaxSpeed() {
298
public void setMaxSpeed(double maxSpeed) {
299
this.maxSpeed = maxSpeed;
302
public double getMinElevation() {
306
public void setMinElevation(double minElevation) {
307
this.minElevation = minElevation;
310
public double getMaxElevation() {
314
public void setMaxElevation(double maxElevation) {
315
this.maxElevation = maxElevation;
318
public double getTotalElevationGain() {
319
return totalElevationGain;
322
public void setTotalElevationGain(double totalElevationGain) {
323
this.totalElevationGain = totalElevationGain;
326
public double getMinGrade() {
330
public void setMinGrade(double minGrade) {
331
this.minGrade = minGrade;
334
public double getMaxGrade() {
338
public void setMaxGrade(double maxGrade) {
339
this.maxGrade = maxGrade;
342
public int getNumberOfPoints() {
343
return numberOfPoints;
346
public void setNumberOfPoints(int numberOfPoints) {
347
this.numberOfPoints = numberOfPoints;
350
public void addLocation(Location l) {
354
public ArrayList<Location> getLocations() {
358
public void setLocations(ArrayList<Location> locations) {
359
this.locations = locations;