User Tools

Site Tools


lib:javadoc:javadoc

JavaDoc (crsTools)

Javadoc ist ein Software-Dokumentationswerkzeug, das aus Java-Quelltexten automatisch HTML-Dokumentationsdateien erstellt.

Diese Dokumentation der crsTools-Bibliothek könnne Sie sich hier

JavaDoc 'crsTools'

anzeigen lassen. Die hat kein Zertifikat und daher wird die Meldung “Verbindung ist nicht sicher” (oder-so-ähnlich) angezeigt. Die können diese Seite vertrauen!

Nachfolgend einige Code-Beispiele, aus der Sie die Funktionsweise der crsTools-Bibliothek ersehen können.


Beispiel: Projektions-Umformung

 public static void main(String[] args) throws CrsException {
 
  /*
   * #############################################################################
    * ####### 1.: über: CrsDef
     */
 
    System.out.println("\n######> Alternative-1\n");
 
    CrsProjConv crsMapConv_1 = new CrsProjConv(); //
 
    boolean okSrc = crsMapConv_1.setCrsSrc(4647); // 4647
    boolean okTrg = crsMapConv_1.setCrsTrg(25832); // 31466
    boolean ok = crsMapConv_1.init();
 
    if (okSrc && okTrg && ok) {
 
      /*
       * ========================== the most cumbersome way to eliminate the zone :-))))
       */
      double cInp[] = new double[] { 32650000.0, 5590000.0 };
      double cRes[] = crsMapConv_1.doTrans(32650000.0, 5590000.0); // => 650000.0 / 5590000.0
      if (cRes != null) {
        System.out.println(String.format("%13.3f %13.3f > %13.3f %13.3f > wasWithinBounds=%b", cInp[0], cInp[1],
            cRes[0], cRes[1], crsMapConv_1.wasWithinBounds()));
      }
 
      /*
       * ============================================================== ... or to add
       */
      cInp = new double[] { 650000.0, 5590000.0 };
      cRes = crsMapConv_1.doTransInv(650000.0, 5590000.0); // => 32650000.0, 5590000.0
      if (cRes != null) {
        System.out.println(String.format("%13.3f %13.3f > %13.3f %13.3f > wasWithinBounds=%b", cInp[0], cInp[1],
            cRes[0], cRes[1], crsMapConv_1.wasWithinBounds()));
      }
 
      /*
       * =============================================================================
       */
      cInp = new double[] { 32713000.0, 5590000.0 }; // just inside
      cRes = crsMapConv_1.doTrans(32713000.0, 5590000.0);
      if (cRes != null) {
        System.out.println(String.format("just inside  : %13.3f %13.3f > %13.3f %13.3f > wasWithinBounds=%b",
            cInp[0], cInp[1], cRes[0], cRes[1], crsMapConv_1.wasWithinBounds()));
      }
 
      /*
       * =============================================================================
       */
      cInp = new double[] { 32714000.0, 5590000.0 }; // just outside
      cRes = crsMapConv_1.doTrans(cInp[0], cInp[1]); // out of bounds - but mathematically legal
      if (cRes != null) {
        System.out.println(String.format("just outside : %13.3f %13.3f > %13.3f %13.3f > wasWithinBounds=%b",
            cInp[0], cInp[1], cRes[0], cRes[1], crsMapConv_1.wasWithinBounds()));
      }
 
      /*
       * ============================================================= Check only
       */
 
      if (crsMapConv_1.isInitOk()) {
 
        cInp = new double[] { 32500000.0, 5590000.0 };
        System.out.println(String.format("SRC = %13.3f %13.3f wasWithinBounds=%b", cInp[0], cInp[1],
            crsMapConv_1.isWithinSrcBounds(cInp[0], cInp[1])));
        cInp = new double[] { 500000.0, 5590000.0 };
        System.out.println(String.format("TRG = %13.3f %13.3f wasWithinBounds=%b", cInp[0], cInp[1],
            crsMapConv_1.isWithinTrgBounds(cInp[0], cInp[1])));
 
        cInp = new double[] { 32800000.0, 5590000.0 };
        System.out.println(String.format("SRC = %13.3f %13.3f wasWithinBounds=%b", cInp[0], cInp[1],
            crsMapConv_1.isWithinSrcBounds(cInp[0], cInp[1])));
        cInp = new double[] { 800000.0, 5590000.0 };
        System.out.println(String.format("TRG = %13.3f %13.3f wasWithinBounds=%b", cInp[0], cInp[1],
            crsMapConv_1.isWithinTrgBounds(cInp[0], cInp[1])));
 
      } else {
        System.out.println("not initialized");
      }
 
      /*
       * ###################################################### 2.: über: Elli+MP+MC
       */
 
      System.out.println("\n######> Alternative-2\n");
 
      CrsProjConv crsMapConv_2 = new CrsProjConv();
 
      if (crsMapConv_2.init(7004, 16263, 9807, 8901, 16264, 9807, 8901)) {
 
        cInp = new double[] { 3600000.0, 5590000.0 }; // just outside
        cRes = crsMapConv_2.doTrans(cInp[0], cInp[1]); // out of bounds - but mathematically legal
        if (cRes != null) {
          System.out.println(String.format("%13.3f %13.3f > %13.3f %13.3f > wasWithinBounds=%b", cInp[0],
              cInp[1], cRes[0], cRes[1], crsMapConv_2.wasWithinBounds()));
        }
 
      } else {
        System.out.println("not initialized");
      }
 
      /*
       * #################################### 3.: über: Elli+MP+MC Instanzen
       */
 
      System.out.println("\n######> Alternative-3\n");
 
      CrsProjConv crsMapConv_3 = new CrsProjConv();
 
      if (crsMapConv_3.init(7004, 16264, 9807, 8901, 16263, 9807, 8901)) {
 
        cInp = new double[] { 4386906.134, 5590264.337 }; // just outside
        cRes = crsMapConv_3.doTrans(cInp[0], cInp[1]); // out of bounds - but mathematically legal
        if (cRes != null) {
          System.out.println(String.format("%13.3f %13.3f > %13.3f %13.3f > wasWithinBounds=%b", cInp[0],
              cInp[1], cRes[0], cRes[1], crsMapConv_3.wasWithinBounds()));
        }
 
      } else {
        System.out.println("not initialized");
      }
    } else {
      System.out.println(String.format("ERROR: SrcOK=%b / TrgOK=%b / OK=%b", okSrc, okTrg, ok));
    }
  }


