View Javadoc

1   package geo.google.datamodel;
2   
3   import java.io.Serializable;
4   
5   import org.apache.commons.lang.builder.EqualsBuilder;
6   import org.apache.commons.lang.builder.HashCodeBuilder;
7   import org.apache.commons.lang.builder.ToStringBuilder;
8   
9   /***
10   * Altitude class.
11   * @author jliang
12   *
13   */
14  public class GeoAltitude implements Serializable, Cloneable{
15    private static final long serialVersionUID = 1646700721957062689L;
16    private double _altitude = 0;
17    private GeoAltitudeMode _mode = GeoAltitudeMode.CLAMP_TO_GROUND;
18    public GeoAltitude() {}
19    public GeoAltitude(double altitude){
20      _altitude = altitude;
21    }
22    public GeoAltitude(double altitude, GeoAltitudeMode mode) {
23      this(altitude);
24      _mode = mode;
25    }
26  
27    /***
28     * Meters above sea level.
29     * @return
30     */
31    public double getAltitude() {
32      return _altitude;
33    }
34  
35    public void setAltitude(double altitude) {
36      _altitude = altitude;
37    }
38    /***
39     * Specifies how altitude components in the <coordinates> element are interpreted. Possible values are
40     * clampToGround - (default) Indicates to ignore an altitude specification (for example, in the <coordinates> tag).
41     * relativeToGround - Sets the altitude of the element relative to the actual ground elevation of a particular location. For example, if the ground elevation of a location is exactly at sea level and the altitude for a point is set to 9 meters, then the elevation for the icon of a point placemark elevation is 9 meters with this mode. However, if the same coordinate is set over a location where the ground elevation is 10 meters above sea level, then the elevation of the coordinate is 19 meters. A typical use of this mode is for placing telephone poles or a ski lift.
42     * absolute - Sets the altitude of the coordinate relative to sea level, regardless of the actual elevation of the terrain beneath the element. For example, if you set the altitude of a coordinate to 10 meters with an absolute altitude mode, the icon of a point placemark will appear to be at ground level if the terrain beneath is also 10 meters above sea level. If the terrain is 3 meters above sea level, the placemark will appear elevated above the terrain by 7 meters. A typical use of this mode is for aircraft placement.
43     * {@link GeoAltitude.GeoAltitudeMode}
44     * @return
45     */
46    public GeoAltitudeMode getMode() {
47      return _mode;
48    }
49  
50    public void setMode(GeoAltitudeMode mode) {
51      _mode = mode;
52    }
53    public enum GeoAltitudeMode{
54      //default
55      CLAMP_TO_GROUND("(default) Indicates to ignore an altitude specification"),
56      RELATIVE_TO_GROUND("Sets the altitude of the element relative to the actual ground elevation of a particular location. For example, if the ground elevation of a location is exactly at sea level and the altitude for a point is set to 9 meters, then the elevation for the icon of a point placemark elevation is 9 meters with this mode. However, if the same coordinate is set over a location where the ground elevation is 10 meters above sea level, then the elevation of the coordinate is 19 meters. A typical use of this mode is for placing telephone poles or a ski lift."),
57      ABSOLUTE("Sets the altitude of the coordinate relative to sea level, regardless of the actual elevation of the terrain beneath the element. For example, if you set the altitude of a coordinate to 10 meters with an absolute altitude mode, the icon of a point placemark will appear to be at ground level if the terrain beneath is also 10 meters above sea level. If the terrain is 3 meters above sea level, the placemark will appear elevated above the terrain by 7 meters. A typical use of this mode is for aircraft placement.");
58      private String _description;
59      private GeoAltitudeMode(String desc){
60        _description = desc;
61      }
62      public String getName(){
63        return CLAMP_TO_GROUND.name();
64      }
65      public String getDescription(String description) {
66        return _description;
67      }
68      
69    }
70    @Override
71    public GeoAltitude clone(){
72     return new GeoAltitude(_altitude, _mode);
73    }
74    
75    @Override
76    public boolean equals(Object o) {
77      return EqualsBuilder.reflectionEquals(this, o);
78    }
79    
80    @Override
81    public int hashCode() {
82      return HashCodeBuilder.reflectionHashCode(this);
83    }
84    
85    @Override
86    public String toString() {
87      return ToStringBuilder.reflectionToString(this);
88    }
89  }