Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.projection / org.gvsig.projection.cresques / org.gvsig.projection.cresques.impl / src / main / java / org / cresques / impl / geo / GeoPoint.java @ 40559

History | View | Annotate | Download (3.53 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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 3
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., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.cresques.impl.geo;
25

    
26
import geojava.Mutil;
27
import geojava.SexaAngle;
28

    
29
import org.cresques.cts.ICoordTrans;
30
import org.cresques.cts.IProjection;
31
import org.cresques.geo.Projected;
32

    
33
import java.awt.geom.Point2D;
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
}