Statistics
| Revision:

root / org.gvsig.proj / branches / refactor2018 / org.gvsig.proj / org.gvsig.proj.catalog / org.gvsig.proj.catalog.api / src / main / java / org / gvsig / proj / catalog / CRSDefinition.java @ 838

History | View | Annotate | Download (11.3 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2018 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 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., 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.gvsig.proj.catalog;
25

    
26
import java.util.List;
27
import java.util.Set;
28

    
29
import javax.measure.Unit;
30
import javax.measure.quantity.Length;
31

    
32
import org.gvsig.proj.catalog.datum.Datum;
33
import org.gvsig.proj.catalog.exception.CoordinateReferenceSystemException;
34
import org.gvsig.proj.catalog.exception.UnsupportedCoordinateReferenceSystemException;
35
import org.gvsig.proj.catalog.ref.Extent;
36

    
37
/**
38
 * Definition of a Coordinate Reference System (CRS).
39
 * 
40
 * A CRS defines how a set of coordinates relate to real positions (on earth, on other
41
 * planet or in the space). A CRS defines the number of coordinate axis, its name, order and
42
 * direction, its units, the mathematical model used to define the geometric figure (ellipsoid)
43
 * to approximate the shape of the earth, the relationship of this mathematical model with the
44
 * earth (datum), among other concepts and parameters. Some CRSs include a projection, which
45
 * defines a mathematical model to approximate the surface of an area of the earth using a
46
 * planar surface.
47
 * 
48
 * Note that a set of coordinates is meaningless if their CRS is not defined, as these
49
 * values can refer to different locations on the Earth depending on the CRS being used.
50
 * 
51
 * @author  gvSIG Team
52
 * @author  Cesar Martinez Izquierdo
53
 */
54
public interface CRSDefinition {
55
    
56
    /**
57
     * A common name for this coordinate reference system
58
     * 
59
     * @return The human-readable name of the CRS. This method should never return null
60
     */
61
        String getName();
62
    
63
    /**
64
     * Gets a code that references an unambiguous definition of the coordinate reference
65
     * system for some authority. Examples: "EPSG:4326", "EPSG:25830".
66
     * 
67
     * Note that identifiers in the "USER:" namespace are an special case, as their
68
     * definition will be different for each user, so they don't reference an
69
     * unambiguous definition.
70
     * 
71
     * @return the identifier which was used to instantiate the object, or the
72
     * identifier that more closely matches the information used to instantiate
73
     * the object (e.g. if derived from an WKT definition), or <code>null</code> if an identifier is
74
     * not available
75
     */
76
    String getIdentifier();
77
        
78
    /**
79
     * Gets the list of identifiers which describe this coordinate reference system
80
     * definition.
81
     *
82
     * @return the list of object identifiers, or an empty collection if there is none.
83
     */
84
    Set<String> getIdentifiers();
85
    
86
    /**
87
     * Gets the authority which defines this coordinate references system
88
     * (e.g. "EPSG", "ESRI", "USER"...).
89
     * 
90
     * If the CRS is defined by several
91
     * authorities, it returns the authority which was used to instantiate
92
     * the object, or the authority that more closely matches the information
93
     * used to instantiate the object (e.g. if derived from an WKT definition)
94
     * 
95
     * @return The authority name, or {@code null} if not available.
96
     */
97
    String getAuthorityName();
98
        
99
    /**
100
     * FIXME: GeoAPI
101
     * Area or region or timeframe in which this (coordinate) reference system is valid.
102
     *
103
     * @return the reference system valid domain, or {@code null} if not available.
104
     * @since 2.1
105
     */
106
        Extent getDomainOfValidity();
107

    
108
    /**
109
     * Textual description of the coordinate reference system, including remarks
110
     * and its scope. 
111
     *
112
     * @return the description, or {@code null} if none.
113
     */
114
    String getDescription();
115
    
116
    /**
117
     * Gets the type of coordinate reference system
118
     * 
119
     * @return
120
     */
121
    CRSType getType();
122
    
123
    /**
124
     * Returns a <cite>Well-Known Text</cite> (WKT) definition for this object.
125
     * Note that there are different versions of the WKT specification
126
     * (the older WKT defined by OGC 01-009 and the newer one, defined by OGC 12-063r5
127
     * and ISO 19162). Also note that ESRI uses different names to refer to CRSs, datums,
128
     * ellipsoids, etc. compared to OGC, so OGC and ESRI WKTs can be considered as different
129
     * dialects. Use 
130
     * {@link #toString(org.gvsig.proj.catalog.TextSerialization.WKTConvention, int)}
131
     * if a particular format and/or convention is required.
132
     * 
133
     * Whenever possible, this method will return a WKT following the same specification and
134
     * dialect that the one used to instantiate this CRSDefinition. If the original
135
     * specification or dialect are unknown, implementations are encouraged to format according
136
     * to the most recent standard and following OGC dialect.
137
     *
138
     * @return the Well-Known Text (WKT) definition for this object.
139
     * @throws UnsupportedOperationException if this object can not be formatted as WKT.
140
     * @see #toString(org.gvsig.proj.catalog.TextSerialization.WKTConvention, int)
141
     */
142
        String toWKT() throws UnsupportedOperationException;
143
        
144
    /**
145
     * Returns a text serialization of this definition (such as a WKT string), using the
146
     * specified {@link TextSerialization.Format} and trying to convert names to the
147
     * specified {@link TextSerialization.WKTConvention}.
148
     *
149
     * @param format The {@link TextSerialization.Format} used to serialize this definition.
150
     * This method must fail if the requested format is not supported by a particular
151
     * implementation
152
     * 
153
     * @return A serialized version of this definition.
154
     * @throws UnsupportedOperationException if the requested format is not supported
155
     * or if this is object can not be formatted using that format.
156
     * @see #toString(org.gvsig.proj.catalog.TextSerialization.WKTConvention, int)
157
     */
158
        String toString(TextSerialization.Format format) throws UnsupportedOperationException;
159
        
160
    /**
161
     * Returns a text serialization of this definition (such as a WKT string), using the
162
     * specified {@link TextSerialization.Format} and trying to convert names to the
163
     * specified {@link TextSerialization.WKTConvention}.
164
     *
165
     * @param format The {@link TextSerialization.Format} used to serialize this definition.
166
     * This method must fail if the requested format is not supported by a particular
167
     * implementation
168
     * @param convention The preferred {@link TextSerialization.WKTConvention} used to
169
     * encode projection names, datum names, units, etc. This is only a hint, 
170
     * implementations can ignore this hint if they are not able to convert this object
171
     * to the requested convention.
172
     * @param indentation  The amount of spaces to use in indentation. Use 0 to produce
173
     * a single line serialization.
174
     * 
175
     * @return A serialized version of this definition.
176
     * @throws UnsupportedOperationException if the requested format is not supported
177
     * or if this is object can not be formatted using that format.
178
     * @see #toString(org.gvsig.proj.catalog.TextSerialization.WKTConvention)
179
     */
180
        String toString(TextSerialization.Format format, TextSerialization.WKTConvention convention, int indentation) throws UnsupportedOperationException;
181
        
182
        /**
183
         * If the CRS type is {@link CRSType#CompoundCRSType}, this method returns the ordered
184
         * list of coordinate reference systems which are its components.
185
         *
186
         * @return the ordered list of coordinate reference systems, or <code>null if the CRS
187
         * is not compound
188
         * @throws UnsupportedCoordinateReferenceSystemException 
189
         * @see #getType()
190
         * @see CRSType#CompoundCRSType
191
         */
192
        List<CRSDefinition> getComponents() throws UnsupportedCoordinateReferenceSystemException;
193
        
194
        /**
195
         * Gets the number of axis of the associated CoordinateSystem
196
         * 
197
         * @return
198
         */
199
        int getAxisCount();
200
        
201
        /**
202
         * Returns the axis for the associated coordinate system at the specified dimension,
203
         * as officially defined by the authority. 
204
         * 
205
         * @param dimension
206
         * @return
207
         * @throws IndexOutOfBoundsException
208
         */
209
        CoordinateSystemAxis getAxis(int dimension) throws IndexOutOfBoundsException;
210
        
211
        /**
212
         * Returns the axis for the associated coordinate system at the specified
213
         * dimension as internally used by gvSIG, which will sometimes differ from
214
         * the order officially defined by the authority.
215
         * 
216
         * The internal order is used for convenience and performance. gvSIG geometries
217
         * and gvSIG coordinate transformations always expect coordinates to be provided
218
         * using the internal order (xy axis order). However, some
219
         * protocols or formats require the coordinates to be encoded using the
220
         * official order. 
221
         * 
222
         * @param dimension
223
         * @return
224
         * @throws IndexOutOfBoundsException
225
         */
226
        CoordinateSystemAxis getAxisInternal(int dimension) throws IndexOutOfBoundsException;
227
        
228
    /**
229
     * Returns the datum associated directly or indirectly to this CRS.
230
     * In the case of a derived CRS, this method returns the
231
     * datum of the {@linkplain #getBaseCRS() base CRS}. In the case of
232
     * a compound CRS, it returns the datum associated to the horizontal component.
233
     *
234
     * @return the datum
235
     */
236
    Datum getDatum();
237
    
238
    /**
239
     * Indicates whether some other CRSDefinition is "equal to" this one.
240
     * 
241
     * Definitions are considered equal if they represent the same CRS (same type,
242
     * same datum, same ellipsoid parameters, etc), despite some differences in
243
     * naming (CRS name, datum aliases, missing/different authority code...).
244
     * 
245
     * @param ignoreAxis Ignores the names and order of the axis in the comparison
246
     * @param ignoreMetadata Ignores metadata (including unit names) in the comparison
247
     * 
248
     * @return
249
     */
250
    boolean equals(CRSDefinition definition, boolean ignoreAxis, boolean ignoreMetadata);
251
    
252

    
253
    /**
254
     * For derived CRSs (such as projected CRSs), it returns the base coordinate
255
     * reference system.
256
     *
257
     * @return the base coordinate reference system or null if the CRS is not
258
     * derived
259
     * @throws UnsupportedCoordinateReferenceSystemException 
260
     * @see CRSType#isDerived()
261
     * @see CRSType#ProjectedCRSType
262
     * @see CRSType#OtherDerivedCRSType
263
     */
264
        CRSDefinition getBaseCRS() throws UnsupportedCoordinateReferenceSystemException;
265

    
266
    /**
267
     * For derived CRSs (such as projected CRSs), it returns the conversion from the
268
     * {@linkplain #getBaseCRS() base CRS} to this CRS.
269
     *
270
     * @return the conversion from the base CRS or null if the CRS is not derived
271
     * @throws CoordinateReferenceSystemException 
272
     *
273
     * @see CRSType#isDerived()
274
     * @see CRSType#ProjectedCRSType
275
     * @see CRSType#OtherDerivedCRSType
276
     */
277
        TransformationDefinition getConversionFromBase() throws CoordinateReferenceSystemException;
278
}