Beispiel: LCRS Local.CRS (LDP)

  public static void main(String[] args) throws CrsException {
 
    double wcArr[][] = { 
        { 500021.305, 5949989.272 }, 
        { 480000.0, 5949989.272 }, 
        { 500021.305, 5970000.0 },
        { 520000.0, 5949989.272 }, 
        { 500021.305, 5930000.0 },
 
    }; // upper-right
 
    int crsEpsgId = 25832; // Z32: 6-digit
 
    CrsLdp crsLdp = new CrsLdp();
 
    double eMin = 1e99;
    double eMax = 1e-99;
    double nMin = 1e99;
    double nMax = 1e-99;
 
    for (double c[] : wcArr) {
      eMin = eMin < c[0] ? eMin : c[0];
      eMax = eMax > c[0] ? eMax : c[0];
      nMin = nMin < c[1] ? nMin : c[1];
      nMax = nMax > c[1] ? nMax : c[1];
    }
 
    System.out.println(String.format("UTM-KOORD           :  eMin=%12.3f  eMax=%12.3f  nMin=%12.3f  nMax=%12.3f",
        eMin, eMax, nMin, nMax));
    double eDelta = eMax - eMin;
    double nDelta = nMax - nMin;
    System.out.println(String.format("UTM-KOORD           :  eDelta=%12.3f  nDelta=%12.3f", eDelta, nDelta));
 
    CrsDefs crsDefs = crsLdp.getCrsDefs();
    CrsDef crsDef = crsDefs.get(crsEpsgId);
    Ellipsoid el = crsDefs.getEllipsoids().get(crsDef.ellipsoidID);
    MapProjection mp = crsDefs.getMapProjections().get(crsDef.mapProjID);
    PrimeMeridian pm = crsDefs.getPrimeMeridians().get(crsDef.primeMeridianID);
    ProjConv pc = crsDefs.getProjConvFactory().create(crsDef.projConvID);
    pc.initParam(el, mp, pm);
    double ll_min_rad[] = pc.inverseTransformRadians(eMin, nMin); // UntenLinks
    double ll_max_rad[] = pc.inverseTransformRadians(eMax, nMax); // ObenRechts
 
    String latMinDeg = CrsMath.conv_LatRad_To_DmshStr(ll_min_rad[0], 0);
    String latMaxDeg = CrsMath.conv_LatRad_To_DmshStr(ll_max_rad[0], 0);
    String lonMinDeg = CrsMath.conv_LatRad_To_DmshStr(ll_min_rad[1], 0);
    String lonMaxDeg = CrsMath.conv_LatRad_To_DmshStr(ll_max_rad[1], 0);
 
    System.out.println(String.format("LAT/LON MIN/MAX     : LatMin=%10s   LatMax=%10s   LonMin=%10s   LonMax=%10s",
        latMinDeg, latMaxDeg, lonMinDeg, lonMaxDeg));
 
    double latCenterRad = (ll_min_rad[0] + ll_max_rad[0]) / 2.0;
    double lonCenterRad = (ll_min_rad[1] + ll_max_rad[1]) / 2.0;
 
    String latCenterDeg = CrsMath.conv_LatRad_To_DmshStr(latCenterRad, 0);
    String lonCenterDeg = CrsMath.conv_LonRad_To_DmshStr(lonCenterRad, 0);
 
    System.out.println(String.format("CENTER LAT/LON      : LatCenter=%12.10s   LonCenter=%12.10s", latCenterDeg,
        lonCenterDeg));
 
    // manuell setzen
    latCenterDeg = "53°42'0\"N";
    lonCenterDeg = "9°0'0\"E";
 
    System.out
        .println(String.format("CENTER LAT/LON      : man. gerundet   : LatCenter=%12.10s   LonCenter=%12.10s",
            latCenterDeg, lonCenterDeg));
 
    // ... oder autmatisch runden
    int latDeg = CrsMath.conv_Rad_To_LatDegInt(latCenterRad);
    int latMin = CrsMath.conv_Rad_To_LatMinInt(latCenterRad);
    int latSec = CrsMath.conv_Rad_To_LatSecInt(latCenterRad);
    String latHem = CrsMath.conv_Rad_To_LatHem(latCenterRad);
    latMin += latSec >= 30 ? 1 : 0;
    latCenterDeg = CrsMath.conv_DMSH_To_DmshStr(latDeg, latMin, 0, latHem, 0);
 
    int lonDeg = CrsMath.conv_Rad_To_LonDegInt(lonCenterRad);
    int lonMin = CrsMath.conv_Rad_To_LonMinInt(lonCenterRad);
    int lonSec = CrsMath.conv_Rad_To_LonSecInt(lonCenterRad);
    String lonHem = CrsMath.conv_Rad_To_LonHem(latCenterRad);
    lonMin += lonSec >= 30 ? 1 : 0;
    lonCenterDeg = CrsMath.conv_DMSH_To_DmshStr(lonDeg, lonMin, 0, lonHem, 0);
 
    System.out
        .println(String.format("CENTER LAT/LON      : autom. gerundet : LatCenter=%12.10s   LonCenter=%12.10s",
            latCenterDeg, lonCenterDeg));
 
    latCenterRad = CrsMath.conv_LatDMSH_To_Rad(latCenterDeg);
    lonCenterRad = CrsMath.conv_LonDMSH_To_Rad(lonCenterDeg);
 
    double scale = crsLdp.calc_Scale(7019, 9807, latCenterDeg, lonCenterDeg, "", "", 1000.0);
    double scaleRnd = CrsMath.round(scale, 5);
    System.out
        .println(String.format("SCALE               : berechnet=%20.10f    gerundet=%20.10f", scale, scaleRnd));
 
    double falseEasting = CrsMath.calcFalseEN(eDelta);
    double falseNorthing = CrsMath.calcFalseEN(nDelta);
    System.out.println(String.format("FALSE EAST-/NORTHING: FE=%12.1f    FN=%12.1f", falseEasting, falseNorthing));
 
    CrsLdpDef ldpDef = new CrsLdpDef();
    ldpDef.setId(100);
    ldpDef.setAbbrev("DP_Oelde");
//    ldpDef.setAzimuth(...);
    ldpDef.setDesc("Lokales Sytem OELDE auf 200m ellipsoidische Höhe");
    ldpDef.setElliEpsgId(crsDef.ellipsoidID);
    ldpDef.setFalseEasting(falseEasting);
    ldpDef.setFalseNorthing(falseNorthing);
    ldpDef.setLat(latCenterDeg);
    ldpDef.setLon(lonCenterDeg);
//    ldpDef.setParNorth(...);
//    ldpDef.setParSouth(...);
    ldpDef.setProjConvEpsgId(crsDef.projConvID);
    ldpDef.setScale(scaleRnd);
//    ldpDef.setSkew(...);
    crsLdp.ldpDefAdd(ldpDef);
  }


