001/*
002 * This file is part of McIDAS-V
003 *
004 * Copyright 2007-2024
005 * Space Science and Engineering Center (SSEC)
006 * University of Wisconsin - Madison
007 * 1225 W. Dayton Street, Madison, WI 53706, USA
008 * https://www.ssec.wisc.edu/mcidas/
009 * 
010 * All Rights Reserved
011 * 
012 * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and
013 * some McIDAS-V source code is based on IDV and VisAD source code.  
014 * 
015 * McIDAS-V is free software; you can redistribute it and/or modify
016 * it under the terms of the GNU Lesser Public License as published by
017 * the Free Software Foundation; either version 3 of the License, or
018 * (at your option) any later version.
019 * 
020 * McIDAS-V is distributed in the hope that it will be useful,
021 * but WITHOUT ANY WARRANTY; without even the implied warranty of
022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
023 * GNU Lesser Public License for more details.
024 * 
025 * You should have received a copy of the GNU Lesser Public License
026 * along with this program.  If not, see https://www.gnu.org/licenses/.
027 */
028
029package edu.wisc.ssec.mcidasv.data.cyclone;
030
031import java.util.ArrayList;
032import java.util.List;
033
034import visad.DateTime;
035import visad.Real;
036import visad.georef.EarthLocation;
037
038/**
039 * Created by IntelliJ IDEA. User: yuanho Date: Apr 18, 2008 Time: 1:45:38 PM To
040 * change this template use File | Settings | File Templates.
041 */
042
043public class StormTrackPoint implements Comparable {
044
045        /** _more_ */
046        private int id = -1;
047
048        /** _more_ */
049        private boolean edited = false;
050
051        /** _more_ */
052        private EarthLocation location;
053
054        /** _more_ */
055        private DateTime time;
056
057        /** _more_ */
058        private List<Real> attributes;
059
060        /** _more_ */
061        private int forecastHour = 0;
062
063        /**
064         * copy ctor
065         * 
066         * @param that
067         *            The track point to copy
068         */
069        public StormTrackPoint(StormTrackPoint that) {
070                this.location = that.location;
071                this.time = that.time;
072                if (that.attributes != null) {
073                        this.attributes = (List<Real>) new ArrayList(that.attributes);
074                }
075                this.forecastHour = that.forecastHour;
076                this.id = that.id;
077                this.edited = that.edited;
078        }
079
080        /**
081         * _more_
082         * 
083         * @param pointLocation
084         *            _more_
085         * @param time
086         *            _more_
087         * @param forecastHour
088         *            _more_
089         * @param attrs
090         *            _more_
091         */
092        public StormTrackPoint(EarthLocation pointLocation, DateTime time,
093                        int forecastHour, List<Real> attrs) {
094                this.location = pointLocation;
095                this.time = time;
096                this.forecastHour = forecastHour;
097                this.attributes = attrs;
098        }
099
100        /**
101         * Compare this object to another.
102         * 
103         * @param o
104         *            object in question.
105         * @return spec from Comparable interface.
106         */
107        public int compareTo(Object o) {
108                if (o instanceof StormTrackPoint) {
109                        StormTrackPoint that = (StormTrackPoint) o;
110                        return (time.compareTo(that.time));
111                }
112                return toString().compareTo(o.toString());
113        }
114
115        /**
116         * Set the ForecastHour property.
117         * 
118         * @param value
119         *            The new value for ForecastHour
120         */
121        public void setForecastHour(int value) {
122                forecastHour = value;
123        }
124
125        /**
126         * Get the ForecastHour property.
127         * 
128         * @return The ForecastHour
129         */
130        public int getForecastHour() {
131                return forecastHour;
132        }
133
134        /**
135         * _more_
136         * 
137         * @param time
138         *            _more_
139         */
140        public void setTime(DateTime time) {
141                this.time = time;
142        }
143
144        /**
145         * _more_
146         * 
147         * @return _more_
148         */
149        public DateTime getTime() {
150                return time;
151        }
152
153        /**
154         * _more_
155         * 
156         * @param point
157         *            _more_
158         */
159        public void setLocation(EarthLocation point) {
160                this.location = point;
161        }
162
163        /**
164         * _more_
165         * 
166         * @return _more_
167         */
168        public EarthLocation getLocation() {
169                return location;
170        }
171
172        /*
173         * _more_
174         * 
175         * @return _more_
176         */
177
178        /**
179         * _more_
180         * 
181         * @return _more_
182         */
183        public List<Real> getTrackAttributes() {
184                return attributes;
185        }
186
187        /**
188         * _more_
189         * 
190         * @return _more_
191         */
192        public String toString() {
193                return location + "";
194        }
195
196        /**
197         * _more_
198         * 
199         * 
200         * @param param
201         *            _more_
202         * 
203         * @return _more_
204         */
205        public Real getAttribute(StormParam param) {
206                return param.getAttribute(attributes);
207        }
208
209        /**
210         * _more_
211         * 
212         * 
213         * @param real
214         *            _more_
215         * 
216         */
217        public void setAttribute(Real real) {
218                for (Real attr : attributes) {
219                        if (attr.getType().equals(real.getType())) {
220                                // attr.(real)
221                                attributes.remove(attr);
222                                attributes.add(real);
223                        }
224                }
225
226        }
227
228        /**
229         * _more_
230         * 
231         * @param attr
232         *            _more_
233         * 
234         */
235        public void addAttribute(Real attr) {
236                if (attributes == null) {
237                        attributes = new ArrayList<Real>();
238                }
239
240                attributes.add(attr);
241
242        }
243
244        /**
245         * _more_
246         * 
247         * @param o
248         *            _more_
249         * 
250         * @param value
251         *            _more_
252         * 
253         * @return _more_
254         */
255        /*
256         * public boolean equals(Object o) { if (o == null) { return false; } if (
257         * !(o instanceof StormTrackPoint)) { return false; } StormTrackPoint other
258         * = (StormTrackPoint) o; return
259         * ((trackPointId.equals(other.trackPointId))); }
260         */
261
262        /**
263         * Set the Id property.
264         * 
265         * @param value
266         *            The new value for Id
267         */
268        public void setId(int value) {
269                id = value;
270        }
271
272        /**
273         * Get the Id property.
274         * 
275         * @return The Id
276         */
277        public int getId() {
278                return id;
279        }
280
281        /**
282         * Set the Edited property.
283         * 
284         * @param value
285         *            The new value for Edited
286         */
287        public void setEdited(boolean value) {
288                edited = value;
289        }
290
291        /**
292         * Get the Edited property.
293         * 
294         * @return The Edited
295         */
296        public boolean getEdited() {
297                return edited;
298        }
299
300}