001 /* 002 * This file is part of McIDAS-V 003 * 004 * Copyright 2007-2013 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 http://www.gnu.org/licenses. 027 */ 028 029 package edu.wisc.ssec.mcidasv.data.cyclone; 030 031 import java.util.ArrayList; 032 import java.util.List; 033 034 import visad.DateTime; 035 import visad.Real; 036 import 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 043 public 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 * @return _more_ 217 */ 218 public void setAttribute(Real real) { 219 for (Real attr : attributes) { 220 if (attr.getType().equals(real.getType())) { 221 // attr.(real) 222 attributes.remove(attr); 223 attributes.add(real); 224 } 225 } 226 227 } 228 229 /** 230 * _more_ 231 * 232 * @param attr 233 * _more_ 234 * 235 */ 236 public void addAttribute(Real attr) { 237 if (attributes == null) { 238 attributes = new ArrayList<Real>(); 239 } 240 241 attributes.add(attr); 242 243 } 244 245 /** 246 * _more_ 247 * 248 * @param o 249 * _more_ 250 * 251 * @param value 252 * _more_ 253 * 254 * @return _more_ 255 */ 256 /* 257 * public boolean equals(Object o) { if (o == null) { return false; } if ( 258 * !(o instanceof StormTrackPoint)) { return false; } StormTrackPoint other 259 * = (StormTrackPoint) o; return 260 * ((trackPointId.equals(other.trackPointId))); } 261 */ 262 263 /** 264 * Set the Id property. 265 * 266 * @param value 267 * The new value for Id 268 */ 269 public void setId(int value) { 270 id = value; 271 } 272 273 /** 274 * Get the Id property. 275 * 276 * @return The Id 277 */ 278 public int getId() { 279 return id; 280 } 281 282 /** 283 * Set the Edited property. 284 * 285 * @param value 286 * The new value for Edited 287 */ 288 public void setEdited(boolean value) { 289 edited = value; 290 } 291 292 /** 293 * Get the Edited property. 294 * 295 * @return The Edited 296 */ 297 public boolean getEdited() { 298 return edited; 299 } 300 301 }