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 / CRSCatalogManager.java @ 829
History | View | Annotate | Download (16.2 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2012 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.io.File; |
27 |
import java.text.ParseException; |
28 |
import java.util.List; |
29 |
|
30 |
import org.gvsig.proj.catalog.exception.CoordinateReferenceSystemException; |
31 |
import org.gvsig.proj.catalog.exception.UnsupportedCoordinateReferenceSystemException; |
32 |
import org.gvsig.proj.catalog.exception.UnsupportedFormatException; |
33 |
import org.gvsig.proj.catalog.exception.UnsupportedTransformationException; |
34 |
|
35 |
/**
|
36 |
* This class is responsible of the management of the CRSCatalog
|
37 |
* library's business logic.
|
38 |
*
|
39 |
* It is the library's main entry point, and provides all the services to manage
|
40 |
* {@link CRSDefinition}s and {@link TransformationDefinition}s.
|
41 |
*
|
42 |
* @author gvSIG team
|
43 |
* @author Cesar Martinez Izquierdo
|
44 |
*/
|
45 |
public interface CRSCatalogManager { |
46 |
|
47 |
/**
|
48 |
* Returns a List of String values with the available authority names.
|
49 |
*
|
50 |
* @return the available authority names
|
51 |
*/
|
52 |
List<String> getAuthorityNames(); |
53 |
|
54 |
/**
|
55 |
* Returns a List of String values with the codes available for all the
|
56 |
* available authorities
|
57 |
*
|
58 |
* @return the list of available codes, using the AUTHORITY:CODE format
|
59 |
*/
|
60 |
List<String> getCodes(); |
61 |
|
62 |
/**
|
63 |
* Returns a List of String values with the codes available for a given
|
64 |
* Authority,
|
65 |
*
|
66 |
* @param authorityName
|
67 |
* name of the authority to get the codes of
|
68 |
* @return the list of available codes, using the AUTHORITY:CODE format
|
69 |
*/
|
70 |
List<String> getCodes(String authorityName); |
71 |
|
72 |
/**
|
73 |
* Returns a list of codes that match the provided search string.
|
74 |
* Examples of valid searchString: "4326", "EPSG:4326", "ESRI:4326", etc.
|
75 |
* Depending on the implementation of the catalogue, it may search only
|
76 |
* codes or it may search on several CRS fields (name, description,
|
77 |
* area description, etc)
|
78 |
*
|
79 |
* @param searchString
|
80 |
* @return
|
81 |
*/
|
82 |
List<String> search(String searchString); |
83 |
|
84 |
/**
|
85 |
* Returns a list of codes that match the provided search string.
|
86 |
* Examples of valid searchString: "4326", "EPSG:4326", "ESRI:4326", etc.
|
87 |
* Depending on the implementation of the catalog, it may only search for
|
88 |
* codes or it may search on several CRS fields (name, description,
|
89 |
* area description, etc)
|
90 |
*
|
91 |
* @param searchString
|
92 |
* @return
|
93 |
*/
|
94 |
List<String> search(String authority, String searchString); |
95 |
|
96 |
/**
|
97 |
* Gets the CRSDefinition for the provided code
|
98 |
* @param code The CRS code (e.g. "EPSG:4326", "ESRI:4326")
|
99 |
*
|
100 |
* @return
|
101 |
* @throws UnsupportedCoordinateReferenceSystemException
|
102 |
*/
|
103 |
CRSDefinition getCRSDefinition(String code) throws UnsupportedCoordinateReferenceSystemException; |
104 |
|
105 |
|
106 |
/**
|
107 |
* Parses the provided CRS definition to create a {@link CRSDefinition} object
|
108 |
*
|
109 |
* @param def A string containing the definition to parse (e.g. a WKT
|
110 |
* CRS definition, a GML CRS definition, etc)
|
111 |
* @return A {@link CRSDefinition} object
|
112 |
* @throws UnsupportedCoordinateReferenceSystemException if the reference system is not supported by
|
113 |
* this implementation
|
114 |
* @throws ParseException if the provided string can't be parsed (for instance because it is not
|
115 |
* a valid document in any of the supported formats)
|
116 |
*/
|
117 |
CRSDefinition parseCRSDefinition(String def)
|
118 |
throws UnsupportedCoordinateReferenceSystemException, ParseException; |
119 |
|
120 |
/**
|
121 |
* Parses the provided CRS definition to create a {@link CRSDefinition} object
|
122 |
*
|
123 |
* @param def A string containing the definition to parse (e.g. a WKT
|
124 |
* definition, a GML definition, etc)
|
125 |
* @param format The format of the definition to parse
|
126 |
* @return A {@link CRSDefinition} object
|
127 |
* @throws UnsupportedCoordinateReferenceSystemException if the reference system is not supported by
|
128 |
* this implementation
|
129 |
* @throws ParseException if the provided string can't be parsed (for instance, because it is not
|
130 |
* a valid document in the specified format)
|
131 |
* @throws UnsupportedFormatException if the format is not supported
|
132 |
*/
|
133 |
CRSDefinition parseCRSDefinition(String def, TextSerialization.Format format)
|
134 |
throws UnsupportedCoordinateReferenceSystemException, ParseException, UnsupportedFormatException; |
135 |
|
136 |
/**
|
137 |
* Creates a compound CRS by combining the provided individual
|
138 |
* CRSDefinitions.
|
139 |
*
|
140 |
* @param crsList The list of CRSDefinitions to compound
|
141 |
* @return The definition of the compound CRS
|
142 |
* @throws CoordinateReferenceSystemException
|
143 |
*
|
144 |
* @see CRSType#CompoundCRSType
|
145 |
* @see CRSDefinition#getComponents()
|
146 |
* @see CRSDefinition#getType()
|
147 |
*/
|
148 |
CRSDefinition getCompoundCRS(CRSDefinition... crsList) throws CoordinateReferenceSystemException;
|
149 |
|
150 |
/**
|
151 |
* Gets the TransformationDefinition for the provided code
|
152 |
* @param code The operation code (e.g. "EPSG:1633", "EPSG:1632")
|
153 |
* @param code The source CRS of the transformation
|
154 |
* @param code The target CRS for the transformation
|
155 |
*
|
156 |
* @return
|
157 |
*/
|
158 |
TransformationDefinition getTransformationDefinition(String code,
|
159 |
CRSDefinition source, |
160 |
CRSDefinition target) throws UnsupportedTransformationException;
|
161 |
|
162 |
/**
|
163 |
* Parses the provided transformation definition to create a {@link TransformationDefinition} object.
|
164 |
* Note that some {@link TextSerialization.Format formats} don't encode the source and target CRSs, so
|
165 |
* this method will fail for these formats. Use {@link #parseTransformationDefinition(String, String, String)
|
166 |
* or #parseTransformationDefinition(String, String, String, org.gvsig.proj.catalog.TextSerialization.Format)
|
167 |
* instead.
|
168 |
*
|
169 |
* @param def A string containing the definition to parse (e.g. a WKT
|
170 |
* definition, a GML definition, etc)
|
171 |
* @return A {@link TransformationDefinition} object
|
172 |
* @throws UnsupportedCoordinateReferenceSystemException if the transformation is not supported by
|
173 |
* this implementation
|
174 |
* @throws ParseException if the provided string can't be parsed (for instance because it is not
|
175 |
* a valid document in any of the supported formats)
|
176 |
* @throws CoordinateReferenceSystemException if the format does not provide enough information to
|
177 |
* construct the CRS. Use {@link #parseTransformationDefinition(String, String, String)} instead
|
178 |
*/
|
179 |
TransformationDefinition parseTransformationDefinition(String def)
|
180 |
throws UnsupportedTransformationException, ParseException, CoordinateReferenceSystemException; |
181 |
|
182 |
/**
|
183 |
* Parses the provided transformation definition to create a {@link TransformationDefinition} object.
|
184 |
* This method also requires the source and target CRSs of the operation, since some serialization
|
185 |
* formats don't encode this information (e.g. {@link TextSerialization.Format#WKT1} only encodes
|
186 |
* the math transform).
|
187 |
*
|
188 |
* @param def A string containing the definition to parse (e.g. a WKT
|
189 |
* definition, a GML definition, etc)
|
190 |
* @param sourceCRS the source CRS for this operation, encoded as a {@link CRSDefinition#getIdentifier() identifier}
|
191 |
* or as a WKT CRS string.
|
192 |
* @param targetCRS the target CRS for this operation, encoded as a {@link CRSDefinition#getIdentifier() identifier}
|
193 |
* or as a WKT CRS string.
|
194 |
* @return A {@link TransformationDefinition} object
|
195 |
* @throws UnsupportedCoordinateReferenceSystemException if the transformation is not supported by
|
196 |
* this implementation
|
197 |
* @throws ParseException if the provided string can't be parsed (for instance because it is not
|
198 |
* a valid document in any of the supported formats)
|
199 |
*/
|
200 |
TransformationDefinition parseTransformationDefinition(String def, String sourceCRS, String targetCRS) |
201 |
throws UnsupportedTransformationException, ParseException; |
202 |
|
203 |
|
204 |
/**
|
205 |
* Parses the provided CRS definition to create a {@link TransformationDefinition} object.
|
206 |
* Note that some {@link TextSerialization.Format formats} don't encode the source and target CRSs, so
|
207 |
* this method will fail for these formats. Use {@link #parseTransformationDefinition(String, String, String)
|
208 |
* or #parseTransformationDefinition(String, String, String, org.gvsig.proj.catalog.TextSerialization.Format)
|
209 |
* instead.
|
210 |
*
|
211 |
* @param def A string containing the definition to parse (e.g. a WKT
|
212 |
* definition, a GML definition, etc)
|
213 |
* @param format The format of the definition to parse
|
214 |
* @return A {@link TransformationDefinition} object
|
215 |
* @throws UnsupportedCoordinateReferenceSystemException if the transformation is not supported by
|
216 |
* this implementation
|
217 |
* @throws ParseException if the provided string can't be parsed (for instance, because it is not
|
218 |
* a valid document in the specified format)
|
219 |
* @throws UnsupportedFormatException if the format is not supported
|
220 |
* @throws CoordinateReferenceSystemException if the format does not provide enough information to
|
221 |
* construct the CRS. Use {@link #parseTransformationDefinition(String, String, String)} instead
|
222 |
*/
|
223 |
TransformationDefinition parseTransformationDefinition(String def, TextSerialization.Format format)
|
224 |
throws UnsupportedTransformationException, ParseException, UnsupportedFormatException, CoordinateReferenceSystemException; |
225 |
|
226 |
/**
|
227 |
* Parses the provided CRS definition to create a {@link TransformationDefinition} object.
|
228 |
* This method also requires the source and target CRSs of the operation, since some serialization
|
229 |
* formats don't encode this information (e.g. {@link TextSerialization.Format#WKT1} only encodes
|
230 |
* the math transform).
|
231 |
*
|
232 |
* @param def A string containing the definition to parse (e.g. a WKT
|
233 |
* definition, a GML definition, etc)?
|
234 |
* @param sourceCRS the source CRS for this operation, encoded as a {@link CRSDefinition#getIdentifier() identifier}
|
235 |
* or as a WKT CRS string.
|
236 |
* @param targetCRS the target CRS for this operation, encoded as a {@link CRSDefinition#getIdentifier() identifier}
|
237 |
* or as a WKT CRS string.
|
238 |
* @param format The format of the definition to parse
|
239 |
* @return A {@link TransformationDefinition} object
|
240 |
* @throws UnsupportedCoordinateReferenceSystemException if the transformation is not supported by
|
241 |
* this implementation
|
242 |
* @throws ParseException if the provided string can't be parsed (for instance, because it is not
|
243 |
* a valid document in the specified format)
|
244 |
* @throws UnsupportedFormatException if the format is not supported
|
245 |
*/
|
246 |
TransformationDefinition parseTransformationDefinition(String def, String sourceCRS, String targetCRS, |
247 |
TextSerialization.Format format) |
248 |
throws UnsupportedTransformationException, ParseException, UnsupportedFormatException; |
249 |
|
250 |
/**
|
251 |
* Register a user-defined CRS from an WKT definition
|
252 |
*
|
253 |
* @param wktDefinition The WKT definition of the CRS to register
|
254 |
* @param description A human-readable description of the CRS
|
255 |
* @return The code assigned to the registered CRS on the USER
|
256 |
* namespace
|
257 |
*/
|
258 |
String registerCoordinateReferenceSystem(String wktDefinition, String description) |
259 |
throws UnsupportedCoordinateReferenceSystemException, ParseException; |
260 |
|
261 |
/**
|
262 |
* Register a user-defined coordinate operation
|
263 |
*
|
264 |
* @param wktDefinition The WKT definition of the operation to register
|
265 |
* @param sourceCRS the source CRS for this operation, encoded as a {@link CRSDefinition#getIdentifier() identifier}
|
266 |
* or as a WKT CRS string.
|
267 |
* @param targetCRS the target CRS for this operation, encoded as a {@link CRSDefinition#getIdentifier() identifier}
|
268 |
* or as a WKT CRS string.
|
269 |
* @param description A human-readable description of the CRS
|
270 |
* @return The code assigned to the registered CRS on the USER
|
271 |
* namespace
|
272 |
*/
|
273 |
String registerTransformation(String wktDefinition, String sourceCRS, String targetCRS, String description) |
274 |
throws UnsupportedTransformationException, ParseException; |
275 |
|
276 |
/**
|
277 |
* Register a user-defined coordinate transformation using the Position
|
278 |
* Vector Transformation method
|
279 |
*
|
280 |
* @param definition The WKT definition of the operation to register
|
281 |
* @return The code assigned to the registered CRS on the USER
|
282 |
* namespace
|
283 |
* @see #registerCoordinateTransformationCFR(String, String, String, float, float, float, float, float, float, float)
|
284 |
*/
|
285 |
String registerCoordinateTransformationPVT(String sourceCRS, String targetCRS, |
286 |
String description,
|
287 |
float xTraslation, float yTraslation, float zTraslation, |
288 |
float xRotation, float yRotation, float zRotation, |
289 |
float scaleDifference)
|
290 |
throws UnsupportedTransformationException, ParseException; |
291 |
|
292 |
/**
|
293 |
* Register a user-defined coordinate transformation using the Coordinate
|
294 |
* Frame Rotation method
|
295 |
*
|
296 |
* @param definition The WKT definition of the operation to register
|
297 |
* @return The code assigned to the registered CRS on the USER
|
298 |
* namespace
|
299 |
* @see #registerCoordinateTransformationPVT(String, String, String, float, float, float, float, float, float, float)
|
300 |
*/
|
301 |
String registerCoordinateTransformationCFR(String sourceCRS, String targetCRS, |
302 |
String description,
|
303 |
float xTraslation, float yTraslation, float zTraslation, |
304 |
float xRotation, float yRotation, float zRotation, |
305 |
float scaleDifference)
|
306 |
throws UnsupportedTransformationException, ParseException; |
307 |
|
308 |
/**
|
309 |
* Register a user-defined coordinate transformation using a
|
310 |
* transformation grid in NTv2 format
|
311 |
*
|
312 |
* @param definition The WKT definition of the operation to register
|
313 |
* @return The code assigned to the registered CRS on the USER
|
314 |
* namespace
|
315 |
*/
|
316 |
String registerCoordinateTransformation(String sourceCRS, String targetCRS, |
317 |
String description, File ntv2Grid) |
318 |
throws UnsupportedTransformationException, ParseException; |
319 |
|
320 |
|
321 |
/**
|
322 |
* Gets the list of available TransformationDefinition to transform or
|
323 |
* convert coordinates from the source CoordinateReferenceSystem to
|
324 |
* the target one.
|
325 |
* @param source
|
326 |
* @param target
|
327 |
* @return
|
328 |
* @throws CoordinateReferenceSystemException
|
329 |
*/
|
330 |
List<TransformationDefinition> getCoordinateTransformations(CRSDefinition source, CRSDefinition target) throws CoordinateReferenceSystemException; |
331 |
|
332 |
/**
|
333 |
* Gets the list of available TransformationDefinition to transform or
|
334 |
* convert coordinates from the source CoordinateReferenceSystem to
|
335 |
* the target one.
|
336 |
*
|
337 |
* @param source The code of the source CRS (e.g. "ESPG:25830")
|
338 |
* @param target The code of the target CRS (e.g. "ESPG:4230")
|
339 |
* @return
|
340 |
*/
|
341 |
List<TransformationDefinition> getCoordinateTransformations(String source, String target) throws CoordinateReferenceSystemException; |
342 |
|
343 |
/**
|
344 |
* Sets the path to the folder to be used by the library to load the CRS and
|
345 |
* transformation definitions. The structure and format of the definitions contained in
|
346 |
* the folder is implementation-dependent, so it must be prepared for a particular
|
347 |
* CRS catalog implementation.
|
348 |
*
|
349 |
* This method only has effect when it is called before any other method in the manager
|
350 |
* (before instantiating any CRS, transformation, etc).
|
351 |
*
|
352 |
* @param path The path to the folder containing the system CRS and transformation
|
353 |
* definitions
|
354 |
*/
|
355 |
void setSystemDataPath(File path); |
356 |
|
357 |
/**
|
358 |
* Sets the path to the folder to be used by the library to load the user defined
|
359 |
* CRS and transformation definitions. The structure and format of the definitions
|
360 |
* contained in the folder is implementation-dependent, so it must be prepared for
|
361 |
* a particular CRS catalog implementation.
|
362 |
*
|
363 |
* This method only has effect when it is called before any other method in the manager
|
364 |
* (before instantiating any CRS, transformation, etc).
|
365 |
*
|
366 |
* @param path The path to the folder containing the user defined CRS and transformation
|
367 |
* definitions
|
368 |
*/
|
369 |
void setUserDataPath(File path); |
370 |
|
371 |
/**
|
372 |
* Gets the formats (WKT, GML, etc) for text serialization of CRSs and transformations
|
373 |
* which are supported by this particular implementation
|
374 |
*
|
375 |
* @return
|
376 |
*/
|
377 |
List<TextSerialization.Format> getSupportedFormats();
|
378 |
} |