svn-gvsig-desktop / trunk / libraries / libCq CMS for java.old / src / org / cresques / geo / GeoPoint.java @ 2
History | View | Annotate | Download (2.1 KB)
1 |
package org.cresques.geo; |
---|---|
2 |
|
3 |
import java.awt.geom.Point2D; |
4 |
import geojava.SexaAngle; |
5 |
import geojava.Mutil; |
6 |
|
7 |
public class GeoPoint extends Point2D implements Projected { |
8 |
Projection proj = null;
|
9 |
public static int decimales=4; |
10 |
public SexaAngle Longitude;
|
11 |
public SexaAngle Latitude;
|
12 |
public double h; |
13 |
|
14 |
public GeoPoint(SexaAngle sexaangle, SexaAngle sexaangle1, double d) { |
15 |
Longitude = sexaangle; |
16 |
Latitude = sexaangle1; |
17 |
h = d; |
18 |
} |
19 |
|
20 |
public GeoPoint()
|
21 |
{ |
22 |
Longitude = new SexaAngle();
|
23 |
Latitude = new SexaAngle();
|
24 |
h = 0.0D;
|
25 |
} |
26 |
|
27 |
public GeoPoint(double x, double y) { |
28 |
setLocation(x, y); |
29 |
h = 0.0D; }
|
30 |
|
31 |
public GeoPoint(Projection proj, double x, double y) { |
32 |
setLocation(x, y); |
33 |
h = 0.0D; ;
|
34 |
this.proj = proj;}
|
35 |
|
36 |
public GeoPoint(Point2D pt) { |
37 |
setLocation(pt.getX(), pt.getY()); |
38 |
h = 0.0D; }
|
39 |
|
40 |
public GeoPoint(Projection proj, Point2D pt) { |
41 |
setLocation(pt.getX(), pt.getY()); |
42 |
h = 0.0D; ;
|
43 |
this.proj = proj;}
|
44 |
|
45 |
public Projection getProjection() { return proj; } |
46 |
public void reProject(ReProjection rp) { |
47 |
// TODO metodo reProject pendiente de implementar
|
48 |
} |
49 |
|
50 |
public double getX() { return Longitude.ToDecimal(); } |
51 |
public double getY() { return Latitude.ToDecimal(); } |
52 |
public void setLocation(double x, double y) { |
53 |
Longitude = SexaAngle.fromDecimal(x); |
54 |
Latitude = SexaAngle.fromDecimal(y); |
55 |
} |
56 |
public String toString() { |
57 |
String str = ""; |
58 |
String s = String.valueOf(Longitude.Deg); |
59 |
String s1 = String.valueOf(Longitude.Min); |
60 |
String s2 = String.valueOf(Mutil.double2String(Longitude.Sec, decimales)); |
61 |
SexaAngle sexaangle = new SexaAngle(s, s1, s2);
|
62 |
sexaangle.Normalize(); |
63 |
str += String.valueOf(sexaangle.Deg)+"?"; |
64 |
str += String.valueOf(sexaangle.Min)+"'"; |
65 |
str += Mutil.double2String(sexaangle.Sec, decimales)+"\"";
|
66 |
str += " ";
|
67 |
s = String.valueOf(Latitude.Deg);
|
68 |
s1 = String.valueOf(Latitude.Min);
|
69 |
s2 = String.valueOf(Mutil.double2String(Latitude.Sec, decimales));
|
70 |
sexaangle = new SexaAngle(s, s1, s2);
|
71 |
sexaangle.Normalize(); |
72 |
str += String.valueOf(sexaangle.Deg)+"?"; |
73 |
str += String.valueOf(sexaangle.Min)+"'"; |
74 |
str += Mutil.double2String(sexaangle.Sec, decimales)+"\"";
|
75 |
return str;
|
76 |
} |
77 |
} |