use of org.hortonmachine.gui.utils.executor.ExecutorProgressGui in project hortonmachine by TheHortonMachine.
the class LasInfoController method exportAction.
private void exportAction(File saveFile) {
String outputFilePath = saveFile.getAbsolutePath();
if (!outputFilePath.toLowerCase().endsWith(".las") && !outputFilePath.toLowerCase().endsWith(".shp")) {
JOptionPane.showMessageDialog(LasInfoController.this, "Only conversion to las and shp is supported.", "ERROR", JOptionPane.ERROR_MESSAGE);
return;
}
ILasHeader header = lasReader.getHeader();
long recordsCount = header.getRecordsCount();
int work = (int) (recordsCount / 1000);
new ExecutorProgressGui(work * 2) {
@Override
public void backGroundWork() throws Exception {
constraints.applyConstraints(lasReader, true, this);
List<LasRecord> filteredPoints = constraints.getFilteredPoints();
publish(new ProgressUpdate("Now writing to file...", work + work / 2));
if (outputFilePath.toLowerCase().endsWith(".las")) {
ALasWriter lasWriter = Las.getWriter(new File(outputFilePath), header.getCrs());
Envelope fEnv = constraints.getFilteredEnvelope();
double[] stats = constraints.getStats();
lasWriter.setBounds(lasReader.getHeader());
lasWriter.setBounds(fEnv.getMinX(), fEnv.getMaxX(), fEnv.getMinY(), fEnv.getMaxY(), stats[0], stats[1]);
lasWriter.open();
filteredPoints.stream().forEach(lr -> {
try {
lasWriter.addPoint(lr);
} catch (IOException e) {
e.printStackTrace();
}
});
lasWriter.close();
} else if (outputFilePath.toLowerCase().endsWith(".shp")) {
DefaultFeatureCollection fc = new DefaultFeatureCollection();
int count = 0;
for (LasRecord lr : filteredPoints) {
SimpleFeature feature = LasUtils.tofeature(lr, count++, header.getCrs());
fc.add(feature);
}
OmsVectorWriter.writeVector(outputFilePath, fc);
}
done();
}
}.execute();
}
use of org.hortonmachine.gui.utils.executor.ExecutorProgressGui in project hortonmachine by TheHortonMachine.
the class LasInfoController method loadDataAction.
private void loadDataAction() {
ILasHeader header = lasReader.getHeader();
long recordsCount = header.getRecordsCount();
int work = (int) (recordsCount / 1000);
new ExecutorProgressGui(work) {
@Override
public void backGroundWork() throws Exception {
constraints.applyConstraints(lasReader, true, this);
// done();
}
}.execute();
}
use of org.hortonmachine.gui.utils.executor.ExecutorProgressGui in project hortonmachine by TheHortonMachine.
the class LasInfoController method createOverviewAction.
private void createOverviewAction(File saveFile) {
String outputFilePath = saveFile.getAbsolutePath();
ILasHeader header = lasReader.getHeader();
long recordsCount = header.getRecordsCount();
int work = (int) (recordsCount / 1000);
new ExecutorProgressGui(work * 2) {
@Override
public void backGroundWork() throws Exception {
constraints.applyConstraints(lasReader, true, this);
publish(new ProgressUpdate("Getting bounds...", work + work / 2));
Envelope filteredEnvelope = constraints.getFilteredEnvelope();
Polygon polygon = GeometryUtilities.createPolygonFromEnvelope(filteredEnvelope);
polygon.setUserData("Overview for " + lasReader.getLasFile().getName());
SimpleFeatureCollection fc = FeatureUtilities.featureCollectionFromGeometry(header.getCrs(), polygon);
String f = outputFilePath;
if (!f.toLowerCase().endsWith(".shp"))
f = f + ".shp";
OmsVectorWriter.writeVector(f, fc);
done();
}
}.execute();
}
Aggregations