public static double [ ] getLastVisiblePointData ( LasRecord baseRecord , List < LasRecord > lasRecords , boolean useGround ) { if ( lasRecords . size ( ) < 1 ) { throw new IllegalArgumentException ( "This needs to have at least 1 point." ) ; } double baseElev = useGround ? baseRecord . groundElevation : baseRecord . z ; Coordinate baseCoord = new Coordinate ( 0 , 0 ) ; double minAzimuthAngle = Double . POSITIVE_INFINITY ; double maxAzimuthAngle = Double . NEGATIVE_INFINITY ; LasRecord minAzimuthPoint = null ; LasRecord maxAzimuthPoint = null ; for ( int i = 0 ; i < lasRecords . size ( ) ; i ++ ) { LasRecord currentPoint = lasRecords . get ( i ) ; double currentElev = useGround ? currentPoint . groundElevation : currentPoint . z ; if ( HMConstants . isNovalue ( currentElev ) ) { continue ; } currentElev = currentElev - baseElev ; double currentProg = LasUtils . distance ( baseRecord , currentPoint ) ; Coordinate currentCoord = new Coordinate ( currentProg , currentElev ) ; double azimuth = GeometryUtilities . azimuth ( baseCoord , currentCoord ) ; if ( azimuth <= minAzimuthAngle ) { minAzimuthAngle = azimuth ; minAzimuthPoint = currentPoint ; } if ( azimuth >= maxAzimuthAngle ) { maxAzimuthAngle = azimuth ; maxAzimuthPoint = currentPoint ; } } if ( minAzimuthPoint == null || maxAzimuthPoint == null ) { return null ; } return new double [ ] { // /* */ useGround ? minAzimuthPoint . groundElevation : minAzimuthPoint . z , // minAzimuthPoint . x , // minAzimuthPoint . y , // LasUtils . distance ( baseRecord , minAzimuthPoint ) , // minAzimuthAngle , // useGround ? maxAzimuthPoint . groundElevation : maxAzimuthPoint . z , // maxAzimuthPoint . x , // maxAzimuthPoint . y , // LasUtils . distance ( baseRecord , maxAzimuthPoint ) , // maxAzimuthAngle , // } ; }
Return last visible point data for a las records points list from a given position .