rename stroke=>line, add line painter classes
This commit is contained in:
@@ -12,6 +12,7 @@ SET(llmr_SOURCES
|
||||
renderer/shader-outline.cpp
|
||||
renderer/shader.cpp
|
||||
renderer/fill_bucket.cpp
|
||||
renderer/line_bucket.cpp
|
||||
resources/style.cpp
|
||||
shader/shaders.cpp
|
||||
style/style.cpp
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <llmr/util/string.hpp>
|
||||
#include <llmr/geometry/geometry.hpp>
|
||||
#include <llmr/renderer/fill_bucket.hpp>
|
||||
#include <llmr/renderer/line_bucket.hpp>
|
||||
#include <llmr/style/style.hpp>
|
||||
#include <cmath>
|
||||
|
||||
@@ -149,6 +150,8 @@ std::shared_ptr<Bucket> Tile::createBucket(const BucketDescription& bucket_desc)
|
||||
const VectorTileLayer& layer = layer_it->second;
|
||||
if (bucket_desc.type == BucketType::Fill) {
|
||||
return createFillBucket(layer, bucket_desc);
|
||||
} else if (bucket_desc.type == BucketType::Line) {
|
||||
return createLineBucket(layer, bucket_desc);
|
||||
} else {
|
||||
// TODO: create other bucket types.
|
||||
}
|
||||
@@ -159,13 +162,6 @@ std::shared_ptr<Bucket> Tile::createBucket(const BucketDescription& bucket_desc)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
enum geom_type {
|
||||
Unknown = 0,
|
||||
Point = 1,
|
||||
LineString = 2,
|
||||
Polygon = 3
|
||||
};
|
||||
|
||||
std::shared_ptr<Bucket> Tile::createFillBucket(const VectorTileLayer& layer, const BucketDescription& bucket_desc) {
|
||||
std::shared_ptr<FillBucket> bucket = std::make_shared<FillBucket>(fillBuffer);
|
||||
|
||||
@@ -173,22 +169,27 @@ std::shared_ptr<Bucket> Tile::createFillBucket(const VectorTileLayer& layer, con
|
||||
for (pbf feature : filtered_layer) {
|
||||
while (feature.next(4)) { // geometry
|
||||
pbf geometry_pbf = feature.message();
|
||||
bucket->addGeometry(geometry_pbf);
|
||||
if (geometry_pbf) {
|
||||
bucket->addGeometry(geometry_pbf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bucket;
|
||||
}
|
||||
|
||||
// void Tile::addLineGeometry(pbf& geom) {
|
||||
// Geometry geometry(geom);
|
||||
std::shared_ptr<Bucket> Tile::createLineBucket(const VectorTileLayer& layer, const BucketDescription& bucket_desc) {
|
||||
std::shared_ptr<LineBucket> bucket = std::make_shared<LineBucket>(lineBuffer);
|
||||
|
||||
// Geometry::command cmd;
|
||||
// int32_t x, y;
|
||||
// while ((cmd = geometry.next(x, y)) != Geometry::end) {
|
||||
// if (cmd == Geometry::move_to) {
|
||||
// lineVertex.addDegenerate();
|
||||
// }
|
||||
// lineVertex.addCoordinate(x, y);
|
||||
// }
|
||||
// }
|
||||
FilteredVectorTileLayer filtered_layer(layer, bucket_desc);
|
||||
for (pbf feature : filtered_layer) {
|
||||
while (feature.next(4)) { // geometry
|
||||
pbf geometry_pbf = feature.message();
|
||||
if (geometry_pbf) {
|
||||
bucket->addGeometry(geometry_pbf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bucket;
|
||||
}
|
||||
|
||||
28
src/renderer/line_bucket.cpp
Normal file
28
src/renderer/line_bucket.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <llmr/renderer/line_bucket.hpp>
|
||||
#include <llmr/geometry/line_buffer.hpp>
|
||||
#include <llmr/geometry/geometry.hpp>
|
||||
|
||||
#include <llmr/renderer/painter.hpp>
|
||||
#include <llmr/style/style.hpp>
|
||||
|
||||
#include <llmr/platform/gl.hpp>
|
||||
|
||||
#define BUFFER_OFFSET(i) ((char *)NULL + (i))
|
||||
|
||||
#include <cassert>
|
||||
|
||||
struct geometry_too_long_exception : std::exception {};
|
||||
|
||||
using namespace llmr;
|
||||
|
||||
LineBucket::LineBucket(const std::shared_ptr<LineBuffer>& buffer)
|
||||
: buffer(buffer) {
|
||||
}
|
||||
|
||||
void LineBucket::addGeometry(pbf& geom) {
|
||||
|
||||
}
|
||||
|
||||
void LineBucket::render(Painter& painter, const std::string& layer_name) {
|
||||
painter.renderLine(*this, layer_name);
|
||||
}
|
||||
@@ -328,6 +328,10 @@ void Painter::renderFill(FillBucket& bucket, const std::string& layer_name) {
|
||||
glStencilFunc(GL_EQUAL, 0x80, 0x80);
|
||||
}
|
||||
|
||||
void Painter::renderLine(LineBucket& bucket, const std::string& layer_name) {
|
||||
const LineProperties& properties = style.computed.lines[layer_name];
|
||||
}
|
||||
|
||||
void Painter::renderDebug(const Tile::Ptr& tile) {
|
||||
// Blend to the front, not the back.
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
@@ -10,7 +10,7 @@ Style::Style() {
|
||||
|
||||
void Style::reset() {
|
||||
computed.fills.clear();
|
||||
computed.strokes.clear();
|
||||
computed.lines.clear();
|
||||
}
|
||||
|
||||
void Style::load(const uint8_t *const data, uint32_t bytes) {
|
||||
@@ -91,7 +91,7 @@ std::pair<std::string, ClassDescription> Style::parseClass(pbf data) {
|
||||
} else if (data.tag == 2) { // fill_style
|
||||
klass.fill.insert(parseFillClass(data.message()));
|
||||
} else if (data.tag == 3) { // stroke_style
|
||||
klass.stroke.insert(parseStrokeClass(data.message()));
|
||||
klass.line.insert(parseLineClass(data.message()));
|
||||
} else {
|
||||
data.skip();
|
||||
}
|
||||
@@ -131,8 +131,8 @@ std::pair<std::string, FillClass> Style::parseFillClass(pbf data) {
|
||||
}
|
||||
|
||||
|
||||
std::pair<std::string, StrokeClass> Style::parseStrokeClass(pbf data) {
|
||||
StrokeClass stroke;
|
||||
std::pair<std::string, LineClass> Style::parseLineClass(pbf data) {
|
||||
LineClass stroke;
|
||||
std::string name;
|
||||
|
||||
while (data.next()) {
|
||||
@@ -216,11 +216,11 @@ void Style::cascade(float z) {
|
||||
}
|
||||
|
||||
// Cascade line classes
|
||||
for (const auto& stroke_pair : sheetClass.stroke) {
|
||||
const std::string& layer_name = stroke_pair.first;
|
||||
const llmr::StrokeClass& layer = stroke_pair.second;
|
||||
for (const auto& line_pair : sheetClass.line) {
|
||||
const std::string& layer_name = line_pair.first;
|
||||
const llmr::LineClass& layer = line_pair.second;
|
||||
|
||||
llmr::StrokeProperties& stroke = computed.strokes[layer_name];
|
||||
llmr::LineProperties& stroke = computed.lines[layer_name];
|
||||
stroke.hidden = layer.hidden(z);
|
||||
stroke.width = layer.width(z);
|
||||
stroke.offset = layer.offset(z);
|
||||
|
||||
Reference in New Issue
Block a user