Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

combine text and icon render types into symbol render type #505

Merged
merged 34 commits into from
Jul 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e701314
start combining symbol and icon render types
ansis Jun 24, 2014
ac9eb9c
continue combining text and icon render types
ansis Jun 25, 2014
d87e1e7
support icons without text
ansis Jun 25, 2014
5327b70
prepare for drawing text and icons similarly
ansis Jun 25, 2014
f184224
draw icons the way glyphs are drawn
ansis Jun 26, 2014
1c3c7bc
remove text-slant experiment
ansis Jun 26, 2014
412497e
start cleaning up placement
ansis Jun 26, 2014
d0b211d
work more directly with Collision
ansis Jun 26, 2014
c70bff9
glyphs -> symbols
ansis Jun 26, 2014
eb51654
silence "not enough vertices" warnings
ansis Jun 26, 2014
6af662c
fix angled icons
ansis Jun 26, 2014
9d28c90
tweak debug style
ansis Jun 27, 2014
469d98a
Merge branch 'master' into symbol-render-type
ansis Jun 27, 2014
1bb95a8
properly handle retina sprites
ansis Jun 27, 2014
2fb881b
fix text and icon padding
ansis Jun 27, 2014
20962ba
finish renames for switch to symol bucket
ansis Jun 27, 2014
cdd2f44
use symbol-rotation-alignment and symbol-placement
ansis Jun 27, 2014
9992155
add render property for keeping text upgright
ansis Jun 27, 2014
9b81460
fix padding for label edge hack
ansis Jun 29, 2014
80788ee
fix reading horizontal vs rotating placement type
ansis Jun 29, 2014
69ba652
shaping should be falsy, not the previous value
ansis Jun 29, 2014
17a9194
add support for icon-max-size and icon-size
ansis Jun 30, 2014
f56d04e
support for sdf icons
ansis Jun 30, 2014
d493b5c
fix tests
ansis Jun 30, 2014
b1f8973
implement icon-translate and text-translate
ansis Jul 1, 2014
549eb1c
remove icon-sdf and rename upright to keep-upright
ansis Jul 2, 2014
b5d1a6e
separate some symbol properties into separate ones for text and icons
ansis Jul 2, 2014
83f81bd
fix setting for allowing icon before text, etc
ansis Jul 2, 2014
97c8766
fix check whether symbol bucket has icons/text
ansis Jul 2, 2014
8c8cfcc
switch symbol-required to *-allow-without-*
ansis Jul 2, 2014
1fae0e8
switch to -optional from -allow-without-
ansis Jul 7, 2014
e2f9862
Merge remote-tracking branch 'origin/master' into symbol-render-type
ansis Jul 7, 2014
c4c4de3
fix test
ansis Jul 7, 2014
a0862a4
use v4 style reference from master
ansis Jul 7, 2014
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
30 changes: 20 additions & 10 deletions debug/style-v3.json
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@
"source-layer": "poi_label",
"filter": { "maki": "park" },
"render": {
"type": "icon"
"type": "symbol"
},
"style": {}
}, {
Expand All @@ -539,7 +539,7 @@
"source-layer": "country_label",
"filter": { "$type": "Point" },
"render": {
"type": "text",
"type": "symbol",
"text-field": "{{name}}",
"text-font": "Open Sans Regular, Arial Unicode MS Regular",
"text-max-size": 16,
Expand All @@ -557,7 +557,7 @@
"source-layer": "place_label",
"filter": { "$type": "Point" },
"render": {
"type": "text",
"type": "symbol",
"text-field": "{{name}}",
"text-font": "Open Sans Semibold, Arial Unicode MS Regular",
"text-max-size": 18,
Expand All @@ -575,7 +575,8 @@
"source-layer": "road_label",
"filter": { "$type": "LineString" },
"render": {
"type": "text",
"type": "symbol",
"symbol-placement": "line",
"text-field": "{{name}}",
"text-font": "Open Sans Regular, Arial Unicode MS Regular",
"text-max-size": 12,
Expand All @@ -601,11 +602,21 @@
"source": "mapbox.mapbox-streets-v5",
"source-layer": "poi_label",
"render": {
"type": "icon",
"type": "symbol",
"icon-size": 12,
"icon-image": "{{maki}}-12"
"icon-image": "{{maki}}-12",
"text-font": "Open Sans Regular, Arial Unicode MS Regular",
"text-max-size": 10,
"text-translate": [0, 1.2],
"text-path": "horizontal",
"text-max-width": 7,
"text-optional": true,
"text-field": "{{name}}"
},
"style": {
"text-size": 10,
"text-color": "#333",
"text-halo-color": "#eee",
"icon-rotate-anchor": "viewport"
}
}, {
Expand All @@ -614,12 +625,11 @@
"source-layer": "road",
"filter": { "oneway": 1, "$type": "LineString" },
"render": {
"type": "icon",
"type": "symbol",
"symbol-placement": "line",
"icon-image": "bicycle-12",
"icon-spacing": 200
},
"style": {
"icon-rotate-anchor": "map"
}
"style": {}
}]
}
26 changes: 16 additions & 10 deletions js/geometry/createbucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@ module.exports = createBucket;

var LineBucket = require('./linebucket.js');
var FillBucket = require('./fillbucket.js');
var PointBucket = require('./pointbucket.js');
var TextBucket = require('./textbucket.js');
var SymbolBucket = require('./symbolbucket.js');
var RenderProperties = require('../style/renderproperties.js');

function createBucket(info, collision, indices, buffers) {

if (!RenderProperties[info.type]) {
//console.warn('unknown bucket type');
return;
}

info = new RenderProperties[info.type](info);

function createBucket(info, placement, indices, buffers) {
if (info.type === 'line') {
return new LineBucket(info, buffers, placement, indices);
return new LineBucket(info, buffers, collision, indices);
} else if (info.type === 'fill') {
return new FillBucket(info, buffers, placement, indices);
} else if (info.type === 'icon') {
return new PointBucket(info, buffers, placement, indices);
} else if (info.type === 'text') {
return new TextBucket(info, buffers, placement, indices);
return new FillBucket(info, buffers, collision, indices);
} else if (info.type === 'symbol') {
return new SymbolBucket(info, buffers, collision, indices);
} else {
console.warn('unknown bucket type');
//console.warn('unknown bucket type');
}
}
2 changes: 1 addition & 1 deletion js/geometry/fillbucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ FillBucket.prototype.addFeature = function(lines) {

FillBucket.prototype.addFill = function(vertices) {
if (vertices.length < 3) {
// console.warn('a fill must have at least three vertices');
//console.warn('a fill must have at least three vertices');
return;
}

Expand Down
17 changes: 9 additions & 8 deletions js/geometry/glyphvertexbuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ GlyphVertexBuffer.prototype.add = function(x, y, ox, oy, tx, ty, angle, minzoom,
this.shorts[pos2 + 2] = Math.round(ox * 64); // use 1/64 pixels for placement
this.shorts[pos2 + 3] = Math.round(oy * 64);

this.ubytes[pos + 8] = Math.floor(tx / 4);
this.ubytes[pos + 9] = Math.floor(ty / 4);
this.ubytes[pos + 10] = Math.floor((labelminzoom || 0) * 10);
this.ubytes[pos + 11] = Math.floor((minzoom || 0) * 10); // 1/10 zoom levels: z16 == 160.
this.ubytes[pos + 12] = Math.floor(Math.min(maxzoom || 25, 25) * 10); // 1/10 zoom levels: z16 == 160.
this.ubytes[pos + 13] = Math.round(angle * angleFactor) % 256;
this.ubytes[pos + 14] = Math.max(Math.round(range[0] * angleFactor), 0) % 256;
this.ubytes[pos + 15] = Math.min(Math.round(range[1] * angleFactor), 255) % 256;
this.ubytes[pos + 8] = Math.floor((labelminzoom || 0) * 10);
this.ubytes[pos + 9] = Math.floor((minzoom || 0) * 10); // 1/10 zoom levels: z16 == 160.
this.ubytes[pos + 10] = Math.floor(Math.min(maxzoom || 25, 25) * 10); // 1/10 zoom levels: z16 == 160.
this.ubytes[pos + 11] = Math.round(angle * angleFactor) % 256;
this.ubytes[pos + 12] = Math.max(Math.round(range[0] * angleFactor), 0) % 256;
this.ubytes[pos + 13] = Math.min(Math.round(range[1] * angleFactor), 255) % 256;

this.ubytes[pos + 14] = Math.floor(tx / 4);
this.ubytes[pos + 15] = Math.floor(ty / 4);

this.pos += this.itemSize;
};
42 changes: 42 additions & 0 deletions js/geometry/iconvertexbuffer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';

var Buffer = require('./buffer.js');

module.exports = GlyphVertexBuffer;

function GlyphVertexBuffer(buffer) {
Buffer.call(this, buffer);
}

GlyphVertexBuffer.prototype = Object.create(Buffer.prototype);

GlyphVertexBuffer.prototype.defaultLength = 2048 * 20;
GlyphVertexBuffer.prototype.itemSize = 20;

// Converts the 0..2pi to an int16 range
GlyphVertexBuffer.angleFactor = 128 / Math.PI;

GlyphVertexBuffer.prototype.add = function(x, y, ox, oy, tx, ty, angle, minzoom, range, maxzoom, labelminzoom) {
var pos = this.pos,
pos2 = pos / 2,
angleFactor = GlyphVertexBuffer.angleFactor;

this.resize();

this.shorts[pos2 + 0] = x;
this.shorts[pos2 + 1] = y;
this.shorts[pos2 + 2] = Math.round(ox * 64); // use 1/64 pixels for placement
this.shorts[pos2 + 3] = Math.round(oy * 64);

this.ubytes[pos + 8] = Math.floor((labelminzoom || 0) * 10);
this.ubytes[pos + 9] = Math.floor((minzoom || 0) * 10); // 1/10 zoom levels: z16 == 160.
this.ubytes[pos + 10] = Math.floor(Math.min(maxzoom || 25, 25) * 10); // 1/10 zoom levels: z16 == 160.
this.ubytes[pos + 11] = Math.round(angle * angleFactor) % 256;
this.ubytes[pos + 12] = Math.max(Math.round(range[0] * angleFactor), 0) % 256;
this.ubytes[pos + 13] = Math.min(Math.round(range[1] * angleFactor), 255) % 256;

this.shorts[pos2 + 8] = tx;
this.shorts[pos2 + 9] = ty;

this.pos += this.itemSize;
};
2 changes: 1 addition & 1 deletion js/geometry/linebucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ LineBucket.prototype.addFeature = function(lines) {

LineBucket.prototype.addLine = function(vertices, join, cap, miterLimit, roundLimit) {
if (vertices.length < 2) {
// console.warn('a line must have at least two vertices');
//console.warn('a line must have at least two vertices');
return;
}

Expand Down
110 changes: 0 additions & 110 deletions js/geometry/pointbucket.js

This file was deleted.

38 changes: 0 additions & 38 deletions js/geometry/pointvertexbuffer.js

This file was deleted.

Loading