|
32 | 32 | * OF SUCH DAMAGE. |
33 | 33 | ****************************************************************************/ |
34 | 34 |
|
| 35 | +#include "PyPipeline.hpp" |
35 | 36 | #include "StreamableExecutor.hpp" |
36 | 37 |
|
37 | 38 | #include <Python.h> |
@@ -68,7 +69,7 @@ void PythonPointTable::finalize() |
68 | 69 | auto gil = PyGILState_Ensure(); |
69 | 70 | if (_import_array() < 0) |
70 | 71 | std::cerr << "Could not import array!\n"; |
71 | | - PyObject *dtype_dict = py_buildNumpyDescriptor(); |
| 72 | + PyObject *dtype_dict = buildNumpyDescriptor(&m_layout); |
72 | 73 | if (PyArray_DescrConverter(dtype_dict, &m_dtype) == NPY_FAIL) |
73 | 74 | throw pdal_error("Unable to create numpy dtype"); |
74 | 75 | Py_XDECREF(dtype_dict); |
@@ -110,62 +111,6 @@ void PythonPointTable::py_resizeArray(point_count_t np) |
110 | 111 | PyGILState_Release(gil); |
111 | 112 | } |
112 | 113 |
|
113 | | -PyObject *PythonPointTable::py_buildNumpyDescriptor() const |
114 | | -{ |
115 | | - // Build up a numpy dtype dictionary |
116 | | - // |
117 | | - // {'formats': ['f8', 'f8', 'f8', 'u2', 'u1', 'u1', 'u1', 'u1', 'u1', |
118 | | - // 'f4', 'u1', 'u2', 'f8', 'u2', 'u2', 'u2'], |
119 | | - // 'names': ['X', 'Y', 'Z', 'Intensity', 'ReturnNumber', |
120 | | - // 'NumberOfReturns', 'ScanDirectionFlag', 'EdgeOfFlightLine', |
121 | | - // 'Classification', 'ScanAngleRank', 'UserData', |
122 | | - // 'PointSourceId', 'GpsTime', 'Red', 'Green', 'Blue']} |
123 | | - // |
124 | | - |
125 | | - auto dims = m_layout.dims(); |
126 | | - |
127 | | - // Need to sort the dimensions by offset |
128 | | - // Is there a better way? Can they be sorted by offset already? |
129 | | - auto sorter = [this](Dimension::Id id1, Dimension::Id id2) -> bool |
130 | | - { |
131 | | - return m_layout.dimOffset(id1) < m_layout.dimOffset(id2); |
132 | | - }; |
133 | | - std::sort(dims.begin(), dims.end(), sorter); |
134 | | - |
135 | | - PyObject* names = PyList_New(dims.size()); |
136 | | - PyObject* formats = PyList_New(dims.size()); |
137 | | - for (size_t i = 0; i < dims.size(); ++i) |
138 | | - { |
139 | | - auto id = dims[i]; |
140 | | - std::string kind; |
141 | | - switch (Dimension::base(m_layout.dimType(id))) |
142 | | - { |
143 | | - case Dimension::BaseType::Unsigned: |
144 | | - kind = 'u'; |
145 | | - break; |
146 | | - case Dimension::BaseType::Signed: |
147 | | - kind = 'i'; |
148 | | - break; |
149 | | - case Dimension::BaseType::Floating: |
150 | | - kind = 'f'; |
151 | | - break; |
152 | | - default: |
153 | | - throw pdal_error("Unable to map kind '" + kind + "' to PDAL dimension type"); |
154 | | - } |
155 | | - |
156 | | - auto name = m_layout.dimName(id); |
157 | | - PyList_SetItem(names, i, PyUnicode_FromString(name.c_str())); |
158 | | - |
159 | | - auto format = kind + std::to_string(m_layout.dimSize(id)); |
160 | | - PyList_SetItem(formats, i, PyUnicode_FromString(format.c_str())); |
161 | | - } |
162 | | - |
163 | | - PyObject* dict = PyDict_New(); |
164 | | - PyDict_SetItemString(dict, "names", names); |
165 | | - PyDict_SetItemString(dict, "formats", formats); |
166 | | - return dict; |
167 | | -} |
168 | | - |
169 | 114 | void PythonPointTable::reset() |
170 | 115 | { |
171 | 116 | point_count_t np = 0; |
@@ -231,7 +176,7 @@ char *PythonPointTable::getPoint(PointId idx) |
231 | 176 | StreamableExecutor::StreamableExecutor(std::string const& json, point_count_t chunkSize, int prefetch) : |
232 | 177 | PipelineExecutor(json), m_table(chunkSize, prefetch) |
233 | 178 | {} |
234 | | - |
| 179 | + |
235 | 180 | StreamableExecutor::~StreamableExecutor() |
236 | 181 | { |
237 | 182 | //ABELL - Hmmm. |
|
0 commit comments