incorporate the color and draw circle dots if we don't have an icon
Conflicts: bin/style.js
This commit is contained in:
@@ -373,7 +373,8 @@ module.exports = {
|
||||
"layer": "place_label",
|
||||
"field": "type",
|
||||
"value": "city",
|
||||
"type": "point"
|
||||
"type": "point",
|
||||
"size": 4
|
||||
},
|
||||
"place_label_city": {
|
||||
"source": "mapbox streets",
|
||||
@@ -1878,7 +1879,6 @@ module.exports = {
|
||||
],
|
||||
},
|
||||
"poi": {
|
||||
"color": "maki",
|
||||
},
|
||||
"satellite": {
|
||||
"type": "raster",
|
||||
|
||||
@@ -65,7 +65,7 @@ struct IconClass {
|
||||
std::array<FunctionProperty, 2> translate = {{ 0, 0 }};
|
||||
TranslateAnchor translateAnchor = TranslateAnchor::Map;
|
||||
FunctionProperty size;
|
||||
Color color = {{ 0, 0, 0, 1 }};
|
||||
Color color = {{ 1, 1, 1, 1 }};
|
||||
FunctionProperty opacity = 1;
|
||||
std::string image;
|
||||
FunctionProperty radius = 0;
|
||||
@@ -77,7 +77,7 @@ struct IconProperties {
|
||||
std::array<float, 2> translate = {{ 0, 0 }};
|
||||
TranslateAnchor translateAnchor = TranslateAnchor::Map;
|
||||
float size = 0;
|
||||
Color color = {{ 0, 0, 0, 1 }};
|
||||
Color color = {{ 1, 1, 1, 1 }};
|
||||
float opacity = 1.0;
|
||||
std::string image;
|
||||
float radius = 0;
|
||||
|
||||
@@ -19,6 +19,10 @@ public:
|
||||
explicit SpritePosition() {}
|
||||
explicit SpritePosition(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t pixelRatio = 1);
|
||||
|
||||
operator bool() const {
|
||||
return !(width == 0 && height == 0 && x == 0 && y == 0);
|
||||
}
|
||||
|
||||
uint16_t x = 0, y = 0;
|
||||
uint16_t width = 0, height = 0;
|
||||
uint8_t pixelRatio = 1;
|
||||
|
||||
@@ -161,8 +161,6 @@ Rect<SpriteAtlas::dimension> SpriteAtlas::getImage(const std::string &name, cons
|
||||
|
||||
copy(rect, pos, sprite);
|
||||
|
||||
dirty = true;
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
@@ -192,6 +190,8 @@ void SpriteAtlas::copy(const Rect<dimension> &dst, const SpritePosition &src, co
|
||||
/* icon dimension */ src.width,
|
||||
/* icon dimension */ src.height
|
||||
);
|
||||
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -202,6 +202,10 @@ void SpriteAtlas::update(const Sprite &sprite) {
|
||||
std::erase_if(uninitialized, [&sprite, &atlas](const std::string &name) {
|
||||
Rect<dimension> dst = atlas.getImage(name, sprite);
|
||||
const SpritePosition &src = sprite.getSpritePosition(name);
|
||||
if (!src) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (src.width == dst.w * atlas.pixelRatio && src.height == dst.h * atlas.pixelRatio && src.pixelRatio == atlas.pixelRatio) {
|
||||
atlas.copy(dst, src, sprite);
|
||||
return true;
|
||||
|
||||
@@ -24,13 +24,19 @@ IconBucket::IconBucket(IconVertexBuffer& vertexBuffer,
|
||||
}
|
||||
|
||||
void IconBucket::addFeature(const VectorTileFeature &feature, SpriteAtlas &sprite_atlas) {
|
||||
auto field_it = feature.properties.find(geometry.field);
|
||||
if (field_it == feature.properties.end()) {
|
||||
// fprintf(stderr, "feature doesn't contain field '%s'\n", geometry.field.c_str());
|
||||
return;
|
||||
}
|
||||
std::string field;
|
||||
|
||||
std::string field = toString(field_it->second);
|
||||
if (geometry.field.size()) {
|
||||
auto field_it = feature.properties.find(geometry.field);
|
||||
if (field_it == feature.properties.end()) {
|
||||
fprintf(stderr, "feature doesn't contain field '%s'\n", geometry.field.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
field = toString(field_it->second);
|
||||
} else {
|
||||
field = "<circle>";
|
||||
}
|
||||
|
||||
const Rect<uint16_t> rect = sprite_atlas.getIcon(geometry.size, field);
|
||||
const uint16_t tx = rect.x + rect.w / 2;
|
||||
|
||||
@@ -7,5 +7,5 @@ varying vec2 v_tex;
|
||||
|
||||
void main() {
|
||||
vec2 pos = (v_tex + (gl_PointCoord - 0.5) * u_size) / u_dimension;
|
||||
gl_FragColor = texture2D(u_image, pos);
|
||||
gl_FragColor = u_color * texture2D(u_image, pos);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ const shader_source llmr::shaders[SHADER_COUNT] = {
|
||||
},
|
||||
{
|
||||
"#version 120\nattribute vec2 a_pos;\nattribute vec2 a_tex;\nuniform mat4 u_matrix;\nuniform float u_size;\nuniform float u_ratio;\nvarying vec2 v_tex;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n gl_PointSize = u_size;\n v_tex = (a_tex * u_ratio);\n}\n\n",
|
||||
"#version 120\nuniform sampler2D u_image;\nuniform vec2 u_dimension;\nuniform float u_size;\nvarying vec2 v_tex;\nvoid main ()\n{\n gl_FragColor = texture2D (u_image, ((v_tex + (\n (gl_PointCoord - 0.5)\n * u_size)) / u_dimension));\n}\n\n",
|
||||
"#version 120\nuniform sampler2D u_image;\nuniform vec2 u_dimension;\nuniform vec4 u_color;\nuniform float u_size;\nvarying vec2 v_tex;\nvoid main ()\n{\n gl_FragColor = (u_color * texture2D (u_image, ((v_tex + \n ((gl_PointCoord - 0.5) * u_size)\n ) / u_dimension)));\n}\n\n",
|
||||
},
|
||||
{
|
||||
"#version 120\nattribute vec2 a_pos;\nattribute vec2 a_extrude;\nattribute float a_linesofar;\nuniform mat4 u_matrix;\nuniform mat4 u_exmatrix;\nuniform float u_ratio;\nuniform vec2 u_linewidth;\nvarying vec2 v_normal;\nvarying float v_linesofar;\nvoid main ()\n{\n vec2 normal_1;\n vec2 tmpvar_2;\n tmpvar_2 = (vec2(mod (a_pos, 2.0)));\n normal_1.x = tmpvar_2.x;\n normal_1.y = sign((tmpvar_2.y - 0.5));\n v_normal = normal_1;\n vec4 tmpvar_3;\n tmpvar_3.zw = vec2(0.0, 0.0);\n tmpvar_3.xy = ((u_linewidth.x * a_extrude) * 0.015873);\n vec4 tmpvar_4;\n tmpvar_4.zw = vec2(0.0, 1.0);\n tmpvar_4.xy = floor((a_pos * 0.5));\n gl_Position = ((u_matrix * tmpvar_4) + (u_exmatrix * tmpvar_3));\n v_linesofar = (a_linesofar * u_ratio);\n}\n\n",
|
||||
|
||||
@@ -12,7 +12,7 @@ const shader_source llmr::shaders[SHADER_COUNT] = {
|
||||
},
|
||||
{
|
||||
"precision highp float;\nattribute vec2 a_pos;\nattribute vec2 a_tex;\nuniform mat4 u_matrix;\nuniform float u_size;\nuniform float u_ratio;\nvarying vec2 v_tex;\nvoid main ()\n{\n vec4 tmpvar_1;\n tmpvar_1.zw = vec2(0.0, 1.0);\n tmpvar_1.xy = a_pos;\n gl_Position = (u_matrix * tmpvar_1);\n gl_PointSize = u_size;\n v_tex = (a_tex * u_ratio);\n}\n\n",
|
||||
"precision highp float;\nuniform sampler2D u_image;\nuniform vec2 u_dimension;\nuniform float u_size;\nvarying vec2 v_tex;\nvoid main ()\n{\n mediump vec2 tmpvar_1;\n tmpvar_1 = ((v_tex + (\n (gl_PointCoord - 0.5)\n * u_size)) / u_dimension);\n lowp vec4 tmpvar_2;\n tmpvar_2 = texture2D (u_image, tmpvar_1);\n gl_FragColor = tmpvar_2;\n}\n\n",
|
||||
"precision highp float;\nuniform sampler2D u_image;\nuniform vec2 u_dimension;\nuniform vec4 u_color;\nuniform float u_size;\nvarying vec2 v_tex;\nvoid main ()\n{\n mediump vec2 tmpvar_1;\n tmpvar_1 = ((v_tex + (\n (gl_PointCoord - 0.5)\n * u_size)) / u_dimension);\n lowp vec4 tmpvar_2;\n tmpvar_2 = (u_color * texture2D (u_image, tmpvar_1));\n gl_FragColor = tmpvar_2;\n}\n\n",
|
||||
},
|
||||
{
|
||||
"precision highp float;\nattribute vec2 a_pos;\nattribute vec2 a_extrude;\nattribute float a_linesofar;\nuniform mat4 u_matrix;\nuniform mat4 u_exmatrix;\nuniform float u_ratio;\nuniform vec2 u_linewidth;\nvarying vec2 v_normal;\nvarying float v_linesofar;\nvoid main ()\n{\n vec2 normal_1;\n vec2 tmpvar_2;\n tmpvar_2 = (vec2(mod (a_pos, 2.0)));\n normal_1.x = tmpvar_2.x;\n normal_1.y = sign((tmpvar_2.y - 0.5));\n v_normal = normal_1;\n vec4 tmpvar_3;\n tmpvar_3.zw = vec2(0.0, 0.0);\n tmpvar_3.xy = ((u_linewidth.x * a_extrude) * 0.015873);\n vec4 tmpvar_4;\n tmpvar_4.zw = vec2(0.0, 1.0);\n tmpvar_4.xy = floor((a_pos * 0.5));\n gl_Position = ((u_matrix * tmpvar_4) + (u_exmatrix * tmpvar_3));\n v_linesofar = (a_linesofar * u_ratio);\n}\n\n",
|
||||
|
||||
Reference in New Issue
Block a user