summaryrefslogtreecommitdiff
path: root/src/mbgl/tile/raster_dem_tile_worker.cpp
blob: 5f6a278c94187088637b5c77ffb9359082fa5c31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <mbgl/tile/raster_dem_tile_worker.hpp>
#include <mbgl/tile/raster_dem_tile.hpp>
#include <mbgl/renderer/buckets/hillshade_bucket.hpp>
#include <mbgl/actor/actor.hpp>
#include <mbgl/util/premultiply.hpp>

namespace mbgl {

RasterDEMTileWorker::RasterDEMTileWorker(ActorRef<RasterDEMTileWorker>, ActorRef<RasterDEMTile> parent_)
    : parent(std::move(parent_)) {
}

void RasterDEMTileWorker::parse(std::shared_ptr<const std::string> data, uint64_t correlationID, Tileset::Encoding encoding) {
    if (!data) {
        parent.invoke(&RasterDEMTile::onParsed, nullptr, correlationID); // No data; empty tile.
        return;
    }

    try {
        auto bucket = std::make_unique<HillshadeBucket>(decodeImage(*data), encoding);
        parent.invoke(&RasterDEMTile::onParsed, std::move(bucket), correlationID);
    } catch (...) {
        parent.invoke(&RasterDEMTile::onError, std::current_exception(), correlationID);
    }
}

} // namespace mbgl