use of org.geotools.geometry.jts.ReferencedEnvelope3D in project hortonmachine by TheHortonMachine.
the class LasInfoController method getHeaderInfo.
private List<String[]> getHeaderInfo(ILasHeader header) {
List<String[]> headerInfoList = new ArrayList<>();
headerInfoList.add(new String[] { "File signature", new String(header.getFileSignature()) });
headerInfoList.add(new String[] { "File source ID", "" + header.getFileSourceID() });
headerInfoList.add(new String[] { "Project ID - data 1", "" + header.getProjectID_GUIDData1() });
headerInfoList.add(new String[] { "Project ID - data 2", "" + header.getProjectID_GUIDData2() });
headerInfoList.add(new String[] { "Project ID - data 3", "" + header.getProjectID_GUIDData3() });
headerInfoList.add(new String[] { "Project ID - data 4", new String(header.getProjectID_GUIDData4()) });
headerInfoList.add(new String[] { "Version", header.getVersion() });
headerInfoList.add(new String[] { "System identifier", new String(header.getSystemIdentifier()) });
headerInfoList.add(new String[] { "Generating software", header.getGeneratingSoftware() });
try {
short fileCreationYear = (short) header.getFileCreationYear();
short fileCreationDayOfYear = (short) header.getFileCreationDayOfYear();
String dtString = " - nv - ";
if (fileCreationYear != 0 && fileCreationDayOfYear != 0) {
DateTime dateTime = new DateTime();
dateTime = dateTime.withYear(fileCreationYear).withDayOfYear(fileCreationDayOfYear);
dtString = dateTime.toString(LasUtils.dateTimeFormatterYYYYMMDD);
}
headerInfoList.add(new String[] { "File creation date", dtString });
} catch (Exception e) {
e.printStackTrace();
}
//
headerInfoList.add(new String[] { "Header size", "" + header.getHeaderSize() });
//
headerInfoList.add(new String[] { "Offset to data", "" + header.getOffset() });
//
headerInfoList.add(new String[] { "Variable length records", "" + header.getNumberOfVariableLengthRecords() });
//
headerInfoList.add(new String[] { "Point data format ID (0-99 for spec)", "" + header.getPointDataRecordFormat() });
//
headerInfoList.add(new String[] { "Number of point records", "" + header.getRecordsCount() });
//
headerInfoList.add(new String[] { "Record length", "" + header.getRecordLength() });
double[] xyzScale = header.getXYZScale();
headerInfoList.add(new String[] { "Scale", xyzScale[0] + ", " + xyzScale[1] + ", " + xyzScale[2] });
double[] xyzOffset = header.getXYZOffset();
headerInfoList.add(new String[] { "Offset", xyzOffset[0] + ", " + xyzOffset[1] + ", " + xyzOffset[2] });
ReferencedEnvelope3D dataEnvelope3D = header.getDataEnvelope();
headerInfoList.add(new String[] { "X Range", dataEnvelope3D.getMinX() + ", " + dataEnvelope3D.getMaxX() });
headerInfoList.add(new String[] { "Y Range", dataEnvelope3D.getMinY() + ", " + dataEnvelope3D.getMaxY() });
headerInfoList.add(new String[] { "Z Range", dataEnvelope3D.getMinZ() + ", " + dataEnvelope3D.getMaxZ() });
return headerInfoList;
}
use of org.geotools.geometry.jts.ReferencedEnvelope3D in project hortonmachine by TheHortonMachine.
the class LasElevationHandler method process.
@Execute
public void process() throws Exception {
checkNull(inFile, inDtm);
GridCoverage2D dtm = getRaster(inDtm);
File inLas = new File(inFile);
try (ALasReader reader = ALasReader.getReader(inLas, null)) {
reader.open();
ILasHeader header = reader.getHeader();
long recordsNum = header.getRecordsCount();
ReferencedEnvelope3D env = header.getDataEnvelope();
File outLas = new File(outFile);
try (ALasWriter writer = ALasWriter.getWriter(outLas, env.getCoordinateReferenceSystem())) {
writer.setBounds(header);
writer.open();
pm.beginTask("Normalizing las...", (int) recordsNum);
while (reader.hasNextPoint()) {
LasRecord dot = reader.getNextPoint();
double dtmValue = CoverageUtilities.getValue(dtm, dot.x, dot.y);
if (HMConstants.isNovalue(dtmValue)) {
dtmValue = 0;
}
if (doAdd) {
dot.z += dtmValue;
} else {
dot.z -= dtmValue;
}
writer.addPoint(dot);
pm.worked(1);
}
pm.done();
}
}
}
use of org.geotools.geometry.jts.ReferencedEnvelope3D in project hortonmachine by TheHortonMachine.
the class OmsPointCloudMaximaFinderStream method main.
public static void main(String[] args) throws Exception {
String lasPath = "/media/hydrologis/LESTOPLUS/test_lidar_spatialite/las_aurina/uni_bz_44.las";
String outPath = "/home/hydrologis/TMP/tops_2m.asc";
OmsPointCloudMaximaFinderStream s = new OmsPointCloudMaximaFinderStream();
List<LasRecord> dotList = new ArrayList<>();
try (ALasReader reader = ALasReader.getReader(new File(lasPath), null)) {
reader.open();
while (reader.hasNextPoint()) {
LasRecord dot = (LasRecord) reader.getNextPoint();
dotList.add(dot);
}
s.inLas = dotList;
ReferencedEnvelope3D dataEnvelope = reader.getHeader().getDataEnvelope();
s.aoi = new ReferencedEnvelope(dataEnvelope);
s.pBaseGridResolution = 0.5;
s.pMaxRadius = 2;
s.process();
OmsRasterWriter.writeRaster(outPath, s.outCoverage);
}
}
use of org.geotools.geometry.jts.ReferencedEnvelope3D in project hortonmachine by TheHortonMachine.
the class LasMerger method process.
@Execute
public void process() throws Exception {
checkNull(inFolder, outLas);
CoordinateReferenceSystem crs = null;
File inFolderFile = new File(inFolder);
File[] lasList = inFolderFile.listFiles(new FilenameFilter() {
public boolean accept(File arg0, String arg1) {
return arg1.toLowerCase().endsWith(".las");
}
});
StringBuilder sb = new StringBuilder("Merging files:");
for (File file : lasList) {
sb.append("\n").append(file.getAbsolutePath());
}
pm.message(sb.toString());
// create readers and calculate bounds
List<ALasReader> readers = new ArrayList<ALasReader>();
double xMin = Double.POSITIVE_INFINITY;
double yMin = Double.POSITIVE_INFINITY;
double zMin = Double.POSITIVE_INFINITY;
double xMax = Double.NEGATIVE_INFINITY;
double yMax = Double.NEGATIVE_INFINITY;
double zMax = Double.NEGATIVE_INFINITY;
int count = 0;
for (File lasFile : lasList) {
ALasReader reader = ALasReader.getReader(lasFile, crs);
reader.open();
ILasHeader header = reader.getHeader();
long recordsNum = header.getRecordsCount();
count = (int) (count + recordsNum);
ReferencedEnvelope3D envelope = header.getDataEnvelope();
xMin = min(xMin, envelope.getMinX());
yMin = min(yMin, envelope.getMinY());
zMin = min(zMin, envelope.getMinZ());
xMax = max(xMax, envelope.getMaxX());
yMax = max(yMax, envelope.getMaxY());
zMax = max(zMax, envelope.getMaxZ());
readers.add(reader);
}
File outFile = new File(outLas);
ALasWriter writer = ALasWriter.getWriter(outFile, crs);
writer.setBounds(xMin, xMax, yMin, yMax, zMin, zMax);
writer.open();
pm.beginTask("Merging...", count);
for (ALasReader reader : readers) {
while (reader.hasNextPoint()) {
LasRecord readNextLasDot = reader.getNextPoint();
writer.addPoint(readNextLasDot);
pm.worked(1);
}
reader.close();
}
writer.close();
pm.done();
}
use of org.geotools.geometry.jts.ReferencedEnvelope3D in project hortonmachine by TheHortonMachine.
the class LasSplitter method process.
@SuppressWarnings("unchecked")
@Execute
public void process() throws Exception {
checkNull(inFile);
File inLas = new File(inFile);
String lasName = FileUtilities.getNameWithoutExtention(inLas);
try (ALasReader reader = ALasReader.getReader(inLas, null)) {
reader.open();
ILasHeader header = reader.getHeader();
long recordsNum = header.getRecordsCount();
double[] xyzScale = header.getXYZScale();
double[] xyzOffset = header.getXYZOffset();
ReferencedEnvelope3D env = header.getDataEnvelope();
double[] xRange = NumericsUtilities.range2Bins(env.getMinX(), env.getMaxX(), pCols);
double[] yRange = NumericsUtilities.range2Bins(env.getMinY(), env.getMaxY(), pRows);
STRtree envelopeTree = new STRtree();
HashMap<Envelope, ALasWriter> env2LaswriterMap = new HashMap<>();
int fileCount = 1;
for (int x = 0; x < xRange.length - 1; x++) {
double minX = xRange[x];
double maxX = xRange[x + 1];
for (int y = 0; y < yRange.length - 1; y++) {
double minY = yRange[y];
double maxY = yRange[y + 1];
Envelope envelope = new Envelope(new Coordinate(minX, minY), new Coordinate(maxX, maxY));
File outLasPiece = new File(inLas.getParentFile(), lasName + "_" + fileCount + ".las");
ALasWriter writer = ALasWriter.getWriter(outLasPiece, env.getCoordinateReferenceSystem());
writer.setOffset(xyzOffset[0], xyzOffset[1], xyzOffset[2]);
writer.setScales(xyzScale[0], xyzScale[1], xyzScale[2]);
writer.setBounds(minX, maxX, minY, maxY, env.getMinZ(), env.getMaxZ());
writer.open();
envelopeTree.insert(envelope, writer);
env2LaswriterMap.put(envelope, writer);
fileCount++;
}
}
pm.beginTask("Split file...", (int) recordsNum);
while (reader.hasNextPoint()) {
LasRecord dot = reader.getNextPoint();
Coordinate coord = new Coordinate(dot.x, dot.y);
List<ALasWriter> result = envelopeTree.query(new Envelope(coord));
int size = result.size();
if (size == 0) {
continue;
}
ALasWriter aLasWriter = result.get(0);
aLasWriter.addPoint(dot);
pm.worked(1);
}
pm.done();
for (ALasWriter writer : env2LaswriterMap.values()) {
writer.close();
}
}
}
Aggregations