| 355 | } |
| 356 | |
| 357 | void writeMatrix(Eigen::MatrixXd data, const std::string& filename, |
| 358 | const std::string& driver, double cell_size, BOX2D bounds, |
| 359 | SpatialReference srs) |
| 360 | { |
| 361 | std::array<double, 6> pixelToPos; |
| 362 | pixelToPos[0] = bounds.minx; |
| 363 | pixelToPos[1] = cell_size; |
| 364 | pixelToPos[2] = 0.0; |
| 365 | pixelToPos[3] = bounds.miny; |
| 366 | pixelToPos[4] = 0.0; |
| 367 | pixelToPos[5] = cell_size; |
| 368 | gdal::Raster raster(filename, driver, srs, pixelToPos); |
| 369 | |
| 370 | gdal::GDALError err = raster.open(data.cols(), data.rows(), 1, |
| 371 | Dimension::Type::Float, -9999.0); |
| 372 | |
| 373 | if (err != gdal::GDALError::None) |
| 374 | throw pdal_error(raster.errorMsg()); |
| 375 | |
| 376 | // Two things going on here. First, Eigen defaults to column major order, |
| 377 | // but GDALUtils expects row major, so we can convert it. Also, double |
| 378 | // doesn't seem to work for some reason, so maybe we go back and make the |
| 379 | // incoming matrix always be a float, but for now just cast it. |
| 380 | using namespace Eigen; |
| 381 | Eigen::Matrix<float, Dynamic, Dynamic, RowMajor> dataRowMajor; |
| 382 | dataRowMajor = data.cast<float>(); |
| 383 | |
| 384 | raster.writeBand((float*)dataRowMajor.data(), -9999.0f, 1); |
| 385 | } |
| 386 | #pragma warning (pop) |
| 387 | |
| 388 | Eigen::Vector3d rotate(const Eigen::Vector3d& v, const Eigen::Quaterniond& rot) |
no test coverage detected