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