This commit is contained in:
Konstantin Käfer
2014-06-26 21:54:57 +02:00
parent 084c938e54
commit 6de9d9769e
18 changed files with 43 additions and 219 deletions

View File

@@ -2,7 +2,6 @@
#define LLMR_RENDERER_DEBUGBUCKET
#include <llmr/renderer/bucket.hpp>
#include <llmr/style/bucket_description.hpp>
#include <llmr/geometry/debug_font_buffer.hpp>
#include <llmr/geometry/vao.hpp>

View File

@@ -2,9 +2,9 @@
#define LLMR_RENDERER_FILLBUCKET
#include <llmr/renderer/bucket.hpp>
#include <llmr/style/bucket_description.hpp>
#include <llmr/geometry/elements_buffer.hpp>
#include <llmr/geometry/fill_buffer.hpp>
#include <llmr/style/style_bucket.hpp>
#include <clipper/clipper.hpp>
#include <libtess2/tesselator.h>

View File

@@ -2,9 +2,9 @@
#define LLMR_RENDERER_ICONBUCKET
#include <llmr/renderer/bucket.hpp>
#include <llmr/style/bucket_description.hpp>
#include <llmr/geometry/elements_buffer.hpp>
#include <llmr/geometry/icon_buffer.hpp>
#include <llmr/style/style_bucket.hpp>
#include <vector>
#include <memory>

View File

@@ -2,10 +2,11 @@
#define LLMR_RENDERER_LINEBUCKET
#include "bucket.hpp"
#include <llmr/style/bucket_description.hpp>
#include <llmr/geometry/vao.hpp>
#include <llmr/geometry/elements_buffer.hpp>
#include <llmr/geometry/line_buffer.hpp>
#include <llmr/style/style_bucket.hpp>
#include <memory>
#include <vector>

View File

