Skip to content
Snippets Groups Projects
Verified Commit ac86caaa authored by philippe.verley_ird.fr's avatar philippe.verley_ird.fr Committed by philippe.verley_ird.fr
Browse files

PointsToShot.java: better handles error when parsing trajectory file.

parent 7331d8bd
No related branches found
No related tags found
No related merge requests found
......@@ -69,7 +69,7 @@ public class PointsToShot extends Process implements IterableWithException<Shot>
}
public void init() throws Exception {
// read LAS / LAZ points
lasPoints = readALSPoints(inputFile);
......@@ -210,11 +210,25 @@ public class PointsToShot extends Process implements IterableWithException<Shot>
while ((line = reader.readLine()) != null) {
fireProgress("Reading trajectory file " + file.getName(), count++, nPoint);
String[] lineSplit = line.split(file.getColumnSeparator());
points.add(new TrajectoryPoint(
Double.valueOf(lineSplit[eastingIndex]),
Double.valueOf(lineSplit[northingIndex]),
Double.valueOf(lineSplit[elevationIndex]),
Double.valueOf(lineSplit[timeIndex])));
if (lineSplit.length < 4) {
StringBuilder msg = new StringBuilder();
msg.append("Line ").append(count).append(" from trajectory file has less than four columns. The point is discarded.");
msg.append('\n').append(line);
LOGGER.warn(msg);
continue;
}
try {
double easting = Double.valueOf(lineSplit[eastingIndex]);
double northing = Double.valueOf(lineSplit[northingIndex]);
double elevation = Double.valueOf(lineSplit[elevationIndex]);
double time = Double.valueOf(lineSplit[timeIndex]);
points.add(new TrajectoryPoint(easting, northing, elevation, time));
} catch (NumberFormatException ex) {
StringBuilder msg = new StringBuilder();
msg.append("Failed to parse line ").append(count).append(" from trajectory file (number format error). The point is discarded.");
msg.append('\n').append(line);
LOGGER.warn(msg);
}
}
LOGGER.info("Sorting and trimming trajectory points");
......@@ -243,7 +257,7 @@ public class PointsToShot extends Process implements IterableWithException<Shot>
// shot origin, apply transformation
Point3d origin = findOrigin(lasPoint);
vopMatrix.transform(origin);
// shot direction
Vector3d direction = new Vector3d(point);
direction.sub(origin);
......@@ -406,7 +420,7 @@ public class PointsToShot extends Process implements IterableWithException<Shot>
// check collinearity
return Math.abs(1.d - Math.abs(AB.dot(AC))) < epsilon;
}
private Point3d toPoint3d(LasPoint point) {
return new Point3d(point.x, point.y, point.z);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment