zhongrj
2025-11-25 b89962006164a462404b79a738bee8cbb6d7fe7e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import logging
import os
import subprocess
import json
 
from app.security import double_quote
 
logger = logging.getLogger('app.logger')
 
def export_pointcloud(input, output, **opts):
    epsg = opts.get('epsg')
    export_format = opts.get('format')
    resample = float(opts.get('resample', 0))
 
    resample_args = []
    reprojection_args = []
    extra_args = []
 
    if epsg:
        reprojection_args = ["reprojection",
                            "--filters.reprojection.out_srs=%s" % double_quote("EPSG:" + str(epsg))]
 
    if export_format == "ply":
        extra_args = ['--writers.ply.sized_types', 'false',
                      '--writers.ply.storage_mode', 'little endian']
 
    if resample > 0:
        resample_args = ['sample', '--filters.sample.radius=%s' % resample]
 
    subprocess.check_output(["pdal", "translate", input, output] + resample_args + reprojection_args + extra_args)
 
 
def is_pointcloud_georeferenced(laz_path):
    if not os.path.isfile(laz_path):
        return False
 
    try:
        j = json.loads(subprocess.check_output(["pdal", "info", "--summary", laz_path]))
        return 'summary' in j and 'srs' in j['summary']
    except Exception as e:
        logger.warning(e)
        return True # Assume georeferenced