remove support for embedded shaping and glyphs

This commit is contained in:
Ansis Brammanis 2014-06-27 11:51:44 -07:00
parent 6b0f713f83
commit 7ff02ce76a
2 changed files with 1 additions and 65 deletions

View File

@ -62,8 +62,6 @@ An object that contains the data for a single vector tile layer.
- **name** (`String) `— layer name
- **extent** (`Number`, default: `4096`) — tile extent size
- **length** (`Number`) — number of features in the layer
- **shaping** (`Object`) — an object with font shaping information
- **faces** (`String[]`) — an array of font faces used
#### Methods

View File

@ -9,8 +9,6 @@ function VectorTileLayer(buffer, end) {
this.name = null;
this.extent = 4096;
this.length = 0;
this.shaping = {};
this.faces = [];
// Private
this._buffer = buffer;
@ -18,9 +16,7 @@ function VectorTileLayer(buffer, end) {
this._values = [];
this._features = [];
var stack_index = [],
labels = [],
val, tag;
var val, tag;
end = end || buffer.length;
@ -43,26 +39,10 @@ function VectorTileLayer(buffer, end) {
this._keys.push(buffer.readString());
} else if (tag === 4) {
this._values.push(this.readFeatureValue());
} else if (tag === 7) {
this.faces.push(buffer.readString());
} else if (tag === 8) {
labels.push(this.readLabel());
} else if (tag === 9) {
stack_index.push(buffer.readString());
} else {
buffer.skip(val);
}
}
// Build index of [stack][text] => shaping information
for (var i = 0; i < labels.length; i++) {
var label = labels[i],
text = this._values[label.text],
stack = stack_index[label.stack];
this.shaping[stack] = this.shaping[stack] || {};
this.shaping[stack][text] = label.glyphs;
}
}
VectorTileLayer.prototype.readFeatureValue = function() {
@ -98,48 +78,6 @@ VectorTileLayer.prototype.readFeatureValue = function() {
return value;
};
VectorTileLayer.prototype.readLabel = function() {
var label = { glyphs: [] },
buffer = this._buffer,
bytes = buffer.readVarint(),
end = buffer.pos + bytes,
val, tag, faces, glyphs, x, y;
while (buffer.pos < end) {
val = buffer.readVarint();
tag = val >> 3;
if (tag === 1) {
label.text = buffer.readVarint();
} else if (tag === 2) {
label.stack = buffer.readVarint();
} else if (tag === 3) {
faces = buffer.readPacked('Varint');
} else if (tag === 4) {
glyphs = buffer.readPacked('Varint');
} else if (tag === 5) {
x = buffer.readPacked('Varint');
} else if (tag === 6) {
y = buffer.readPacked('Varint');
} else {
buffer.skip(val);
}
}
if (glyphs) {
for (var i = 0; i < glyphs.length; i++) {
label.glyphs.push({
face: faces[i],
glyph: glyphs[i],
x: x[i],
y: y[i]
});
}
}
return label;
};
// return feature `i` from this layer as a `VectorTileFeature`
VectorTileLayer.prototype.feature = function(i) {
if (i < 0 || i >= this._features.length) throw new Error('feature index out of bounds');