Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

clean up members, arguments, and formatting #937

Merged
merged 2 commits into from
Mar 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions src/mbgl/map/tile_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ namespace mbgl {
// its header file.
TileParser::~TileParser() = default;

TileParser::TileParser(const std::string &data, VectorTileData &tile_,
const util::ptr<const Style> &style_,
GlyphAtlas & glyphAtlas_,
GlyphStore & glyphStore_,
SpriteAtlas & spriteAtlas_,
const util::ptr<Sprite> &sprite_)
: vector_data(pbf((const uint8_t *)data.data(), data.size())),
TileParser::TileParser(const std::string& rawData_,
VectorTileData& tile_,
const util::ptr<const Style>& style_,
GlyphAtlas& glyphAtlas_,
GlyphStore& glyphStore_,
SpriteAtlas& spriteAtlas_,
const util::ptr<Sprite>& sprite_)
: vectorTile(pbf((const uint8_t *)rawData_.data(), rawData_.size())),
tile(tile_),
style(style_),
glyphAtlas(glyphAtlas_),
Expand Down Expand Up @@ -180,31 +181,31 @@ std::unique_ptr<StyleLayoutSymbol> parseStyleLayoutSymbol(const StyleBucket &buc
return symbolPtr;
}

std::unique_ptr<Bucket> TileParser::createBucket(const StyleBucket &bucket_desc) {
std::unique_ptr<Bucket> TileParser::createBucket(const StyleBucket &bucketDesc) {
// Skip this bucket if we are to not render this
if (tile.id.z < std::floor(bucket_desc.min_zoom) && std::floor(bucket_desc.min_zoom) < tile.source.max_zoom) return nullptr;
if (tile.id.z >= std::ceil(bucket_desc.max_zoom)) return nullptr;
if (bucket_desc.visibility == mbgl::VisibilityType::None) return nullptr;
if (tile.id.z < std::floor(bucketDesc.min_zoom) && std::floor(bucketDesc.min_zoom) < tile.source.max_zoom) return nullptr;
if (tile.id.z >= std::ceil(bucketDesc.max_zoom)) return nullptr;
if (bucketDesc.visibility == mbgl::VisibilityType::None) return nullptr;

auto layer_it = vector_data.layers.find(bucket_desc.source_layer);
if (layer_it != vector_data.layers.end()) {
auto layer_it = vectorTile.layers.find(bucketDesc.source_layer);
if (layer_it != vectorTile.layers.end()) {
const VectorTileLayer &layer = layer_it->second;
if (bucket_desc.type == StyleLayerType::Fill) {
return createFillBucket(layer, bucket_desc);
} else if (bucket_desc.type == StyleLayerType::Line) {
return createLineBucket(layer, bucket_desc);
} else if (bucket_desc.type == StyleLayerType::Symbol) {
return createSymbolBucket(layer, bucket_desc);
} else if (bucket_desc.type == StyleLayerType::Raster) {
if (bucketDesc.type == StyleLayerType::Fill) {
return createFillBucket(layer, bucketDesc);
} else if (bucketDesc.type == StyleLayerType::Line) {
return createLineBucket(layer, bucketDesc);
} else if (bucketDesc.type == StyleLayerType::Symbol) {
return createSymbolBucket(layer, bucketDesc);
} else if (bucketDesc.type == StyleLayerType::Raster) {
return nullptr;
} else {
fprintf(stderr, "[WARNING] unknown bucket render type for layer '%s' (source layer '%s')\n", bucket_desc.name.c_str(), bucket_desc.source_layer.c_str());
fprintf(stderr, "[WARNING] unknown bucket render type for layer '%s' (source layer '%s')\n", bucketDesc.name.c_str(), bucketDesc.source_layer.c_str());
}
} else {
// The layer specified in the bucket does not exist. Do nothing.
if (debug::tileParseWarnings) {
fprintf(stderr, "[WARNING] layer '%s' does not exist in tile %d/%d/%d\n",
bucket_desc.source_layer.c_str(), tile.id.z, tile.id.x, tile.id.y);
bucketDesc.source_layer.c_str(), tile.id.z, tile.id.x, tile.id.y);
}
}

Expand Down
31 changes: 16 additions & 15 deletions src/mbgl/map/tile_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ class TexturePool;
class TileParser : private util::noncopyable
{
public:
TileParser(const std::string &data, VectorTileData &tile,
const util::ptr<const Style> &style,
GlyphAtlas & glyphAtlas,
GlyphStore & glyphStore,
SpriteAtlas & spriteAtlas,
const util::ptr<Sprite> &sprite);
TileParser(const std::string& rawData,
VectorTileData& tile,
const util::ptr<const Style>& style,
GlyphAtlas& glyphAtlas,
GlyphStore& glyphStore,
SpriteAtlas& spriteAtlas,
const util::ptr<Sprite>& sprite);
~TileParser();

public:
Expand All @@ -50,22 +51,22 @@ class TileParser : private util::noncopyable
bool obsolete() const;
void parseStyleLayers(util::ptr<const StyleLayerGroup> group);

std::unique_ptr<Bucket> createBucket(const StyleBucket &bucket_desc);
std::unique_ptr<Bucket> createFillBucket(const VectorTileLayer &layer, const StyleBucket &bucket_desc);
std::unique_ptr<Bucket> createLineBucket(const VectorTileLayer& layer, const StyleBucket &bucket_desc);
std::unique_ptr<Bucket> createSymbolBucket(const VectorTileLayer& layer, const StyleBucket &bucket_desc);
std::unique_ptr<Bucket> createBucket(const StyleBucket& bucketDesc);
std::unique_ptr<Bucket> createFillBucket(const VectorTileLayer& layer, const StyleBucket& bucketDesc);
std::unique_ptr<Bucket> createLineBucket(const VectorTileLayer& layer, const StyleBucket& bucketDesc);
std::unique_ptr<Bucket> createSymbolBucket(const VectorTileLayer& layer, const StyleBucket& bucketDesc);

template <class Bucket> void addBucketGeometries(Bucket& bucket, const VectorTileLayer& layer, const FilterExpression &filter);
template <class Bucket> void addBucketGeometries(Bucket& bucket, const VectorTileLayer& layer, const FilterExpression& filter);

private:
const VectorTile vector_data;
const VectorTile vectorTile;
VectorTileData& tile;

// Cross-thread shared data.
util::ptr<const Style> style;
GlyphAtlas & glyphAtlas;
GlyphStore & glyphStore;
SpriteAtlas & spriteAtlas;
GlyphAtlas& glyphAtlas;
GlyphStore& glyphStore;
SpriteAtlas& spriteAtlas;
util::ptr<Sprite> sprite;

std::unique_ptr<Collision> collision;
Expand Down