Changeset 11648 in josm


Ignore:
Timestamp:
2017-03-02T01:28:53+01:00 (7 years ago)
Author:
Don-vip
Message:

see #14422 - update unit test

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/data_nodist/projection/projection-reference-data

    r9958 r11648  
    3686336863    -55.98383921869693,75.63573463956286,-1305237.430092321,4153869.129437317
    3686436864    72.879933882633,17.159780630468802,7512109.287242818,-227918.925727678
    36865 <EPSG:27561> +proj=lcc +lat_0=49.5 +lat_1=48d35'54.682" +lat_2=50d23'45.282" +lon_0=2d20'14.025" +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +nadgrids=ntf_r93_b.gsb +units=m +bounds=-4.416666666666665,46.65,9.18,51.300000000000004  <>
     36865<EPSG:27561> +proj=lcc +lat_0=49.5 +lat_1=48d35'54.682" +lat_2=50d23'45.282" +lon_0=2d20'14.025" +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +nadgrids=ntf_r93.gsb +units=m +bounds=-4.416666666666665,46.65,9.18,51.300000000000004  <>
    3686636866    0.18240099467414606,50.70084348205154,447822.248657583,335749.731598569
    3686736867    0.9331174400163427,50.72485379853146,500898.93039386,337167.651206067
     
    3687236872    -4.333309987158797,51.19431458229903,134211.681457075,409113.828883267
    3687336873    1.1731830014909175,50.71607717203845,517834.559535807,335902.29111521
    36874 <EPSG:27562> +proj=lcc +lat_0=46.8 +lat_1=45d53'56.108" +lat_2=47d41'45.652" +lon_0=2d20'14.025" +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +nadgrids=ntf_r93_b.gsb +units=m +bounds=-4.416666666666665,43.95,9.18,49.65  <>
     36874<EPSG:27562> +proj=lcc +lat_0=46.8 +lat_1=45d53'56.108" +lat_2=47d41'45.652" +lon_0=2d20'14.025" +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +nadgrids=ntf_r93.gsb +units=m +bounds=-4.416666666666665,43.95,9.18,49.65  <>
    3687536875    -1.1133365185429613,46.3561696607643,334590.433494117,156502.072351671
    3687636876    3.0874804507525653,45.63813153451019,658552.478959508,71143.221253895
     
    3688136881    -3.27634515762172,46.42448034097477,168953.266260769,173664.349652023
    3688236882    -2.0042440238165162,46.66226754677738,267991.824542247,193869.189478427
    36883 <EPSG:27563> +proj=lcc +lat_0=44.1 +lat_1=43d11'57.449" +lat_2=44d59'45.938" +lon_0=2d20'14.025" +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +nadgrids=ntf_r93_b.gsb +units=m +bounds=-4.416666666666665,41.49,9.18,46.95  <>
     36883<EPSG:27563> +proj=lcc +lat_0=44.1 +lat_1=43d11'57.449" +lat_2=44d59'45.938" +lon_0=2d20'14.025" +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +nadgrids=ntf_r93.gsb +units=m +bounds=-4.416666666666665,41.49,9.18,46.95  <>
    3688436884    5.248868656095957,46.65569220077895,823071.560393645,488045.265500711
    3688536885    -3.4493869915884816,44.008526482123635,136434.227145081,206138.130591396
     
    3689036890    8.290835975632522,43.39091449780428,1081988.039463948,138654.923060995
    3689136891    3.5219714239015083,44.69297807859731,693954.617792124,266562.331242614
    36892 <EPSG:27564> +proj=lcc +lat_0=42.165 +lat_1=41d33'37.396" +lat_2=42d46'3.588" +lon_0=2d20'14.025" +x_0=234.358 +y_0=185861.369 +a=6378249.2 +b=6356515 +nadgrids=ntf_r93_b.gsb +units=m +bounds=-4.416666666666665,41.49,9.18,44.267667  <>
     36892<EPSG:27564> +proj=lcc +lat_0=42.165 +lat_1=41d33'37.396" +lat_2=42d46'3.588" +lon_0=2d20'14.025" +x_0=234.358 +y_0=185861.369 +a=6378249.2 +b=6356515 +nadgrids=ntf_r93.gsb +units=m +bounds=-4.416666666666665,41.49,9.18,44.267667  <>
    3689336893    -2.544556181890229,43.769485647452164,-392694.173102384,375360.931743444
    3689436894    5.293428616903728,41.7317796332518,246180.966307288,141998.148829765
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRefTest.java

    r11324 r11648  
    3131
    3232import org.junit.Assert;
     33import org.junit.Rule;
    3334import org.junit.Test;
    3435import org.openstreetmap.josm.data.Bounds;
     
    3637import org.openstreetmap.josm.data.coor.LatLon;
    3738import org.openstreetmap.josm.gui.preferences.projection.CodeProjectionChoice;
     39import org.openstreetmap.josm.testutils.JOSMTestRules;
    3840import org.openstreetmap.josm.tools.Pair;
    3941import org.openstreetmap.josm.tools.Utils;
     
    4850 * program from the proj.4 library in path (or use <code>CS2CS_EXE</code> to set
    4951 * the full path of the executable). Make sure the required *.gsb grid files
    50  * can be accessed, i.e. copy them from <code>data/projection</code> to <code>/usr/share/proj</code> or
     52 * can be accessed, i.e. copy them from <code>data_nodist/projection</code> to <code>/usr/share/proj</code> or
    5153 * wherever cs2cs expects them to be placed.
    5254 *
     
    7577
    7678    static Random rand = new SecureRandom();
     79
     80    /**
     81     * Setup test.
     82     */
     83    @Rule
     84    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     85    public JOSMTestRules test = new JOSMTestRules().platform();
    7786
    7887    /**
     
    284293    }
    285294
     295    /**
     296     * Test projections.
     297     * @throws IOException if any I/O error occurs
     298     */
    286299    @Test
    287300    public void testProjections() throws IOException {
     
    296309            }
    297310            if (!ref.def.equals(def0)) {
    298                 Assert.fail("definitions for " + ref.code + " do not match");
    299             }
    300             Projection proj = Projections.getProjectionByCode(ref.code);
    301             double scale = ((CustomProjection) proj).getToMeter();
    302             for (Pair<LatLon, EastNorth> p : ref.data) {
    303                 LatLon ll = p.a;
    304                 EastNorth enRef = p.b;
    305                 enRef = new EastNorth(enRef.east() * scale, enRef.north() * scale); // convert to meter
    306 
    307                 EastNorth en = proj.latlon2eastNorth(ll);
    308                 if (proj.switchXY()) {
    309                     en = new EastNorth(en.north(), en.east());
    310                 }
    311                 en = new EastNorth(en.east() * scale, en.north() * scale); // convert to meter
    312                 final double EPSILON_EN = 1e-2; // 1cm
    313                 if (!isEqual(enRef, en, EPSILON_EN, true)) {
    314                     String errorEN = String.format("%s (%s): Projecting latlon(%s,%s):%n" +
    315                             "        expected: eastnorth(%s,%s),%n" +
    316                             "        but got:  eastnorth(%s,%s)!%n",
    317                             proj.toString(), proj.toCode(), ll.lat(), ll.lon(), enRef.east(), enRef.north(), en.east(), en.north());
    318                     fail.append(errorEN);
     311                fail.append("definitions for ").append(ref.code).append(" do not match\n");
     312            } else {
     313                Projection proj = Projections.getProjectionByCode(ref.code);
     314                double scale = ((CustomProjection) proj).getToMeter();
     315                for (Pair<LatLon, EastNorth> p : ref.data) {
     316                    LatLon ll = p.a;
     317                    EastNorth enRef = p.b;
     318                    enRef = new EastNorth(enRef.east() * scale, enRef.north() * scale); // convert to meter
     319
     320                    EastNorth en = proj.latlon2eastNorth(ll);
     321                    if (proj.switchXY()) {
     322                        en = new EastNorth(en.north(), en.east());
     323                    }
     324                    en = new EastNorth(en.east() * scale, en.north() * scale); // convert to meter
     325                    final double EPSILON_EN = 1e-2; // 1cm
     326                    if (!isEqual(enRef, en, EPSILON_EN, true)) {
     327                        String errorEN = String.format("%s (%s): Projecting latlon(%s,%s):%n" +
     328                                "        expected: eastnorth(%s,%s),%n" +
     329                                "        but got:  eastnorth(%s,%s)!%n",
     330                                proj.toString(), proj.toCode(), ll.lat(), ll.lon(), enRef.east(), enRef.north(), en.east(), en.north());
     331                        fail.append(errorEN);
     332                    }
    319333                }
    320334            }
Note: See TracChangeset for help on using the changeset viewer.