source: josm/trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2GridShiftFileWrapper.java@ 10308

Last change on this file since 10308 was 10212, checked in by Don-vip, 8 years ago

sonar - squid:S2221 - "Exception" should not be caught when not required by called methods

  • Property svn:eol-style set to native
File size: 2.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.projection.datum;
3
4import java.io.IOException;
5import java.io.InputStream;
6
7import org.openstreetmap.josm.io.CachedFile;
8
9/**
10 * Wrapper for {@link NTV2GridShiftFile}.
11 *
12 * Loads the shift file from disk, when it is first accessed.
13 * @since 5226
14 */
15public class NTV2GridShiftFileWrapper {
16
17 // CHECKSTYLE.OFF: LineLength
18
19 /**
20 * Used in Germany to convert coordinates between the DHDN (<i>Deutsches Hauptdreiecksnetz</i>)
21 * and ETRS89 (<i>European Terrestrial Reference System 1989</i>) datums.
22 * @see <a href="http://crs.bkg.bund.de/crseu/crs/descrtrans/eu-descrtrans.php?crs_id=REVfREhETiAvIEdLXzM=&op_id=REVfREhETiAoQmVUQSwgMjAwNykgdG8gRVRSUzg5">
23 * Description of Transformation - DE_DHDN (BeTA, 2007) to ETRS89</a>
24 */
25 public static final NTV2GridShiftFileWrapper BETA2007 = new NTV2GridShiftFileWrapper("resource://data/projection/BETA2007.gsb");
26
27 /**
28 * Used in France to convert coordinates between the NTF (<i>Nouvelle triangulation de la France</i>)
29 * and RGF93 (<i>Réseau géodésique français 1993</i>) datums.
30 * @see <a href="http://geodesie.ign.fr/contenu/fichiers/documentation/algorithmes/notice/NT111_V1_HARMEL_TransfoNTF-RGF93_FormatGrilleNTV2.pdf">
31 * [French] Transformation de coordonnées NTF – RGF93 / Format de grille NTv2</a>
32 */
33 public static final NTV2GridShiftFileWrapper ntf_rgf93 = new NTV2GridShiftFileWrapper("resource://data/projection/ntf_r93_b.gsb");
34
35 // CHECKSTYLE.ON: LineLength
36
37 private NTV2GridShiftFile instance;
38 private final String gridFileName;
39
40 /**
41 * Constructs a new {@code NTV2GridShiftFileWrapper}.
42 * @param filename Path to the grid file (GSB format)
43 */
44 public NTV2GridShiftFileWrapper(String filename) {
45 this.gridFileName = filename;
46 }
47
48 /**
49 * Returns the actual {@link NTV2GridShiftFile} behind this wrapper.
50 * The grid file is only loaded once, when first accessed.
51 * @return The NTv2 grid file
52 */
53 public NTV2GridShiftFile getShiftFile() {
54 if (instance == null) {
55 try (CachedFile cf = new CachedFile(gridFileName); InputStream is = cf.getInputStream()) {
56 instance = new NTV2GridShiftFile();
57 instance.loadGridShiftFile(is, false);
58 } catch (IOException e) {
59 throw new RuntimeException(e);
60 }
61 }
62 return instance;
63 }
64}
Note: See TracBrowser for help on using the repository browser.