Class LasUtils
- java.lang.Object
-
- org.hortonmachine.gears.io.las.utils.LasUtils
-
public class LasUtils extends Object
Utilities for Las handling classes.- Author:
- Andrea Antonello (www.hydrologis.com)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLasUtils.VALUETYPE
-
Field Summary
Fields Modifier and Type Field Description static StringCLASSIFICATIONstatic org.joda.time.format.DateTimeFormatterdateTimeFormatterYYYYMMDDstatic StringdateTimeFormatterYYYYMMDD_stringstatic StringELEVATIONstatic StringIDstatic StringIMPULSEstatic StringINTENSITYstatic StringNUM_OF_IMPULSESstatic StringTHE_GEOM
-
Constructor Summary
Constructors Constructor Description LasUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.joda.time.DateTimeadjustedStandardGpsTime2DateTime(double adjustedStandardGpsTime)Converts las adjusted standard gps time toDateTime.static doubleavg(List<LasRecord> points, LasUtils.VALUETYPE valueType)Calculate the avg of a value in a list ofLasRecords.static LasRecordclone(LasRecord lasRecord)Clone aLasRecord.static doubledateTimeToStandardGpsTime(org.joda.time.DateTime dateTime)Converts an date object to standard gps time.static doubledistance(LasRecord r1, LasRecord r2)Projected distance between two points.static doubledistance3D(LasRecord r1, LasRecord r2)Distance between two points.static voiddumpLasFolderOverview(String folder, org.opengis.referencing.crs.CoordinateReferenceSystem crs)Dump an overview shapefile for a las folder.static org.geotools.feature.simple.SimpleFeatureBuildergetLasFeatureBuilder(org.opengis.referencing.crs.CoordinateReferenceSystem crs)Creates a builder for las data.static StringgetLasFileVersion(File lasFile)Read just the version bytes from a las file.static List<LasRecord>getLasRecordsFromFeatureCollection(org.geotools.data.simple.SimpleFeatureCollection lasCollection, boolean elevIsGround)Create aLasRecordfrom a collection.static double[]getLastVisiblePointData(LasRecord baseRecord, List<LasRecord> lasRecords, boolean useGround)Return last visible point data for a las records points list from a given position.static double[][]histogram(List<LasRecord> points, LasUtils.VALUETYPE valueType, int bins)Calculate the histogram of a list ofLasRecords.static booleanlasRecordEqual(LasRecord dot1, LasRecord dot2)Compare twoLasRecords.static StringlasRecordToString(LasRecord dot)String representation for aLasRecord.static voidsmoothIDW(List<LasRecord> lasPoints, boolean useGround, double idwBuffer, IHMProgressMonitor pm)Smooths a set of las points through the IDW method.static org.opengis.feature.simple.SimpleFeaturetofeature(LasRecord r, Integer featureId, org.opengis.referencing.crs.CoordinateReferenceSystem crs)Convert a record to a feature.static org.locationtech.jts.geom.PointtoGeometry(LasRecord r)static List<org.locationtech.jts.geom.Geometry>triangulate(List<LasRecord> lasPoints, Double elevThres, boolean useGround, IHMProgressMonitor pm)Triangulates a set of las points.
-
-
-
Field Detail
-
THE_GEOM
public static final String THE_GEOM
- See Also:
- Constant Field Values
-
ID
public static final String ID
- See Also:
- Constant Field Values
-
ELEVATION
public static final String ELEVATION
- See Also:
- Constant Field Values
-
INTENSITY
public static final String INTENSITY
- See Also:
- Constant Field Values
-
CLASSIFICATION
public static final String CLASSIFICATION
- See Also:
- Constant Field Values
-
IMPULSE
public static final String IMPULSE
- See Also:
- Constant Field Values
-
NUM_OF_IMPULSES
public static final String NUM_OF_IMPULSES
- See Also:
- Constant Field Values
-
dateTimeFormatterYYYYMMDD_string
public static String dateTimeFormatterYYYYMMDD_string
-
dateTimeFormatterYYYYMMDD
public static org.joda.time.format.DateTimeFormatter dateTimeFormatterYYYYMMDD
-
-
Method Detail
-
getLasFileVersion
public static String getLasFileVersion(File lasFile) throws IOException
Read just the version bytes from a las file.This can be handy is one needs to choose version reader.
- Parameters:
lasFile- the las file to check.- Returns:
- the version string as "major.minor" .
- Throws:
IOException
-
getLasFeatureBuilder
public static org.geotools.feature.simple.SimpleFeatureBuilder getLasFeatureBuilder(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
Creates a builder for las data. The attributes are:- the_geom: a point geometry
- elev
- intensity
- classification
- impulse
- numimpulse
- Parameters:
crs- theCoordinateReferenceSystem.- Returns:
- the
builder.
-
tofeature
public static org.opengis.feature.simple.SimpleFeature tofeature(LasRecord r, Integer featureId, org.opengis.referencing.crs.CoordinateReferenceSystem crs)
Convert a record to a feature.- Parameters:
r- the record to convert.featureId- an optional feature id, if not available, the id is set to -1.crs- the crs to apply.- Returns:
- the feature.
-
toGeometry
public static org.locationtech.jts.geom.Point toGeometry(LasRecord r)
-
getLasRecordsFromFeatureCollection
public static List<LasRecord> getLasRecordsFromFeatureCollection(org.geotools.data.simple.SimpleFeatureCollection lasCollection, boolean elevIsGround)
Create aLasRecordfrom a collection.The collection has to be created with the methods of this class previously, else some fields will be missing.
- Parameters:
lasCollection- the collection to convert.elevIsGround- iftrue, the elevation is the ground height.- Returns:
- the list of las records.
-
adjustedStandardGpsTime2DateTime
public static org.joda.time.DateTime adjustedStandardGpsTime2DateTime(double adjustedStandardGpsTime)
Converts las adjusted standard gps time toDateTime.- Parameters:
adjustedStandardGpsTime- the time value.- Returns:
- the UTC date object.
-
dateTimeToStandardGpsTime
public static double dateTimeToStandardGpsTime(org.joda.time.DateTime dateTime)
Converts an date object to standard gps time.- Parameters:
dateTime- the object (UTC).- Returns:
- the standard gps time in seconds.
-
dumpLasFolderOverview
public static void dumpLasFolderOverview(String folder, org.opengis.referencing.crs.CoordinateReferenceSystem crs) throws Exception
Dump an overview shapefile for a las folder.- Parameters:
folder- the folder.crs- the crs to use.- Throws:
Exception
-
distance
public static double distance(LasRecord r1, LasRecord r2)
Projected distance between two points.- Parameters:
r1- the first point.r2- the second point.- Returns:
- the 2D distance.
-
distance3D
public static double distance3D(LasRecord r1, LasRecord r2)
Distance between two points.- Parameters:
r1- the first point.r2- the second point.- Returns:
- the 3D distance.
-
lasRecordToString
public static String lasRecordToString(LasRecord dot)
String representation for aLasRecord.- Parameters:
dot- the record to convert.- Returns:
- the string.
-
lasRecordEqual
public static boolean lasRecordEqual(LasRecord dot1, LasRecord dot2)
Compare twoLasRecords.- Parameters:
dot1- the first record.dot2- the second record.- Returns:
true, if the records are the same.
-
avg
public static double avg(List<LasRecord> points, LasUtils.VALUETYPE valueType)
Calculate the avg of a value in a list ofLasRecords.- Parameters:
points- the records.valueType- the value to consider.- Returns:
- the avg.
-
histogram
public static double[][] histogram(List<LasRecord> points, LasUtils.VALUETYPE valueType, int bins)
Calculate the histogram of a list ofLasRecords.- Parameters:
points- the list of points.valueType- the value to consider.bins- the number of bins.- Returns:
- the histogram as matrix of rows num like bins and 3 columns for [binCenter, count, cummulated-normalize-count].
-
triangulate
public static List<org.locationtech.jts.geom.Geometry> triangulate(List<LasRecord> lasPoints, Double elevThres, boolean useGround, IHMProgressMonitor pm)
Triangulates a set of las points.If a threshold is supplied, a true dsm filtering is also applied.
- Parameters:
lasPoints- the list of points.elevThres- the optional threshold for true dsm calculation.useGround- use the ground elevation instead of z.pm- the monitor.- Returns:
- the list of triangles.
-
smoothIDW
public static void smoothIDW(List<LasRecord> lasPoints, boolean useGround, double idwBuffer, IHMProgressMonitor pm)
Smooths a set of las points through the IDW method.Note that the values in the original data are changed.
- Parameters:
lasPoints- the list of points to smooth.useGround- iftrue, the ground elev is smoothed instead of the z.idwBuffer- the buffer around the points to consider for smoothing.pm- the monitor.
-
getLastVisiblePointData
public static double[] getLastVisiblePointData(LasRecord baseRecord, List<LasRecord> lasRecords, boolean useGround)
Return last visible point data for a las records points list from a given position.For the profile the min and max angles of "sight" are calculated. The min azimuth angle represents the "upper" line of sight, as thought from the zenith.
The max azimuth angle represents the "below the earth" line of sight (think of a viewer looking in direction nadir).
The return values are in an array of doubles containing:
- [0] min point elev,
- [1] min point x,
- [2] min point y,
- [3] min point progressive,
- [4] min point azimuth,
- [5] max point elev,
- [6] max point x,
- [7] max point y,
- [8] max point progressive,
- [9] max point azimuth
- Parameters:
baseRecord- the record to use as center point.lasRecords- theLasRecordpoints sorted by nearest from the center dot.useGround- iftrue, use the ground info instead of z elevation.- Returns:
- the last visible point parameters.
-
-