void DebugTextStyle::addData(TileData& _data, MapTile& _tile, const MapProjection& _mapProjection) { if (Tangram::getDebugFlag(Tangram::DebugFlags::TILE_INFOS)) { onBeginBuildTile(_tile); std::shared_ptr<VboMesh> mesh(new Mesh(m_vertexLayout, m_drawMode)); auto ftContext = m_labels->getFontContext(); auto textBuffer = _tile.getTextBuffer(*this); ftContext->setFont(m_fontName, m_fontSize * m_pixelScale); if (m_sdf) { float blurSpread = 2.5; ftContext->setSignedDistanceField(blurSpread); } std::string tileID = std::to_string(_tile.getID().x) + "/" + std::to_string(_tile.getID().y) + "/" + std::to_string(_tile.getID().z); m_labels->addLabel(_tile, m_name, { glm::vec2(0), glm::vec2(0) }, tileID, Label::Type::DEBUG); onEndBuildTile(_tile, mesh); mesh->compileVertexBuffer(); _tile.addGeometry(*this, mesh); } }
void Style::addData(TileData& _data, MapTile& _tile, const MapProjection& _mapProjection) { onBeginBuildTile(_tile); std::shared_ptr<VboMesh> mesh(newMesh()); for (auto& layer : _data.layers) { // Skip any layers that this style doesn't have a rule for auto it = m_layers.begin(); while (it != m_layers.end() && it->first != layer.name) { ++it; } if (it == m_layers.end()) { continue; } // Loop over all features for (auto& feature : layer.features) { /* * TODO: do filter evaluation for each feature for sublayer! * construct a unique ID for a the set of filters matched * use this ID pass to the style's parseStyleParams method to construct styleParam cache * NOTE: for the time being use layerName as ID for cache */ feature.props.numericProps["zoom"] = _tile.getID().z; switch (feature.geometryType) { case GeometryType::POINTS: // Build points for (auto& point : feature.points) { buildPoint(point, parseStyleParams(it->first, it->second), feature.props, *mesh); } break; case GeometryType::LINES: // Build lines for (auto& line : feature.lines) { buildLine(line, parseStyleParams(it->first, it->second), feature.props, *mesh); } break; case GeometryType::POLYGONS: // Build polygons for (auto& polygon : feature.polygons) { buildPolygon(polygon, parseStyleParams(it->first, it->second), feature.props, *mesh); } break; default: break; } } } onEndBuildTile(_tile, mesh); if (mesh->numVertices() == 0) { mesh.reset(); } else { mesh->compileVertexBuffer(); _tile.addGeometry(*this, mesh); } }
void DebugTextStyle::addData(TileData& _data, MapTile& _tile, const MapProjection& _mapProjection) { if (Tangram::getDebugFlag(Tangram::DebugFlags::TILE_INFOS)) { onBeginBuildTile(_tile); Mesh* mesh = new Mesh(m_vertexLayout, m_drawMode); auto labelContainer = LabelContainer::GetInstance(); auto ftContext = labelContainer->getFontContext(); auto textBuffer = _tile.getTextBuffer(*this); ftContext->setFont(m_fontName, m_fontSize * m_pixelScale); if (m_sdf) { float blurSpread = 2.5; ftContext->setSignedDistanceField(blurSpread); } std::string tileID = std::to_string(_tile.getID().x) + "/" + std::to_string(_tile.getID().y) + "/" + std::to_string(_tile.getID().z); labelContainer->addLabel(_tile, m_name, { glm::vec2(0), glm::vec2(0) }, tileID, Label::Type::DEBUG); std::vector<PosTexID> vertices; vertices.resize(textBuffer->getVerticesSize()); if (textBuffer->getVertices(reinterpret_cast<float*>(vertices.data()))) { mesh->addVertices(std::move(vertices), {}); } mesh->compileVertexBuffer(); _tile.addGeometry(*this, std::unique_ptr<VboMesh>(mesh)); onEndBuildTile(_tile); } }