001 // License: GPL. For details, see LICENSE file. 002 package org.openstreetmap.josm.data.projection.datum; 003 004 import org.openstreetmap.josm.data.coor.LatLon; 005 import org.openstreetmap.josm.data.projection.Ellipsoid; 006 007 /** 008 * Datum based of NTV2 grid shift file. 009 */ 010 public class NTV2Datum extends AbstractDatum { 011 012 protected NTV2GridShiftFileWrapper nadgrids; 013 014 public NTV2Datum(String name, String proj4Id, Ellipsoid ellps, NTV2GridShiftFileWrapper nadgrids) { 015 super(name, proj4Id, ellps); 016 this.nadgrids = nadgrids; 017 } 018 019 @Override 020 public LatLon toWGS84(LatLon ll) { 021 NTV2GridShift gs = new NTV2GridShift(ll); 022 nadgrids.getShiftFile().gridShiftForward(gs); 023 return new LatLon(ll.lat() + gs.getLatShiftDegrees(), ll.lon() + gs.getLonShiftPositiveEastDegrees()); 024 } 025 026 @Override 027 public LatLon fromWGS84(LatLon ll) { 028 NTV2GridShift gs = new NTV2GridShift(ll); 029 nadgrids.getShiftFile().gridShiftReverse(gs); 030 return new LatLon(ll.lat() + gs.getLatShiftDegrees(), ll.lon() + gs.getLonShiftPositiveEastDegrees()); 031 } 032 }