Changeset 5073 in josm


Ignore:
Timestamp:
2012-03-11T21:19:59+01:00 (8 years ago)
Author:
bastiK
Message:

move ntv2 to datum (see #7494)

Location:
trunk
Files:
1 added
4 edited
4 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/projection/AbstractProjection.java

    r5040 r5073  
    2020 * Subclasses of AbstractProjection must set ellps and proj to a non-null value.
    2121 * In addition, either datum or nadgrid has to be initialized to some value.
    22  *
    23  * FIXME: nadgrids should probably be implemented as a Datum
    2422 */
    2523abstract public class AbstractProjection implements Projection {
     
    3230    protected double lon_0 = 0.0;   /* central meridian */
    3331    protected double k_0 = 1.0;     /* general scale factor */
    34     protected NTV2GridShiftFile nadgrids = null;
    35    
     32
    3633    public final Ellipsoid getEllipsoid() {
    3734        return ellps;
     
    6461    @Override
    6562    public EastNorth latlon2eastNorth(LatLon ll) {
    66         if (nadgrids != null) {
    67             NTV2GridShift gs = new NTV2GridShift(ll);
    68             nadgrids.gridShiftReverse(gs);
    69             ll = new LatLon(ll.lat()+gs.getLatShiftDegrees(), ll.lon()+gs.getLonShiftPositiveEastDegrees());
    70         } else {
    71             ll = datum.fromWGS84(ll);
    72         }
     63        ll = datum.fromWGS84(ll);
    7364        double[] en = proj.project(Math.toRadians(ll.lat()), Math.toRadians(ll.lon() - lon_0));
    7465        return new EastNorth(ellps.a * k_0 * en[0] + x_0, ellps.a * k_0 * en[1] + y_0);
     
    7970        double[] latlon_rad = proj.invproject((en.east() - x_0) / ellps.a / k_0, (en.north() - y_0) / ellps.a / k_0);
    8071        LatLon ll = new LatLon(Math.toDegrees(latlon_rad[0]), Math.toDegrees(latlon_rad[1]) + lon_0);
    81         if (nadgrids != null) {
    82             NTV2GridShift gs = new NTV2GridShift(ll);
    83             nadgrids.gridShiftForward(gs);
    84             ll = new LatLon(ll.lat()+gs.getLatShiftDegrees(), ll.lon()+gs.getLonShiftPositiveEastDegrees());
    85         } else {
    86             ll = datum.toWGS84(ll);
    87         }
    88         return ll;
     72        return datum.toWGS84(ll);
    8973    }
    9074
     
    9478        return 10;
    9579    }
    96    
     80
    9781    /**
    9882     * @return The EPSG Code of this CRS, null if it doesn't have one.
     
    10892        return "EPSG:" + getEpsgCode();
    10993    }
    110    
     94
    11195    protected static final double convertMinuteSecond(double minute, double second) {
    11296        return (minute/60.0) + (second/3600.0);
    11397    }
    114    
     98
    11599    protected static final double convertDegreeMinuteSecond(double degree, double minute, double second) {
    116100        return degree + convertMinuteSecond(minute, second);
  • trunk/src/org/openstreetmap/josm/data/projection/GaussKrueger.java

    r5066 r5073  
    1717import org.openstreetmap.josm.data.Bounds;
    1818import org.openstreetmap.josm.data.coor.LatLon;
     19import org.openstreetmap.josm.data.projection.datum.NTV2Datum;
     20import org.openstreetmap.josm.data.projection.datum.NTV2GridShiftFile;
    1921import org.openstreetmap.josm.data.projection.proj.ProjParameters;
    2022import org.openstreetmap.josm.data.projection.proj.TransverseMercator;
     
    6062        this.zone = zone;
    6163        ellps = Ellipsoid.Bessel1841;
    62         nadgrids = BETA2007;
     64        datum = new NTV2Datum("BETA2007", null, ellps, BETA2007);
    6365        ////less acurrate datum (errors up to 3m):
    6466        //datum = new SevenParameterDatum(
  • trunk/src/org/openstreetmap/josm/data/projection/Lambert.java

    r5067 r5073  
    1717import org.openstreetmap.josm.data.Bounds;
    1818import org.openstreetmap.josm.data.coor.LatLon;
     19import org.openstreetmap.josm.data.projection.datum.NTV2Datum;
     20import org.openstreetmap.josm.data.projection.datum.NTV2GridShiftFile;
    1921import org.openstreetmap.josm.data.projection.proj.LambertConformalConic;
    2022import org.openstreetmap.josm.data.projection.proj.ProjParameters;
     
    101103        this.layoutZone = layoutZone;
    102104        ellps = Ellipsoid.clarkeIGN;
    103         datum = null; // no datum needed, we have a shift file
    104         nadgrids = ntf_rgf93Grid;
     105        datum = new NTV2Datum("ntf_rgf93Grid", null, ellps, ntf_rgf93Grid);
    105106        x_0 = x_0s[layoutZone];
    106107        lon_0 = 2.0 + 20.0 / 60 + 14.025 / 3600; // 0 grade Paris
  • trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2GridShift.java

    r5067 r5073  
    1818 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1919 */
    20 package org.openstreetmap.josm.data.projection;
     20package org.openstreetmap.josm.data.projection.datum;
    2121
    2222import java.io.Serializable;
  • trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2GridShiftFile.java

    r5067 r5073  
    1818 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1919 */
    20 package org.openstreetmap.josm.data.projection;
     20package org.openstreetmap.josm.data.projection.datum;
    2121
    2222import java.io.IOException;
  • trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2SubGrid.java

    r5067 r5073  
    1818 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1919 */
    20 package org.openstreetmap.josm.data.projection;
     20package org.openstreetmap.josm.data.projection.datum;
    2121
    2222import java.io.IOException;
  • trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2Util.java

    r5067 r5073  
    1818 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1919 */
    20 package org.openstreetmap.josm.data.projection;
     20package org.openstreetmap.josm.data.projection.datum;
    2121
    2222/**
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java

    r5065 r5073  
    2424import java.util.Set;
    2525
     26import org.junit.BeforeClass;
    2627import org.junit.Test;
     28import org.openstreetmap.josm.Main;
    2729import org.openstreetmap.josm.data.Bounds;
     30import org.openstreetmap.josm.data.Preferences;
    2831import org.openstreetmap.josm.data.coor.EastNorth;
    2932import org.openstreetmap.josm.data.coor.LatLon;
     
    5457
    5558    public static void main(String[] args) throws IOException, FileNotFoundException {
     59        setUp();
    5660        Map<String, Projection> allCodes = new LinkedHashMap<String, Projection>();
    5761        List<Projection> projs = Projections.getProjections();
     
    144148    }
    145149
     150    @BeforeClass
     151    public static void setUp() {
     152        Main.pref = new Preferences();
     153    }
     154
    146155    @Test
    147156    public void regressionTest() throws IOException, FileNotFoundException {
Note: See TracChangeset for help on using the changeset viewer.