7 from __future__
import print_function
10 from opals
import pyDM
12 def DM_spatial_query(filename, renderPoints = False):
14 dm = pyDM.Datamanager.load(filename,
True,
False)
16 print(
"Unable to open ODM '" + filename +
"'")
21 print(
"ODM contains", dm.sizePoint(),
"points")
22 print(
"2D-limit (%.3f," % limit.xmin,
"%.3f) -" % limit.ymin,
"(%.3f," % limit.xmax,
"%.3f)" % limit.ymax)
25 lf = pyDM.AddInfoLayoutFactory()
26 type, inDM = lf.addColumn(dm,
"Id",
True);
assert inDM ==
True
27 type, inDM = lf.addColumn(dm,
"GPSTime",
True);
assert inDM ==
True
28 type, inDM = lf.addColumn(dm,
"Amplitude",
True);
assert inDM ==
True
29 type, inDM = lf.addColumn(dm,
"Classification",
True);
assert inDM ==
True
30 layout = lf.getLayout()
34 pf = pyDM.PolygonFactory()
35 pf.addPoint(529600, 5338600)
36 pf.addPoint(529650, 5338620)
37 pf.addPoint(529650, 5338650)
38 pf.addPoint(529630, 5338650)
40 queryPoly = pf.getPolygon()
41 queryWin = pyDM.Window(529600, 5338600, 529650, 5338650)
45 filter = pyDM.Filter(
"class[ground]")
48 print(
"\nPerform spatial query")
49 result = pyDM.NumpyConverter.searchPoint(dm, queryPoly, layout, withCoordinates=
True)
52 print(
"result=", result)
56 ptsQueried = result[next(iter(result))].size
57 print(f
"{ptsQueried} points queried")
61 import matplotlib.pyplot
as plt
63 ax = fig.add_subplot(projection=
'3d')
64 ax.scatter(result[
"x"], result[
"y"], result[
"z"], c=result[
"Amplitude"], marker=
'.', cmap=plt.cm.Greys.reversed())
70 if len(sys.argv) == 1:
71 print(
"ODM parameter missing")
76 renderPts = sys.argv[2] ==
'1' or sys.argv[2].lower() ==
'true'
78 DM_spatial_query(sys.argv[1], renderPts)