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

Last change on this file since 11374 was 11374, checked in by Don-vip, 7 years ago

sonar - squid:S00112 - Generic exceptions should never be thrown: define JosmRuntimeException

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