gdalchop: improve speed, especially when using a high number of datasets.
We only pass images to gdal now, if they intersect in any way with the current bucket.
This commit is contained in:
parent
76e7d8fcbe
commit
6d72319a68
2 changed files with 20 additions and 7 deletions
|
@ -2,8 +2,8 @@ include_directories(${GDAL_INCLUDE_DIR})
|
|||
add_executable(gdalchop gdalchop.cxx)
|
||||
|
||||
target_link_libraries(gdalchop
|
||||
${GDAL_LIBRARY}
|
||||
${SIMGEAR_CORE_LIBRARIES}
|
||||
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||
terragear ${GDAL_LIBRARY}
|
||||
${SIMGEAR_CORE_LIBRARIES}
|
||||
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||
)
|
||||
install(TARGETS gdalchop RUNTIME DESTINATION bin)
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include <simgear/misc/sg_path.hxx>
|
||||
#include <simgear/misc/sg_dir.hxx>
|
||||
|
||||
#include <Lib/terragear/tg_rectangle.hxx>
|
||||
|
||||
#include <gdal.h>
|
||||
#include <gdal_alg.h>
|
||||
#include <gdal_priv.h>
|
||||
|
@ -114,6 +116,12 @@ public:
|
|||
w = west;
|
||||
}
|
||||
|
||||
tgRectangle GetBoundingBox() const {
|
||||
tgRectangle box( SGGeod::fromDeg(east, south), SGGeod::fromDeg(west, north) );
|
||||
box.sanify();
|
||||
return box;
|
||||
}
|
||||
|
||||
const char* GetDescription() const {
|
||||
return dataset->GetDescription();
|
||||
}
|
||||
|
@ -358,6 +366,9 @@ void process_bucket(const SGPath& work_dir, SGBucket bucket,
|
|||
{
|
||||
double bnorth, bsouth, beast, bwest;
|
||||
|
||||
tgRectangle BucketBounds(bucket.get_corner(0), bucket.get_corner(2));
|
||||
BucketBounds.sanify();
|
||||
|
||||
bnorth = bucket.get_center_lat() + bucket.get_height() * 0.5;
|
||||
bsouth = bucket.get_center_lat() - bucket.get_height() * 0.5;
|
||||
beast = bucket.get_center_lon() + bucket.get_width() * 0.5;
|
||||
|
@ -391,10 +402,12 @@ void process_bucket(const SGPath& work_dir, SGBucket bucket,
|
|||
::memset(buffer.get(), 0, cellcount * sizeof(int));
|
||||
|
||||
for (int i = 0; i < imagecount; i++) {
|
||||
images[i]->GetDataChunk(work_dir, buffer.get(),
|
||||
bwest, bsouth,
|
||||
col_step / 3600.0, row_step / 3600.0,
|
||||
span_x, span_y );
|
||||
if ( images[i]->GetBoundingBox().intersects(BucketBounds) ) {
|
||||
images[i]->GetDataChunk(work_dir, buffer.get(),
|
||||
bwest, bsouth,
|
||||
col_step / 3600.0, row_step / 3600.0,
|
||||
span_x, span_y );
|
||||
}
|
||||
}
|
||||
|
||||
/* ...check the amount of undefined cells... */
|
||||
|
|
Loading…
Add table
Reference in a new issue