Beispiel: NTv2 (Schweiz: LV03 > LV95(LV03+))

 public static void main(String[] args) throws CrsException {
 
    CrsNTv2R crsNtv2 = new CrsNTv2R();
 
//    String fileName = "CHENYX06_etrs.gsb"; //   LV03 > ETRS89   
    String fileName = "CHENYX06a.gsb"; // LV03 > LV95(LV03+)
    String pathFileName = "C:/dev/data/crstools/ntv2_dev/CH/00_CH/" + fileName;
 
    boolean ok = crsNtv2.init(pathFileName);
 
    if (ok) {
 
      // NTv2-FROM (nicht User-Sichtweise! NTv2-Sichtweise!)
      crsNtv2.addCrsF(21781); // = LV03
 
      // NTv2-TO (nicht User-Sichtweise! NTv2-Sichtweise!)
      crsNtv2.addCrsT(2056); // LV95
 
      // LV03 <-> LV95
      double cArr[][] = 
          {
 
              { 512685.917, 153251.375, 2512685.437, 1153251.997 },
              { 588440.201, 94368.962, 2588439.429, 1094369.005 },
              { 624028.403, 239015.162, 2624028.909, 1239015.427 },
              { 714755.683, 99258.947, 2714755.924, 1099257.907 },
              { 751330.747, 249590.652, 2751331.317, 1249590.295 },
              { 803028.014, 131610.093, 2803029.585, 1131610.039 },
              { 826151.467, 192081.414, 2826152.548, 1192081.572 },
 
          };
 
      for (double[] c : cArr) {
 
        double wc0[] = crsNtv2.doTrans(c[0], c[1]);
 
        System.out.println("");
 
        if (wc0 != null) {
          System.out.println(String.format("SRC= %13.3f %13.3f  >  TRG= %13.3f %13.3f   Diff= %7.3f %7.3f",
              c[0], c[1], wc0[0], wc0[1], c[2] - wc0[0], c[3] - wc0[1])); // IST:
        } else {
          System.out.println(String.format("SRC= %13.3f %13.3f TRG= no transformation", c[0], c[1]));
        }
 
        double wc1[] = crsNtv2.doTransInv(c[2], c[3]);
        if (wc1 != null) {
          System.out.println(String.format("SRC= %13.3f %13.3f  >  TRG= %13.3f %13.3f   Diff= %7.3f %7.3f",
              c[2], c[3], wc1[0], wc1[1], c[0] - wc1[0], c[1] - wc1[1])); // IST:
        } else {
          System.out.println(String.format("SRC= %13.3f %13.3f TRG= no transformation", c[3], c[4]));
        }
 
      }
 
    } else {
      System.out.println("ERR: crsNtv2 NOT OK!");
    }
 
  }
lib/javadoc/javadoc.txt · Last modified: 2023/07/03 18:26 by 127.0.0.1