@@ -2,7 +2,6 @@
#define LLMR_RENDERER_RASTERBUCKET
#include <llmr/renderer/bucket.hpp>
#include <llmr/style/bucket_description.hpp>
#include <llmr/util/raster.hpp>
namespace llmr {

View File

@@ -2,12 +2,13 @@
#define LLMR_RENDERER_TEXTBUCKET
#include "bucket.hpp"
#include <llmr/style/bucket_description.hpp>
#include <llmr/geometry/vao.hpp>
#include <llmr/geometry/elements_buffer.hpp>
#include <llmr/map/vector_tile.hpp>
#include <llmr/text/types.hpp>
#include <llmr/text/glyph.hpp>
#include <llmr/style/style_bucket.hpp>
#include <memory>
#include <map>
#include <vector>

View File

@@ -1,19 +0,0 @@
#ifndef LLMR_STYLE_BUCKET_DESCRIPTION
#define LLMR_STYLE_BUCKET_DESCRIPTION
#include <string>
#include <vector>
#include <cmath>
#include <llmr/util/vec.hpp>
#include <llmr/map/filter_expression.hpp>
#include <llmr/style/value.hpp>
#include <llmr/style/style_bucket.hpp>
namespace llmr {
std::ostream& operator<<(std::ostream&, BucketType type);
}
#endif

View File

@@ -1,39 +0,0 @@
#ifndef LLMR_STYLE_CLASS_DESCRIPTION
#define LLMR_STYLE_CLASS_DESCRIPTION
#include <string>
#include <unordered_map>
#include "properties.hpp"
namespace llmr {
class ClassDescription {
public:
inline const ClassProperties &operator[](const std::string &name) const {
auto it = styles.find(name);
if (it != styles.end()) {
return it->second;
} else {
return defaultProperties;
}
}
void addClass(const std::string &name, ClassProperties &&properties);
inline std::unordered_map<std::string, ClassProperties>::const_iterator begin() const {
return styles.begin();
}
inline std::unordered_map<std::string, ClassProperties>::const_iterator end() const {
return styles.end();
}
private:
std::unordered_map<std::string, ClassProperties> styles;
static const ClassProperties defaultProperties;
};
}
#endif

View File

@@ -1,22 +0,0 @@
#ifndef LLMR_STYLE_LAYER_DESCRIPTION
#define LLMR_STYLE_LAYER_DESCRIPTION
#include <string>
#include <vector>
namespace llmr {
//
//class LayerDescription {
//public:
// std::string name;
// std::string bucket_name;
// std::vector<LayerDescription> child_layer;
//
// size_t size() const;
//};
//
//std::ostream& operator<<(std::ostream&, const LayerDescription& layer);
}
#endif

View File

@@ -25,22 +25,6 @@ struct ClassPropertyTransition {
uint16_t delay = 0;
};
enum class TransitionablePropertyKey {
Translate = 1,
FillColor = 2,
StrokeColor = 3,
Opacity = 4,
Width = 5,
Offset = 6,
Color = 7,
DashArray = 8,
Radius = 9,
Blur = 10,
Halo = 11,
HaloRadius = 12,
HaloBlur = 13,
};
enum class Property {
Null = 1,
Constant = 2,
@@ -187,38 +171,6 @@ struct PrerenderProperties {
uint16_t size = 256;
uint16_t blur = 0;
};
//
//struct GenericProperties {
// bool enabled = true;
// std::array<float, 2> translate = {{ 0, 0 }};
// TranslateAnchorType translateAnchor = parseTranslateAnchorType();
// float opacity = 1.0;
//
// // These are unresolved properties because the value here is per tile, so it might differ.
// boost::optional<FunctionProperty> prerender;
// boost::optional<FunctionProperty> prerenderBuffer;
// boost::optional<FunctionProperty> prerenderSize;
// boost::optional<FunctionProperty> prerenderBlur;
//
// inline bool getPrerender(int8_t z) const {
// return prerender && prerender.get().evaluate<bool>(z);
// }
//
// // Obtains prerender properties by integer zoom level.
// inline PrerenderProperties getPrerenderProperties(int8_t z) const {
// PrerenderProperties props;
// if (prerenderBuffer) props.buffer = prerenderBuffer.get().evaluate<float>(z);
// if (prerenderSize) props.size = prerenderSize.get().evaluate<uint16_t>(z);
// if (prerenderBlur) props.blur = prerenderBlur.get().evaluate<uint16_t>(z);
// return props;
// }
//
// virtual bool isVisible() const {
// if (!enabled) { return false; }
// if (opacity <= 0) { return false; }
// return true;
// }
//};
struct FillProperties {
FillProperties() {}
@@ -325,18 +277,6 @@ typedef util::variant<
template <typename T>
const T &defaultStyleProperties();
//class StyleSource {
//public:
// typedef std::shared_ptr<StyleSource> Ptr;
//
// enum { Vector, Raster } type = Vector;
// std::string url;
// float tileSize = 512.0f;
//};
class RasterizeProperties {
public:
boost::optional<FunctionProperty> enabled;
@@ -347,17 +287,4 @@ public:
}
namespace std {
template <> struct hash<llmr::TransitionablePropertyKey> {
public:
inline size_t operator()(llmr::TransitionablePropertyKey prop) const {
typedef typename std::underlying_type<llmr::TransitionablePropertyKey>::type type;
return std::hash<type>()(static_cast<type>(prop));
}
};
}
#endif

View File

@@ -3,10 +3,8 @@
#include <cstdint>
#include <llmr/style/style_bucket.hpp>
#include <llmr/util/pbf.hpp>
#include <llmr/style/bucket_description.hpp>
#include <llmr/style/layer_description.hpp>
#include <llmr/style/class_description.hpp>
#include <llmr/geometry/sprite_atlas.hpp>
#include <llmr/util/transition.hpp>
#include <llmr/util/uv.hpp>

View File

@@ -15,6 +15,11 @@ enum class BucketType : uint8_t {
Default = None
};
BucketType parseBucketType(const std::string &type);
const char *stringifyBucketType(BucketType type);
std::ostream& operator<<(std::ostream&, BucketType type);
enum class WindingType : uint8_t {
EvenOdd,
NonZero,
@@ -63,15 +68,6 @@ enum class SourceType : uint8_t {
Default = Vector
};
inline BucketType parseBucketType(const std::string &type) {
if (type == "fill") return BucketType::Fill;
if (type == "line") return BucketType::Line;
if (type == "icon") return BucketType::Icon;
if (type == "text") return BucketType::Text;
if (type == "raster") return BucketType::Raster;
return BucketType::None;
}
inline WindingType parseWindingType(const std::string &type) {
if (type == "even-odd") return WindingType::EvenOdd;
if (type == "non-zero") return WindingType::NonZero;

View File

@@ -1,5 +1,4 @@
#include <llmr/map/vector_tile.hpp>
#include <llmr/style/bucket_description.hpp>
#include <algorithm>
#include <iostream>

View File

@@ -1,15 +0,0 @@
#include <llmr/style/bucket_description.hpp>
#include <iostream>
std::ostream& llmr::operator<<(std::ostream& os, BucketType type) {
switch (type) {
case BucketType::None: os << "None"; return os;
case BucketType::Fill: os << "Fill"; return os;
case BucketType::Line: os << "Line"; return os;
case BucketType::Icon: os << "Icon"; return os;
case BucketType::Text: os << "Text"; return os;
case BucketType::Raster: os << "Raster"; return os;
default: os << "<unknown>"; return os;
}
}

View File

@@ -1,9 +0,0 @@
#include <llmr/style/class_description.hpp>
namespace llmr {
void ClassDescription::addClass(const std::string &name, ClassProperties &&properties) {
styles.emplace(name, std::move(properties));
}
}

View File

@@ -1,22 +0,0 @@
#include <llmr/style/layer_description.hpp>
#include <iostream>
using namespace llmr;
//
//size_t LayerDescription::size() const {
// size_t count = 1;
// for (const LayerDescription &layer : child_layer) {
// count += layer.size();
// }
// return count;
//}
//
//std::ostream& llmr::operator<<(std::ostream& os, const LayerDescription& layer) {
// os << "Structure: " << layer.name << std::endl;
// os << " - bucket_name: " << layer.bucket_name << std::endl;
// for (const LayerDescription& value : layer.child_layer) {
// os << " - child_layer: " << value << std::endl;
// }
// return os;
//}

31
src/style/types.cpp Normal file
View File

@@ -0,0 +1,31 @@
#include <llmr/style/types.hpp>
#include <iostream>
namespace llmr {
BucketType parseBucketType(const std::string &type) {
if (type == "fill") return BucketType::Fill;
if (type == "line") return BucketType::Line;
if (type == "icon") return BucketType::Icon;
if (type == "text") return BucketType::Text;
if (type == "raster") return BucketType::Raster;
return BucketType::None;
}
const char *stringifyBucketType(BucketType type) {
switch (type) {
case BucketType::Fill: return "fill";
case BucketType::Line: return "line";
case BucketType::Icon: return "icon";
case BucketType::Text: return "text";
case BucketType::Raster: return "raster";
default: return "none";
}
}
std::ostream& operator<<(std::ostream& os, BucketType type) {
return os << stringifyBucketType(type);
}
}

View File

@@ -1,7 +1,6 @@
#include <llmr/text/placement.hpp>
#include <llmr/map/vector_tile.hpp>
#include <llmr/geometry/interpolate.hpp>
#include <llmr/style/bucket_description.hpp>
#include <llmr/renderer/text_bucket.hpp>
#include <llmr/util/math.hpp>
#include <llmr/util/constants.hpp>