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