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