Parsing errors will be reported to Observers. In practice this will bubble all the way to the Map object. This will make possible to identify possible corrupted data instead of rendering without sprites like we do in case of semantic errors.
46 lines
1.1 KiB
C++
46 lines
1.1 KiB
C++
#ifndef MBGL_ANNOTATIONS_SPRITE_PARSER
|
|
#define MBGL_ANNOTATIONS_SPRITE_PARSER
|
|
|
|
#include <mbgl/util/noncopyable.hpp>
|
|
#include <mbgl/util/geo.hpp>
|
|
#include <mbgl/util/variant.hpp>
|
|
|
|
#include <string>
|
|
#include <memory>
|
|
#include <map>
|
|
|
|
namespace mbgl {
|
|
|
|
namespace util {
|
|
|
|
class Image;
|
|
|
|
} // namespace util
|
|
|
|
class SpriteImage;
|
|
|
|
using SpriteImagePtr = std::shared_ptr<const SpriteImage>;
|
|
|
|
// Extracts an individual image from a spritesheet from the given location.
|
|
SpriteImagePtr createSpriteImage(const util::Image& image,
|
|
uint16_t srcX,
|
|
uint16_t srcY,
|
|
uint16_t srcWidth,
|
|
uint16_t srcHeight,
|
|
double ratio,
|
|
bool sdf);
|
|
|
|
using Sprites = std::map<std::string, SpriteImagePtr>;
|
|
|
|
|
|
using SpriteParseResult = mapbox::util::variant<
|
|
Sprites, // success
|
|
std::string>; // error
|
|
|
|
// Parses an image and an associated JSON file and returns the sprite objects.
|
|
SpriteParseResult parseSprite(const std::string& image, const std::string& json);
|
|
|
|
} // namespace mbgl
|
|
|
|
#endif
|