2 * Copyright 2006 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
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,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.wamblee.gps.track;
19 import java.io.Serializable;
20 import java.util.ArrayList;
21 import java.util.List;
23 import org.wamblee.gps.geometry.Point;
26 * Represents a GPS track.
28 public class Track implements Serializable {
30 private List<TrackPoint> _points;
33 * Constructs an empty track.
37 _points = new ArrayList<TrackPoint>();
41 * Adds a point to a track.
42 * @param aPoint Point.
44 public void addPoint(TrackPoint aPoint) {
49 * @return Number of points in the track.
52 return _points.size();
55 public double getMinCoordinate(int i) {
57 throw new IllegalArgumentException("empty track");
59 double min = getPoint(0).getCoordinates().getX(i);
60 for (int j = 1; j < size(); j++) {
61 min = Math.min(min, getPoint(j).getCoordinates().getX(i));
66 public double getMaxCoordinate(int i) {
68 throw new IllegalArgumentException("empty track");
70 double max = getPoint(0).getCoordinates().getX(i);
71 for (int j = 1; j < size(); j++) {
72 max = Math.max(max, getPoint(j).getCoordinates().getX(i));
78 * Gets the point at the given inded.
79 * @param aIndex 0 <= aIndex < size()
82 public Point getPoint(int aIndex) {
83 return _points.get(aIndex);