├── .github ├── FUNDING.yml ├── dependabot.yml └── workflows │ ├── maven.yml │ └── codeql.yml ├── src ├── test │ ├── resources │ │ ├── extra-bytes.las │ │ ├── record-format-7.laz │ │ ├── record-format-8.laz │ │ ├── 2019_saipan_waveform.laz │ │ └── 500m_5460_59370_IM2023_subset.laz │ └── java │ │ └── com │ │ └── github │ │ └── mreutegg │ │ └── laszip4j │ │ ├── laslib │ │ ├── LASreadOpenerTest.java │ │ └── LASwriterLASTest.java │ │ ├── CstdlibTest.java │ │ ├── laszip │ │ ├── MyDefsTest.java │ │ └── MultiMMappedDataInputTest.java │ │ └── LASReaderPerformanceTest.java └── main │ └── java │ └── com │ └── github │ └── mreutegg │ └── laszip4j │ ├── laszip │ ├── LASreadItem.java │ ├── LASwriteItem.java │ ├── LAScontextBYTE14.java │ ├── LASreadItemCompressed.java │ ├── LASwriteItemRaw_GPSTIME11.java │ ├── LASwriteItemRaw_RGB12.java │ ├── LASwriteItemCompressed.java │ ├── LASwriteItemRaw_RGBNIR14.java │ ├── LASreadItemRaw.java │ ├── LASwriteItemRaw_BYTE.java │ ├── IByteStreamInProvider.java │ ├── LASwriteItemRaw.java │ ├── LAScontextRGB14.java │ ├── LASwriteItemCompressed_RGB12_v1.java │ ├── LASwriteItemCompressed_RGB12_v2.java │ ├── LASwriteItemCompressed_RGB14_v3.java │ ├── LASwriteItemCompressed_RGB14_v4.java │ ├── LASwriteItemCompressed_POINT10_v1.java │ ├── LASwriteItemCompressed_POINT10_v2.java │ ├── LASwriteItemCompressed_POINT14_v3.java │ ├── LASwriteItemCompressed_POINT14_v4.java │ ├── LASwriteItemCompressed_BYTE_v1.java │ ├── LASwriteItemCompressed_BYTE_v2.java │ ├── LASwriteItemCompressed_RGBNIR14_v3.java │ ├── LASwriteItemCompressed_RGBNIR14_v4.java │ ├── LASwriteItemCompressed_BYTE14_v3.java │ ├── LASwriteItemCompressed_BYTE14_v4.java │ ├── LASwriteItemCompressed_GPSTIME11_v1.java │ ├── LASwriteItemCompressed_GPSTIME11_v2.java │ ├── LASwriteItemCompressed_WAVEPACKET13_v1.java │ ├── LASwriteItemCompressed_WAVEPACKET14_v3.java │ ├── LASwriteItemCompressed_WAVEPACKET14_v4.java │ ├── LASreadItemRaw_BYTE.java │ ├── LAScontextWAVEPACKET14.java │ ├── UncheckedEOFException.java │ ├── LASintervalCell.java │ ├── LAScontextRGBNIR14.java │ ├── LASreadItemRaw_GPSTIME11.java │ ├── MutableInteger.java │ ├── LASreadItemRaw_RGB12.java │ ├── LASreadItemRaw_RGBNIR14.java │ ├── LASwriteItemRaw_POINT10.java │ ├── LASwriteItemRaw_WAVEPACKET13.java │ ├── LASwriteItemRaw_POINT14.java │ ├── LASreadItemRaw_POINT10.java │ ├── LASreadItemRaw_WAVEPACKET13.java │ ├── U32I32F32.java │ ├── LASreadItemRaw_POINT14.java │ ├── U64I64F64.java │ ├── LASreadItemCompressed_BYTE_v1.java │ ├── LASquantizer.java │ ├── LASintervalStartCell.java │ ├── LAScontextPOINT14.java │ ├── ByteStreamOutOstream.java │ ├── ByteStreamInStream.java │ ├── LASreadItemCompressed_BYTE_v2.java │ ├── ByteStreamIn.java │ ├── LASreadItemCompressed_RGB12_v1.java │ ├── Common_v2.java │ ├── ByteStreamOutDataOutput.java │ ├── StreamingMedian5.java │ ├── ByteStreamOut.java │ ├── ByteStreamInDataInput.java │ ├── ByteStreamInArray.java │ ├── MyDefs.java │ └── LASitem.java │ ├── laslib │ ├── LASwaveformDescription.java │ ├── LASreaderASCreoffset.java │ ├── LASreaderASCrescale.java │ ├── LASreaderBILreoffset.java │ ├── LASreaderBILrescale.java │ ├── LASreaderBINreoffset.java │ ├── LASreaderBINrescale.java │ ├── LASreaderDTMreoffset.java │ ├── LASreaderDTMrescale.java │ ├── LASreaderLASrescale.java │ ├── LASreaderSHPreoffset.java │ ├── LASreaderSHPrescale.java │ ├── LASreaderQFITreoffset.java │ ├── LASreaderQFITrescale.java │ ├── LASreaderBINrescalereoffset.java │ ├── LASreaderASCrescalereoffset.java │ ├── LASreaderBILrescalereoffset.java │ ├── LASreaderDTMrescalereoffset.java │ ├── LASreaderSHPrescalereoffset.java │ ├── LASreaderQFITrescalereoffset.java │ ├── LASevlr.java │ ├── LASreaderLASreoffset.java │ ├── LASvlr.java │ ├── LASreaderLASrescalereoffset.java │ ├── LASvlr_lasoriginal.java │ ├── LASvlr_lastiling.java │ ├── LASvlr_classification.java │ ├── LASreaderBIN.java │ ├── LASreaderDTM.java │ ├── LASreaderBIL.java │ ├── LASreaderQFIT.java │ ├── LASreaderSHP.java │ ├── LASreaderASC.java │ ├── LASreaderPipeOn.java │ ├── LASwriterQFIT.java │ ├── LASwriterBIN.java │ ├── LASwriterWRL.java │ ├── LASvlr_geo_keys.java │ ├── LAStransform.java │ ├── LASwriter.java │ ├── LasDefinitions.java │ ├── LASvlr_key_entry.java │ ├── LASvlr_wave_packet_descr.java │ ├── LASreaderTXT.java │ ├── LASreaderBuffered.java │ └── LASreaderMerged.java │ ├── lastools │ ├── OffsetSize.java │ ├── GeoProjectionGeoKeys.java │ └── GeoProjectionConverter.java │ ├── CloseablePointIterable.java │ ├── LASPointModifier.java │ ├── LASPointTransformer.java │ ├── clib │ ├── Cstdlib.java │ └── Cstring.java │ ├── LASVariableLengthRecord.java │ ├── LASExtendedVariableLengthRecord.java │ ├── LASWriter.java │ └── LASExtraBytesType.java ├── .gitignore ├── azure-pipelines.yml ├── .vscode └── launch.json ├── cloudbuild.yaml └── README.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: mreutegg 4 | -------------------------------------------------------------------------------- /src/test/resources/extra-bytes.las: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mreutegg/laszip4j/HEAD/src/test/resources/extra-bytes.las -------------------------------------------------------------------------------- /src/test/resources/record-format-7.laz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mreutegg/laszip4j/HEAD/src/test/resources/record-format-7.laz -------------------------------------------------------------------------------- /src/test/resources/record-format-8.laz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mreutegg/laszip4j/HEAD/src/test/resources/record-format-8.laz -------------------------------------------------------------------------------- /src/test/resources/2019_saipan_waveform.laz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mreutegg/laszip4j/HEAD/src/test/resources/2019_saipan_waveform.laz -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "maven" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | -------------------------------------------------------------------------------- /src/test/resources/500m_5460_59370_IM2023_subset.laz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mreutegg/laszip4j/HEAD/src/test/resources/500m_5460_59370_IM2023_subset.laz -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | *.ipr 3 | *.iws 4 | *.iml 5 | .shelf 6 | /.idea/ 7 | 8 | .vscode/* 9 | !.vscode/settings.json 10 | !.vscode/tasks.json 11 | !.vscode/launch.json 12 | !.vscode/extensions.json 13 | !.vscode/*.code-snippets 14 | 15 | # Local History for Visual Studio Code 16 | .history/ 17 | 18 | # Built Visual Studio Code Extensions 19 | *.vsix 20 | -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | # Maven 2 | # Build your Java projects and run tests with Apache Maven. 3 | # Add steps that analyze code, save build artifacts, deploy, and more: 4 | # https://docs.microsoft.com/vsts/pipelines/languages/java 5 | 6 | pool: 7 | vmImage: 'ubuntu-latest' 8 | 9 | steps: 10 | - task: Maven@4 11 | inputs: 12 | mavenPOMFile: 'pom.xml' 13 | mavenOptions: '-Xmx1g' 14 | javaHomeOption: 'JDKVersion' 15 | jdkVersionOption: '1.11' 16 | publishJUnitResults: false 17 | testResultsFiles: '**/TEST-*.xml' 18 | goals: 'verify -B' 19 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASreadItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2014, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | public abstract class LASreadItem { 14 | 15 | public abstract PointDataRecord read(MutableInteger context); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | public abstract class LASwriteItem { 14 | 15 | public abstract boolean write(T point, int /* unsigned */ context); 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASwaveformDescription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | public class LASwaveformDescription { 14 | public byte compression; 15 | public byte nbits; 16 | public char nsamples; 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LAScontextBYTE14.java: -------------------------------------------------------------------------------- 1 | /* 2 | COPYRIGHT: 3 | 4 | (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 5 | 6 | This is free software; you can redistribute and/or modify it under the 7 | terms of the Apache Public License 2.0 published by the Apache Software 8 | Foundation. See the COPYING file for more information. 9 | 10 | This software is distributed WITHOUT ANY WARRANTY and without even the 11 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | */ 13 | package com.github.mreutegg.laszip4j.laszip; 14 | 15 | class LAScontextBYTE14 16 | { 17 | public boolean unused; 18 | 19 | public PointDataRecordBytes last_item; 20 | 21 | public ArithmeticModel[] m_bytes; 22 | } 23 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "java", 9 | "name": "Launch Current File", 10 | "request": "launch", 11 | "mainClass": "${file}" 12 | }, 13 | { 14 | "type": "java", 15 | "name": "Launch Laszip", 16 | "request": "launch", 17 | "mainClass": "com.github.mreutegg.laszip4j.lastools.Laszip", 18 | "projectName": "laszip4j", 19 | "args":"YOUR-FILE.laz -dry -iparse xyzicRGB" 20 | } 21 | ] 22 | } -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderASCreoffset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2014, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | // TODO: only dummy implementation 14 | public class LASreaderASCreoffset extends LASreaderASC { 15 | 16 | public LASreaderASCreoffset(double v, double v1, double v2) { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderASCrescale.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2014, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | // TODO: only dummy implementation 14 | public class LASreaderASCrescale extends LASreaderASC { 15 | 16 | public LASreaderASCrescale(double v, double v1, double v2) { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderBILreoffset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | // TODO: only dummy implementation 14 | public class LASreaderBILreoffset extends LASreaderBIL { 15 | 16 | public LASreaderBILreoffset(double v, double v1, double v2) { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderBILrescale.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | // TODO: only dummy implementation 14 | public class LASreaderBILrescale extends LASreaderBIL { 15 | 16 | public LASreaderBILrescale(double v, double v1, double v2) { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderBINreoffset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | // TODO: only dummy implementation 14 | public class LASreaderBINreoffset extends LASreaderBIN { 15 | 16 | public LASreaderBINreoffset(double v, double v1, double v2) { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderBINrescale.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | // TODO: only dummy implementation 14 | public class LASreaderBINrescale extends LASreaderBIN { 15 | 16 | public LASreaderBINrescale(double v, double v1, double v2) { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderDTMreoffset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | // TODO: only dummy implementation 14 | public class LASreaderDTMreoffset extends LASreaderDTM { 15 | 16 | public LASreaderDTMreoffset(double v, double v1, double v2) { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderDTMrescale.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | // TODO: only dummy implementation 14 | public class LASreaderDTMrescale extends LASreaderDTM { 15 | 16 | public LASreaderDTMrescale(double v, double v1, double v2) { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderLASrescale.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | // TODO: only dummy implementation 14 | public class LASreaderLASrescale extends LASreaderLAS { 15 | 16 | public LASreaderLASrescale(double v, double v1, double v2) { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderSHPreoffset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | // TODO: only dummy implementation 14 | public class LASreaderSHPreoffset extends LASreaderSHP { 15 | 16 | public LASreaderSHPreoffset(double v, double v1, double v2) { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderSHPrescale.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | // TODO: only dummy implementation 14 | public class LASreaderSHPrescale extends LASreaderSHP { 15 | 16 | public LASreaderSHPrescale(double v, double v1, double v2) { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderQFITreoffset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | // TODO: only dummy implementation 14 | public class LASreaderQFITreoffset extends LASreaderQFIT { 15 | 16 | public LASreaderQFITreoffset(double v, double v1, double v2) { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderQFITrescale.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | // TODO: only dummy implementation 14 | public class LASreaderQFITrescale extends LASreaderQFIT { 15 | 16 | public LASreaderQFITrescale(double v, double v1, double v2) { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASreadItemCompressed.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | public abstract class LASreadItemCompressed extends LASreadItem { 14 | 15 | public abstract void init(PointDataRecord seedItem, MutableInteger context); 16 | public abstract boolean chunk_sizes(); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/lastools/OffsetSize.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2015, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.lastools; 12 | 13 | class OffsetSize { 14 | 15 | final long offset; // unsigned 16 | final int size; // unsigned 17 | 18 | OffsetSize(long offset, int size) { 19 | this.offset = offset; 20 | this.size = size; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderBINrescalereoffset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | // TODO: only dummy implementation 14 | public class LASreaderBINrescalereoffset extends LASreaderBIN { 15 | public LASreaderBINrescalereoffset(double v, double v1, double v2, double v3, double v4, double v5) { 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderASCrescalereoffset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2014, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | // TODO: only dummy implementation 14 | public class LASreaderASCrescalereoffset extends LASreaderASC { 15 | 16 | public LASreaderASCrescalereoffset(double v, double v1, double v2, double v3, double v4, double v5) { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderBILrescalereoffset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | // TODO: only dummy implementation 14 | public class LASreaderBILrescalereoffset extends LASreaderBIL { 15 | 16 | public LASreaderBILrescalereoffset(double v, double v1, double v2, double v3, double v4, double v5) { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderDTMrescalereoffset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | // TODO: only dummy implementation 14 | public class LASreaderDTMrescalereoffset extends LASreaderDTM { 15 | 16 | public LASreaderDTMrescalereoffset(double v, double v1, double v2, double v3, double v4, double v5) { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderSHPrescalereoffset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | // TODO: only dummy implementation 14 | public class LASreaderSHPrescalereoffset extends LASreaderSHP { 15 | 16 | public LASreaderSHPrescalereoffset(double v, double v1, double v2, double v3, double v4, double v5) { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderQFITrescalereoffset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | // TODO: only dummy implementation 14 | public class LASreaderQFITrescalereoffset extends LASreaderQFIT { 15 | 16 | public LASreaderQFITrescalereoffset(double v, double v1, double v2, double v3, double v4, double v5) { 17 | 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/lastools/GeoProjectionGeoKeys.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2016, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.lastools; 12 | 13 | import com.github.mreutegg.laszip4j.laslib.LASvlr_key_entry; 14 | 15 | public class GeoProjectionGeoKeys extends LASvlr_key_entry { 16 | 17 | public GeoProjectionGeoKeys(GeoProjectionGeoKeys other) { 18 | super(other); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASevlr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2014, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | public class LASevlr { 14 | 15 | public char reserved; 16 | public byte[] user_id = new byte[16]; 17 | public char record_id; 18 | public long record_length_after_header; 19 | public byte[] description = new byte[32]; 20 | public byte[] data; 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderLASreoffset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | // TODO: only dummy implementation 14 | public class LASreaderLASreoffset extends LASreaderLAS { 15 | 16 | public LASreaderLASreoffset() { 17 | 18 | } 19 | 20 | public LASreaderLASreoffset(double v, double v1, double v2) { 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemRaw_GPSTIME11.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | public class LASwriteItemRaw_GPSTIME11 extends LASwriteItemRaw { 14 | @Override 15 | public boolean write(PointDataRecordGpsTime point, int context) { 16 | outstream.put64bitsLE(point.GPSTime); 17 | return true; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASvlr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2014, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | public class LASvlr { 14 | 15 | public char reserved; 16 | public byte[] user_id = new byte[16]; // 16 bytes 17 | public char record_id; 18 | public char record_length_after_header; 19 | public byte[] description = new byte[32]; // 32 bytes 20 | public byte[] data; 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemRaw_RGB12.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | public class LASwriteItemRaw_RGB12 extends LASwriteItemRaw { 14 | @Override 15 | public boolean write(PointDataRecordRGB point, int context) { 16 | outstream.put16bitsLE(point.R); 17 | outstream.put16bitsLE(point.G); 18 | outstream.put16bitsLE(point.B); 19 | return true; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /cloudbuild.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Marcel Reutegger 2 | # 3 | # This program is free software: you can redistribute it and/or modify 4 | # it under the terms of the GNU Lesser General Public License as published by 5 | # the Free Software Foundation, either version 3 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this program. If not, see . 15 | steps: 16 | - name: gcr.io/cloud-builders/git 17 | args: ['clone', 'https://github.com/mreutegg/laszip4j.git'] 18 | - name: 'gcr.io/cloud-builders/mvn' 19 | args: ['-B', 'verify'] -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderLASrescalereoffset.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | // TODO: only dummy implementation 14 | public class LASreaderLASrescalereoffset extends LASreaderLAS { 15 | 16 | public LASreaderLASrescalereoffset(double v, double v1, double v2) { 17 | 18 | } 19 | 20 | public LASreaderLASrescalereoffset(double v, double v1, double v2, double v3, double v4, double v5) { 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemCompressed.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | import static java.lang.Boolean.FALSE; 14 | 15 | public abstract class LASwriteItemCompressed extends LASwriteItem { 16 | 17 | public abstract boolean init(PointDataRecord point, int context); 18 | 19 | public boolean chunk_sizes() { 20 | return FALSE; 21 | } 22 | 23 | public boolean chunk_bytes() { 24 | return FALSE; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASvlr_lasoriginal.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2014, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | public class LASvlr_lasoriginal { 14 | 15 | public long position; 16 | 17 | public long number_of_point_records; 18 | public long[] number_of_points_by_return = new long[15]; 19 | public double max_x; 20 | public double min_x; 21 | public double max_y; 22 | public double min_y; 23 | public double max_z; 24 | public double min_z; 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASvlr_lastiling.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2014, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | public class LASvlr_lastiling { 14 | public int level; // unsigned 15 | public int level_index; // unsigned 16 | public int implicit_levels = 30; // unsigned 17 | public int buffer = 1; // unsigned 18 | public int reversible = 1; // unsigned 19 | public float min_x; 20 | public float max_x; 21 | public float min_y; 22 | public float max_y; 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemRaw_RGBNIR14.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | public class LASwriteItemRaw_RGBNIR14 extends LASwriteItemRaw { 14 | @Override 15 | public boolean write(PointDataRecordRgbNIR point, int context) { 16 | outstream.put16bitsLE(point.R); 17 | outstream.put16bitsLE(point.G); 18 | outstream.put16bitsLE(point.B); 19 | outstream.put16bitsLE(point.NIR); 20 | return true; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASreadItemRaw.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | import static java.lang.Boolean.FALSE; 14 | import static java.lang.Boolean.TRUE; 15 | 16 | public abstract class LASreadItemRaw extends LASreadItem { 17 | 18 | protected ByteStreamIn instream; 19 | 20 | public boolean init(ByteStreamIn instream) 21 | { 22 | if (instream == null) return FALSE; 23 | this.instream = instream; 24 | return TRUE; 25 | }; 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemRaw_BYTE.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | public class LASwriteItemRaw_BYTE extends LASwriteItemRaw { 14 | 15 | private final int byteCount; 16 | 17 | public LASwriteItemRaw_BYTE(int byteCount) { 18 | this.byteCount = byteCount; 19 | } 20 | 21 | @Override 22 | public boolean write(PointDataRecordBytes point, int context) { 23 | return outstream.putBytes(point.Bytes, byteCount); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/IByteStreamInProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Marcel Reutegger 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.mreutegg.laszip4j.laszip; 18 | 19 | public interface IByteStreamInProvider { 20 | 21 | void setByteStreamIn(ByteStreamIn instream); 22 | ByteStreamIn getByteStreamIn(); 23 | } -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemRaw.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | import static java.lang.Boolean.FALSE; 14 | import static java.lang.Boolean.TRUE; 15 | 16 | public abstract class LASwriteItemRaw extends LASwriteItem { 17 | 18 | protected ByteStreamOut outstream; 19 | 20 | public boolean init(ByteStreamOut outstream) { 21 | if (outstream == null) { 22 | return FALSE; 23 | } 24 | this.outstream = outstream; 25 | return TRUE; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LAScontextRGB14.java: -------------------------------------------------------------------------------- 1 | /* 2 | COPYRIGHT: 3 | 4 | (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 5 | 6 | This is free software; you can redistribute and/or modify it under the 7 | terms of the Apache Public License 2.0 published by the Apache Software 8 | Foundation. See the COPYING file for more information. 9 | 10 | This software is distributed WITHOUT ANY WARRANTY and without even the 11 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | */ 13 | package com.github.mreutegg.laszip4j.laszip; 14 | 15 | class LAScontextRGB14 16 | { 17 | public boolean unused; 18 | 19 | public PointDataRecordRGB last_item = null; 20 | 21 | public ArithmeticModel m_byte_used; 22 | public ArithmeticModel m_rgb_diff_0; 23 | public ArithmeticModel m_rgb_diff_1; 24 | public ArithmeticModel m_rgb_diff_2; 25 | public ArithmeticModel m_rgb_diff_3; 26 | public ArithmeticModel m_rgb_diff_4; 27 | public ArithmeticModel m_rgb_diff_5; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemCompressed_RGB12_v1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | // TODO: only dummy implementation 14 | public class LASwriteItemCompressed_RGB12_v1 extends LASwriteItemCompressed { 15 | public LASwriteItemCompressed_RGB12_v1(ArithmeticEncoder enc) { 16 | } 17 | 18 | @Override 19 | public boolean write(PointDataRecord point, int context) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean init(PointDataRecord point, int context) { 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemCompressed_RGB12_v2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | // TODO: only dummy implementation 14 | public class LASwriteItemCompressed_RGB12_v2 extends LASwriteItemCompressed { 15 | public LASwriteItemCompressed_RGB12_v2(ArithmeticEncoder enc) { 16 | } 17 | 18 | @Override 19 | public boolean write(PointDataRecord point, int context) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean init(PointDataRecord point, int context) { 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemCompressed_RGB14_v3.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | // TODO: only dummy implementation 14 | public class LASwriteItemCompressed_RGB14_v3 extends LASwriteItemCompressed { 15 | public LASwriteItemCompressed_RGB14_v3(ArithmeticEncoder enc) { 16 | } 17 | 18 | @Override 19 | public boolean write(PointDataRecord point, int context) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean init(PointDataRecord point, int context) { 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemCompressed_RGB14_v4.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | // TODO: only dummy implementation 14 | public class LASwriteItemCompressed_RGB14_v4 extends LASwriteItemCompressed { 15 | public LASwriteItemCompressed_RGB14_v4(ArithmeticEncoder enc) { 16 | } 17 | 18 | @Override 19 | public boolean write(PointDataRecord point, int context) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean init(PointDataRecord point, int context) { 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemCompressed_POINT10_v1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | // TODO: only dummy implementation 14 | public class LASwriteItemCompressed_POINT10_v1 extends LASwriteItemCompressed { 15 | public LASwriteItemCompressed_POINT10_v1(ArithmeticEncoder enc) { 16 | } 17 | 18 | @Override 19 | public boolean write(PointDataRecord point, int context) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean init(PointDataRecord point, int context) { 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemCompressed_POINT10_v2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | // TODO: only dummy implementation 14 | public class LASwriteItemCompressed_POINT10_v2 extends LASwriteItemCompressed { 15 | public LASwriteItemCompressed_POINT10_v2(ArithmeticEncoder enc) { 16 | } 17 | 18 | @Override 19 | public boolean write(PointDataRecord point, int context) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean init(PointDataRecord point, int context) { 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemCompressed_POINT14_v3.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | // TODO: only dummy implementation 14 | public class LASwriteItemCompressed_POINT14_v3 extends LASwriteItemCompressed { 15 | public LASwriteItemCompressed_POINT14_v3(ArithmeticEncoder enc) { 16 | } 17 | 18 | @Override 19 | public boolean write(PointDataRecord point, int context) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean init(PointDataRecord point, int context) { 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemCompressed_POINT14_v4.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | // TODO: only dummy implementation 14 | public class LASwriteItemCompressed_POINT14_v4 extends LASwriteItemCompressed { 15 | public LASwriteItemCompressed_POINT14_v4(ArithmeticEncoder enc) { 16 | } 17 | 18 | @Override 19 | public boolean write(PointDataRecord point, int context) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean init(PointDataRecord point, int context) { 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemCompressed_BYTE_v1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | // TODO: only dummy implementation 14 | public class LASwriteItemCompressed_BYTE_v1 extends LASwriteItemCompressed { 15 | public LASwriteItemCompressed_BYTE_v1(ArithmeticEncoder enc, char size) { 16 | } 17 | 18 | @Override 19 | public boolean write(PointDataRecord point, int context) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean init(PointDataRecord point, int context) { 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemCompressed_BYTE_v2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | // TODO: only dummy implementation 14 | public class LASwriteItemCompressed_BYTE_v2 extends LASwriteItemCompressed { 15 | public LASwriteItemCompressed_BYTE_v2(ArithmeticEncoder enc, char size) { 16 | } 17 | 18 | @Override 19 | public boolean write(PointDataRecord point, int context) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean init(PointDataRecord point, int context) { 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemCompressed_RGBNIR14_v3.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | // TODO: only dummy implementation 14 | public class LASwriteItemCompressed_RGBNIR14_v3 extends LASwriteItemCompressed { 15 | public LASwriteItemCompressed_RGBNIR14_v3(ArithmeticEncoder enc) { 16 | } 17 | 18 | @Override 19 | public boolean write(PointDataRecord point, int context) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean init(PointDataRecord point, int context) { 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemCompressed_RGBNIR14_v4.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | // TODO: only dummy implementation 14 | public class LASwriteItemCompressed_RGBNIR14_v4 extends LASwriteItemCompressed { 15 | public LASwriteItemCompressed_RGBNIR14_v4(ArithmeticEncoder enc) { 16 | } 17 | 18 | @Override 19 | public boolean write(PointDataRecord point, int context) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean init(PointDataRecord point, int context) { 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemCompressed_BYTE14_v3.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | // TODO: only dummy implementation 14 | public class LASwriteItemCompressed_BYTE14_v3 extends LASwriteItemCompressed { 15 | public LASwriteItemCompressed_BYTE14_v3(ArithmeticEncoder enc, char size) { 16 | } 17 | 18 | @Override 19 | public boolean write(PointDataRecord point, int context) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean init(PointDataRecord point, int context) { 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemCompressed_BYTE14_v4.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | // TODO: only dummy implementation 14 | public class LASwriteItemCompressed_BYTE14_v4 extends LASwriteItemCompressed { 15 | public LASwriteItemCompressed_BYTE14_v4(ArithmeticEncoder enc, char size) { 16 | } 17 | 18 | @Override 19 | public boolean write(PointDataRecord point, int context) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean init(PointDataRecord point, int context) { 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemCompressed_GPSTIME11_v1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | // TODO: only dummy implementation 14 | public class LASwriteItemCompressed_GPSTIME11_v1 extends LASwriteItemCompressed { 15 | public LASwriteItemCompressed_GPSTIME11_v1(ArithmeticEncoder enc) { 16 | } 17 | 18 | @Override 19 | public boolean write(PointDataRecord point, int context) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean init(PointDataRecord point, int context) { 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemCompressed_GPSTIME11_v2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | // TODO: only dummy implementation 14 | public class LASwriteItemCompressed_GPSTIME11_v2 extends LASwriteItemCompressed { 15 | public LASwriteItemCompressed_GPSTIME11_v2(ArithmeticEncoder enc) { 16 | } 17 | 18 | @Override 19 | public boolean write(PointDataRecord point, int context) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean init(PointDataRecord point, int context) { 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemCompressed_WAVEPACKET13_v1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | // TODO: only dummy implementation 14 | public class LASwriteItemCompressed_WAVEPACKET13_v1 extends LASwriteItemCompressed { 15 | public LASwriteItemCompressed_WAVEPACKET13_v1(ArithmeticEncoder enc) { 16 | } 17 | 18 | @Override 19 | public boolean write(PointDataRecord point, int context) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean init(PointDataRecord point, int context) { 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemCompressed_WAVEPACKET14_v3.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | // TODO: only dummy implementation 14 | public class LASwriteItemCompressed_WAVEPACKET14_v3 extends LASwriteItemCompressed { 15 | public LASwriteItemCompressed_WAVEPACKET14_v3(ArithmeticEncoder enc) { 16 | } 17 | 18 | @Override 19 | public boolean write(PointDataRecord point, int context) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean init(PointDataRecord point, int context) { 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemCompressed_WAVEPACKET14_v4.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | // TODO: only dummy implementation 14 | public class LASwriteItemCompressed_WAVEPACKET14_v4 extends LASwriteItemCompressed { 15 | public LASwriteItemCompressed_WAVEPACKET14_v4(ArithmeticEncoder enc) { 16 | } 17 | 18 | @Override 19 | public boolean write(PointDataRecord point, int context) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean init(PointDataRecord point, int context) { 25 | return false; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASreadItemRaw_BYTE.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | public class LASreadItemRaw_BYTE extends LASreadItemRaw { 14 | 15 | private final int byteCount; 16 | 17 | public LASreadItemRaw_BYTE(int byteCount) { 18 | this.byteCount = byteCount; 19 | } 20 | 21 | @Override 22 | public PointDataRecordBytes read(MutableInteger notUsed) { 23 | 24 | PointDataRecordBytes result = new PointDataRecordBytes(byteCount); 25 | instream.getBytes(result.Bytes, byteCount); 26 | return result; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/lastools/GeoProjectionConverter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2016, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.lastools; 12 | 13 | // TODO: only contains dummy implementation 14 | public class GeoProjectionConverter { 15 | 16 | 17 | public boolean parse(int argc, String[] argv) { 18 | return true; 19 | } 20 | 21 | public boolean has_projection() { 22 | return false; 23 | } 24 | 25 | public boolean get_geo_keys_from_projection(int number_of_keys, GeoProjectionGeoKeys[] geo_keys, int num_geo_double_params, double[] geo_double_params) { 26 | return false; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/CloseablePointIterable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Marcel Reutegger 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.mreutegg.laszip4j; 18 | 19 | /** 20 | * An iterable over LASPoints that can be used with 'try'-with-resources. 21 | */ 22 | public interface CloseablePointIterable extends Iterable, AutoCloseable { 23 | 24 | @Override 25 | void close(); 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LAScontextWAVEPACKET14.java: -------------------------------------------------------------------------------- 1 | /* 2 | COPYRIGHT: 3 | 4 | (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 5 | 6 | This is free software; you can redistribute and/or modify it under the 7 | terms of the Apache Public License 2.0 published by the Apache Software 8 | Foundation. See the COPYING file for more information. 9 | 10 | This software is distributed WITHOUT ANY WARRANTY and without even the 11 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | */ 13 | package com.github.mreutegg.laszip4j.laszip; 14 | 15 | class LAScontextWAVEPACKET14 16 | { 17 | public boolean unused; 18 | 19 | public PointDataRecordWavepacket last_item; 20 | public int last_diff_32; 21 | public int sym_last_offset_diff; 22 | 23 | public ArithmeticModel m_packet_index; 24 | public ArithmeticModel[] m_offset_diff = new ArithmeticModel[4]; 25 | public IntegerCompressor ic_offset_diff; 26 | public IntegerCompressor ic_packet_size; 27 | public IntegerCompressor ic_return_point; 28 | public IntegerCompressor ic_xyz; 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/UncheckedEOFException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Marcel Reutegger 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.mreutegg.laszip4j.laszip; 18 | 19 | import java.io.EOFException; 20 | import java.io.UncheckedIOException; 21 | 22 | public class UncheckedEOFException extends UncheckedIOException { 23 | 24 | public UncheckedEOFException() { 25 | super(new EOFException()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASvlr_classification.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2014, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | import java.nio.ByteBuffer; 14 | import java.nio.ByteOrder; 15 | 16 | public class LASvlr_classification { 17 | 18 | public byte class_number; 19 | byte[] description = new byte[15]; 20 | 21 | public static LASvlr_classification fromByteArray(byte[] data) { 22 | ByteBuffer bb = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN); 23 | LASvlr_classification c = new LASvlr_classification(); 24 | c.class_number = bb.get(); 25 | bb.get(c.description); 26 | return c; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASintervalCell.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2015, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | public class LASintervalCell { 14 | public int start; // unsigned 15 | public int end; // unsigned 16 | public LASintervalCell next; 17 | 18 | public LASintervalCell() { 19 | start = 0; 20 | end = 0; 21 | next = null; 22 | } 23 | 24 | LASintervalCell(int p_index) 25 | { 26 | start = p_index; 27 | end = p_index; 28 | next = null; 29 | } 30 | 31 | LASintervalCell(LASintervalCell cell) 32 | { 33 | start = cell.start; 34 | end = cell.end; 35 | next = null; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/com/github/mreutegg/laszip4j/laslib/LASreadOpenerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Marcel Reutegger 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.mreutegg.laszip4j.laslib; 18 | 19 | import org.junit.Test; 20 | 21 | import static org.junit.Assert.assertFalse; 22 | 23 | public class LASreadOpenerTest { 24 | 25 | @Test 26 | public void reopenWithNullReader() { 27 | LASreadOpener o = new LASreadOpener(); 28 | assertFalse(o.reopen(null, true)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LAScontextRGBNIR14.java: -------------------------------------------------------------------------------- 1 | /* 2 | COPYRIGHT: 3 | 4 | (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 5 | 6 | This is free software; you can redistribute and/or modify it under the 7 | terms of the Apache Public License 2.0 published by the Apache Software 8 | Foundation. See the COPYING file for more information. 9 | 10 | This software is distributed WITHOUT ANY WARRANTY and without even the 11 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | */ 13 | package com.github.mreutegg.laszip4j.laszip; 14 | 15 | class LAScontextRGBNIR14 16 | { 17 | public boolean unused; 18 | 19 | public PointDataRecordRgbNIR last_item = null; 20 | 21 | public ArithmeticModel m_rgb_bytes_used; 22 | public ArithmeticModel m_rgb_diff_0; 23 | public ArithmeticModel m_rgb_diff_1; 24 | public ArithmeticModel m_rgb_diff_2; 25 | public ArithmeticModel m_rgb_diff_3; 26 | public ArithmeticModel m_rgb_diff_4; 27 | public ArithmeticModel m_rgb_diff_5; 28 | 29 | public ArithmeticModel m_nir_bytes_used; 30 | public ArithmeticModel m_nir_diff_0; 31 | public ArithmeticModel m_nir_diff_1; 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASreadItemRaw_GPSTIME11.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | import java.nio.ByteBuffer; 14 | import java.nio.ByteOrder; 15 | 16 | public class LASreadItemRaw_GPSTIME11 extends LASreadItemRaw { 17 | 18 | private ByteBuffer bb = ByteBuffer.allocate(Long.BYTES).order(ByteOrder.LITTLE_ENDIAN); 19 | 20 | @Override 21 | public PointDataRecordGpsTime read(MutableInteger notUsed) { 22 | 23 | bb.clear(); 24 | instream.getBytes(bb.array(), Long.BYTES); 25 | 26 | PointDataRecordGpsTime result = new PointDataRecordGpsTime(); 27 | result.GPSTime = bb.getLong(0); 28 | return result; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/MutableInteger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Marcel Reutegger 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.mreutegg.laszip4j.laszip; 18 | 19 | public final class MutableInteger { 20 | 21 | private int value; 22 | 23 | public MutableInteger(int value) { 24 | this.value = value; 25 | } 26 | 27 | public int get() { 28 | return value; 29 | } 30 | 31 | public void set(int value) { 32 | this.value = value; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASreadItemRaw_RGB12.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | import java.nio.ByteBuffer; 14 | import java.nio.ByteOrder; 15 | 16 | public class LASreadItemRaw_RGB12 extends LASreadItemRaw { 17 | 18 | private ByteBuffer bb = ByteBuffer.allocate(6).order(ByteOrder.LITTLE_ENDIAN); 19 | 20 | @Override 21 | public PointDataRecordRGB read(MutableInteger notUsed) { 22 | bb.clear(); 23 | instream.getBytes(bb.array(), 6); 24 | 25 | PointDataRecordRGB result = new PointDataRecordRGB(); 26 | 27 | result.R = bb.getChar(); 28 | result.G = bb.getChar(); 29 | result.B = bb.getChar(); 30 | return result; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASreadItemRaw_RGBNIR14.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | import java.nio.ByteBuffer; 14 | import java.nio.ByteOrder; 15 | 16 | public class LASreadItemRaw_RGBNIR14 extends LASreadItemRaw { 17 | 18 | private ByteBuffer bb = ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN); 19 | 20 | @Override 21 | public PointDataRecordRgbNIR read(MutableInteger notUsed) { 22 | bb.clear(); 23 | instream.getBytes(bb.array(), 8); 24 | 25 | PointDataRecordRgbNIR result = new PointDataRecordRgbNIR(); 26 | result.R = bb.getChar(); 27 | result.G = bb.getChar(); 28 | result.B = bb.getChar(); 29 | result.NIR = bb.getChar(); 30 | return result; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemRaw_POINT10.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | public class LASwriteItemRaw_POINT10 extends LASwriteItemRaw { 14 | 15 | @Override 16 | public boolean write(PointDataRecordPoint10 point, int /* unsigned */ context) { 17 | outstream.put32bitsLE(point.X); 18 | outstream.put32bitsLE(point.Y); 19 | outstream.put32bitsLE(point.Z); 20 | outstream.put16bitsLE(point.Intensity); 21 | outstream.putByte(point.Flags); 22 | outstream.putByte((byte) point.Classification); 23 | outstream.putByte(point.ScanAngleRank); 24 | outstream.putByte((byte) point.UserData); 25 | outstream.put16bitsLE(point.PointSourceID); 26 | return true; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemRaw_WAVEPACKET13.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | public class LASwriteItemRaw_WAVEPACKET13 extends LASwriteItemRaw { 14 | @Override 15 | public boolean write(PointDataRecordWavepacket point, int context) { 16 | outstream.putByte((byte) point.DescriptorIndex); 17 | outstream.put64bitsLE(point.OffsetToWaveformData); 18 | outstream.put32bitsLE((int) point.PacketSize); 19 | outstream.put32bitsLE(Float.floatToIntBits(point.ReturnPointWaveformLocation)); 20 | outstream.put32bitsLE(Float.floatToIntBits(point.ParametricDx)); 21 | outstream.put32bitsLE(Float.floatToIntBits(point.ParametricDy)); 22 | outstream.put32bitsLE(Float.floatToIntBits(point.ParametricDz)); 23 | return true; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderBIN.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | import com.github.mreutegg.laszip4j.laszip.ByteStreamIn; 14 | 15 | // TODO: only dummy implementation 16 | public class LASreaderBIN extends LASreader { 17 | @Override 18 | public int get_format() { 19 | return 0; 20 | } 21 | 22 | @Override 23 | public boolean seek(long p_index) { 24 | return false; 25 | } 26 | 27 | @Override 28 | public ByteStreamIn get_stream() { 29 | return null; 30 | } 31 | 32 | @Override 33 | public void close(boolean close_stream) { 34 | 35 | } 36 | 37 | @Override 38 | protected boolean read_point_default() { 39 | return false; 40 | } 41 | 42 | public boolean open(String file_name) { 43 | return false; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderDTM.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | import com.github.mreutegg.laszip4j.laszip.ByteStreamIn; 14 | 15 | // TODO: only dummy implementation 16 | public class LASreaderDTM extends LASreader { 17 | @Override 18 | public int get_format() { 19 | return 0; 20 | } 21 | 22 | @Override 23 | public boolean seek(long p_index) { 24 | return false; 25 | } 26 | 27 | @Override 28 | public ByteStreamIn get_stream() { 29 | return null; 30 | } 31 | 32 | @Override 33 | public void close(boolean close_stream) { 34 | 35 | } 36 | 37 | @Override 38 | protected boolean read_point_default() { 39 | return false; 40 | } 41 | 42 | public boolean open(String file_name) { 43 | return false; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderBIL.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | import com.github.mreutegg.laszip4j.laszip.ByteStreamIn; 14 | 15 | // TODO: only dummy implementation 16 | public class LASreaderBIL extends LASreader { 17 | @Override 18 | public int get_format() { 19 | return 0; 20 | } 21 | 22 | @Override 23 | public boolean seek(long p_index) { 24 | return false; 25 | } 26 | 27 | @Override 28 | public ByteStreamIn get_stream() { 29 | return null; 30 | } 31 | 32 | @Override 33 | public void close(boolean close_stream) { 34 | 35 | } 36 | 37 | @Override 38 | protected boolean read_point_default() { 39 | return false; 40 | } 41 | 42 | public boolean open(String file_name) { 43 | return false; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderQFIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | import com.github.mreutegg.laszip4j.laszip.ByteStreamIn; 14 | 15 | // TODO: only dummy implementation 16 | public class LASreaderQFIT extends LASreader { 17 | @Override 18 | public int get_format() { 19 | return 0; 20 | } 21 | 22 | @Override 23 | public boolean seek(long p_index) { 24 | return false; 25 | } 26 | 27 | @Override 28 | public ByteStreamIn get_stream() { 29 | return null; 30 | } 31 | 32 | @Override 33 | public void close(boolean close_stream) { 34 | 35 | } 36 | 37 | @Override 38 | protected boolean read_point_default() { 39 | return false; 40 | } 41 | 42 | public boolean open(String file_name) { 43 | return false; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderSHP.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | import com.github.mreutegg.laszip4j.laszip.ByteStreamIn; 14 | 15 | // TODO: only dummy implementation 16 | public class LASreaderSHP extends LASreader { 17 | @Override 18 | public int get_format() { 19 | return 0; 20 | } 21 | 22 | @Override 23 | public boolean seek(long p_index) { 24 | return false; 25 | } 26 | 27 | @Override 28 | public ByteStreamIn get_stream() { 29 | return null; 30 | } 31 | 32 | @Override 33 | public void close(boolean close_stream) { 34 | 35 | } 36 | 37 | @Override 38 | protected boolean read_point_default() { 39 | return false; 40 | } 41 | 42 | public boolean open(String file_name) { 43 | return false; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASwriteItemRaw_POINT14.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the Apache Public License 2.0 published by the Apache Software 6 | * Foundation. See the COPYING file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | public class LASwriteItemRaw_POINT14 extends LASwriteItemRaw { 14 | @Override 15 | public boolean write(PointDataRecordPoint14 point, int context) { 16 | outstream.put32bitsLE(point.X); 17 | outstream.put32bitsLE(point.Y); 18 | outstream.put32bitsLE(point.Z); 19 | outstream.put16bitsLE(point.Intensity); 20 | outstream.putByte(point.ReturnFlags); 21 | outstream.putByte(point.ScanFlags); 22 | outstream.putByte((byte) point.Classification); 23 | outstream.putByte((byte) point.UserData); 24 | outstream.put16bitsLE(point.ScanAngle); 25 | outstream.put16bitsLE(point.PointSourceID); 26 | outstream.put64bitsLE(point.GPSTime); 27 | return true; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderASC.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2014, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | import com.github.mreutegg.laszip4j.laszip.ByteStreamIn; 14 | 15 | // TODO: only dummy implementation 16 | public class LASreaderASC extends LASreader { 17 | @Override 18 | public int get_format() { 19 | return 0; 20 | } 21 | 22 | @Override 23 | public boolean seek(long p_index) { 24 | return false; 25 | } 26 | 27 | @Override 28 | public ByteStreamIn get_stream() { 29 | return null; 30 | } 31 | 32 | @Override 33 | public void close(boolean close_stream) { 34 | 35 | } 36 | 37 | @Override 38 | protected boolean read_point_default() { 39 | return false; 40 | } 41 | 42 | public boolean open(String file_name, boolean comma_not_point) { 43 | return false; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | name: Java CI with Maven 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v3.3.0 16 | with: 17 | # Disabling shallow clone for SonarCloud 18 | fetch-depth: 0 19 | - name: Set up JDK 17 20 | uses: actions/setup-java@v3.12.0 21 | with: 22 | distribution: temurin 23 | java-version: 17 24 | - name: Cache local Maven repository 25 | uses: actions/cache@v4 26 | with: 27 | path: ~/.m2/repository 28 | key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} 29 | restore-keys: | 30 | ${{ runner.os }}-maven- 31 | - name: Cache SonarCloud packages 32 | uses: actions/cache@v4 33 | with: 34 | path: ~/.sonar/cache 35 | key: ${{ runner.os }}-sonar 36 | restore-keys: ${{ runner.os }}-sonar 37 | - name: Build with Maven 38 | env: 39 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 40 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} 41 | run: mvn -B -Pcoverage verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar 42 | - name: Upload to Codecov 43 | env: 44 | CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} 45 | run: bash <(curl -s https://codecov.io/bash) 46 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderPipeOn.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | import com.github.mreutegg.laszip4j.laszip.ByteStreamIn; 14 | 15 | // TODO: only dummy implementation 16 | public class LASreaderPipeOn extends LASreader { 17 | 18 | @Override 19 | public int get_format() { 20 | return 0; 21 | } 22 | 23 | @Override 24 | public boolean seek(long p_index) { 25 | return false; 26 | } 27 | 28 | @Override 29 | public ByteStreamIn get_stream() { 30 | return null; 31 | } 32 | 33 | @Override 34 | public void close(boolean close_stream) { 35 | 36 | } 37 | 38 | @Override 39 | protected boolean read_point_default() { 40 | return false; 41 | } 42 | 43 | public boolean open(LASreader reader) { 44 | return false; 45 | } 46 | 47 | public LASreader get_lasreader() { 48 | return null; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/LASPointModifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Marcel Reutegger 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.mreutegg.laszip4j; 18 | 19 | /** 20 | * A facade to modify a point. 21 | */ 22 | public interface LASPointModifier { 23 | 24 | /** 25 | * Set the classification value (0..255) of a point. 26 | * 27 | * @param classification the classification value. 28 | */ 29 | void setClassification(short classification); 30 | 31 | /** 32 | * Sets the withheld flag of a point. 33 | * 34 | * @param withheld {@code true} if the withheld flag should be set, 35 | * {@code false} if it should be cleared. 36 | */ 37 | void setWithheld(boolean withheld); 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/LASPointTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Marcel Reutegger 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.mreutegg.laszip4j; 18 | 19 | /** 20 | * Allows an implementation to transform a point. 21 | */ 22 | public interface LASPointTransformer { 23 | 24 | /** 25 | * This is a noop transformation that does not modify the point. 26 | */ 27 | LASPointTransformer NONE = (point, modifier) -> {}; 28 | 29 | /** 30 | * Potentially transform the given point using the modifier. 31 | * 32 | * @param point the current point. 33 | * @param modifier the modifier to apply transformations to the current point. 34 | */ 35 | void transform(LASPoint point, LASPointModifier modifier); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASwriterQFIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | import com.github.mreutegg.laszip4j.laszip.LASpoint; 14 | 15 | import java.io.PrintStream; 16 | 17 | // TODO: only dummy implementation 18 | public class LASwriterQFIT extends LASwriter { 19 | @Override 20 | public boolean write_point(LASpoint point) { 21 | return false; 22 | } 23 | 24 | @Override 25 | public boolean chunk() { 26 | return false; 27 | } 28 | 29 | @Override 30 | public boolean update_header(LASheader header, boolean use_inventory, boolean update_extra_bytes) { 31 | return false; 32 | } 33 | 34 | @Override 35 | public long close(boolean update_npoints) { 36 | return 0; 37 | } 38 | 39 | public boolean open(String file_name, LASheader header, int i) { 40 | return false; 41 | } 42 | 43 | public boolean open(PrintStream out, LASheader header, int i) { 44 | return false; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASwriterBIN.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | import com.github.mreutegg.laszip4j.laszip.LASpoint; 14 | 15 | import java.io.PrintStream; 16 | 17 | // TODO: only dummy implementation 18 | public class LASwriterBIN extends LASwriter { 19 | @Override 20 | public boolean write_point(LASpoint point) { 21 | return false; 22 | } 23 | 24 | @Override 25 | public boolean chunk() { 26 | return false; 27 | } 28 | 29 | @Override 30 | public boolean update_header(LASheader header, boolean use_inventory, boolean update_extra_bytes) { 31 | return false; 32 | } 33 | 34 | @Override 35 | public long close(boolean update_npoints) { 36 | return 0; 37 | } 38 | 39 | public boolean open(String file_name, LASheader header, String ts8) { 40 | return false; 41 | } 42 | 43 | public boolean open(PrintStream out, LASheader header, String ts8) { 44 | return false; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASwriterWRL.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | import com.github.mreutegg.laszip4j.laszip.LASpoint; 14 | 15 | import java.io.PrintStream; 16 | 17 | // TODO: only dummy implementation 18 | public class LASwriterWRL extends LASwriter { 19 | @Override 20 | public boolean write_point(LASpoint point) { 21 | return false; 22 | } 23 | 24 | @Override 25 | public boolean chunk() { 26 | return false; 27 | } 28 | 29 | @Override 30 | public boolean update_header(LASheader header, boolean use_inventory, boolean update_extra_bytes) { 31 | return false; 32 | } 33 | 34 | @Override 35 | public long close(boolean update_npoints) { 36 | return 0; 37 | } 38 | 39 | public boolean open(String file_name, LASheader header, String parse_string) { 40 | return false; 41 | } 42 | 43 | public boolean open(PrintStream out, LASheader header, String parse_string) { 44 | return false; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASvlr_geo_keys.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2014, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | import java.nio.ByteBuffer; 14 | import java.nio.ByteOrder; 15 | 16 | public class LASvlr_geo_keys { 17 | 18 | public char key_directory_version; 19 | public char key_revision; 20 | public char minor_revision; 21 | public char number_of_keys; 22 | 23 | public void writeTo(ByteBuffer buffer) { 24 | buffer.putChar(key_directory_version); 25 | buffer.putChar(key_revision); 26 | buffer.putChar(minor_revision); 27 | buffer.putChar(number_of_keys); 28 | } 29 | 30 | public static LASvlr_geo_keys fromByteArray(byte[] data) { 31 | ByteBuffer bb = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN); 32 | LASvlr_geo_keys gk = new LASvlr_geo_keys(); 33 | gk.key_directory_version = bb.getChar(); 34 | gk.key_revision = bb.getChar(); 35 | gk.minor_revision = bb.getChar(); 36 | gk.number_of_keys = bb.getChar(); 37 | return gk; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASreadItemRaw_POINT10.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | import java.nio.ByteBuffer; 14 | import java.nio.ByteOrder; 15 | 16 | public class LASreadItemRaw_POINT10 extends LASreadItemRaw { 17 | 18 | private ByteBuffer bb = ByteBuffer.allocate(20).order(ByteOrder.LITTLE_ENDIAN); 19 | 20 | @Override 21 | public PointDataRecordPoint10 read(MutableInteger notUsed) { 22 | bb.clear(); 23 | instream.getBytes(bb.array(), 20); 24 | 25 | PointDataRecordPoint10 result = new PointDataRecordPoint10(); 26 | result.X = bb.getInt(); 27 | result.Y = bb.getInt(); 28 | result.Z = bb.getInt(); 29 | result.Intensity = bb.getChar(); 30 | result.Flags = bb.get(); 31 | result.Classification = (short)Byte.toUnsignedInt(bb.get()); 32 | result.ScanAngleRank = bb.get(); 33 | result.UserData = (short)Byte.toUnsignedInt(bb.get()); 34 | result.PointSourceID = bb.getChar(); 35 | return result; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASreadItemRaw_WAVEPACKET13.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | import java.nio.ByteBuffer; 14 | import java.nio.ByteOrder; 15 | 16 | public class LASreadItemRaw_WAVEPACKET13 extends LASreadItemRaw { 17 | 18 | private ByteBuffer bb = ByteBuffer.allocate(29).order(ByteOrder.LITTLE_ENDIAN); 19 | 20 | @Override 21 | public PointDataRecordWavepacket read(MutableInteger notUsed) { 22 | bb.clear(); 23 | instream.getBytes(bb.array(), 29); 24 | 25 | PointDataRecordWavepacket result = new PointDataRecordWavepacket(); 26 | result.DescriptorIndex = (short) Byte.toUnsignedInt(bb.get()); 27 | result.OffsetToWaveformData = bb.getLong(); 28 | result.PacketSize = Integer.toUnsignedLong(bb.getInt()); 29 | result.ReturnPointWaveformLocation = bb.getFloat(); 30 | result.ParametricDx = bb.getFloat(); 31 | result.ParametricDy = bb.getFloat(); 32 | result.ParametricDz = bb.getFloat(); 33 | return result; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/U32I32F32.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2015, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | import java.nio.ByteBuffer; 14 | 15 | public class U32I32F32 { 16 | 17 | private final ByteBuffer data; 18 | 19 | private U32I32F32(ByteBuffer buffer) { 20 | this.data = buffer.duplicate(); 21 | } 22 | 23 | public U32I32F32() { 24 | this(ByteBuffer.allocate(4)); 25 | } 26 | 27 | public static U32I32F32 wrap(ByteBuffer buffer) { 28 | return new U32I32F32(buffer); 29 | } 30 | 31 | public void setU32(int value) { 32 | data.putInt(0, value); 33 | } 34 | 35 | public int getU32() { 36 | return data.getInt(0); 37 | } 38 | 39 | public void setI32(int value) { 40 | data.putInt(0, value); 41 | } 42 | 43 | public int getI32() { 44 | return data.getInt(0); 45 | } 46 | 47 | public void setF32(float value) { 48 | data.putFloat(0, value); 49 | } 50 | 51 | public float getFloat() { 52 | return data.getFloat(0); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LAStransform.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | import com.github.mreutegg.laszip4j.laszip.LASpoint; 14 | 15 | import static com.github.mreutegg.laszip4j.laszip.LASzip.LASZIP_DECOMPRESS_SELECTIVE_CHANNEL_RETURNS_XY; 16 | 17 | // TODO: dummy implementation only 18 | public class LAStransform { 19 | 20 | public void transform(LASpoint point) { 21 | 22 | } 23 | 24 | public int get_decompress_selective() { return LASZIP_DECOMPRESS_SELECTIVE_CHANNEL_RETURNS_XY; } 25 | 26 | public void reset() { 27 | 28 | } 29 | 30 | public void setPointSource(int file_name_current) { 31 | 32 | } 33 | 34 | public static void usage() { 35 | 36 | } 37 | 38 | public void clean() { 39 | 40 | } 41 | 42 | public boolean parse(int argc, String[] argv) { 43 | return true; 44 | } 45 | 46 | public boolean active() { 47 | return false; 48 | } 49 | 50 | public boolean filtered() { 51 | return false; 52 | } 53 | 54 | public void setFilter(LASfilter filter) { 55 | 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASreadItemRaw_POINT14.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | import java.nio.ByteBuffer; 14 | import java.nio.ByteOrder; 15 | 16 | public class LASreadItemRaw_POINT14 extends LASreadItemRaw { 17 | 18 | private ByteBuffer bb = ByteBuffer.allocate(30).order(ByteOrder.LITTLE_ENDIAN); 19 | 20 | @Override 21 | public PointDataRecordPoint14 read(MutableInteger notUsed) { 22 | bb.clear(); 23 | instream.getBytes(bb.array(), 30); 24 | 25 | PointDataRecordPoint14 result = new PointDataRecordPoint14(); 26 | result.X = bb.getInt(); 27 | result.Y = bb.getInt(); 28 | result.Z = bb.getInt(); 29 | result.Intensity = bb.getChar(); 30 | result.ReturnFlags = bb.get(); 31 | result.ScanFlags = bb.get(); 32 | result.Classification = (short)Byte.toUnsignedInt(bb.get()); 33 | result.UserData = (short)Byte.toUnsignedInt(bb.get()); 34 | result.ScanAngle = bb.getShort(); 35 | result.PointSourceID = bb.getChar(); 36 | result.GPSTime = bb.getLong(); 37 | 38 | return result; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASwriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | import com.github.mreutegg.laszip4j.laszip.LASpoint; 14 | import com.github.mreutegg.laszip4j.laszip.LASquantizer; 15 | 16 | public abstract class LASwriter { 17 | 18 | public LASquantizer quantizer = new LASquantizer(); 19 | public long npoints; 20 | public long p_count; 21 | public LASinventory inventory; 22 | 23 | public abstract boolean write_point(LASpoint point); 24 | public void update_inventory(LASpoint point) { inventory.add(point); }; 25 | public abstract boolean chunk(); 26 | 27 | public boolean update_header(LASheader header) { 28 | return update_header(header, false, false); 29 | } 30 | public boolean update_header(LASheader header, boolean use_inventory) { 31 | return update_header(header, use_inventory, false); 32 | } 33 | public abstract boolean update_header(LASheader header, boolean use_inventory, boolean update_extra_bytes); 34 | public long close() { 35 | return close(true); 36 | } 37 | public abstract long close(boolean update_npoints); 38 | 39 | public LASwriter() { npoints = 0; p_count = 0; }; 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/com/github/mreutegg/laszip4j/CstdlibTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Marcel Reutegger 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.mreutegg.laszip4j; 18 | 19 | import com.github.mreutegg.laszip4j.clib.Cstdlib; 20 | import org.junit.After; 21 | import org.junit.Test; 22 | 23 | import static org.junit.Assert.assertEquals; 24 | 25 | public class CstdlibTest { 26 | 27 | @After 28 | public void resetSeed() { 29 | Cstdlib.srand(1); 30 | } 31 | 32 | @Test 33 | public void srand() { 34 | int first = Cstdlib.rand(); 35 | int second = Cstdlib.rand(); 36 | Cstdlib.srand(1); 37 | assertEquals(first, Cstdlib.rand()); 38 | assertEquals(second, Cstdlib.rand()); 39 | } 40 | 41 | @Test 42 | public void srandWithSeed() { 43 | Cstdlib.srand(42); 44 | int first = Cstdlib.rand(); 45 | int second = Cstdlib.rand(); 46 | Cstdlib.srand(42); 47 | assertEquals(first, Cstdlib.rand()); 48 | assertEquals(second, Cstdlib.rand()); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/U64I64F64.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2015, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | import java.nio.ByteBuffer; 14 | 15 | public class U64I64F64 { 16 | 17 | private final ByteBuffer data; 18 | 19 | public static U64I64F64[] newU64I64F64Array(int size) { 20 | U64I64F64[] array = new U64I64F64[size]; 21 | for (int i = 0; i < size; i++) { 22 | array[i] = new U64I64F64(); 23 | } 24 | return array; 25 | } 26 | 27 | public U64I64F64() { 28 | this(ByteBuffer.allocate(8)); 29 | } 30 | 31 | private U64I64F64(ByteBuffer buffer) { 32 | this.data = buffer.duplicate(); 33 | } 34 | public static U64I64F64 wrap(ByteBuffer buffer) { 35 | return new U64I64F64(buffer); 36 | } 37 | 38 | public void setU64(long value) { 39 | data.putLong(0, value); 40 | } 41 | 42 | public void setI64(long value) { 43 | data.putLong(0, value); 44 | } 45 | 46 | public void setF64(double value) { 47 | data.putDouble(0, value); 48 | } 49 | 50 | public long getU64() { 51 | return data.getLong(0); 52 | } 53 | 54 | public long getI64() { 55 | return data.getLong(0); 56 | } 57 | 58 | public double getF64() { 59 | return data.getDouble(0); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LasDefinitions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2014, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | public class LasDefinitions { 14 | 15 | public static final int LAS_TOOLS_VERSION = 220310; 16 | 17 | public static final int LAS_TOOLS_FORMAT_DEFAULT = 0; 18 | public static final int LAS_TOOLS_FORMAT_LAS = 1; 19 | public static final int LAS_TOOLS_FORMAT_LAZ = 2; 20 | public static final int LAS_TOOLS_FORMAT_BIN = 3; 21 | public static final int LAS_TOOLS_FORMAT_QFIT = 4; 22 | public static final int LAS_TOOLS_FORMAT_VRML = 5; 23 | public static final int LAS_TOOLS_FORMAT_TXT = 6; 24 | public static final int LAS_TOOLS_FORMAT_SHP = 7; 25 | public static final int LAS_TOOLS_FORMAT_ASC = 8; 26 | public static final int LAS_TOOLS_FORMAT_BIL = 9; 27 | public static final int LAS_TOOLS_FORMAT_FLT = 10; 28 | public static final int LAS_TOOLS_FORMAT_DTM = 11; 29 | 30 | public static final int LAS_TOOLS_GLOBAL_ENCODING_BIT_GPS_TIME_TYPE = 0; 31 | public static final int LAS_TOOLS_GLOBAL_ENCODING_BIT_WDP_INTERNAL = 1; 32 | public static final int LAS_TOOLS_GLOBAL_ENCODING_BIT_WDP_EXTERNAL = 2; 33 | public static final int LAS_TOOLS_GLOBAL_ENCODING_BIT_SYNTHETIC = 3; 34 | public static final int LAS_TOOLS_GLOBAL_ENCODING_BIT_OGC_WKT_CRS = 4; 35 | 36 | public static final int LAS_TOOLS_IO_IBUFFER_SIZE = 262144; 37 | public static final int LAS_TOOLS_IO_OBUFFER_SIZE = 262144; 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASvlr_key_entry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2014, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | import java.nio.ByteBuffer; 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | public class LASvlr_key_entry { 18 | public char key_id; 19 | public char tiff_tag_location; 20 | public char count; 21 | public char value_offset; 22 | 23 | public LASvlr_key_entry() { 24 | } 25 | 26 | public LASvlr_key_entry(LASvlr_key_entry other) { 27 | this.key_id = other.key_id; 28 | this.tiff_tag_location = other.tiff_tag_location; 29 | this.count = other.count; 30 | this.value_offset = other.value_offset; 31 | } 32 | 33 | public void writeTo(ByteBuffer buffer) { 34 | buffer.putChar(key_id); 35 | buffer.putChar(tiff_tag_location); 36 | buffer.putChar(count); 37 | buffer.putChar(value_offset); 38 | } 39 | 40 | public static LASvlr_key_entry[] fromByteBuffer(ByteBuffer buffer) { 41 | List entries = new ArrayList<>(); 42 | while (buffer.hasRemaining()) { 43 | LASvlr_key_entry entry = new LASvlr_key_entry(); 44 | entry.key_id = buffer.getChar(); 45 | entry.tiff_tag_location = buffer.getChar(); 46 | entry.count = buffer.getChar(); 47 | entry.value_offset = buffer.getChar(); 48 | entries.add(entry); 49 | } 50 | return entries.toArray(new LASvlr_key_entry[entries.size()]); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/com/github/mreutegg/laszip4j/laslib/LASwriterLASTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Marcel Reutegger 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.mreutegg.laszip4j.laslib; 18 | 19 | import com.github.mreutegg.laszip4j.DataFiles; 20 | import com.github.mreutegg.laszip4j.LASReader; 21 | import com.github.mreutegg.laszip4j.LASReaderTest; 22 | import com.github.mreutegg.laszip4j.lastools.Laszip; 23 | import org.junit.Rule; 24 | import org.junit.Test; 25 | 26 | import java.io.File; 27 | 28 | public class LASwriterLASTest { 29 | 30 | @Rule 31 | public final DataFiles files = new DataFiles(); 32 | 33 | private final File las = new File("target", files.laz.getName() + LASwriterLASTest.class.getSimpleName() + ".las"); 34 | 35 | private final File las14 = new File("target", files.laz14.getName() + LASwriterLASTest.class.getSimpleName() + ".las"); 36 | 37 | @Test 38 | public void writeLas() { 39 | Laszip.run(new String[]{"-i", files.laz.getPath(), "-o", las.getPath()}); 40 | LASReader reader = new LASReader(las); 41 | LASReaderTest.verifyLaz(reader.getPoints(), reader.getHeader()); 42 | } 43 | 44 | @Test 45 | public void writeLas14() { 46 | Laszip.run(new String[]{"-i", files.laz14.getPath(), "-o", las14.getPath()}); 47 | LASReaderTest.verifyLaz14(las14); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASreadItemCompressed_BYTE_v1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2014, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | public class LASreadItemCompressed_BYTE_v1 extends LASreadItemCompressed { 14 | 15 | private int number; // unsigned 16 | private PointDataRecordBytes last_item; 17 | 18 | private IntegerCompressor ic_byte; 19 | 20 | public LASreadItemCompressed_BYTE_v1(ArithmeticDecoder dec, int number) 21 | { 22 | /* set decoder */ 23 | assert(dec != null); 24 | assert(number != 0); 25 | this.number = number; 26 | 27 | /* create models and integer compressors */ 28 | ic_byte = new IntegerCompressor(dec, 8, number); 29 | } 30 | 31 | @Override 32 | public void init(PointDataRecord seedItem, MutableInteger notUsed) 33 | { 34 | /* init state */ 35 | 36 | /* init models and integer compressors */ 37 | ic_byte.initDecompressor(); 38 | 39 | /* init last item */ 40 | last_item = new PointDataRecordBytes((PointDataRecordBytes) seedItem); 41 | } 42 | 43 | @Override 44 | public PointDataRecord read(MutableInteger notUsed) 45 | { 46 | PointDataRecordBytes result = new PointDataRecordBytes(number); 47 | 48 | for (int i = 0; i < number; i++) 49 | { 50 | result.Bytes[i] = (byte)(ic_byte.decompress(last_item.Bytes[i], i)); 51 | } 52 | 53 | return result; 54 | } 55 | 56 | @Override 57 | public boolean chunk_sizes() { 58 | return false; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASvlr_wave_packet_descr.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2014, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | import java.nio.ByteBuffer; 14 | import java.nio.ByteOrder; 15 | 16 | import static com.github.mreutegg.laszip4j.clib.Cstring.memset; 17 | 18 | public class LASvlr_wave_packet_descr { 19 | 20 | private ByteBuffer data = ByteBuffer.allocate(26).order(ByteOrder.LITTLE_ENDIAN); 21 | 22 | LASvlr_wave_packet_descr() {clean();}; 23 | void clean() {memset(data, (byte) 0, 26);}; 24 | public byte getBitsPerSample() {return data.get(0);}; 25 | public byte getCompressionType() {return data.get(1);}; 26 | public int getNumberOfSamples() {return data.getInt(2);}; 27 | public int getTemporalSpacing() {return data.getInt(6);}; 28 | public double getDigitizerGain() {return data.getDouble(10);}; 29 | public double getDigitizerOffset() {return data.getDouble(18);}; 30 | public void setBitsPerSample(byte bps) {data.put(0, bps);}; 31 | public void setCompressionType(byte compression) {data.put(1, compression);}; 32 | public void setNumberOfSamples(int samples) {data.putInt(2, samples);}; 33 | public void setTemporalSpacing(int spacing) {data.putInt(6, spacing);}; 34 | public void setDigitizerGain(double gain) {data.putDouble(10, gain);}; 35 | public void setDigitizerOffset(double offset) {data.putDouble(18, offset);}; 36 | 37 | public static LASvlr_wave_packet_descr fromByteArray(byte[] data) { 38 | LASvlr_wave_packet_descr descr = new LASvlr_wave_packet_descr(); 39 | descr.data.put(data); 40 | return descr; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASquantizer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2015, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | public class LASquantizer { 14 | 15 | public double x_scale_factor; 16 | public double y_scale_factor; 17 | public double z_scale_factor; 18 | public double x_offset; 19 | public double y_offset; 20 | public double z_offset; 21 | 22 | public double get_x(int X) { return x_scale_factor*X+x_offset; }; 23 | public double get_y(int Y) { return y_scale_factor*Y+y_offset; }; 24 | public double get_z(int Z) { return z_scale_factor*Z+z_offset; }; 25 | 26 | public int get_X(double x) { if (x >= x_offset) return (int)((x-x_offset)/x_scale_factor+0.5); else return (int)((x-x_offset)/x_scale_factor-0.5); }; 27 | public int get_Y(double y) { if (y >= y_offset) return (int)((y-y_offset)/y_scale_factor+0.5); else return (int)((y-y_offset)/y_scale_factor-0.5); }; 28 | public int get_Z(double z) { if (z >= z_offset) return (int)((z-z_offset)/z_scale_factor+0.5); else return (int)((z-z_offset)/z_scale_factor-0.5); }; 29 | 30 | public LASquantizer() 31 | { 32 | x_scale_factor = 0.01; 33 | y_scale_factor = 0.01; 34 | z_scale_factor = 0.01; 35 | x_offset = 0.0; 36 | y_offset = 0.0; 37 | z_offset = 0.0; 38 | }; 39 | 40 | LASquantizer(LASquantizer other) { 41 | this.x_scale_factor = other.x_scale_factor; 42 | this.y_scale_factor = other.y_scale_factor; 43 | this.z_scale_factor = other.z_scale_factor; 44 | this.x_offset = other.x_offset; 45 | this.y_offset = other.y_offset; 46 | this.z_offset = other.z_offset; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # laszip4j 2 | 3 | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.mreutegg/laszip4j/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.mreutegg/laszip4j/) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=mreutegg_laszip4j&metric=alert_status)](https://sonarcloud.io/dashboard?id=mreutegg_laszip4j) [![Build Status](https://mreutegg.visualstudio.com/laszip4j/_apis/build/status/mreutegg.laszip4j)](https://mreutegg.visualstudio.com/laszip4j/_build/latest?definitionId=1) 4 | 5 | The LASzip library ported to Java 6 | 7 | This is a Java port of the [LASzip](https://github.com/LASzip/LASzip) and 8 | [LAStools](https://github.com/LAStools/LAStools) libraries by Martin Isenburg ([RIP](https://lidarmag.com/2021/10/30/in-memoriam-martin-isenburg-1972-2021/)). 9 | 10 | The port to Java is *not* complete. Many classes are stubs only and have not 11 | been ported. The main driver was to have a Java implementation of the laszip 12 | utility and be able to unpack LAZ files for 13 | [Canton of Zurich](http://geolion.zh.ch/geodatensatz/2618) 14 | in Switzerland, which works fine. 15 | 16 | Usage is the same as with the native laszip utility, but invoked as a runnable 17 | jar: 18 | 19 | java -jar laszip4j-0.20.jar -oparse xyzc -keep_class 3 4 5 6 10 -i 7015_2640.laz -o 7015_2640.xyzk 20 | 21 | On top of LASzip and LAStools this library also provides convenience classes 22 | for reading LAS points. You can read LAS points in your code like this: 23 | 24 | LASReader reader = new LASReader(new File("data.laz")); 25 | for (LASPoint p : reader.getPoints()) { 26 | // read something from point 27 | p.getClassification(); 28 | } 29 | 30 | See also [LASReaderTest](src/test/java/com/github/mreutegg/laszip4j/LASReaderTest.java) 31 | on how to use the LASReader class. 32 | 33 | As of version 0.13, laszip4j also supports writing las files. In the simplest 34 | case the executable jar file can be used to read compressed data from a laz 35 | file and write it to a corresponding las file. 36 | 37 | java -jar laszip4j-0.18.jar -i 7015_2640.laz -o 7015_2640.las 38 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASintervalStartCell.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011-2015, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | import static java.lang.Boolean.FALSE; 14 | import static java.lang.Boolean.TRUE; 15 | 16 | public class LASintervalStartCell extends LASintervalCell { 17 | public int full; // unsigned 18 | public int total; // unsigned 19 | public LASintervalCell last; 20 | 21 | public LASintervalStartCell() { 22 | full = 0; 23 | total = 0; 24 | last = null; 25 | } 26 | 27 | LASintervalStartCell(int p_index) 28 | { 29 | super(p_index); 30 | full = 1; 31 | total = 1; 32 | last = null; 33 | } 34 | 35 | boolean add(int p_index) { 36 | return add(p_index, 1000); 37 | } 38 | 39 | boolean add(int p_index, int threshold) 40 | { 41 | int current_end = (last != null ? last.end : end); 42 | assert(p_index > current_end); 43 | int diff = p_index - current_end; 44 | full++; 45 | if (diff > threshold) 46 | { 47 | if (last != null) 48 | { 49 | last.next = new LASintervalCell(p_index); 50 | last = last.next; 51 | } 52 | else 53 | { 54 | next = new LASintervalCell(p_index); 55 | last = next; 56 | } 57 | total++; 58 | return TRUE; // created new interval 59 | } 60 | if (last != null) 61 | { 62 | last.end = p_index; 63 | } 64 | else 65 | { 66 | end = p_index; 67 | } 68 | total += diff; 69 | return FALSE; // added to interval 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LAScontextPOINT14.java: -------------------------------------------------------------------------------- 1 | /* 2 | COPYRIGHT: 3 | 4 | (c) 2007-2022, rapidlasso GmbH - fast tools to catch reality 5 | 6 | This is free software; you can redistribute and/or modify it under the 7 | terms of the Apache Public License 2.0 published by the Apache Software 8 | Foundation. See the COPYING file for more information. 9 | 10 | This software is distributed WITHOUT ANY WARRANTY and without even the 11 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | */ 13 | package com.github.mreutegg.laszip4j.laszip; 14 | 15 | class LAScontextPOINT14 16 | { 17 | public boolean unused; 18 | 19 | public PointDataRecordPoint14 last_item = null; 20 | public int[] last_intensity = new int[8]; 21 | public StreamingMedian5[] last_X_diff_median5 = StreamingMedian5.newStreamingMedian5(12); 22 | public StreamingMedian5[] last_Y_diff_median5 = StreamingMedian5.newStreamingMedian5(12); 23 | public long[] last_Z = new long[8]; 24 | 25 | public boolean initialized = false; 26 | public ArithmeticModel[] m_changed_values = new ArithmeticModel[8]; 27 | public ArithmeticModel m_scanner_channel; 28 | public ArithmeticModel[] m_number_of_returns = new ArithmeticModel[16]; 29 | public ArithmeticModel m_return_number_gps_same; 30 | public ArithmeticModel[] m_return_number = new ArithmeticModel[16]; 31 | public IntegerCompressor ic_dX; 32 | public IntegerCompressor ic_dY; 33 | public IntegerCompressor ic_Z; 34 | 35 | public ArithmeticModel[] m_classification = new ArithmeticModel[64]; 36 | 37 | public ArithmeticModel[] m_flags = new ArithmeticModel[64]; 38 | 39 | public ArithmeticModel[] m_user_data = new ArithmeticModel[64]; 40 | 41 | public IntegerCompressor ic_intensity; 42 | 43 | public IntegerCompressor ic_scan_angle; 44 | 45 | public IntegerCompressor ic_point_source_ID; 46 | 47 | // GPS time stuff 48 | public int last, next; 49 | public long[] last_gpstime = new long[4]; 50 | public int[] last_gpstime_diff = new int[4]; 51 | public int[] multi_extreme_counter = new int[4]; 52 | 53 | public ArithmeticModel m_gpstime_multi; 54 | public ArithmeticModel m_gpstime_0diff; 55 | public IntegerCompressor ic_gpstime; 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/ByteStreamOutOstream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | import java.io.DataOutputStream; 14 | import java.io.FilterOutputStream; 15 | import java.io.IOException; 16 | import java.io.OutputStream; 17 | 18 | public class ByteStreamOutOstream extends ByteStreamOutDataOutput { 19 | 20 | private final CountingOutputStream cOut; 21 | 22 | public ByteStreamOutOstream(OutputStream out) { 23 | super(null); 24 | this.cOut = new CountingOutputStream(out); 25 | this.dataOut = new DataOutputStream(cOut); 26 | } 27 | 28 | @Override 29 | public boolean isSeekable() { 30 | return false; 31 | } 32 | 33 | @Override 34 | public long tell() { 35 | return cOut.getCount(); 36 | } 37 | 38 | @Override 39 | public boolean seek(long position) { 40 | return false; 41 | } 42 | 43 | @Override 44 | public boolean seekEnd() { 45 | return false; 46 | } 47 | 48 | @Override 49 | public void close() throws IOException { 50 | cOut.close(); 51 | } 52 | 53 | private static class CountingOutputStream extends FilterOutputStream { 54 | 55 | private long count = 0; 56 | 57 | CountingOutputStream(OutputStream out) { 58 | super(out); 59 | } 60 | 61 | long getCount() { 62 | return count; 63 | } 64 | 65 | @Override 66 | public void write(int b) throws IOException { 67 | super.write(b); 68 | count++; 69 | } 70 | 71 | @Override 72 | public void write(byte[] b, int off, int len) throws IOException { 73 | super.write(b, off, len); 74 | count += len; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/clib/Cstdlib.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Marcel Reutegger 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.mreutegg.laszip4j.clib; 18 | 19 | import java.nio.ByteBuffer; 20 | import java.security.NoSuchAlgorithmException; 21 | import java.security.SecureRandom; 22 | import java.util.Random; 23 | 24 | public final class Cstdlib { 25 | 26 | public static final int RAND_MAX = Character.MAX_VALUE; 27 | 28 | private static final ByteBuffer SEED = ByteBuffer.allocate(32) 29 | .put(SecureRandom.getSeed(32)); 30 | 31 | private static Random random = newSecureRandom(SEED); 32 | 33 | private Cstdlib() { 34 | } 35 | 36 | public static double atof(String s) { 37 | return Double.parseDouble(s.trim()); 38 | } 39 | 40 | public static int atoi(String s) { 41 | return Integer.parseInt(s.trim()); 42 | } 43 | 44 | public static void srand(int seed) { 45 | ByteBuffer seedBytes = SEED; 46 | if (seed != 1) { 47 | seedBytes = ByteBuffer.allocate(4).putInt(seed); 48 | } 49 | random = newSecureRandom(seedBytes); 50 | } 51 | 52 | public static int rand() { 53 | return random.nextInt(RAND_MAX + 1); 54 | } 55 | 56 | private static SecureRandom newSecureRandom(ByteBuffer seed) { 57 | try { 58 | SecureRandom r = SecureRandom.getInstance("SHA1PRNG"); 59 | r.setSeed(seed.array()); 60 | return r; 61 | } catch (NoSuchAlgorithmException e) { 62 | throw new IllegalStateException(); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/ByteStreamInStream.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | import java.io.DataInputStream; 14 | import java.io.FilterInputStream; 15 | import java.io.IOException; 16 | import java.io.InputStream; 17 | 18 | public class ByteStreamInStream extends ByteStreamInDataInput { 19 | 20 | private final CountingInputStream cIn; 21 | 22 | public ByteStreamInStream(InputStream in) { 23 | super(null); 24 | this.cIn = new CountingInputStream(in); 25 | this.dataIn = new DataInputStream(cIn); 26 | } 27 | 28 | @Override 29 | public boolean isSeekable() { 30 | return false; 31 | } 32 | 33 | @Override 34 | public long tell() { 35 | return cIn.getCount(); 36 | } 37 | 38 | @Override 39 | public boolean seek(long position) { 40 | return false; 41 | } 42 | 43 | @Override 44 | public boolean seekEnd(long distance) { 45 | return false; 46 | } 47 | 48 | @Override 49 | public void close() throws IOException { 50 | cIn.close(); 51 | } 52 | 53 | private static class CountingInputStream extends FilterInputStream { 54 | 55 | private long count = 0; 56 | 57 | CountingInputStream(InputStream in) { 58 | super(in); 59 | } 60 | 61 | long getCount() { 62 | return count; 63 | } 64 | 65 | @Override 66 | public int read() throws IOException { 67 | int c = super.read(); 68 | if (c != -1) { 69 | count++; 70 | } 71 | return c; 72 | } 73 | 74 | @Override 75 | public int read(byte[] b, int off, int len) throws IOException { 76 | int num = super.read(b, off, len); 77 | if (num != -1) { 78 | count += num; 79 | } 80 | return num; 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASreadItemCompressed_BYTE_v2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | import static com.github.mreutegg.laszip4j.laszip.MyDefs.U8_FOLD; 14 | 15 | public class LASreadItemCompressed_BYTE_v2 extends LASreadItemCompressed { 16 | 17 | private ArithmeticDecoder dec; 18 | private int number; // unsigned 19 | private PointDataRecordBytes last_item; 20 | 21 | private ArithmeticModel[] m_byte; 22 | 23 | public LASreadItemCompressed_BYTE_v2(ArithmeticDecoder dec, int number) 24 | { 25 | int i; 26 | 27 | /* set decoder */ 28 | assert(dec != null); 29 | this.dec = dec; 30 | assert(number != 0); 31 | this.number = number; 32 | 33 | /* create models and integer compressors */ 34 | m_byte = new ArithmeticModel[number]; 35 | for (i = 0; i < number; i++) 36 | { 37 | m_byte[i] = dec.createSymbolModel(256); 38 | } 39 | } 40 | 41 | @Override 42 | public void init(PointDataRecord seedItem, MutableInteger notUsed) 43 | { 44 | int i; 45 | /* init state */ 46 | 47 | /* init models and integer compressors */ 48 | for (i = 0; i < number; i++) 49 | { 50 | dec.initSymbolModel(m_byte[i]); 51 | } 52 | 53 | last_item = new PointDataRecordBytes((PointDataRecordBytes) seedItem); 54 | } 55 | 56 | @Override 57 | public PointDataRecord read(MutableInteger notUsed) 58 | { 59 | PointDataRecordBytes result = new PointDataRecordBytes(number); 60 | 61 | for (int i = 0; i < number; i++) 62 | { 63 | int value = last_item.Bytes[i] + dec.decodeSymbol(m_byte[i]); 64 | result.Bytes[i] = U8_FOLD(value); 65 | } 66 | 67 | return result; 68 | } 69 | 70 | @Override 71 | public boolean chunk_sizes() { 72 | return false; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderTXT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | import com.github.mreutegg.laszip4j.laszip.ByteStreamIn; 14 | 15 | import java.io.InputStream; 16 | 17 | // TODO: only dummy implementation 18 | public class LASreaderTXT extends LASreader { 19 | @Override 20 | public int get_format() { 21 | return 0; 22 | } 23 | 24 | @Override 25 | public boolean seek(long p_index) { 26 | return false; 27 | } 28 | 29 | @Override 30 | public ByteStreamIn get_stream() { 31 | return null; 32 | } 33 | 34 | @Override 35 | public void close(boolean close_stream) { 36 | 37 | } 38 | 39 | @Override 40 | protected boolean read_point_default() { 41 | return false; 42 | } 43 | 44 | public void set_pts(boolean pts) { 45 | 46 | } 47 | 48 | public void set_ptx(boolean ptx) { 49 | 50 | } 51 | 52 | public void set_translate_intensity(float translate_intensity) { 53 | 54 | } 55 | 56 | public void set_scale_intensity(float scale_intensity) { 57 | 58 | } 59 | 60 | public void set_translate_scan_angle(float translate_scan_angle) { 61 | 62 | } 63 | 64 | public void set_scale_scan_angle(float scale_scan_angle) { 65 | 66 | } 67 | 68 | public void set_scale_factor(double[] scale_factor) { 69 | 70 | } 71 | 72 | public void set_offset(double[] offset) { 73 | 74 | } 75 | 76 | public void add_attribute(int attribute_data_type, String attribute_name, String attribute_description, double attribute_scale, double attribute_offset, double attribute_pre_scale, double attribute_pre_offset) { 77 | 78 | } 79 | 80 | public boolean open(String file_name, String parse_string, int skip_lines, boolean populate_header) { 81 | return false; 82 | } 83 | 84 | public boolean open(InputStream in, int i, String parse_string, int skip_lines, boolean b) { 85 | return false; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/test/java/com/github/mreutegg/laszip4j/laszip/MyDefsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2024 Marcel Reutegger 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.mreutegg.laszip4j.laszip; 18 | 19 | import org.junit.Test; 20 | 21 | import static com.github.mreutegg.laszip4j.laszip.MyDefs.clearBit; 22 | import static com.github.mreutegg.laszip4j.laszip.MyDefs.setBit; 23 | import static org.junit.Assert.assertEquals; 24 | 25 | public class MyDefsTest { 26 | 27 | @Test 28 | public void setBitByte() { 29 | byte value = 0; 30 | for (int i = 0; i < Byte.SIZE; i++) { 31 | assertEquals(i, bitCount(value)); 32 | value = setBit(value, i); 33 | assertEquals(i + 1, bitCount(value)); 34 | } 35 | for (int i = 0; i < Byte.SIZE; i++) { 36 | assertEquals(Byte.SIZE - i, bitCount(value)); 37 | value = clearBit(value, i); 38 | assertEquals(Byte.SIZE - 1 - i, bitCount(value)); 39 | } 40 | } 41 | 42 | @Test 43 | public void setBitShort() { 44 | short value = 0; 45 | for (int i = 0; i < Short.SIZE; i++) { 46 | assertEquals(i, bitCount(value)); 47 | value = setBit(value, i); 48 | assertEquals(i + 1, bitCount(value)); 49 | } 50 | for (int i = 0; i < Short.SIZE; i++) { 51 | assertEquals(Short.SIZE - i, bitCount(value)); 52 | value = clearBit(value, i); 53 | assertEquals(Short.SIZE - 1 - i, bitCount(value)); 54 | } 55 | } 56 | 57 | private static int bitCount(short value) { 58 | return Integer.bitCount(Short.toUnsignedInt(value)); 59 | } 60 | 61 | private static int bitCount(byte value) { 62 | return Integer.bitCount(Byte.toUnsignedInt(value)); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderBuffered.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | import com.github.mreutegg.laszip4j.laszip.ByteStreamIn; 14 | 15 | // TODO: only dummy implementation 16 | public class LASreaderBuffered extends LASreader { 17 | @Override 18 | public int get_format() { 19 | return 0; 20 | } 21 | 22 | @Override 23 | public boolean seek(long p_index) { 24 | return false; 25 | } 26 | 27 | @Override 28 | public ByteStreamIn get_stream() { 29 | return null; 30 | } 31 | 32 | @Override 33 | public void close(boolean close_stream) { 34 | 35 | } 36 | 37 | @Override 38 | protected boolean read_point_default() { 39 | return false; 40 | } 41 | 42 | 43 | public void set_buffer_size(float buffer_size) { 44 | 45 | } 46 | 47 | public void set_scale_factor(double[] scale_factor) { 48 | 49 | } 50 | 51 | public void set_offset(double[] offset) { 52 | 53 | } 54 | 55 | public void set_parse_string(String parse_string) { 56 | 57 | } 58 | 59 | public void set_skip_lines(int skip_lines) { 60 | 61 | } 62 | 63 | public void set_populate_header(boolean populate_header) { 64 | 65 | } 66 | 67 | public void set_translate_intensity(float translate_intensity) { 68 | 69 | } 70 | 71 | public void set_scale_intensity(float scale_intensity) { 72 | 73 | } 74 | 75 | public void set_translate_scan_angle(float translate_scan_angle) { 76 | 77 | } 78 | 79 | public void set_scale_scan_angle(float scale_scan_angle) { 80 | 81 | } 82 | 83 | public void set_file_name(String file_name) { 84 | 85 | } 86 | 87 | public void add_neighbor_file_name(String s) { 88 | 89 | } 90 | 91 | public boolean open() { 92 | return false; 93 | } 94 | 95 | public boolean reopen() { 96 | return false; 97 | } 98 | 99 | public void remove_buffer() { 100 | 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/LASVariableLengthRecord.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Marcel Reutegger 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.mreutegg.laszip4j; 18 | 19 | import com.github.mreutegg.laszip4j.laslib.LASvlr; 20 | 21 | import java.nio.ByteBuffer; 22 | 23 | import static com.github.mreutegg.laszip4j.laszip.MyDefs.stringFromByteArray; 24 | 25 | /** 26 | * A LAS variable length header record. 27 | */ 28 | public class LASVariableLengthRecord { 29 | 30 | private final LASvlr vlr; 31 | 32 | LASVariableLengthRecord(LASvlr vlr) { 33 | this.vlr = vlr; 34 | } 35 | 36 | /** 37 | * @return "Reserved" as an unsigned short (char). 38 | */ 39 | public char getReserved() { 40 | return vlr.reserved; 41 | } 42 | 43 | /** 44 | * @return "User ID" as a String. 45 | */ 46 | public String getUserID() { 47 | return stringFromByteArray(vlr.user_id); 48 | } 49 | 50 | /** 51 | * @return "Record ID" as an unsigned short (char). 52 | */ 53 | public char getRecordID() { 54 | return vlr.record_id; 55 | } 56 | 57 | /** 58 | * @return "Record Length After Header" as an unsigned short (char). 59 | */ 60 | public char getRecordLength() { 61 | return vlr.record_length_after_header; 62 | } 63 | 64 | /** 65 | * @return "Description" as a String. 66 | */ 67 | public String getDescription() { 68 | return stringFromByteArray(vlr.description); 69 | } 70 | 71 | /** 72 | * @return the data of the record as a read-only ByteBuffer. 73 | */ 74 | public ByteBuffer getData() { 75 | return ByteBuffer.wrap(vlr.data).asReadOnlyBuffer(); 76 | } 77 | 78 | /** 79 | * @return the data of the record as a String. 80 | */ 81 | public String getDataAsString() { 82 | return stringFromByteArray(vlr.data); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/LASExtendedVariableLengthRecord.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Marcel Reutegger 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.mreutegg.laszip4j; 18 | 19 | import com.github.mreutegg.laszip4j.laslib.LASevlr; 20 | 21 | import java.nio.ByteBuffer; 22 | 23 | import static com.github.mreutegg.laszip4j.laszip.MyDefs.stringFromByteArray; 24 | 25 | /** 26 | * A LAS extended variable length header record. 27 | */ 28 | public class LASExtendedVariableLengthRecord { 29 | 30 | private final LASevlr evlr; 31 | 32 | LASExtendedVariableLengthRecord(LASevlr evlr) { 33 | this.evlr = evlr; 34 | } 35 | 36 | /** 37 | * @return "Reserved" as an unsigned short (char). 38 | */ 39 | public char getReserved() { 40 | return evlr.reserved; 41 | } 42 | 43 | /** 44 | * @return "User ID" as a String. 45 | */ 46 | public String getUserID() { 47 | return stringFromByteArray(evlr.user_id); 48 | } 49 | 50 | /** 51 | * @return "Record ID" as an unsigned short (char). 52 | */ 53 | public char getRecordID() { 54 | return evlr.record_id; 55 | } 56 | 57 | /** 58 | * @return "Record Length After Header" as an unsigned long 59 | */ 60 | public long getRecordLength() { 61 | return evlr.record_length_after_header; 62 | } 63 | 64 | /** 65 | * @return "Description" as a String. 66 | */ 67 | public String getDescription() { 68 | return stringFromByteArray(evlr.description); 69 | } 70 | 71 | /** 72 | * @return the data of the record as a read-only ByteBuffer. 73 | */ 74 | public ByteBuffer getData() { 75 | return ByteBuffer.wrap(evlr.data).asReadOnlyBuffer(); 76 | } 77 | 78 | /** 79 | * @return the data of the record as a String. 80 | */ 81 | public String getDataAsString() { 82 | return stringFromByteArray(evlr.data); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laslib/LASreaderMerged.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laslib; 12 | 13 | import com.github.mreutegg.laszip4j.laszip.ByteStreamIn; 14 | 15 | import static java.lang.Boolean.FALSE; 16 | 17 | // TODO: only dummy implementation 18 | public class LASreaderMerged extends LASreader { 19 | 20 | @Override 21 | public int get_format() { 22 | return 0; 23 | } 24 | 25 | @Override 26 | public boolean seek(long p_index) { 27 | return FALSE; 28 | } 29 | 30 | @Override 31 | public ByteStreamIn get_stream() { 32 | return null; 33 | } 34 | 35 | @Override 36 | public void close(boolean close_stream) { 37 | 38 | } 39 | 40 | @Override 41 | protected boolean read_point_default() { 42 | return false; 43 | } 44 | 45 | public void set_scale_factor(double[] scale_factor) { 46 | 47 | } 48 | 49 | public void set_offset(double[] offset) { 50 | 51 | } 52 | 53 | public void set_parse_string(String parse_string) { 54 | 55 | } 56 | 57 | public void set_skip_lines(int skip_lines) { 58 | 59 | } 60 | 61 | public void set_populate_header(boolean populate_header) { 62 | 63 | } 64 | 65 | public void set_keep_lastiling(boolean keep_lastiling) { 66 | 67 | } 68 | 69 | public void set_translate_intensity(float translate_intensity) { 70 | 71 | } 72 | 73 | public void set_scale_intensity(float scale_intensity) { 74 | 75 | } 76 | 77 | public void set_translate_scan_angle(float translate_scan_angle) { 78 | 79 | } 80 | 81 | public void set_scale_scan_angle(float scale_scan_angle) { 82 | 83 | } 84 | 85 | public void set_io_ibuffer_size(int io_ibuffer_size) { 86 | 87 | } 88 | 89 | public void add_file_name(String s) { 90 | 91 | } 92 | 93 | public boolean open() { 94 | return false; 95 | } 96 | 97 | public void set_files_are_flightlines(boolean files_are_flightlines) { 98 | 99 | } 100 | 101 | public void set_apply_file_source_ID(boolean apply_file_source_ID) { 102 | 103 | } 104 | 105 | public boolean reopen() { 106 | return false; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/clib/Cstring.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Marcel Reutegger 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.mreutegg.laszip4j.clib; 18 | 19 | import com.github.mreutegg.laszip4j.laszip.MyDefs; 20 | 21 | import java.nio.ByteBuffer; 22 | 23 | public final class Cstring { 24 | 25 | private Cstring() { 26 | } 27 | 28 | public static int strcmp(byte[] s1, String s2) { 29 | return trim(MyDefs.stringFromByteArray(s1)).compareTo(trim(s2)); 30 | } 31 | 32 | public static int strcmp(String s1, String s2) { 33 | return trim(s1).compareTo(trim(s2)); 34 | } 35 | 36 | public static int strncmp(String s1, String s2, int num) { 37 | s1 = trim(s1); 38 | s2 = trim(s2); 39 | if (s1.length() > num) { 40 | s1 = s1.substring(0, num); 41 | } 42 | if (s2.length() > num) { 43 | s2 = s2.substring(0, num); 44 | } 45 | return s1.compareTo(s2); 46 | } 47 | 48 | public static int memcmp(byte[] b1, byte[] b2, int num) { 49 | for (int i = 0; i < num; i++) { 50 | int cmp = Byte.compare(b1[i], b2[i]); 51 | if (cmp != 0) { 52 | return cmp; 53 | } 54 | } 55 | return 0; 56 | } 57 | 58 | public static byte[] memcpy(byte[] dest, byte[] src, int num) { 59 | System.arraycopy(src, 0, dest, 0, num); 60 | return dest; 61 | } 62 | 63 | public static void memset(ByteBuffer bb, byte value, int num) { 64 | for (int i = 0; i < num; i++) { 65 | bb.put(i, value); 66 | } 67 | } 68 | 69 | public static int strlen(String s) { 70 | return trim(s).length(); 71 | } 72 | 73 | public static int strlen(char[] s) { 74 | return strlen(new String(s)); 75 | } 76 | 77 | public static String trim(char[] s) { 78 | return trim(new String(s)); 79 | } 80 | 81 | public static String trim(String s) { 82 | int idx = s.indexOf('\0'); 83 | if (idx != -1) { 84 | return s.substring(0, idx); 85 | } else { 86 | return s; 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/LASWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Marcel Reutegger 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.mreutegg.laszip4j; 18 | 19 | import com.github.mreutegg.laszip4j.laslib.LASreader; 20 | import com.github.mreutegg.laszip4j.laslib.LASwriteOpener; 21 | import com.github.mreutegg.laszip4j.laslib.LASwriter; 22 | 23 | import java.io.File; 24 | import java.util.Arrays; 25 | 26 | /** 27 | * Utility for writing a LAS file. 28 | */ 29 | public final class LASWriter { 30 | 31 | private final LASReader reader; 32 | 33 | /** 34 | * Create a new writer that will read point data from the given reader. 35 | * 36 | * @param reader the source of the points to write. 37 | */ 38 | public LASWriter(LASReader reader) { 39 | this.reader = reader; 40 | } 41 | 42 | /** 43 | * Write the points to the given output file. 44 | * 45 | * @param out the output file. 46 | */ 47 | public void write(File out) { 48 | try (LASreader r = reader.openReader()) { 49 | LASwriteOpener opener = new LASwriteOpener(); 50 | opener.set_file_name(out.getAbsolutePath()); 51 | LASwriter w = opener.open(r.header); 52 | int[] byReturn = r.header.number_of_points_by_return; 53 | Arrays.fill(byReturn, 0); 54 | long[] extByReturn = r.header.extended_number_of_points_by_return; 55 | Arrays.fill(extByReturn, 0); 56 | r.header.number_of_point_records = 0; 57 | try { 58 | while (r.read_point()) { 59 | w.write_point(r.point); 60 | short returnNumber = r.point.get_return_number(); 61 | returnNumber--; 62 | if (returnNumber < byReturn.length) { 63 | byReturn[returnNumber]++; 64 | } 65 | if (returnNumber < extByReturn.length) { 66 | extByReturn[returnNumber]++; 67 | } 68 | r.header.number_of_point_records++; 69 | } 70 | w.update_header(r.header); 71 | } finally { 72 | w.close(); 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ "master" ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ "master" ] 20 | schedule: 21 | - cron: '41 16 * * 4' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: [ 'java' ] 36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] 37 | # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support 38 | 39 | steps: 40 | - name: Checkout repository 41 | uses: actions/checkout@v3 42 | 43 | # Initializes the CodeQL tools for scanning. 44 | - name: Initialize CodeQL 45 | uses: github/codeql-action/init@v2 46 | with: 47 | languages: ${{ matrix.language }} 48 | # If you wish to specify custom queries, you can do so here or in a config file. 49 | # By default, queries listed here will override any specified in a config file. 50 | # Prefix the list here with "+" to use these queries and those in the config file. 51 | 52 | # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs 53 | # queries: security-extended,security-and-quality 54 | 55 | 56 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 57 | # If this step fails, then you should remove it and run the build manually (see below) 58 | - name: Autobuild 59 | uses: github/codeql-action/autobuild@v2 60 | 61 | # ℹ️ Command-line programs to run using the OS shell. 62 | # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun 63 | 64 | # If the Autobuild fails above, remove it and uncomment the following three lines. 65 | # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. 66 | 67 | # - run: | 68 | # echo "Run, Build Application using script" 69 | # ./location_of_script_within_repo/buildscript.sh 70 | 71 | - name: Perform CodeQL Analysis 72 | uses: github/codeql-action/analyze@v2 73 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/ByteStreamIn.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | import java.io.Closeable; 14 | 15 | public abstract class ByteStreamIn implements Closeable { 16 | 17 | private long u_bit_buffer; 18 | private int u_num_buffer; 19 | 20 | /* write single bits */ 21 | protected final int getBits(int u_num_bits) 22 | { 23 | if (u_num_buffer < u_num_bits) 24 | { 25 | int u_input_bits = get32bitsLE(); 26 | u_bit_buffer = u_bit_buffer | ((Integer.toUnsignedLong(u_input_bits)) << u_num_buffer); 27 | u_num_buffer = u_num_buffer + 32; 28 | } 29 | int u_new_bits = (int)(u_bit_buffer & ((1 << u_num_bits) - 1)); 30 | u_bit_buffer = u_bit_buffer >>> u_num_bits; 31 | u_num_buffer = u_num_buffer - u_num_bits; 32 | return u_new_bits; 33 | } 34 | 35 | /* read a single byte */ 36 | public abstract byte getByte(); 37 | /* read an array of bytes */ 38 | public abstract void getBytes(byte[] bytes, int u_num_bytes); 39 | /* read 16 bit low-endian field */ 40 | public abstract char get16bitsLE(); 41 | /* read 32 bit low-endian field */ 42 | public abstract int get32bitsLE(); 43 | /* read 64 bit low-endian field */ 44 | public abstract long get64bitsLE(); 45 | /* read 16 bit big-endian field */ 46 | public abstract char get16bitsBE(); 47 | /* read 32 bit big-endian field */ 48 | public abstract int get32bitsBE(); 49 | /* read 64 bit big-endian field */ 50 | public abstract long get64bitsBE(); 51 | /* is the stream seekable (e.g. stdin is not) */ 52 | public abstract boolean isSeekable(); 53 | /* get current position of stream */ 54 | public abstract long tell(); 55 | /* seek to this position in the stream */ 56 | public abstract boolean seek(long position); 57 | /* seek to the end of the file */ 58 | public abstract boolean seekEnd(long distance); 59 | public boolean seekEnd() {return seekEnd(0);} 60 | /* constructor */ 61 | public ByteStreamIn() { u_bit_buffer = 0; u_num_buffer = 0; }; 62 | 63 | public boolean skipBytes(int num_bytes) 64 | { 65 | return seek(tell() + num_bytes); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/test/java/com/github/mreutegg/laszip4j/LASReaderPerformanceTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Marcel Reutegger 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.mreutegg.laszip4j; 18 | 19 | import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; 20 | import org.junit.After; 21 | import org.junit.Before; 22 | import org.junit.Rule; 23 | import org.junit.Test; 24 | 25 | import java.io.File; 26 | import java.io.InputStream; 27 | import java.nio.file.Files; 28 | 29 | public class LASReaderPerformanceTest { 30 | 31 | @Rule 32 | public final DataFiles files = new DataFiles(); 33 | 34 | private final File las = new File("target", LASReaderPerformanceTest.class.getSimpleName() + ".las"); 35 | 36 | @Before 37 | public void prepareLas() { 38 | System.setProperty("laszip4j.mmap.buffer.size", String.valueOf(100 * 1024 * 1024)); 39 | if (!las.exists()) { 40 | LASWriter writer = new LASWriter(new LASReader(files.laz14)); 41 | writer.write(las); 42 | } 43 | } 44 | 45 | @After 46 | public void removeProperty() { 47 | System.clearProperty("laszip4j.mmap.buffer.size"); 48 | } 49 | 50 | @Test 51 | public void readLasFile() { 52 | DescriptiveStatistics stats = new DescriptiveStatistics(); 53 | for (int i = 0; i < 10; i++) { 54 | long time = System.currentTimeMillis(); 55 | LASReader reader = new LASReader(las); 56 | try (CloseablePointIterable points = reader.getCloseablePoints()) { 57 | points.forEach(LASPoint::getClassification); 58 | } 59 | time = System.currentTimeMillis() - time; 60 | // ignore first run 61 | if (i > 0) { 62 | stats.addValue(time); 63 | } 64 | } 65 | System.out.println(stats); 66 | } 67 | 68 | @Test 69 | public void readLasStream() throws Exception { 70 | DescriptiveStatistics stats = new DescriptiveStatistics(); 71 | for (int i = 0; i < 10; i++) { 72 | long time = System.currentTimeMillis(); 73 | try (InputStream in = Files.newInputStream(las.toPath())) { 74 | LASReader.getPoints(in).forEach(LASPoint::getClassification); 75 | } 76 | time = System.currentTimeMillis() - time; 77 | // ignore first run 78 | if (i > 0) { 79 | stats.addValue(time); 80 | } 81 | } 82 | System.out.println(stats); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASreadItemCompressed_RGB12_v1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2014, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | public class LASreadItemCompressed_RGB12_v1 extends LASreadItemCompressed { 14 | 15 | private ArithmeticDecoder dec; 16 | private PointDataRecordRGB last_item; 17 | 18 | private ArithmeticModel m_byte_used; 19 | private IntegerCompressor ic_rgb; 20 | 21 | public LASreadItemCompressed_RGB12_v1(ArithmeticDecoder dec) 22 | { 23 | /* set decoder */ 24 | assert(dec != null); 25 | this.dec = dec; 26 | 27 | /* create models and integer compressors */ 28 | m_byte_used = dec.createSymbolModel(64); 29 | ic_rgb = new IntegerCompressor(dec, 8, 6); 30 | 31 | last_item = null; 32 | } 33 | 34 | @Override 35 | public void init(PointDataRecord seedItem, MutableInteger notUsed) 36 | { 37 | /* init state */ 38 | 39 | /* init models and integer compressors */ 40 | dec.initSymbolModel(m_byte_used); 41 | ic_rgb.initDecompressor(); 42 | 43 | last_item = new PointDataRecordRGB((PointDataRecordRGB)seedItem); 44 | } 45 | 46 | @Override 47 | public PointDataRecord read(MutableInteger notUsed) 48 | { 49 | PointDataRecordRGB result = new PointDataRecordRGB(); 50 | 51 | int sym = dec.decodeSymbol(m_byte_used); 52 | if ((sym & (1 << 0)) != 0) 53 | result.R = (char)ic_rgb.decompress(last_item.R&255, 0); 54 | else 55 | result.R = (char)(last_item.R&0xFF); 56 | if ((sym & (1 << 1)) != 0) 57 | result.R |= (((char)ic_rgb.decompress(last_item.R>>8, 1)) << 8); 58 | else 59 | result.R |= (last_item.R&0xFF00); 60 | if ((sym & (1 << 2)) != 0) 61 | result.G = (char)ic_rgb.decompress(last_item.G&255, 2); 62 | else 63 | result.G = (char)(last_item.G&0xFF); 64 | if ((sym & (1 << 3)) != 0) 65 | result.G |= (((char)ic_rgb.decompress(last_item.G>>8, 3)) << 8); 66 | else 67 | result.G |= (last_item.G&0xFF00); 68 | if ((sym & (1 << 4)) != 0) 69 | result.B = (char)ic_rgb.decompress(last_item.B&255, 4); 70 | else 71 | result.B = (char)(last_item.B&0xFF); 72 | if ((sym & (1 << 5)) != 0) 73 | result.B |= (((char)ic_rgb.decompress(last_item.B>>8, 5)) << 8); 74 | else 75 | result.B |= (last_item.B&0xFF00); 76 | 77 | last_item.R = result.R; 78 | last_item.G = result.G; 79 | last_item.B = result.B; 80 | 81 | return result; 82 | } 83 | 84 | @Override 85 | public boolean chunk_sizes() { 86 | return false; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/Common_v2.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | public final class Common_v2 { 14 | 15 | // for LAS files with the return (r) and the number (n) of 16 | // returns field correctly populated the mapping should really 17 | // be only the following. 18 | // { 15, 15, 15, 15, 15, 15, 15, 15 }, 19 | // { 15, 0, 15, 15, 15, 15, 15, 15 }, 20 | // { 15, 1, 2, 15, 15, 15, 15, 15 }, 21 | // { 15, 3, 4, 5, 15, 15, 15, 15 }, 22 | // { 15, 6, 7, 8, 9, 15, 15, 15 }, 23 | // { 15, 10, 11, 12, 13, 14, 15, 15 }, 24 | // { 15, 15, 15, 15, 15, 15, 15, 15 }, 25 | // { 15, 15, 15, 15, 15, 15, 15, 15 } 26 | // however, some files start the numbering of r and n with 0, 27 | // only have return counts r, or only have number of return 28 | // counts n, or mix up the position of r and n. we therefore 29 | // "complete" the table to also map those "undesired" r & n 30 | // combinations to different contexts 31 | static final byte[][] number_return_map = 32 | { 33 | { 15, 14, 13, 12, 11, 10, 9, 8 }, 34 | { 14, 0, 1, 3, 6, 10, 10, 9 }, 35 | { 13, 1, 2, 4, 7, 11, 11, 10 }, 36 | { 12, 3, 4, 5, 8, 12, 12, 11 }, 37 | { 11, 6, 7, 8, 9, 13, 13, 12 }, 38 | { 10, 10, 11, 12, 13, 14, 14, 13 }, 39 | { 9, 10, 11, 12, 13, 14, 15, 14 }, 40 | { 8, 9, 10, 11, 12, 13, 14, 15 } 41 | }; 42 | 43 | // for LAS files with the return (r) and the number (n) of 44 | // returns field correctly populated the mapping should really 45 | // be only the following. 46 | // { 0, 7, 7, 7, 7, 7, 7, 7 }, 47 | // { 7, 0, 7, 7, 7, 7, 7, 7 }, 48 | // { 7, 1, 0, 7, 7, 7, 7, 7 }, 49 | // { 7, 2, 1, 0, 7, 7, 7, 7 }, 50 | // { 7, 3, 2, 1, 0, 7, 7, 7 }, 51 | // { 7, 4, 3, 2, 1, 0, 7, 7 }, 52 | // { 7, 5, 4, 3, 2, 1, 0, 7 }, 53 | // { 7, 6, 5, 4, 3, 2, 1, 0 } 54 | // however, some files start the numbering of r and n with 0, 55 | // only have return counts r, or only have number of return 56 | // counts n, or mix up the position of r and n. we therefore 57 | // "complete" the table to also map those "undesired" r & n 58 | // combinations to different contexts 59 | static final byte[][] number_return_level = 60 | { 61 | { 0, 1, 2, 3, 4, 5, 6, 7 }, 62 | { 1, 0, 1, 2, 3, 4, 5, 6 }, 63 | { 2, 1, 0, 1, 2, 3, 4, 5 }, 64 | { 3, 2, 1, 0, 1, 2, 3, 4 }, 65 | { 4, 3, 2, 1, 0, 1, 2, 3 }, 66 | { 5, 4, 3, 2, 1, 0, 1, 2 }, 67 | { 6, 5, 4, 3, 2, 1, 0, 1 }, 68 | { 7, 6, 5, 4, 3, 2, 1, 0 } 69 | }; 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/ByteStreamOutDataOutput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Marcel Reutegger 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.mreutegg.laszip4j.laszip; 18 | 19 | import java.io.DataOutput; 20 | import java.io.IOException; 21 | import java.nio.ByteBuffer; 22 | import java.nio.ByteOrder; 23 | 24 | abstract class ByteStreamOutDataOutput extends ByteStreamOut { 25 | 26 | private final ByteBuffer buffer; 27 | protected DataOutput dataOut; 28 | 29 | ByteStreamOutDataOutput(DataOutput out) { 30 | this.dataOut = out; 31 | this.buffer = ByteBuffer.allocate(8); 32 | this.buffer.order(ByteOrder.LITTLE_ENDIAN); 33 | } 34 | 35 | @Override 36 | public boolean putByte(byte b) { 37 | try { 38 | dataOut.writeByte(b); 39 | return true; 40 | } catch (IOException e) { 41 | return false; 42 | } 43 | } 44 | 45 | @Override 46 | public boolean putBytes(byte[] bytes, int u_num_bytes) { 47 | try { 48 | dataOut.write(bytes, 0, u_num_bytes); 49 | return true; 50 | } catch (IOException e) { 51 | return false; 52 | } 53 | } 54 | 55 | @Override 56 | public boolean put16bitsLE(char bytes) { 57 | bufferLE().putChar(bytes); 58 | return putBytes(buffer.array(), 2); 59 | } 60 | 61 | public boolean put16bitsLE(short bytes) { 62 | bufferLE().putShort(bytes); 63 | return putBytes(buffer.array(), 2); 64 | } 65 | 66 | @Override 67 | public boolean put32bitsLE(int bytes) { 68 | bufferLE().putInt(bytes); 69 | return putBytes(buffer.array(), 4); 70 | } 71 | 72 | @Override 73 | public boolean put64bitsLE(long bytes) { 74 | bufferLE().putLong(bytes); 75 | return putBytes(buffer.array(), 8); 76 | } 77 | 78 | @Override 79 | boolean put16bitsBE(char bytes) { 80 | try { 81 | dataOut.writeShort(bytes); 82 | return true; 83 | } catch (IOException e) { 84 | return false; 85 | } 86 | } 87 | 88 | @Override 89 | boolean put32bitsBE(int bytes) { 90 | try { 91 | dataOut.writeInt(bytes); 92 | return true; 93 | } catch (IOException e) { 94 | return false; 95 | } 96 | } 97 | 98 | @Override 99 | boolean put64bitsBE(long bytes) { 100 | try { 101 | dataOut.writeLong(bytes); 102 | return true; 103 | } catch (IOException e) { 104 | return false; 105 | } 106 | } 107 | 108 | private ByteBuffer bufferLE() { 109 | buffer.rewind(); 110 | return buffer; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/StreamingMedian5.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2012, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | public class StreamingMedian5 { 14 | 15 | public static StreamingMedian5[] newStreamingMedian5(int num) { 16 | StreamingMedian5[] medians = new StreamingMedian5[num]; 17 | for (int i = 0; i < num; i++) { 18 | medians[i] = new StreamingMedian5(); 19 | } 20 | return medians; 21 | } 22 | 23 | public int[] values = new int[5]; 24 | public boolean high; 25 | 26 | public void init() 27 | { 28 | values[0] = values[1] = values[2] = values[3] = values[4] = 0; 29 | high = true; 30 | } 31 | 32 | public void add(int v) 33 | { 34 | if (high) 35 | { 36 | if (v < values[2]) 37 | { 38 | values[4] = values[3]; 39 | values[3] = values[2]; 40 | if (v < values[0]) 41 | { 42 | values[2] = values[1]; 43 | values[1] = values[0]; 44 | values[0] = v; 45 | } 46 | else if (v < values[1]) 47 | { 48 | values[2] = values[1]; 49 | values[1] = v; 50 | } 51 | else 52 | { 53 | values[2] = v; 54 | } 55 | } 56 | else 57 | { 58 | if (v < values[3]) 59 | { 60 | values[4] = values[3]; 61 | values[3] = v; 62 | } 63 | else 64 | { 65 | values[4] = v; 66 | } 67 | high = false; 68 | } 69 | } 70 | else 71 | { 72 | if (values[2] < v) 73 | { 74 | values[0] = values[1]; 75 | values[1] = values[2]; 76 | if (values[4] < v) 77 | { 78 | values[2] = values[3]; 79 | values[3] = values[4]; 80 | values[4] = v; 81 | } 82 | else if (values[3] < v) 83 | { 84 | values[2] = values[3]; 85 | values[3] = v; 86 | } 87 | else 88 | { 89 | values[2] = v; 90 | } 91 | } 92 | else 93 | { 94 | if (values[1] < v) 95 | { 96 | values[0] = values[1]; 97 | values[1] = v; 98 | } 99 | else 100 | { 101 | values[0] = v; 102 | } 103 | high = true; 104 | } 105 | } 106 | } 107 | 108 | public int get() 109 | { 110 | return values[2]; 111 | } 112 | 113 | StreamingMedian5() 114 | { 115 | init(); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/ByteStreamOut.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | import java.io.Closeable; 14 | 15 | public abstract class ByteStreamOut implements Closeable { 16 | 17 | private long u_bit_buffer; 18 | private int u_num_buffer; 19 | 20 | 21 | /* write single bits */ 22 | protected final boolean putBits(int u_bits, int u_num_bits) 23 | { 24 | long u_new_bits = Integer.toUnsignedLong(u_bits); 25 | u_bit_buffer |= (u_new_bits << u_num_buffer); 26 | u_num_buffer += u_num_bits; 27 | if (Integer.compareUnsigned(u_num_buffer, 32) >= 0) 28 | { 29 | int u_output_bits = (int) u_bit_buffer; 30 | u_bit_buffer = u_bit_buffer >>> 32; 31 | u_num_buffer = u_num_buffer - 32; 32 | return put32bitsLE(u_output_bits); 33 | } 34 | return true; 35 | }; 36 | /* called after writing bits before closing or writing bytes */ 37 | protected final boolean flushBits() 38 | { 39 | if (Integer.compareUnsigned(u_num_buffer, 0) > 0) 40 | { 41 | int u_num_zero_bits = 32 - u_num_buffer; 42 | int u_output_bits = (int)(u_bit_buffer >>> u_num_zero_bits); 43 | u_bit_buffer = 0; 44 | u_num_buffer = 0; 45 | return put32bitsLE(u_output_bits); 46 | } 47 | return true; 48 | }; 49 | /* write a single byte */ 50 | public abstract boolean putByte(byte b); 51 | /* write an array of bytes */ 52 | public abstract boolean putBytes(byte[] bytes, int u_num_bytes); 53 | /* write 16 bit low-endian field */ 54 | public abstract boolean put16bitsLE(char bytes); 55 | /* write 16 bit low-endian field */ 56 | public abstract boolean put16bitsLE(short bytes); 57 | /* write 32 bit low-endian field */ 58 | public abstract boolean put32bitsLE(int bytes); 59 | /* write 64 bit low-endian field */ 60 | public abstract boolean put64bitsLE(long bytes); 61 | /* write 16 bit big-endian field */ 62 | abstract boolean put16bitsBE(char bytes); 63 | /* write 32 bit big-endian field */ 64 | abstract boolean put32bitsBE(int bytes); 65 | /* write 64 bit big-endian field */ 66 | abstract boolean put64bitsBE(long bytes); 67 | /* is the stream seekable (e.g. standard out is not) */ 68 | public abstract boolean isSeekable(); 69 | /* get current position of stream */ 70 | public abstract long tell(); 71 | /* seek to this position in the stream */ 72 | public abstract boolean seek(long position); 73 | /* seek to the end of the file */ 74 | public abstract boolean seekEnd(); 75 | /* constructor */ 76 | protected ByteStreamOut() { u_bit_buffer = 0; u_num_buffer = 0; }; 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/ByteStreamInDataInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 Marcel Reutegger 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.mreutegg.laszip4j.laszip; 18 | 19 | import java.io.DataInput; 20 | import java.io.IOException; 21 | import java.io.UncheckedIOException; 22 | import java.nio.ByteBuffer; 23 | 24 | import static java.nio.ByteOrder.LITTLE_ENDIAN; 25 | 26 | public abstract class ByteStreamInDataInput extends ByteStreamIn { 27 | 28 | private final ByteBuffer buffer; 29 | protected DataInput dataIn; 30 | 31 | public ByteStreamInDataInput(DataInput in) { 32 | super(); 33 | this.dataIn = in; 34 | this.buffer = ByteBuffer.allocate(8); 35 | this.buffer.order(LITTLE_ENDIAN); 36 | } 37 | 38 | @Override 39 | public byte getByte() { 40 | try { 41 | return dataIn.readByte(); 42 | } catch (IOException e) { 43 | throw new UncheckedIOException(e); 44 | } 45 | } 46 | 47 | @Override 48 | public void getBytes(byte[] bytes, int u_num_bytes) { 49 | try { 50 | dataIn.readFully(bytes, 0, u_num_bytes); 51 | } catch (IOException e) { 52 | throw new UncheckedIOException(e); 53 | } 54 | } 55 | 56 | @Override 57 | public char get16bitsLE() { 58 | try { 59 | dataIn.readFully(buffer.array(), 0, 2); 60 | return bufferLE().getChar(); 61 | } catch (IOException e) { 62 | throw new UncheckedIOException(e); 63 | } 64 | } 65 | 66 | @Override 67 | public int get32bitsLE() { 68 | try { 69 | dataIn.readFully(buffer.array(), 0, 4); 70 | return bufferLE().getInt(); 71 | } catch (IOException e) { 72 | throw new UncheckedIOException(e); 73 | } 74 | } 75 | 76 | @Override 77 | public long get64bitsLE() { 78 | try { 79 | dataIn.readFully(buffer.array(), 0, 8); 80 | return bufferLE().getLong(); 81 | } catch (IOException e) { 82 | throw new UncheckedIOException(e); 83 | } 84 | } 85 | 86 | @Override 87 | public char get16bitsBE() { 88 | try { 89 | return dataIn.readChar(); 90 | } catch (IOException e) { 91 | throw new UncheckedIOException(e); 92 | } 93 | } 94 | 95 | @Override 96 | public int get32bitsBE() { 97 | try { 98 | return dataIn.readInt(); 99 | } catch (IOException e) { 100 | throw new UncheckedIOException(e); 101 | } 102 | } 103 | 104 | @Override 105 | public long get64bitsBE() { 106 | try { 107 | return dataIn.readLong(); 108 | } catch (IOException e) { 109 | throw new UncheckedIOException(e); 110 | } 111 | } 112 | 113 | private ByteBuffer bufferLE() { 114 | buffer.rewind(); 115 | return buffer; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/test/java/com/github/mreutegg/laszip4j/laszip/MultiMMappedDataInputTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Marcel Reutegger 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.mreutegg.laszip4j.laszip; 18 | 19 | import com.github.mreutegg.laszip4j.laszip.ByteStreamInFile.MultiMMappedDataInput; 20 | import org.junit.Before; 21 | import org.junit.Rule; 22 | import org.junit.Test; 23 | import org.junit.rules.TemporaryFolder; 24 | 25 | import java.io.File; 26 | import java.io.RandomAccessFile; 27 | 28 | import static org.junit.Assert.assertEquals; 29 | import static org.junit.Assert.assertTrue; 30 | import static org.junit.Assert.fail; 31 | 32 | public class MultiMMappedDataInputTest { 33 | 34 | @Rule 35 | public TemporaryFolder tempFolder = new TemporaryFolder(new File("target")); 36 | 37 | private RandomAccessFile file; 38 | 39 | @Before 40 | public void setup() throws Exception { 41 | file = new RandomAccessFile(tempFolder.newFile(MultiMMappedDataInputTest.class.getSimpleName()), "rw"); 42 | file.writeInt(42); 43 | file.writeBoolean(true); 44 | file.writeLong(0xcafe); 45 | file.writeChars("foo"); 46 | } 47 | 48 | @Test 49 | public void position() throws Exception { 50 | MultiMMappedDataInput input = new MultiMMappedDataInput(file, 7); 51 | assertEquals(0, input.position()); 52 | int[] positions = new int[] {6, 7, 8}; 53 | for (int p : positions) { 54 | input.position(p); 55 | assertEquals(p, input.position()); 56 | } 57 | input.position(file.length()); 58 | assertEquals(file.length(), input.position()); 59 | long pos = file.length() + 1; 60 | try { 61 | input.position(pos); 62 | fail("IllegalArgumentException expected"); 63 | } catch (IllegalArgumentException e) { 64 | // expected 65 | } 66 | } 67 | 68 | @Test 69 | public void skip() throws Exception { 70 | MultiMMappedDataInput input = new MultiMMappedDataInput(file, 7); 71 | input.skipBytes(3); 72 | assertEquals(3, input.position()); 73 | input.position(0); 74 | assertEquals(0, input.position()); 75 | assertEquals(file.length(), input.skipBytes((int) file.length() + 1)); 76 | } 77 | 78 | @Test 79 | public void read() throws Exception { 80 | MultiMMappedDataInput input = new MultiMMappedDataInput(file, 7); 81 | assertEquals(42, input.readInt()); 82 | assertTrue(input.readBoolean()); 83 | assertEquals(0xcafe, input.readLong()); 84 | String expected = "foo"; 85 | for (char c : expected.toCharArray()) { 86 | assertEquals(c, input.readChar()); 87 | } 88 | } 89 | 90 | @Test 91 | public void readFully() throws Exception { 92 | MultiMMappedDataInput input = new MultiMMappedDataInput(file, 7); 93 | byte[] data = new byte[100]; 94 | try { 95 | input.readFully(data, 0, data.length); 96 | fail("UncheckedEOFException expected"); 97 | } catch (UncheckedEOFException e) { 98 | // expected 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/ByteStreamInArray.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2013, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | import java.nio.ByteBuffer; 14 | 15 | import static java.nio.ByteOrder.BIG_ENDIAN; 16 | import static java.nio.ByteOrder.LITTLE_ENDIAN; 17 | 18 | public class ByteStreamInArray extends ByteStreamIn { 19 | 20 | private ByteBuffer data; 21 | 22 | public ByteStreamInArray() 23 | { 24 | data = null; 25 | } 26 | 27 | public ByteStreamInArray(byte[] bytes, long size) { 28 | super(); 29 | 30 | init(bytes,size); 31 | } 32 | 33 | public boolean init(byte[] bytes, long size) 34 | { 35 | if (size > Integer.MAX_VALUE) { 36 | throw new IllegalArgumentException(); 37 | } 38 | 39 | if ( null != bytes ) 40 | { 41 | this.data = ByteBuffer.wrap(bytes, 0, (int) size); 42 | this.data.order(LITTLE_ENDIAN); 43 | } 44 | else 45 | { 46 | this.data = null; 47 | } 48 | 49 | return true; 50 | } 51 | 52 | @Override 53 | public byte getByte() { 54 | if (!data.hasRemaining()) { 55 | throw new UncheckedEOFException(); 56 | } 57 | return data.get(); 58 | } 59 | 60 | @Override 61 | public void getBytes(byte[] bytes, int u_num_bytes) { 62 | if (data.remaining() < u_num_bytes) { 63 | throw new UncheckedEOFException(); 64 | } 65 | data.get(bytes, 0, u_num_bytes); 66 | } 67 | 68 | @Override 69 | public char get16bitsLE() { 70 | return data.getChar(); 71 | } 72 | 73 | @Override 74 | public int get32bitsLE() { 75 | return data.getInt(); 76 | } 77 | 78 | @Override 79 | public long get64bitsLE() { 80 | return data.getLong(); 81 | } 82 | 83 | @Override 84 | public char get16bitsBE() { 85 | data.order(BIG_ENDIAN); 86 | try { 87 | return data.getChar(); 88 | } finally { 89 | data.order(LITTLE_ENDIAN); 90 | } 91 | } 92 | 93 | @Override 94 | public int get32bitsBE() { 95 | data.order(BIG_ENDIAN); 96 | try { 97 | return data.getInt(); 98 | } finally { 99 | data.order(LITTLE_ENDIAN); 100 | } 101 | } 102 | 103 | @Override 104 | public long get64bitsBE() { 105 | data.order(BIG_ENDIAN); 106 | try { 107 | return data.getLong(); 108 | } finally { 109 | data.order(LITTLE_ENDIAN); 110 | } 111 | } 112 | 113 | @Override 114 | public boolean isSeekable() { 115 | return true; 116 | } 117 | 118 | @Override 119 | public long tell() { 120 | return data.position(); 121 | } 122 | 123 | @Override 124 | public boolean seek(long position) { 125 | if (position > Integer.MAX_VALUE) { 126 | throw new IllegalArgumentException(); 127 | } 128 | data.position((int) position); 129 | return true; 130 | } 131 | 132 | @Override 133 | public boolean seekEnd(long distance) { 134 | if (distance > Integer.MAX_VALUE) { 135 | throw new IllegalArgumentException(); 136 | } 137 | if ((0 <= distance) && (distance <= data.capacity())) 138 | { 139 | data.position(data.capacity() - (int) distance); 140 | return true; 141 | } 142 | return false; 143 | } 144 | 145 | @Override 146 | public void close() { 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/MyDefs.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2005-2015, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | import java.nio.charset.StandardCharsets; 14 | 15 | public interface MyDefs { 16 | 17 | char U16_MAX = Character.MAX_VALUE; 18 | 19 | int U32_MAX = 0xFFFFFFFF; 20 | 21 | int I32_MIN = Integer.MIN_VALUE; 22 | 23 | byte U8_MIN = 0x0; 24 | byte I8_MIN = Byte.MIN_VALUE; 25 | 26 | byte U8_MAX = (byte) 0xFF; // 255 27 | byte I8_MAX = Byte.MAX_VALUE; 28 | byte U8_MAX_MINUS_ONE = (byte) 0xFE; // 254 29 | char U8_MAX_PLUS_ONE = 0x0100; // 256 30 | 31 | 32 | static byte U8_FOLD(int n) { 33 | return (byte) ((n < U8_MIN) ? (n+U8_MAX_PLUS_ONE) : (((n) > Byte.toUnsignedInt(U8_MAX)) ? (n-U8_MAX_PLUS_ONE) : (n))); 34 | } 35 | 36 | static int U8_CLAMP(int n) { 37 | return (((n) <= U8_MIN) ? U8_MIN : (((n) >= Byte.toUnsignedInt(U8_MAX)) ? U8_MAX : ((byte)(n)))); 38 | } 39 | 40 | static int I8_CLAMP(int n) { 41 | return (((n) <= I8_MIN) ? I8_MIN : (((n) >= I8_MAX) ? I8_MAX : ((byte)(n)))); 42 | } 43 | 44 | static short I16_QUANTIZE(float n) { 45 | return ((n) >= 0) ? (short)((n)+0.5f) : (short)((n)-0.5f); 46 | } 47 | 48 | static int I32_QUANTIZE(double n) { 49 | return n >= 0 ? (int)((n)+0.5f) : (int)((n)-0.5f); 50 | } 51 | 52 | static int U32_QUANTIZE(double n) { 53 | return ((n) >= 0) ? (int)((n)+0.5f) : 0; 54 | } 55 | 56 | static int I32_FLOOR(double value) { 57 | return (int) Math.floor(value); 58 | } 59 | 60 | static long I64_FLOOR(double value) { 61 | return (long) Math.floor(value); 62 | } 63 | 64 | static int U32_ZERO_BIT_0(int n) { 65 | return n & 0xFFFFFFFE; 66 | } 67 | 68 | static boolean IS_LITTLE_ENDIAN() { 69 | return false; 70 | } 71 | 72 | static int sizeof(Class attributeClass) { 73 | return LASattribute.getMemory(); 74 | } 75 | 76 | static byte[] asByteArray(char[] chars) { 77 | return asByteArray(new String(chars)); 78 | } 79 | 80 | static byte[] asByteArray(String s) { 81 | return s.getBytes(StandardCharsets.US_ASCII); 82 | } 83 | 84 | static String stringFromByteArray(byte[] bytes) { 85 | int idx = -1; 86 | for (int i = 0; i < bytes.length; i++) { 87 | if (bytes[i] == '\0') { 88 | idx = i; 89 | break; 90 | } 91 | } 92 | if (idx != -1) { 93 | return new String(bytes, 0, idx, StandardCharsets.US_ASCII); 94 | } else { 95 | return new String(bytes, StandardCharsets.US_ASCII); 96 | } 97 | } 98 | 99 | static int[] realloc(int[] data, int size) { 100 | if (data.length >= size) { 101 | return data; 102 | } 103 | int[] tmp = new int[size]; 104 | System.arraycopy(data, 0, tmp, 0, data.length); 105 | return tmp; 106 | } 107 | 108 | static long[] realloc(long[] data, int size) { 109 | if (data == null) { 110 | return new long[size]; 111 | } else if (data.length >= size) { 112 | return data; 113 | } 114 | long[] tmp = new long[size]; 115 | System.arraycopy(data, 0, tmp, 0, data.length); 116 | return tmp; 117 | } 118 | 119 | static short setBit(short value, int bit) { 120 | return (short) (value | (short) (1 << bit)); 121 | } 122 | 123 | static short clearBit(short value, int bit) { 124 | return (short) (value & (~ (1 << bit))); 125 | } 126 | 127 | static byte setBit(byte value, int bit) { 128 | return (byte) (value | (byte) (1 << bit)); 129 | } 130 | 131 | static byte clearBit(byte value, int bit) { 132 | return (byte) (value & (~ (1 << bit))); 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/LASExtraBytesType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Marcel Reutegger 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public License 15 | * along with this program. If not, see . 16 | */ 17 | package com.github.mreutegg.laszip4j; 18 | 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | 22 | /** 23 | * The data type of some extra bytes. 24 | */ 25 | public final class LASExtraBytesType { 26 | 27 | private static final Map TYPES = new HashMap<>(); 28 | 29 | static { 30 | create(1, Byte.class, 1, true); 31 | create(2, Byte.class, 1, false); 32 | create(3, Short.class, 1, true); 33 | create(4, Short.class, 1, false); 34 | create(5, Integer.class, 1, true); 35 | create(6, Integer.class, 1, false); 36 | create(7, Long.class, 1, true); 37 | create(8, Long.class, 1, false); 38 | create(9, Float.class, 1, false); 39 | create(10, Double.class, 1, false); 40 | create(11, Byte.class, 2, true); 41 | create(12, Byte.class, 2, false); 42 | create(13, Short.class, 2, true); 43 | create(14, Short.class, 2, false); 44 | create(15, Integer.class, 2, true); 45 | create(16, Integer.class, 2, false); 46 | create(17, Long.class, 2, true); 47 | create(18, Long.class, 2, false); 48 | create(19, Float.class, 2, false); 49 | create(20, Double.class, 2, false); 50 | create(21, Byte.class, 3, true); 51 | create(22, Byte.class, 3, false); 52 | create(23, Short.class, 3, true); 53 | create(24, Short.class, 3, false); 54 | create(25, Integer.class, 3, true); 55 | create(26, Integer.class, 3, false); 56 | create(27, Long.class, 3, true); 57 | create(28, Long.class, 3, false); 58 | create(29, Float.class, 3, false); 59 | create(30, Double.class, 3, false); 60 | } 61 | 62 | private final int dataType; 63 | 64 | private final Class clazz; 65 | 66 | private final int cardinality; 67 | 68 | private final boolean unsigned; 69 | 70 | private LASExtraBytesType(int dataType, Class clazz, int cardinality, boolean unsigned) { 71 | this.dataType = dataType; 72 | this.clazz = clazz; 73 | this.cardinality = cardinality; 74 | this.unsigned = unsigned; 75 | } 76 | 77 | private static void create(int dataType, Class clazz, int cardinality, boolean unsigned) { 78 | LASExtraBytesType t = new LASExtraBytesType(dataType, clazz, cardinality, unsigned); 79 | TYPES.put(dataType, t); 80 | } 81 | 82 | static LASExtraBytesType fromOrdinal(int ordinal) { 83 | LASExtraBytesType t = TYPES.get(ordinal); 84 | if (t == null) { 85 | throw new IllegalArgumentException("Invalid data type: " + ordinal); 86 | } 87 | return t; 88 | } 89 | 90 | /** 91 | * @return the data type as defined in LAS 1.4 specification for extra bytes. 92 | */ 93 | int getDataType() { 94 | return dataType; 95 | } 96 | 97 | /** 98 | * The cardinality of this extra bytes type. Depending on the type this 99 | * method return 1, 2 or 3. 100 | * 101 | * @return the cardinality of this extra bytes. 102 | */ 103 | public int getCardinality() { 104 | return cardinality; 105 | } 106 | 107 | /** 108 | * @return {@code true} if this is an unsigned type, {@code false} otherwise. 109 | */ 110 | public boolean isUnsigned() { 111 | return unsigned; 112 | } 113 | 114 | /** 115 | * @return the Java primitive type class used by this extra bytes. 116 | */ 117 | Class getClazz() { 118 | return clazz; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/main/java/com/github/mreutegg/laszip4j/laszip/LASitem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-2016, martin isenburg, rapidlasso - fast tools to catch reality 3 | * 4 | * This is free software; you can redistribute and/or modify it under the 5 | * terms of the GNU Lesser General Licence as published by the Free Software 6 | * Foundation. See the LICENSE.txt file for more information. 7 | * 8 | * This software is distributed WITHOUT ANY WARRANTY and without even the 9 | * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | */ 11 | package com.github.mreutegg.laszip4j.laszip; 12 | 13 | public class LASitem { 14 | 15 | public enum Type { 16 | BYTE, 17 | SHORT, 18 | INT, 19 | LONG, 20 | FLOAT, 21 | DOUBLE, 22 | POINT10, 23 | GPSTIME11, 24 | RGB12, 25 | WAVEPACKET13, 26 | POINT14, 27 | RGB14, 28 | RGBNIR14, 29 | WAVEPACKET14, 30 | BYTE14 ; 31 | 32 | private static final Type[] TYPES = Type.values(); 33 | 34 | public static Type fromOrdinal(int i) { 35 | return TYPES[i]; 36 | } 37 | } 38 | 39 | public LASitem() { 40 | 41 | } 42 | 43 | public LASitem(Type type, int size, int version) { 44 | this.type = type; 45 | this.size = (char)size; 46 | this.version = (char)version; 47 | } 48 | 49 | public Type type; 50 | public char size; // unsigned 51 | public char version; // unsigned 52 | 53 | public static LASitem Point10(int ver) { return new LASitem(Type.POINT10, 20, ver); } 54 | public static LASitem GpsTime11(int ver) { return new LASitem(Type.GPSTIME11, 8, ver); } 55 | public static LASitem Rgb12(int ver) { return new LASitem(Type.RGB12, 6, ver); } 56 | public static LASitem WavePacket13(int ver) { return new LASitem(Type.WAVEPACKET13, 29, ver); } 57 | public static LASitem Point14(int ver) { return new LASitem(Type.POINT14, 30, ver); } 58 | public static LASitem RgbNIR14(int ver) { return new LASitem(Type.RGBNIR14, 8, ver); } 59 | public static LASitem ExtraBytes(int size, int ver) { return new LASitem(Type.BYTE, size, ver); } 60 | public static LASitem Rgb14(int ver) { return new LASitem(Type.RGB14, 6, ver); } 61 | public static LASitem WavePacket14(int ver) { return new LASitem(Type.WAVEPACKET14, 29, ver); } 62 | public static LASitem ExtraBytes14(int size, int ver) { return new LASitem(Type.BYTE14, size, ver); } 63 | 64 | boolean is_type(Type t) 65 | { 66 | if (t != type) return false; 67 | switch (t) 68 | { 69 | case POINT10: 70 | if (size != 20) return false; 71 | break; 72 | case POINT14: 73 | if (size != 30) return false; 74 | break; 75 | case GPSTIME11: 76 | if (size != 8) return false; 77 | break; 78 | case RGB12: 79 | case RGB14: 80 | if (size != 6) return false; 81 | break; 82 | case RGBNIR14: 83 | if (size != 8) return false; 84 | break; 85 | case WAVEPACKET13: 86 | case WAVEPACKET14: 87 | if (size != 29) return false; 88 | break; 89 | case BYTE: 90 | case BYTE14: 91 | if (size < 1) return false; 92 | break; 93 | default: 94 | return false; 95 | } 96 | return true; 97 | } 98 | 99 | String get_name() 100 | { 101 | switch (type) 102 | { 103 | case POINT10: 104 | return "POINT10"; 105 | case POINT14: 106 | return "POINT14"; 107 | case GPSTIME11: 108 | return "GPSTIME11"; 109 | case RGB12: 110 | return "RGB12"; 111 | case BYTE: 112 | return "BYTE"; 113 | case RGB14: 114 | return "RGB14"; 115 | case RGBNIR14: 116 | return "RGBNIR14"; 117 | case BYTE14: 118 | return "BYTE14"; 119 | case WAVEPACKET13: 120 | return "WAVEPACKET13"; 121 | case WAVEPACKET14: 122 | return "WAVEPACKET14"; 123 | default: 124 | break; 125 | } 126 | return null; 127 | } 128 | } 129 | --------------------------------------------------------------------------------