~opensatnav-admins/opensatnav/release-1.0

« back to all changes in this revision

Viewing changes to src/org/opensatnav/android/contribute/content/Track.java

  • Committer: Kieran Fleming
  • Date: 2010-12-13 13:13:48 UTC
  • Revision ID: kieran.fleming@gmail.com-20101213131348-pixo12i0wjf11jk3
Add all the missing stuff from the failed package rename

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2008 Google Inc.
 
3
 * 
 
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
 
6
 * the License at
 
7
 * 
 
8
 * http://www.apache.org/licenses/LICENSE-2.0
 
9
 * 
 
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
 
14
 * the License.
 
15
 */
 
16
//TODO: Might not need mapID
 
17
package org.opensatnav.android.contribute.content;
 
18
 
 
19
import android.location.Location;
 
20
import android.os.Parcel;
 
21
import android.os.Parcelable;
 
22
 
 
23
import java.util.ArrayList;
 
24
 
 
25
/**
 
26
 * A class representing a (GPS) Track.
 
27
 *
 
28
 * @author Leif Hendrik Wilden
 
29
 */
 
30
public class Track implements Parcelable {
 
31
 
 
32
  /**
 
33
   * Creator for a Track object
 
34
   */
 
35
  public static class Creator implements Parcelable.Creator<Track> {
 
36
 
 
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);
 
67
      }
 
68
      return track;
 
69
    }
 
70
 
 
71
    public Track[] newArray(int size) {
 
72
      return new Track[size];
 
73
    }
 
74
  }
 
75
 
 
76
  public static final Creator CREATOR = new Creator();
 
77
 
 
78
  /**
 
79
   * The track points.
 
80
   */
 
81
  private ArrayList<Location> locations = new ArrayList<Location>();
 
82
 
 
83
  private long id = -1;
 
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 = "";
 
90
 
 
91
  // Fields derived from locations. Use setDerivedFields() to set them:
 
92
  //-------------------------------------------------------------------
 
93
 
 
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;
 
100
  private int left;
 
101
  private int top;
 
102
  private int right;
 
103
  private int bottom;
 
104
 
 
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;
 
113
 
 
114
  public Track() {
 
115
    left = Integer.MAX_VALUE;
 
116
    top = Integer.MIN_VALUE;
 
117
    right = Integer.MIN_VALUE;
 
118
    bottom = Integer.MAX_VALUE;
 
119
  }
 
120
 
 
121
  public void writeToParcel(Parcel dest, int flags) {
 
122
    dest.writeLong(id);
 
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);
 
142
    dest.writeInt(left);
 
143
    dest.writeInt(top);
 
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);
 
149
    }
 
150
  }
 
151
 
 
152
  // Getters and setters:
 
153
  //---------------------
 
154
 
 
155
  public int getLeft() {
 
156
    return left;
 
157
  }
 
158
 
 
159
  public int getTop() {
 
160
    return top;
 
161
  }
 
162
 
 
163
  public int getRight() {
 
164
    return right;
 
165
  }
 
166
 
 
167
  public int getBottom() {
 
168
    return bottom;
 
169
  }
 
170
 
 
171
  public void setBounds(int aLeft, int aTop, int aRight, int aBottom) {
 
172
    left = aLeft;
 
173
    top = aTop;
 
174
    right = aRight;
 
175
    bottom = aBottom;
 
176
  }
 
177
 
 
178
  public int describeContents() {
 
179
    return 0;
 
180
  }
 
181
 
 
182
  public long getId() {
 
183
    return id;
 
184
  }
 
185
 
 
186
  public void setId(long id) {
 
187
    this.id = id;
 
188
  }
 
189
 
 
190
  public double getTotalDistance() {
 
191
    return totalDistance;
 
192
  }
 
193
 
 
194
  public void setTotalDistance(double totalDistance) {
 
195
    this.totalDistance = totalDistance;
 
196
  }
 
197
 
 
198
  public long getTotalTime() {
 
199
    return totalTime;
 
200
  }
 
201
 
 
202
  public void setTotalTime(long totalTime) {
 
203
    this.totalTime = totalTime;
 
204
  }
 
205
 
 
206
  public long getMovingTime() {
 
207
    return movingTime;
 
208
  }
 
209
 
 
210
  public void setMovingTime(long movingTime) {
 
211
    this.movingTime = movingTime;
 
212
  }
 
