svn-gvsig-desktop / branches / Mobile_Compatible_Hito_1 / libDXF / src / org / cresques / geo / GeoPoint.java @ 21930
History | View | Annotate | Download (3.6 KB)
1 | 21930 | csanchez | /*
|
---|---|---|---|
2 | * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
|
||
3 | *
|
||
4 | * Copyright (C) 2004-5.
|
||
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 2
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
19 | *
|
||
20 | * For more information, contact:
|
||
21 | *
|
||
22 | * cresques@gmail.com
|
||
23 | */
|
||
24 | package org.cresques.geo; |
||
25 | |||
26 | import geojava.Mutil; |
||
27 | import geojava.SexaAngle; |
||
28 | |||
29 | import java.awt.geom.Point2D; |
||
30 | |||
31 | import org.gvsig.projection.cts.ICoordTrans; |
||
32 | import org.gvsig.projection.cts.IProjection; |
||
33 | import org.gvsig.projection.geo.Projected; |
||
34 | |||
35 | |||
36 | public class GeoPoint extends Point2D implements Projected { |
||
37 | public static int decimales = 4; |
||
38 | IProjection proj = null;
|
||
39 | public SexaAngle Longitude;
|
||
40 | public SexaAngle Latitude;
|
||
41 | public double h; |
||
42 | |||
43 | public GeoPoint(SexaAngle sexaangle, SexaAngle sexaangle1, double d) { |
||
44 | Longitude = sexaangle; |
||
45 | Latitude = sexaangle1; |
||
46 | h = d; |
||
47 | } |
||
48 | |||
49 | public GeoPoint() {
|
||
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 | |||
60 | public GeoPoint(Projection proj, double x, double y) { |
||
61 | setLocation(x, y); |
||
62 | h = 0.0D;
|
||
63 | ; |
||
64 | this.proj = proj;
|
||
65 | } |
||
66 | |||
67 | public GeoPoint(Point2D pt) { |
||
68 | setLocation(pt.getX(), pt.getY()); |
||
69 | h = 0.0D;
|
||
70 | } |
||
71 | |||
72 | public GeoPoint(Projection proj, Point2D pt) { |
||
73 | setLocation(pt.getX(), pt.getY()); |
||
74 | h = 0.0D;
|
||
75 | ; |
||
76 | this.proj = proj;
|
||
77 | } |
||
78 | |||
79 | public IProjection getProjection() {
|
||
80 | return proj;
|
||
81 | } |
||
82 | |||
83 | public void reProject(ICoordTrans rp) { |
||
84 | // TODO metodo reProject pendiente de implementar
|
||
85 | } |
||
86 | |||
87 | public double getX() { |
||
88 | return Longitude.ToDecimal();
|
||
89 | } |
||
90 | |||
91 | public double getY() { |
||
92 | return Latitude.ToDecimal();
|
||
93 | } |
||
94 | |||
95 | public void setLocation(double x, double y) { |
||
96 | Longitude = SexaAngle.fromDecimal(x); |
||
97 | Latitude = SexaAngle.fromDecimal(y); |
||
98 | } |
||
99 | |||
100 | public String toString() { |
||
101 | String str = ""; |
||
102 | String s = String.valueOf(Longitude.Deg); |
||
103 | String s1 = String.valueOf(Longitude.Min); |
||
104 | String s2 = String.valueOf(Mutil.double2String(Longitude.Sec, decimales)); |
||
105 | SexaAngle sexaangle = new SexaAngle(s, s1, s2);
|
||
106 | sexaangle.Normalize(); |
||
107 | str += (String.valueOf(sexaangle.Deg) + "?"); |
||
108 | str += (String.valueOf(sexaangle.Min) + "'"); |
||
109 | str += (Mutil.double2String(sexaangle.Sec, decimales) + "\"");
|
||
110 | str += " ";
|
||
111 | s = String.valueOf(Latitude.Deg);
|
||
112 | s1 = String.valueOf(Latitude.Min);
|
||
113 | s2 = String.valueOf(Mutil.double2String(Latitude.Sec, decimales));
|
||
114 | sexaangle = new SexaAngle(s, s1, s2);
|
||
115 | sexaangle.Normalize(); |
||
116 | str += (String.valueOf(sexaangle.Deg) + "?"); |
||
117 | str += (String.valueOf(sexaangle.Min) + "'"); |
||
118 | str += (Mutil.double2String(sexaangle.Sec, decimales) + "\"");
|
||
119 | |||
120 | return str;
|
||
121 | } |
||
122 | } |