Statistics
| Revision:

root / trunk / libraries / libCq_CMS_praster / src / org / cresques / geo / GeoPoint.java @ 8026

History | View | Annotate | Download (3.43 KB)

1
/*
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 org.cresques.cts.ICoordTrans;
30
import org.cresques.cts.IProjection;
31

    
32
import java.awt.geom.Point2D;
33

    
34

    
35
public class GeoPoint extends Point2D implements Projected {
36
    public static int decimales = 4;
37
    IProjection proj = null;
38
    public SexaAngle Longitude;
39
    public SexaAngle Latitude;
40
    public double h;
41

    
42
    public GeoPoint(SexaAngle sexaangle, SexaAngle sexaangle1, double d) {
43
        Longitude = sexaangle;
44
        Latitude = sexaangle1;
45
        h = d;
46
    }
47

    
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
}