Statistics
| Revision:

root / org.gvsig.proj / branches / refactor2018 / org.gvsig.proj / org.gvsig.proj.lib / org.gvsig.proj.lib.api / src / main / java / org / gvsig / proj / CoordinateReferenceSystem.java @ 827

History | View | Annotate | Download (6.23 KB)

1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2012 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.proj;
24

    
25
import javax.measure.Unit;
26
import javax.measure.quantity.Length;
27

    
28
import org.cresques.cts.IProjection;
29
import org.gvsig.proj.catalog.CRSDefinition;
30
import org.gvsig.proj.catalog.CRSType;
31
import org.gvsig.proj.catalog.TransformationDefinition;
32
import org.gvsig.proj.catalog.exception.CoordinateReferenceSystemException;
33
import org.gvsig.proj.catalog.exception.TransformationException;
34
import org.gvsig.proj.catalog.exception.UnsupportedCoordinateReferenceSystemException;
35
import org.gvsig.tools.lang.Cloneable;
36

    
37
/**
38
 * Coordinate Reference System (CRS). A CRS defines how a set of coordinates relate
39
 * to real positions (on earth, on other planet or in the space). Some CRSs include
40
 * a projection, which defines a mathematical model to approximate the surface of an
41
 * area of the earth using a planar surface.
42
 * 
43
 * Note that a set of coordinates is meaningless if their CRS is not defined, as these
44
 * values can refer to different locations on the Earth depending on the CRS being used.
45
 * 
46
 * @see http://en.wikipedia.org/wiki/Coordinate_reference_system
47
 * @see http://en.wikipedia.org/wiki/Map_projection
48
 * @author gvSIG Team
49
 */
50
public interface CoordinateReferenceSystem extends Cloneable {    
51
    /**
52
     * Gets the definition of the coordinate reference system. The CRSDefinition
53
     * fully defines the CRS
54
     * 
55
     * @return
56
     */
57
    CRSDefinition getDefinition();
58
    
59
    /**
60
     * Some CRSs include a projection, which defines a mathematical model to approximate
61
     * the surface of an area of the earth using a planar surface. CRS including a
62
     * projection are called projected CRSs
63
     * 
64
     * @return true if the CRS is projected, false otherwise. It also returns true
65
     * for derived CRSs whose {@link #getBaseCRS() base CRS} is a projected CRS
66
     */
67
    boolean isProjected();
68
    
69
    /**
70
     * Returns true if the CRS is geographic. It also returns true for derived CRSs
71
     * whose {@link #getBaseCRS() base CRS} is a geographic CRS. 
72
     * 
73
     * @return
74
     */
75
    boolean isGeographic();
76
    
77
    /**
78
     * If this CRS is a projected CRS (or a derived CRS whose base CRS is a projected
79
     * CRS), it converts coordinates from this CoordinateReferenceSystem to the
80
     * base Geographic CRS. If the CRS is a geographic CRS, it returns the same
81
     * coordinates without further transformation.
82
     * 
83
     * @param point
84
     * @return
85
     * @throws TransformationException if {@link #isProjected()} and 
86
     * {@link #isGeographic()} are both false
87
     */
88
    double[] toGeo(double[] point) throws TransformationException;
89

    
90
    
91
    /**
92
     * Calculates the distance between 2 points on the surface of the Earth.
93
     * 
94
     * The distances are calculated based on the characteristics of CRSDefinition,
95
     * using geodetic distances when possible. Geodetic distances offer highly
96
     * accurate measurements and are based on the exact shape of the ellipsoid.
97
     * 
98
     * If this CRSDefinition is projected, then the geodetic calculations are done
99
     * using its base (geographic) CRS. If this CRSDefinition is not geodetic nor
100
     * projected, then Euclidean distances are calculated.
101
     * 
102
     * The provided points are considered to be 2D points
103
     * (additional dimensions are ignored).
104
     * 
105
     * @param point1
106
     * @param point2
107
     * @param the unit in which the distance should be measure
108
     * 
109
     * @return The distance between point1 and point2 measured in the units
110
     * provided by the unit parameter.
111
     * @throws CoordinateReferenceSystemException if an error is produced calculating the distance
112
     */
113
    double getDistance(double[] point1, double[] point2, Unit<Length> unit) throws CoordinateReferenceSystemException;
114

    
115
    /**
116
     * Calculates the distance between 2 points on the surface of the Earth.
117
     *  
118
     * If this CRS is projected and useBaseCRS is <code>false</code>, then
119
     * the Euclidean distance is calculated. If the CRS is projected and
120
     * <code>useBaseCRS</code> is <code>true<code>, then the
121
     * geodetic distance is calculated, using its base (geographic) CRS.
122
     * 
123
     * If the CRS is geodetic, then the geodetic distance is calculated.
124
     * If the CRS is not projected nor geometric, then the Euclidean distance
125
     * is calculated.
126
     * 
127
     * Geodetic distances offer highly accurate measurements and are based on
128
     * the exact shape of the ellipsoid.
129
     * 
130
     * The provided points are considered to be 2D points
131
     * (additional dimensions are ignored).
132
     * 
133
     * @param point1
134
     * @param point2
135
     * @param the unit in which the distance should be measure
136
     * 
137
     * @return The distance between point1 and point2 measured in the units
138
     * provided by the unit parameter.
139
     * @throws CoordinateReferenceSystemException if an error is produced calculating the distance
140
     */
141
    double getDistance(double[] point1, double[] point2, boolean useBaseCRS, Unit<Length> unit) throws CoordinateReferenceSystemException;
142
    
143
    /**
144
     * Returns a legacy IProjection object, the interface used in older gvSIG
145
     * versions to represent CoordinateReferenceSystems. This method will be
146
     * removed in the future, so migrate your code to {@link CoordinateReferenceSystem}
147
     * and the new API as soon as possible.
148
     * 
149
     * @return
150
     */
151
    @Deprecated
152
    IProjection getIProjection();
153
}