Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
Various warp-related fixes; setup-resource uses cubicspline for downs…
Browse files Browse the repository at this point in the history
…amplig; metatile warping uses avg(min, max) if value is unavailable.
  • Loading branch information
vaclavblazek committed Oct 21, 2020
1 parent 3241c5a commit d42fdfc
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 15 deletions.
2 changes: 1 addition & 1 deletion externals/libgeo
4 changes: 0 additions & 4 deletions mapproxy/src/mapproxy/definition/factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ DefinitionBase::pointer definition(const Resource::Generator &type)
const auto &r(registry());
auto fregistry(r.find(type));
if (fregistry == r.end()) {
for (const auto &item : registry()) {
LOG(info4) << " " << item.first;
}
LOGTHROW(err1, UnknownGenerator)
<< "Unknown generator type <" << type << ">.";
}
Expand All @@ -60,7 +57,6 @@ void registerDefinition(const Resource::Generator &type
, const std::function<DefinitionBase::pointer()>
&factory)
{
LOG(info4) << "registering <" << type << ">.";
registry().insert(Registry::value_type(type, factory));
}

Expand Down
21 changes: 15 additions & 6 deletions mapproxy/src/mapproxy/gdalsupport/gdalsupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,9 @@ void GdalWarper::Detail::runManager(Process::Id parentId)

void GdalWarper::Detail::killLeviathan()
{
// stop if there are no workers (yet)
if (workers_.empty()) { return; }

utility::PidList pids;
for (const auto &item : workers_) { pids.push_back(item.first); }

Expand Down Expand Up @@ -767,13 +770,19 @@ void GdalWarper::Detail::killLeviathan()
<< "Killing large GDAL process " << u.pid
<< " occupying " << (double(total) / 1024) << "MB of memory.";

auto fworkers(workers_.find(u.pid));
if (fworkers != workers_.end()) {
fworkers->second->terminate();
} else {
// should not happen
Process::kill(u.pid);
try {
auto fworkers(workers_.find(u.pid));
if (fworkers != workers_.end()) {
fworkers->second->terminate();
} else {
// should not happen
Process::kill(u.pid);
}
} catch (const std::exception &e) {
LOG(warn2) << "Unable to kill worker process: <"
<< e.what() << ">; ignoring.";
}

total -= u.mem;
}
}
Expand Down
8 changes: 7 additions & 1 deletion mapproxy/src/mapproxy/gdalsupport/operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,13 @@ cv::Mat* warpValueMinMax(DatasetCache &cache, ManagedBuffer &mb
{
// skip invalid value
auto value(*id);
if (value == ForcedNodata) { continue; }
if (value == ForcedNodata) {
if ((*idmin == ForcedNodata) || (*idmax == ForcedNodata)) {
continue;
}
// no value but we have valid min/max -> average
value = (*idmin + *idmax) / 2;
}

auto &sample(*itile);
sample[0] = value;
Expand Down
6 changes: 6 additions & 0 deletions mapproxy/src/mapproxy/generator/metatile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,15 @@ metatileFromDemImpl(const vts::TileId &tileId, Sink &sink, Arsenal &arsenal
<< ", size in tiles: " << vts::tileRangesSize(block.view)
<< ".";

#if 0
#if GDAL_VERSION_NUM >= 2020000
// force average since cubicspline is somewhat dubious on GDAL >= 2.2
// FIXME: disabled, seems to be working when GDAL is fixed
const auto resampling(geo::GeoDataset::Resampling::average);
#else
// use "dem" resampling (cubicspline or average)
const auto resampling(geo::GeoDataset::Resampling::dem);
#endif
#else
// use "dem" resampling (cubicspline or average)
const auto resampling(geo::GeoDataset::Resampling::dem);
Expand Down
1 change: 1 addition & 0 deletions mapproxy/src/mapproxy/generator/surface-dem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ void SurfaceDem::generateNavtile(const vts::TileId &tileId
const auto *metanode(metatile.get(tileId, std::nothrow));
if (!metanode) {
sink.error(utility::makeError<NotFound>("Metatile not found."));
return;
}

const auto heightRange(metanode->heightRange);
Expand Down
4 changes: 3 additions & 1 deletion mapproxy/src/setup-resource/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,9 @@ fs::path createVrtWO(const calipers::Measurement &cm
{
LogLinePrefix linePrefix(" (dem)");
createVrtWO(datasetPath, rootDir, "dem"
, geo::GeoDataset::Resampling::dem, cm);
// , geo::GeoDataset::Resampling::average
, geo::GeoDataset::Resampling::cubicspline
, cm);
}

LOG(info4) << "Generating minimum height overviews.";
Expand Down

0 comments on commit d42fdfc

Please sign in to comment.