#include #include #include #include #include #include #include #include #include #include #include #include #include namespace mbgl { Style::Style() : mtx(util::make_unique()) { } // Note: This constructor is seemingly empty, but we need to declare it anyway // because this file includes uv_detail.hpp, which has the declarations necessary // for deleting the std::unique_ptr. Style::~Style() {} void Style::updateProperties(float z, std::chrono::steady_clock::time_point now) { uv::writelock lock(mtx); zoomHistory.update(z, now); if (layers) { layers->updateProperties(z, now, zoomHistory); } // Apply transitions after the first time. if (!initial_render_complete) { initial_render_complete = true; return; } } const std::string &Style::getSpriteURL() const { return sprite_url; } void Style::setDefaultTransitionDuration(std::chrono::steady_clock::duration duration) { defaultTransition.duration = duration; } void Style::cascadeClasses(const std::vector& classes) { if (layers) { layers->setClasses(classes, std::chrono::steady_clock::now(), defaultTransition); } } bool Style::hasTransitions() const { if (layers) { if (layers->hasTransitions()) { return true; } } return false; } void Style::loadJSON(const uint8_t *const data) { uv::writelock lock(mtx); rapidjson::Document doc; doc.Parse<0>((const char *const)data); if (doc.HasParseError()) { Log::Error(Event::ParseStyle, "Error parsing style JSON at %i: %s", doc.GetErrorOffset(), doc.GetParseError()); throw error::style_parse(doc.GetErrorOffset(), doc.GetParseError()); } StyleParser parser; parser.parse(doc); layers = parser.getLayers(); sprite_url = parser.getSprite(); glyph_url = parser.getGlyphURL(); } }