OpenRoadCode
Public API reference for OpenRoadCode
Loading...
Searching...
No Matches
poi_brand_images.hpp
1// SPDX-FileCopyrightText: 2026 Mark G. Russell
2// SPDX-License-Identifier: MIT
3#pragma once
4#include "poi_brand_payload.hpp"
5#include <mbgl/style/image.hpp>
6#include <mbgl/style/style.hpp>
7#include <mbgl/util/image.hpp>
8#include <memory>
9
10inline std::string preparePoiBrandResults(mbgl::style::Style& style, const std::string& geojson) {
11 for (const auto& [id, data] : poiBrandImages(geojson)) {
12 if (style.getImage(id)) continue;
13 try {
14 style.addImage(std::make_unique<mbgl::style::Image>(id, mbgl::decodeImage(data), 2.0f));
15 } catch (const std::exception&) {
16 // Keep the category badge when an optional logo cannot be decoded.
17 }
18 }
19 return withPoiBrandAvailability(geojson, [&style](const std::string& id) {
20 return style.getImage(id).has_value();
21 });
22}