source: josm/trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2Datum.java@ 14159

Last change on this file since 14159 was 13627, checked in by Don-vip, 6 years ago

see #16129 - datum javadoc

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.projection.datum;
3
4import java.io.IOException;
5
6import org.openstreetmap.josm.data.coor.LatLon;
7import org.openstreetmap.josm.data.projection.Ellipsoid;
8import org.openstreetmap.josm.tools.JosmRuntimeException;
9
10/**
11 * Datum based of NTV2 grid shift file.
12 * @since 5073
13 */
14public class NTV2Datum extends AbstractDatum {
15
16 private final NTV2GridShiftFileWrapper nadgrids;
17
18 /**
19 * Constructs a new {@code NTV2Datum}.
20 * @param name datum name
21 * @param proj4Id PROJ.4 id
22 * @param ellps ellipsoid
23 * @param nadgrids NTV2 grid shift file wrapper
24 */
25 public NTV2Datum(String name, String proj4Id, Ellipsoid ellps, NTV2GridShiftFileWrapper nadgrids) {
26 super(name, proj4Id, ellps);
27 this.nadgrids = nadgrids;
28 }
29
30 @Override
31 public LatLon toWGS84(LatLon ll) {
32 NTV2GridShift gs = new NTV2GridShift(ll);
33 try {
34 nadgrids.getShiftFile().gridShiftForward(gs);
35 return new LatLon(ll.lat() + gs.getLatShiftDegrees(), ll.lon() + gs.getLonShiftPositiveEastDegrees());
36 } catch (IOException e) {
37 throw new JosmRuntimeException(e);
38 }
39 }
40
41 @Override
42 public LatLon fromWGS84(LatLon ll) {
43 NTV2GridShift gs = new NTV2GridShift(ll);
44 try {
45 nadgrids.getShiftFile().gridShiftReverse(gs);
46 return new LatLon(ll.lat() + gs.getLatShiftDegrees(), ll.lon() + gs.getLonShiftPositiveEastDegrees());
47 } catch (IOException e) {
48 throw new JosmRuntimeException(e);
49 }
50 }
51}
Note: See TracBrowser for help on using the repository browser.