213
 
 
214
  public long getStartTime() {
 
215
    return startTime;
 
216
  }
 
217
 
 
218
  public void setStartTime(long startTime) {
 
219
    this.startTime = startTime;
 
220
  }
 
221
 
 
222
  public long getStopTime() {
 
223
    return stopTime;
 
224
  }
 
225
 
 
226
  public void setStopTime(long stopTime) {
 
227
    this.stopTime = stopTime;
 
228
  }
 
229
 
 
230
  public String getName() {
 
231
    return name;
 
232
  }
 
233
 
 
234
  public void setName(String name) {
 
235
    this.name = name;
 
236
  }
 
237
 
 
238
  public long getStartId() {
 
239
    return startId;
 
240
  }
 
241
 
 
242
  public void setStartId(long startId) {
 
243
    this.startId = startId;
 
244
  }
 
245
 
 
246
  public long getStopId() {
 
247
    return stopId;
 
248
  }
 
249
 
 
250
  public void setStopId(long stopId) {
 
251
    this.stopId = stopId;
 
252
  }
 
253
 
 
254
  public String getDescription() {
 
255
    return description;
 
256
  }
 
257
 
 
258
  public void setDescription(String description) {
 
259
    this.description = description;
 
260
  }
 
261
 
 
262
  public String getMapId() {
 
263
    return mapId;
 
264
  }
 
265
 
 
266
  public void setMapId(String mapId) {
 
267
    this.mapId = mapId;
 
268
  }
 
269
 
 
270
  public String getCategory() {
 
271
    return category;
 
272
  }
 
273
 
 
274
  public void setCategory(String category) {
 
275
    this.category = category;
 
276
  }
 
277
 
 
278
  public double getAverageSpeed() {
 
279
    return averageSpeed;
 
280
  }
 
281
 
 
282
  public void setAverageSpeed(double averageSpeed) {
 
283
    this.averageSpeed = averageSpeed;
 
284
  }
 
285
 
 
286
  public double getAverageMovingSpeed() {
 
287
    return averageMovingSpeed;
 
288
  }
 
289
 
 
290
  public void setAverageMovingSpeed(double averageMovingSpeed) {
 
291
    this.averageMovingSpeed = averageMovingSpeed;
 
292
  }
 
293
 
 
294
  public double getMaxSpeed() {
 
295
    return maxSpeed;
 
296
  }
 
297
 
 
298
  public void setMaxSpeed(double maxSpeed) {
 
299
    this.maxSpeed = maxSpeed;
 
300
  }
 
301
 
 
302
  public double getMinElevation() {
 
303
    return minElevation;
 
304
  }
 
305
 
 
306
  public void setMinElevation(double minElevation) {
 
307
    this.minElevation = minElevation;
 
308
  }
 
309
 
 
310
  public double getMaxElevation() {
 
311
    return maxElevation;
 
312
  }
 
313
 
 
314
  public void setMaxElevation(double maxElevation) {
 
315
    this.maxElevation = maxElevation;
 
316
  }
 
317
 
 
318
  public double getTotalElevationGain() {
 
319
    return totalElevationGain;
 
320
  }
 
321
 
 
322
  public void setTotalElevationGain(double totalElevationGain) {
 
323
    this.totalElevationGain = totalElevationGain;
 
324
  }
 
325
 
 
326
  public double getMinGrade() {
 
327
    return minGrade;
 
328
  }
 
329
 
 
330
  public void setMinGrade(double minGrade) {
 
331
    this.minGrade = minGrade;
 
332
  }
 
333
 
 
334
  public double getMaxGrade() {
 
335
    return maxGrade;
 
336
  }
 
337
 
 
338
  public void setMaxGrade(double maxGrade) {
 
339
    this.maxGrade = maxGrade;
 
340
  }
 
341
 
 
342
  public int getNumberOfPoints() {
 
343
    return numberOfPoints;
 
344
  }
 
345
 
 
346
  public void setNumberOfPoints(int numberOfPoints) {
 
347
    this.numberOfPoints = numberOfPoints;
 
348
  }
 
349
 
 
350
  public void addLocation(Location l) {
 
351
    locations.add(l);
 
352
  }
 
353
 
 
354
  public ArrayList<Location> getLocations() {
 
355
    return locations;
 
356
  }
 
357
 
 
358
  public void setLocations(ArrayList<Location> locations) {
 
359
    this.locations = locations;
 
360
  }
 
361
}