Annotation tiles may become partially parsed just like regular tiles, for example if a point annotation is added to the map before the style's sprite has been loaded. In such cases, they need to be reparsed or the annotation will not be rendered. Previously, the code path for reparsing would be short-circuited by a dynamic_cast<VectorTileData*> followed by a null check. This commit removes that case and adds (back) a virtual reparse method to the TileData interface.
35 lines
1.2 KiB
C++
35 lines
1.2 KiB
C++
#include "../fixtures/util.hpp"
|
|
|
|
#include <mbgl/annotation/point_annotation.hpp>
|
|
#include <mbgl/map/map.hpp>
|
|
#include <mbgl/map/still_image.hpp>
|
|
#include <mbgl/platform/default/headless_display.hpp>
|
|
#include <mbgl/platform/default/headless_view.hpp>
|
|
#include <mbgl/storage/default_file_source.hpp>
|
|
#include <mbgl/util/image.hpp>
|
|
#include <mbgl/util/io.hpp>
|
|
|
|
#include <future>
|
|
#include <vector>
|
|
|
|
TEST(Annotations, PointAnnotation) {
|
|
using namespace mbgl;
|
|
|
|
auto display = std::make_shared<mbgl::HeadlessDisplay>();
|
|
HeadlessView view(display, 1);
|
|
DefaultFileSource fileSource(nullptr);
|
|
|
|
Map map(view, fileSource, MapMode::Still);
|
|
map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"), "");
|
|
map.addPointAnnotation(PointAnnotation({ 0, 0 }, "default_marker"));
|
|
|
|
std::promise<std::unique_ptr<const StillImage>> promise;
|
|
map.renderStill([&promise](std::exception_ptr, std::unique_ptr<const StillImage> image) {
|
|
promise.set_value(std::move(image));
|
|
});
|
|
|
|
auto result = promise.get_future().get();
|
|
const std::string png = util::compress_png(result->width, result->height, result->pixels.get());
|
|
util::write_file("test/output/point_annotation.png", png);
|
|
}
|