Avatar

CoordTrans im Batch-Modus (Software)

Micha ⌂, Bad Vilbel, Samstag, 03. Februar 2018, 21:50 (vor 15 Tagen) @ Axel Wagner

Hi Axel,

ich habe das CMD-File für CoordTrans erweitert, sodass nun die 6-Parameter, die Helmert und die Affintransformation im Raum unterstützt werden: CoordTransConsole.zip

Ist das so korrekt? :-)

Ich habs einfach mal übernommen, siehe unten.

Viele Grüße
Micha


 /**********************************************************************
 *                       CoordTransConsole                              *
 ************************************************************************
 * Copyright (C) by Michael Loesler, http//derletztekick.com            *
 *                                                                      *
 * This program is free software; you can redistribute it and/or modify *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation; either version 3 of the License, or    *
 * (at your option) any later version.                                  *
 *                                                                      *
 * This program is distributed in the hope that it will be useful,      *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with this program; if not, see <http://www.gnu.org/licenses/>  *
 * or write to the                                                      *
 * Free Software Foundation, Inc.,                                      *
 * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.            *
 *                                                                      *
 **********************************************************************/
package com.derletztekick.geodesy.coordtrans.batch;
 
import java.io.File;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Set;
 
import com.derletztekick.geodesy.coordtrans.v2.gui.TransformationManager;
import com.derletztekick.geodesy.coordtrans.v2.io.PointFileReader;
import com.derletztekick.geodesy.coordtrans.v2.point.group.PointGroup;
import com.derletztekick.geodesy.coordtrans.v2.transformation.Transformation;
import com.derletztekick.geodesy.coordtrans.v2.transformation.Transformation2D;
import com.derletztekick.geodesy.coordtrans.v2.transformation.Transformation3D;
 
public class CoordTransConsole {
 
 /**
  * @param args
  */
 public static void main(String[] args) {
  System.setProperty("com.github.fommil.netlib.BLAS",   "com.github.fommil.netlib.F2jBLAS");
  System.setProperty("com.github.fommil.netlib.LAPACK", "com.github.fommil.netlib.F2jLAPACK");
  System.setProperty("com.github.fommil.netlib.ARPACK", "com.github.fommil.netlib.F2jARPACK");
 
  if (args.length < 4) {
   System.err.println("Fehler, benoetige vier Parameter fuer eine Transformation\n- 3PARAM2D/HELMERT2D/AFFIN2D/6PARAM3D/HELMERT3D/AFFIN3D\n- SRC-FILE\n- TRG-FILE\n- REPORT");
   return;
  }
  int dim = 2;
  String TYPE = args[0].trim();
 
  switch(TYPE.toUpperCase()) {
  case "3PARAM2D":
  case "HELMERT2D":
  case "AFFIN2D":
   dim = 2;
   break;
  case "6PARAM3D":
  case "HELMERT3D":
  case "AFFIN3D":
   dim = 3;
   break;
  }
 
  File srcFile = new File(args[1]);
  File trgFile = new File(args[2]);
  File report  = new File(args[3]);
 
  TransformationManager transformationManager = new TransformationManager(null, Locale.GERMAN);
  PointFileReader srcReader = new PointFileReader(srcFile, dim);
  PointFileReader trgReader = new PointFileReader(trgFile, dim);
 
  srcReader.ignoreLinesWhichStartWith("#");
  trgReader.ignoreLinesWhichStartWith("#");
 
  if (srcReader.readSourceFile() && trgReader.readSourceFile()) {
   PointGroup srcGroup = srcReader.getPoints();
   PointGroup trgGroup = trgReader.getPoints();
 
   transformationManager.setDimension(dim);
   transformationManager.setSourcePointGroup(srcGroup);
   transformationManager.setTargetPointGroup(trgGroup);
 
   // Restriktionen
   Set<Integer> restrictionSet = new LinkedHashSet<Integer>(); 
   if (TYPE.equalsIgnoreCase("3PARAM2D")) {
    restrictionSet.add(Transformation2D.FIXED_SHEAR);
    restrictionSet.add(Transformation2D.FIXED_SCALE_X);
    restrictionSet.add(Transformation2D.FIXED_SCALE_Y);
   }
   else if (TYPE.equalsIgnoreCase("HELMERT2D")) {
    restrictionSet.add(Transformation2D.FIXED_SHEAR);
    restrictionSet.add(Transformation2D.IDENT_SCALES_XY);
   }
   else if (TYPE.equalsIgnoreCase("6PARAM3D")) {
    restrictionSet.add(Transformation3D.FIXED_SHEAR_X);
    restrictionSet.add(Transformation3D.FIXED_SHEAR_Y);
    restrictionSet.add(Transformation3D.FIXED_SHEAR_Z);
    restrictionSet.add(Transformation3D.FIXED_SCALE_X);
    restrictionSet.add(Transformation3D.FIXED_SCALE_Y);
    restrictionSet.add(Transformation3D.FIXED_SCALE_Z);
   }
   else if (TYPE.equalsIgnoreCase("HELMERT3D")) {
    restrictionSet.add(Transformation3D.FIXED_SHEAR_X);
    restrictionSet.add(Transformation3D.FIXED_SHEAR_Y);
    restrictionSet.add(Transformation3D.FIXED_SHEAR_Z);
    restrictionSet.add(Transformation3D.IDENT_SCALES_XY);
    restrictionSet.add(Transformation3D.IDENT_SCALES_YZ);
   }
   transformationManager.setRestrictionSet(restrictionSet);
   transformationManager.adjustUnknownParametersOnly(false);
   Transformation transformation = transformationManager.createTransformation();
 
   int status = transformation.estimateModel();
   System.out.println(status==1?"\n\nBerechnung erfolgreich!":"\n\nBerechnung nicht erfolgreich!");
   transformationManager.exportTransformedPointsToFile(report);
   for (int i=0; i<transformation.getParameterNames().length; i++) 
    System.out.println(transformation.getParameterNames()[i] + " = " + transformation.getEstimatedParameters()[i]);
 
  }
  else {
   System.err.println("Fehler beim Einlesen der Dateien. Bitte Dateipfad pruefen!");
  }
 }
}

--
kostenlose Scripte und Software nicht nur für Geodäten || Portal für Geodäten mit angeschlossenem Forum-Vermessung

Tags:
Helmert, java, CoordTrans, Transformation, Batch, Affin


gesamter Thread:

 RSS-Feed dieser Diskussion