Store SourceInfo as direct member
This commit is contained in:
@@ -29,16 +29,11 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class StyleSource : public std::enable_shared_from_this<StyleSource> {
|
||||
class StyleSource : private util::noncopyable {
|
||||
public:
|
||||
util::ptr<SourceInfo> info;
|
||||
|
||||
SourceInfo info;
|
||||
bool enabled = false;
|
||||
util::ptr<Source> source;
|
||||
|
||||
StyleSource(const util::ptr<SourceInfo> &info_)
|
||||
: info(info_)
|
||||
{}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -606,7 +606,7 @@ void Map::updateSources() {
|
||||
for (const util::ptr<StyleSource> &style_source : activeSources) {
|
||||
if (style_source->enabled) {
|
||||
if (!style_source->source) {
|
||||
style_source->source = std::make_shared<Source>(*style_source->info);
|
||||
style_source->source = std::make_shared<Source>(style_source->info);
|
||||
style_source->source->load(*this, *fileSource);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -178,14 +178,12 @@ void StyleParser::parseSources(JSVal value) {
|
||||
rapidjson::Value::ConstMemberIterator itr = value.MemberBegin();
|
||||
for (; itr != value.MemberEnd(); ++itr) {
|
||||
std::string name { itr->name.GetString(), itr->name.GetStringLength() };
|
||||
util::ptr<SourceInfo> info = std::make_shared<SourceInfo>();
|
||||
SourceInfo& info = sources.emplace(name, std::make_shared<StyleSource>()).first->second->info;
|
||||
|
||||
parseRenderProperty<SourceTypeClass>(itr->value, info->type, "type");
|
||||
parseRenderProperty(itr->value, info->url, "url");
|
||||
parseRenderProperty(itr->value, info->tile_size, "tileSize");
|
||||
info->parseTileJSONProperties(itr->value);
|
||||
|
||||
sources.emplace(std::move(name), std::make_shared<StyleSource>(info));
|
||||
parseRenderProperty<SourceTypeClass>(itr->value, info.type, "type");
|
||||
parseRenderProperty(itr->value, info.url, "url");
|
||||
parseRenderProperty(itr->value, info.tile_size, "tileSize");
|
||||
info.parseTileJSONProperties(itr->value);
|
||||
}
|
||||
} else {
|
||||
Log::Warning(Event::ParseStyle, "sources must be an object");
|
||||
|
||||
Reference in New Issue
Block a user