2016-05-04 9 views
0

Ich habe eine Zuordnung zum Konvertieren von Koordinaten in North Carolina State Ebene in Breitengrad und Längengrad.Wie verdeckt man die Projektion "102719 = NAD 1983 StatePlane North Carolina FIPS 3200 Feet" auf Längen- und Breitengrad in jMapProgLib?

EX: 2_329_394.77272739, 524_784.10055898 wandelt in -77,8975142, 35,1869162 See: https://epsg.io/transform#s_srs=102719&t_srs=4326&x=2329394.7727274&y=524784.1005590

ich mit jMapProjLib gestartet. Aber nicht die richtige Antwort bekommen.

Hier ist mein Code in JUnit-Testform:

@Test 
public void testLCCProjection() { 
    System.out.println("getLCCProjection"); 

    // From \coordsys\esri file in project. Line 5703 
    //# NAD 1983 StatePlane North Carolina FIPS 3200 Feet 
    //<102719> +proj=lcc +lat_1=34.33333333333334 +lat_2=36.16666666666666 +lat_0=33.75 +lon_0=-79 +x_0=609601.2199999999 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 no_defs <> 
    String[] args = new String[]{ 
     "+proj=lcc", // projection name is Lambert Conformal Conic 
     "+lat_1=34.33333333333334", // projectionLatitude 1 
     "+lat_2=36.16666666666666", // projectionLatitude 2 
     "+lat_0=33.75", // projectionLatitude 
     "+lon_0=-79", // projectionLongitude 
     "+x_0=609601.2199999999", // falseEasting in meters. This is the correct value. 
     // "+x_0=2000000.002616666", // falseEasting in feet 
     "+y_0=0", // falseNorthing 
     "+ellps=GRS80", // 
     "+datum=NAD83", // 
     "+to_meter=0.3048006096012192", // conversion to meters. 
    }; 

    // lccp stands for LamberConformalConicProjection 
    Projection lccp = ProjectionFactory.fromPROJ4Specification(args); 
    lccp.initialize(); 

    // input 
    double x = 2_329_394.77272739; // in feet 
    double y = 524_784.10055898; // in feet 
    // the correct answer see: https://epsg.io/transform#s_srs=102719&t_srs=4326&x=2329394.7727274&y=524784.1005590 
    double expectedLong = -77.8975142D; 
    double expectedLat = 35.1869162D; 

    // convert to meters 
    double toMeters = 0.3048006096012192; 
    double x_in_meters = x * toMeters; 
    double y_in_meters = y * toMeters; 
    Point2D.Double out = new Point2D.Double(); 
    Point2D.Double in = new Point2D.Double(); 
    in.x = x_in_meters; 
    in.y = y_in_meters; 

    // run the inverse transform. The magic happens here! 
    lccp.inverseTransform(in, out); 

    // verify the answer 
    double longitude = out.x; 
    double latitude = out.y; 
    System.out.println("lat/Long expected = " + expectedLat + " " + expectedLong); 
    System.out.println("lat/long in deg decimal = " + latitude + " " + longitude); 
    System.out.println("diff lat/long = " + Math.abs(expectedLat - latitude) + " " + Math.abs(
      expectedLong - longitude)); 
    assertEquals(expectedLong, longitude, 0.1); 
    assertEquals(expectedLat, latitude, 0.1); 

} 

Dieser einen Punkt in Georgien zurück. Es sollte in North Carolina sein.

Wie es zu beheben?

Jede Hilfe würde geschätzt werden !!

Gibt es eine bessere Bibliothek oder ein besseres Paket für diese Konvertierung?

Ausgabe auf System.out:

lat/Long expected = 35.1869162 -77.8975142 
lat/long in deg decimal = 34.113370281502604 -83.26272018000135 
diff lat/long = 1.0735459184973948 5.365205980001349 
+1

Was waren die Ausgaben von System.out? Warum hast du den Schritt "in Meter umrechnen"? Die [Quelle SRS hat '+ Einheiten = us-ft'] (http://epsg.io/102719.proj4). Auch '+ x_0 = 609601.21999999999' ist in us-ft. –

+0

Die Ausgabe von System.out wird am Ende des Fragetextes hinzugefügt. – fishjd

+0

Der Wert + x_0 = 609601.21999999999 (auch bekannt als "Ostseefall") ist in Metern angegeben. Der Wert für + x_0 in Fuß ist + x_0 = 2000000.002616666. Dies wurde zu den Kommentaren des Codes hinzugefügt. – fishjd

Antwort

0

gelöst. Das obige funktioniert, wenn die Umwandlung von x und y zu Messgeräten entfernt wird. Ich war so nah. Danke an Mike T für den Vorschlag.

Arbeits Code:

public void testLCCProjection() { 
     System.out.println("getLCCProjection"); 

     // From \coordsys\esri file in project. Line 5703 
     //# NAD 1983 StatePlane North Carolina FIPS 3200 Feet 
     //<102719> +proj=lcc +lat_1=34.33333333333334 +lat_2=36.16666666666666 +lat_0=33.75 +lon_0=-79 +x_0=609601.2199999999 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 no_defs <> 
     String[] args = new String[]{ 
      "+proj=lcc", // projection name is Lambert Conformal Conic 
      "+lat_1=34.33333333333334", // projectionLatitude 1 
      "+lat_2=36.16666666666666", // projectionLatitude 2 
      "+lat_0=33.75", // projectionLatitude 
      "+lon_0=-79", // projectionLongitude 
      "+x_0=609601.2199999999", // falseEasting in meters. This is the correct value. 
      // "+x_0=2000000.002616666", // falseEasting in feet 
      "+y_0=0", // falseNorthing 
      "+ellps=GRS80", // 
      "+datum=NAD83", // 
      "+to_meter=0.3048006096012192", // conversion to meters. 
     }; 

     // lccp stands for LamberConformalConicProjection 
     Projection lccp = ProjectionFactory.fromPROJ4Specification(args); 
     lccp.initialize(); 

     // input 
     double x = 2_329_394.77272739; // in feet 
     double y = 524_784.10055898; // in feet 
     // the correct answer see: https://epsg.io/transform#s_srs=102719&t_srs=4326&x=2329394.7727274&y=524784.1005590 
     double expectedLong = -77.8975142D; 
     double expectedLat = 35.1869162D; 
     // double toMeters = 0.3048006096012192; 

     Point2D.Double out = new Point2D.Double(); 
     Point2D.Double in = new Point2D.Double(); 
     in.x = x; 
     in.y = y; 

     // run the inverse transform. The magic happens here! 
     lccp.inverseTransform(in, out); 

     // verify the answer 
     double longitude = out.x; 
     double latitude = out.y; 
     System.out.println("lat/Long expected = " + expectedLat + " " + expectedLong); 
     System.out.println("lat/long in deg decimal = " + latitude + " " + longitude); 
     System.out.println("diff lat/long = " + Math.abs(expectedLat - latitude) + " " + Math.abs(
       expectedLong - longitude)); 
     assertEquals(expectedLong, longitude, 0.1); 
     assertEquals(expectedLat, latitude, 0.1); 

    } 

Ausgabe auf System.out:

lat/Long expected = 35.1869162 -77.8975142 
lat/long in deg decimal = 35.18691619350664 -77.89751408312104 
diff lat/long = 6.493358739589894E-9 1.16878965172873E-7 

Ja!