Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_metadata(self):
"""Can we fetch PDAL metadata"""
json = self.fetch_json('sort.json')
r = pdal.Pipeline(json)
r.validate()
r.execute()
metadata = r.metadata
import json
j = json.loads(metadata)
self.assertEqual(j["metadata"]["readers.las"][0]["count"], 1065)
def test_merged_arrays(self):
"""Can we fetch multiple point views from merged PDAL data """
json = self.fetch_json('chip.json')
r = pdal.Pipeline(json)
r.validate()
r.execute()
arrays = r.arrays
self.assertEqual(len(arrays), 43)
def test_execution(self):
"""Can we execute a PDAL pipeline"""
x = self.fetch_json('sort.json')
r = pdal.Pipeline(x)
r.validate()
r.execute()
self.assertGreater(len(r.pipeline), 200)
def test_validate(self):
"""Do we complain with bad pipelines"""
r = pdal.Pipeline(bad_json)
with self.assertRaises(RuntimeError):
r.validate()
sys.exit(1)
# read the pdal file and project the points
json = u"""
{
"pipeline": [
"%s",
{
"type":"filters.reprojection",
"out_srs":"EPSG:4326"
}
]
}"""
print("Loading Point Cloud")
json = json % args.source_points
pipeline = pdal.Pipeline(json)
pipeline.validate() # check if our JSON and options were good
# this causes a segfault at the end of the program
# pipeline.loglevel = 8 # really noisy
count = pipeline.execute()
arrays = pipeline.arrays
arrayX = arrays[0]['X']
arrayY = arrays[0]['Y']
arrayZ = arrays[0]['Z']
pipeline = None
# Sort the points by height so that higher points project last
print("Sorting by Height")
heightIdx = numpy.argsort(arrayZ)
arrayX = arrayX[heightIdx]
arrayY = arrayY[heightIdx]
arrayZ = arrayZ[heightIdx]
def execute(self):
"""
Shortcut to execute and return the results of the pipeline.
"""
# TODO: do some validation before calling execute
# TODO: some exception/error handling around pdal
pipeline = pdal.Pipeline(json.dumps(self.spec))
# pipeline.validate() # NOTE: disabling this because it causes segfaults in certain cases
pipeline.execute()
return pipeline.arrays[0] # NOTE: are there situation where arrays has multiple elements?
json = {
"pipeline": [
{
"type":"readers.las",
"filename":filename,
},
{
"type":"filters.transformation",
#"matrix":"0.4 -1 0 1 1 0 0 2 0 0 1 3 0 0 0 1",
"matrix":t,
},
]
}
tic()
pipeline = pdal.Pipeline(unicode(js.dumps(json)))
#pipeline.validate() # check if our JSON and options were good
pipeline.loglevel = 0 #really noisy
count = pipeline.execute()
arrays = pipeline.arrays
toc()
tic()
pipeline = pdal.Pipeline(unicode(js.dumps(json)))
#pipeline.validate() # check if our JSON and options were good
#pipeline.loglevel = 8 #really noisy
count = pipeline.execute()
arrays = pipeline.arrays
toc()
raise RuntimeError("Error: driver {} does not supports Create().".format(driver))
# read the pdal file and project the points
json = u"""
{
"pipeline": [
"%s",
{
"type":"filters.reprojection",
"out_srs":"EPSG:4326"
}
]
}"""
print("Loading Point Cloud")
json = json % args.source_points
pipeline = pdal.Pipeline(json)
pipeline.validate() # check if our JSON and options were good
# this causes a segfault at the end of the program
# pipeline.loglevel = 8 # really noisy
pipeline.execute()
arrays = pipeline.arrays
arrayX = arrays[0]['X']
arrayY = arrays[0]['Y']
arrayZ = arrays[0]['Z']
pipeline = None
# Sort the points by height so that higher points project last
print("Sorting by Height")
heightIdx = numpy.argsort(arrayZ)
arrayX = arrayX[heightIdx]
arrayY = arrayY[heightIdx]
arrayZ = arrayZ[heightIdx]