Revision 2669 branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/geo/GeoPoint.java
GeoPoint.java | ||
---|---|---|
1 | 1 |
/* |
2 | 2 |
* Cresques Mapping Suite. Graphic Library for constructing mapping applications. |
3 |
* |
|
4 |
* Copyright (C) 2004-5. |
|
5 | 3 |
* |
4 |
* Copyright (C) 2004-5. |
|
5 |
* |
|
6 | 6 |
* This program is free software; you can redistribute it and/or |
7 | 7 |
* modify it under the terms of the GNU General Public License |
8 | 8 |
* as published by the Free Software Foundation; either version 2 |
... | ... | |
18 | 18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
19 | 19 |
* |
20 | 20 |
* For more information, contact: |
21 |
*
|
|
21 |
* |
|
22 | 22 |
* cresques@gmail.com |
23 | 23 |
*/ |
24 |
|
|
25 | 24 |
package org.cresques.geo; |
26 | 25 |
|
27 |
import java.awt.geom.Point2D; |
|
26 |
import geojava.Mutil; |
|
27 |
import geojava.SexaAngle; |
|
28 | 28 |
|
29 | 29 |
import org.cresques.cts.ICoordTrans; |
30 | 30 |
import org.cresques.cts.IProjection; |
31 | 31 |
|
32 |
import geojava.SexaAngle; |
|
33 |
import geojava.Mutil; |
|
32 |
import java.awt.geom.Point2D; |
|
34 | 33 |
|
34 |
|
|
35 | 35 |
public class GeoPoint extends Point2D implements Projected { |
36 |
IProjection proj = null;
|
|
37 |
public static int decimales=4;
|
|
38 |
public SexaAngle Longitude;
|
|
39 |
public SexaAngle Latitude;
|
|
40 |
public double h;
|
|
36 |
public static int decimales = 4;
|
|
37 |
IProjection proj = null;
|
|
38 |
public SexaAngle Longitude;
|
|
39 |
public SexaAngle Latitude;
|
|
40 |
public double h;
|
|
41 | 41 |
|
42 |
public GeoPoint(SexaAngle sexaangle, SexaAngle sexaangle1, double d) {
|
|
43 |
Longitude = sexaangle;
|
|
44 |
Latitude = sexaangle1;
|
|
45 |
h = d;
|
|
46 |
}
|
|
42 |
public GeoPoint(SexaAngle sexaangle, SexaAngle sexaangle1, double d) {
|
|
43 |
Longitude = sexaangle;
|
|
44 |
Latitude = sexaangle1;
|
|
45 |
h = d;
|
|
46 |
}
|
|
47 | 47 |
|
48 |
public GeoPoint() |
|
49 |
{ |
|
50 |
Longitude = new SexaAngle(); |
|
51 |
Latitude = new SexaAngle(); |
|
52 |
h = 0.0D; |
|
53 |
} |
|
54 |
|
|
55 |
public GeoPoint(double x, double y) { |
|
56 |
setLocation(x, y); |
|
57 |
h = 0.0D; } |
|
58 |
|
|
59 |
public GeoPoint(Projection proj, double x, double y) { |
|
60 |
setLocation(x, y); |
|
61 |
h = 0.0D; ; |
|
62 |
this.proj = proj;} |
|
63 |
|
|
64 |
public GeoPoint(Point2D pt) { |
|
65 |
setLocation(pt.getX(), pt.getY()); |
|
66 |
h = 0.0D; } |
|
67 |
|
|
68 |
public GeoPoint(Projection proj, Point2D pt) { |
|
69 |
setLocation(pt.getX(), pt.getY()); |
|
70 |
h = 0.0D; ; |
|
71 |
this.proj = proj;} |
|
72 |
|
|
73 |
public IProjection getProjection() { return proj; } |
|
74 |
public void reProject(ICoordTrans rp) { |
|
75 |
// TODO metodo reProject pendiente de implementar |
|
76 |
} |
|
77 |
|
|
78 |
public double getX() { return Longitude.ToDecimal(); } |
|
79 |
public double getY() { return Latitude.ToDecimal(); } |
|
80 |
public void setLocation(double x, double y) { |
|
81 |
Longitude = SexaAngle.fromDecimal(x); |
|
82 |
Latitude = SexaAngle.fromDecimal(y); |
|
83 |
} |
|
84 |
public String toString() { |
|
85 |
String str = ""; |
|
86 |
String s = String.valueOf(Longitude.Deg); |
|
87 |
String s1 = String.valueOf(Longitude.Min); |
|
88 |
String s2 = String.valueOf(Mutil.double2String(Longitude.Sec, decimales)); |
|
89 |
SexaAngle sexaangle = new SexaAngle(s, s1, s2); |
|
90 |
sexaangle.Normalize(); |
|
91 |
str += String.valueOf(sexaangle.Deg)+"?"; |
|
92 |
str += String.valueOf(sexaangle.Min)+"'"; |
|
93 |
str += Mutil.double2String(sexaangle.Sec, decimales)+"\""; |
|
94 |
str += " "; |
|
95 |
s = String.valueOf(Latitude.Deg); |
|
96 |
s1 = String.valueOf(Latitude.Min); |
|
97 |
s2 = String.valueOf(Mutil.double2String(Latitude.Sec, decimales)); |
|
98 |
sexaangle = new SexaAngle(s, s1, s2); |
|
99 |
sexaangle.Normalize(); |
|
100 |
str += String.valueOf(sexaangle.Deg)+"?"; |
|
101 |
str += String.valueOf(sexaangle.Min)+"'"; |
|
102 |
str += Mutil.double2String(sexaangle.Sec, decimales)+"\""; |
|
103 |
return str; |
|
104 |
} |
|
105 |
} |
|
48 |
public GeoPoint() { |
|
49 |
Longitude = new SexaAngle(); |
|
50 |
Latitude = new SexaAngle(); |
|
51 |
h = 0.0D; |
|
52 |
} |
|
53 |
|
|
54 |
public GeoPoint(double x, double y) { |
|
55 |
setLocation(x, y); |
|
56 |
h = 0.0D; |
|
57 |
} |
|
58 |
|
|
59 |
public GeoPoint(Projection proj, double x, double y) { |
|
60 |
setLocation(x, y); |
|
61 |
h = 0.0D; |
|
62 |
; |
|
63 |
this.proj = proj; |
|
64 |
} |
|
65 |
|
|
66 |
public GeoPoint(Point2D pt) { |
|
67 |
setLocation(pt.getX(), pt.getY()); |
|
68 |
h = 0.0D; |
|
69 |
} |
|
70 |
|
|
71 |
public GeoPoint(Projection proj, Point2D pt) { |
|
72 |
setLocation(pt.getX(), pt.getY()); |
|
73 |
h = 0.0D; |
|
74 |
; |
|
75 |
this.proj = proj; |
|
76 |
} |
|
77 |
|
|
78 |
public IProjection getProjection() { |
|
79 |
return proj; |
|
80 |
} |
|
81 |
|
|
82 |
public void reProject(ICoordTrans rp) { |
|
83 |
// TODO metodo reProject pendiente de implementar |
|
84 |
} |
|
85 |
|
|
86 |
public double getX() { |
|
87 |
return Longitude.ToDecimal(); |
|
88 |
} |
|
89 |
|
|
90 |
public double getY() { |
|
91 |
return Latitude.ToDecimal(); |
|
92 |
} |
|
93 |
|
|
94 |
public void setLocation(double x, double y) { |
|
95 |
Longitude = SexaAngle.fromDecimal(x); |
|
96 |
Latitude = SexaAngle.fromDecimal(y); |
|
97 |
} |
|
98 |
|
|
99 |
public String toString() { |
|
100 |
String str = ""; |
|
101 |
String s = String.valueOf(Longitude.Deg); |
|
102 |
String s1 = String.valueOf(Longitude.Min); |
|
103 |
String s2 = String.valueOf(Mutil.double2String(Longitude.Sec, decimales)); |
|
104 |
SexaAngle sexaangle = new SexaAngle(s, s1, s2); |
|
105 |
sexaangle.Normalize(); |
|
106 |
str += (String.valueOf(sexaangle.Deg) + "?"); |
|
107 |
str += (String.valueOf(sexaangle.Min) + "'"); |
|
108 |
str += (Mutil.double2String(sexaangle.Sec, decimales) + "\""); |
|
109 |
str += " "; |
|
110 |
s = String.valueOf(Latitude.Deg); |
|
111 |
s1 = String.valueOf(Latitude.Min); |
|
112 |
s2 = String.valueOf(Mutil.double2String(Latitude.Sec, decimales)); |
|
113 |
sexaangle = new SexaAngle(s, s1, s2); |
|
114 |
sexaangle.Normalize(); |
|
115 |
str += (String.valueOf(sexaangle.Deg) + "?"); |
|
116 |
str += (String.valueOf(sexaangle.Min) + "'"); |
|
117 |
str += (Mutil.double2String(sexaangle.Sec, decimales) + "\""); |
|
118 |
|
|
119 |
return str; |
|
120 |
} |
|
121 |
} |
Also available in: Unified diff