Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 38 additions & 37 deletions raster/r.in.pdal/info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*
*/
#include <cmath>
#include <utility>

#include <pdal/filters/ReprojectionFilter.hpp>
#include <pdal/io/BufferReader.hpp>
Expand Down Expand Up @@ -137,49 +138,49 @@ void get_reprojected_extent(pdal::SpatialReference &spatial_reference,
// Generate points along the 4 edges of the bounding box
// First point of each edge starts at the corner and
// the last point is right before the corner
for (int i = 0; i < points_per_edge - 1; ++i) {
double t = i / (double)(points_per_edge - 1);
try {
for (int i = 0; i < points_per_edge - 1; ++i) {
double t = i / (double)(points_per_edge - 1);

// South edge (y = min_y)
view->setField(pdal::Dimension::Id::X, idx,
*min_x + t * (*max_x - *min_x));
view->setField(pdal::Dimension::Id::Y, idx, *min_y);
view->setField(pdal::Dimension::Id::Z, idx, *min_z);
idx++;
// South edge (y = min_y)
view->setField(pdal::Dimension::Id::X, idx,
*min_x + t * (*max_x - *min_x));
view->setField(pdal::Dimension::Id::Y, idx, *min_y);
view->setField(pdal::Dimension::Id::Z, idx, *min_z);
idx++;

// East edge (x = max_x)
view->setField(pdal::Dimension::Id::X, idx, *max_x);
view->setField(pdal::Dimension::Id::Y, idx,
*min_y + t * (*max_y - *min_y));
view->setField(pdal::Dimension::Id::Z, idx, *max_z);
idx++;
// East edge (x = max_x)
view->setField(pdal::Dimension::Id::X, idx, *max_x);
view->setField(pdal::Dimension::Id::Y, idx,
*min_y + t * (*max_y - *min_y));
view->setField(pdal::Dimension::Id::Z, idx, *max_z);
idx++;

// North edge (y = max_y)
view->setField(pdal::Dimension::Id::X, idx,
*max_x - t * (*max_x - *min_x));
view->setField(pdal::Dimension::Id::Y, idx, *max_y);
view->setField(pdal::Dimension::Id::Z, idx, *min_z);
idx++;
// North edge (y = max_y)
view->setField(pdal::Dimension::Id::X, idx,
*max_x - t * (*max_x - *min_x));
view->setField(pdal::Dimension::Id::Y, idx, *max_y);
view->setField(pdal::Dimension::Id::Z, idx, *min_z);
idx++;

// West edge (x = min_x)
view->setField(pdal::Dimension::Id::X, idx, *min_x);
view->setField(pdal::Dimension::Id::Y, idx,
*max_y - t * (*max_y - *min_y));
view->setField(pdal::Dimension::Id::Z, idx, *max_z);
idx++;
}
// West edge (x = min_x)
view->setField(pdal::Dimension::Id::X, idx, *min_x);
view->setField(pdal::Dimension::Id::Y, idx,
*max_y - t * (*max_y - *min_y));
view->setField(pdal::Dimension::Id::Z, idx, *max_z);
idx++;
}

pdal::BufferReader reader;
reader.addView(view);
pdal::BufferReader reader;
reader.addView(view);

pdal::StageFactory factory;
pdal::Stage *reproject = factory.createStage("filters.reprojection");
pdal::Options reproject_options;
reproject_options.add("in_srs", spatial_reference.getWKT());
reproject_options.add("out_srs", location_projection_as_wkt(false));
reproject->setOptions(reproject_options);
reproject->setInput(reader);
try {
pdal::StageFactory factory;
pdal::Stage *reproject = factory.createStage("filters.reprojection");
pdal::Options reproject_options;
reproject_options.add("in_srs", spatial_reference.getWKT());
reproject_options.add("out_srs", location_projection_as_wkt(false));
reproject->setOptions(std::move(reproject_options));
reproject->setInput(reader);
reproject->prepare(table);
reproject->execute(table);
}
Expand Down
Loading