2 Copyright (C) 2001, 2006 United States Government
3 as represented by the Administrator of the
4 National Aeronautics and Space Administration.
7 package gov
.nasa
.worldwind
.formats
.gpx
;
9 import gov
.nasa
.worldwind
.*;
13 * @version $Id: GpxTrackPoint.java 515 2007-01-18 05:09:19Z ericdalgliesh $
15 public class GpxTrackPoint
extends gov
.nasa
.worldwind
.formats
.gpx
.ElementParser
implements gov
.nasa
.worldwind
.TrackPoint
17 private double latitude
;
18 private double longitude
;
19 private double elevation
;
27 * @throws IllegalArgumentException if attribues is null
29 @SuppressWarnings({"UnusedDeclaration"})
30 public GpxTrackPoint(String uri
, String lname
, String qname
, org
.xml
.sax
.Attributes attributes
)
34 //don't validate uri, lname or qname - they aren't used.
36 if (attributes
== null)
38 String msg
= WorldWind
.retrieveErrMsg("nullValue.org.xml.sax.AttributesIsNull");
39 WorldWind
.logger().log(java
.util
.logging
.Level
.FINE
, msg
);
40 throw new IllegalArgumentException(msg
);
43 for (int i
= 0; i
< attributes
.getLength(); i
++)
45 String attrName
= attributes
.getLocalName(i
);
46 String attrValue
= attributes
.getValue(i
);
47 if (attrName
.equalsIgnoreCase("lat"))
49 this.latitude
= Double
.parseDouble(attrValue
);
51 else if (attrName
.equalsIgnoreCase("lon"))
53 this.longitude
= Double
.parseDouble(attrValue
);
59 public void doStartElement(String uri
, String lname
, String qname
, org
.xml
.sax
.Attributes attributes
)
60 throws org
.xml
.sax
.SAXException
62 //don't perform validation here - no parameters are actually used
69 * @throws IllegalArgumentException if <code>lname</code> is null
70 * @throws org.xml.sax.SAXException
73 public void doEndElement(String uri
, String lname
, String qname
) throws org
.xml
.sax
.SAXException
77 String msg
= WorldWind
.retrieveErrMsg("nullValue.LNameIsNull");
78 WorldWind
.logger().log(java
.util
.logging
.Level
.FINE
, msg
);
79 throw new IllegalArgumentException(msg
);
81 // don't validate uri or qname - they aren't used.
83 if (lname
.equalsIgnoreCase("ele"))
85 this.elevation
= Double
.parseDouble(this.currentCharacters
);
87 else if (lname
.equalsIgnoreCase("time"))
89 this.time
= this.currentCharacters
.trim();
93 public double getLatitude()
100 * @throws IllegalArgumentException if <code>latitude</code> is less than -90 or greater than 90
102 public void setLatitude(double latitude
)
104 if (latitude
> 90 || latitude
< -90)
106 String msg
= WorldWind
.retrieveErrMsg("generic.angleOutOfRange") + WorldWind
.retrieveErrMsg(
107 "punctuation.space") + latitude
;
108 WorldWind
.logger().log(java
.util
.logging
.Level
.FINE
, msg
);
109 throw new IllegalArgumentException(msg
);
112 this.latitude
= latitude
;
115 public double getLongitude()
122 * @throws IllegalArgumentException if <code>longitude</code> is less than -180 or greater than 180
124 public void setLongitude(double longitude
)
126 if (longitude
> 180 || longitude
< -180)
128 String msg
= WorldWind
.retrieveErrMsg("generic.angleOutOfRange") + WorldWind
.retrieveErrMsg(
129 "punctuation.space") + longitude
;
130 WorldWind
.logger().log(java
.util
.logging
.Level
.FINE
, msg
);
131 throw new IllegalArgumentException(msg
);
134 this.longitude
= longitude
;
137 public double getElevation()
142 public void setElevation(double elevation
)
144 this.elevation
= elevation
;
147 public String
getTime()
154 * @throws IllegalArgumentException if <code>time</code> is null
156 public void setTime(String time
)
160 String msg
= WorldWind
.retrieveErrMsg("nullValue.TimeIsNull");
161 WorldWind
.logger().log(java
.util
.logging
.Level
.FINE
, msg
);
162 throw new IllegalArgumentException(msg
);
168 public String
toString()
170 return String
.format("(%10.6f\u00B0, %11.6f\u00B0, %10.4g m, %s)", this.latitude
, this.longitude
,
171 this.elevation
, this.time
);