1 package cz.cuni.amis.pogamut.usar2004.communication.messages.datatypes;
2
3
4
5
6
7
8
9
10
11
12 public class Latitude extends GeographicCoordinates
13 {
14 public Latitude()
15 {
16 }
17
18 public Latitude(int degree, double minute, char cardinal)
19 {
20 super(degree, minute, cardinal);
21 }
22
23
24
25
26
27
28
29
30 public static double DMCToMinutes(Latitude latitude)
31 {
32 double returnee = latitude.minute + latitude.degree * 60;
33 return (latitude.cardinal == 'S')?-returnee:returnee;
34 }
35
36
37
38
39
40
41
42
43 public static Latitude MinutesTODMC(double minutes)
44 {
45 double minute = Math.abs(minutes % 60);
46 int degree = Math.abs((int) minutes / 60);
47 char cardinal = (minutes < 0)?'S':'N';
48 return new Latitude(degree, minute, cardinal);
49 }
50
51
52
53
54
55
56
57
58 public static double DMCToDegree(Latitude latitude)
59 {
60 double returnee = latitude.minute / 60d + latitude.degree;
61 return (latitude.getCardinal() == 'S')?-returnee:returnee;
62 }
63
64
65
66
67
68
69
70
71 public static Latitude DegreeToDMC(double degree)
72 {
73 int deg = (int) Math.abs(degree);
74 double minute = (Math.abs(degree) - deg) * 60;
75 char cardinal = (degree < 0)?'S':'N';
76 return new Latitude(deg, minute, cardinal);
77 }
78 }