------------------------------------------------------------------------------
| 59 | |
| 60 | //------------------------------------------------------------------------------ |
| 61 | int vtkPDALReader::RequestInformation( |
| 62 | vtkInformation*, vtkInformationVector**, vtkInformationVector*) |
| 63 | { |
| 64 | this->OffsetAsString.clear(); |
| 65 | this->HasOffset = false; |
| 66 | |
| 67 | try |
| 68 | { |
| 69 | pdal::StageFactory factory; |
| 70 | |
| 71 | std::string driverName = pdal::StageFactory::inferReaderDriver(this->FileName); |
| 72 | |
| 73 | pdal::Stage* reader = factory.createStage(driverName); |
| 74 | if (!reader) |
| 75 | { |
| 76 | vtkErrorMacro("CreateStage failed"); |
| 77 | return 1; |
| 78 | } |
| 79 | |
| 80 | pdal::Options opts; |
| 81 | opts.add(pdal::Option("filename", this->FileName)); |
| 82 | reader->setOptions(opts); |
| 83 | |
| 84 | pdal::PointTable table; |
| 85 | reader->prepare(table); |
| 86 | |
| 87 | auto offsets = this->GetLasOffsets(reader); |
| 88 | |
| 89 | if (!(offsets[0] == 0.0 && offsets[1] == 0.0 && offsets[2] == 0.0)) |
| 90 | { |
| 91 | std::ostringstream ss; |
| 92 | ss.setf(std::ios::fixed); |
| 93 | ss.precision(3); |
| 94 | ss << "(" << offsets[0] << ", " << offsets[1] << ", " << offsets[2] << ")"; |
| 95 | |
| 96 | this->HasOffset = true; |
| 97 | this->OffsetAsString = ss.str(); |
| 98 | } |
| 99 | } |
| 100 | catch (const pdal::pdal_error& e) |
| 101 | { |
| 102 | vtkErrorMacro(<< "PDAL error: " << e.what()); |
| 103 | } |
| 104 | |
| 105 | return 1; |
| 106 | } |
| 107 | |
| 108 | int vtkPDALReader::RequestData(vtkInformation* vtkNotUsed(request), |
| 109 | vtkInformationVector** vtkNotUsed(request), vtkInformationVector* outputVector) |