This repository has been archived by the owner on Aug 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/chunked-read-write'
- Loading branch information
Showing
35 changed files
with
1,686 additions
and
686 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import numpy as np | ||
|
||
import pylas | ||
from pathlib import Path | ||
import argparse | ||
import io | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("path") | ||
parser.add_argument("--ilaz", default=None) | ||
parser.add_argument("--olaz", default=None) | ||
|
||
args = parser.parse_args() | ||
|
||
if args.olaz is not None: | ||
olaz_backend = (getattr(pylas.LazBackend, args.olaz),) | ||
do_compress = True | ||
else: | ||
olaz_backend = None | ||
do_compress = False | ||
|
||
if args.ilaz is not None: | ||
ilaz_backend = (getattr(pylas.LazBackend, args.ilaz),) | ||
all_files = Path(args.path).rglob("*.la[sz]") | ||
else: | ||
ilaz_backend = None | ||
all_files = Path(args.path).rglob("*.las") | ||
|
||
for file_path in all_files: | ||
print(f"checking {file_path}") | ||
# with io.BytesIO() as output: | ||
# # with open('lol.laz', mode="w+b") as output: | ||
# with pylas.open(str(file_path), laz_backends=ilaz_backend) as las_file: | ||
# with pylas.open(output, | ||
# mode='w', | ||
# header=las_file.header, | ||
# do_compress=do_compress, | ||
# closefd=False, | ||
# laz_backends=olaz_backend) as las_out: | ||
# las_out.vlrs = las_file.vlrs | ||
# for points in las_file.chunk_iterator(1_216_418): | ||
# las_out.write(points) | ||
# # break | ||
# | ||
# output.seek(0, io.SEEK_END) | ||
# print(f"output is {output.tell()}") | ||
# output.seek(0, io.SEEK_SET) | ||
# | ||
# with open("dump.laz", mode="wb") as dumpf: | ||
# dumpf.write(output.getbuffer()) | ||
# | ||
# original_las = pylas.read(str(file_path), laz_blackends=ilaz_backend) | ||
# written_las = pylas.read(output, laz_blackends=ilaz_backend) | ||
# | ||
# assert original_las.points.dtype == written_las.points.dtype | ||
# for dim_name in original_las.points.dtype.names: | ||
# assert np.allclose(original_las.points[dim_name], | ||
# written_las.points[dim_name]), f"{dim_name} dimensions are not equal" | ||
|
||
|
||
original_las = pylas.read(str(file_path), laz_blackends=ilaz_backend) | ||
with io.BytesIO() as output: | ||
# with open('lol.laz', mode="w+b") as output: | ||
original_las.write(output, do_compress=True, laz_backend=olaz_backend) | ||
|
||
print(output.tell()) | ||
print(output.seek(0, io.SEEK_SET)) | ||
|
||
original_las = pylas.read(str(file_path), laz_blackends=ilaz_backend) | ||
written_las = pylas.read(output, laz_blackends=ilaz_backend) | ||
|
||
assert original_las.points.dtype == written_las.points.dtype | ||
for dim_name in original_las.points.dtype.names: | ||
assert np.allclose(original_las.points[dim_name], | ||
written_las.points[dim_name]), f"{dim_name} dimensions are not equal" | ||
|
||
break | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
__version__ = "0.4.2" | ||
|
||
import logging | ||
|
||
from . import errors, vlrs | ||
from .evlrs import EVLR | ||
from .headers import HeaderFactory | ||
from .laswriter import LasWriter | ||
from .lib import LazBackend | ||
from .lib import convert, create_from_header | ||
from .lib import create_las as create | ||
from .lib import merge_las as merge | ||
from .lib import mmap_las as mmap | ||
from .lib import open_las as open | ||
from .lib import read_las as read | ||
from .lib import merge_las as merge | ||
from .point import PointFormat | ||
from .point.dims import supported_point_formats, supported_versions | ||
from .point.format import lost_dimensions | ||
|
||
import logging | ||
logging.getLogger(__name__).addHandler(logging.NullHandler()) | ||
logging.getLogger(__name__).addHandler(logging.NullHandler()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.