]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/data/Longitude.java
Version 4, January 2008
[GpsPrune.git] / tim / prune / data / Longitude.java
1 package tim.prune.data;
2
3 /**
4  * Class to represent a Longitude Coordinate
5  */
6 public class Longitude extends Coordinate
7 {
8         /**
9          * Constructor
10          * @param inString string value from file
11          */
12         public Longitude(String inString)
13         {
14                 super(inString);
15         }
16
17
18         /**
19          * Constructor
20          * @param inValue value of coordinate
21          * @param inFormat format to use
22          */
23         public Longitude(double inValue, int inFormat)
24         {
25                 super(inValue, inFormat, inValue < 0.0 ? WEST : EAST);
26         }
27
28
29         /**
30          * Turn the given character into a cardinal
31          * @see tim.prune.data.Coordinate#getCardinal(char)
32          */
33         protected int getCardinal(char inChar)
34         {
35                 // Longitude recognises E, W and -
36                 // default is no cardinal
37                 int cardinal = NO_CARDINAL;
38                 switch (inChar)
39                 {
40                         case 'E':
41                         case 'e':
42                                 cardinal = EAST; break;
43                         case 'W':
44                         case 'w':
45                         case '-':
46                                 cardinal = WEST; break;
47                         default:
48                                 // no character given
49                 }
50                 return cardinal;
51         }
52
53
54         /**
55          * @return default cardinal (East)
56          * @see tim.prune.data.Coordinate#getDefaultCardinal()
57          */
58         protected int getDefaultCardinal()
59         {
60                 return EAST;
61         }
62
63
64         /**
65          * Make a new Longitude object
66          * @see tim.prune.data.Coordinate#makeNew(double, int)
67          */
68         protected Coordinate makeNew(double inValue, int inFormat)
69         {
70                 return new Longitude(inValue, inFormat);
71         }
72
73         /**
74          * @return the maximum degree range for this coordinate
75          */
76         protected int getMaxDegrees()
77         {
78                 return 180;
79         }
80 }