Add VectorTile renderer

This commit is contained in:
Andreas Hocevar
2015-10-13 14:34:26 +02:00
parent 7d3fc3ccc7
commit 4b942bc4f6
5 changed files with 489 additions and 3 deletions

View File

@@ -1158,6 +1158,8 @@ ol.render.canvas.PolygonReplay = function(tolerance, maxExtent, resolution) {
miterLimit: undefined
};
this.rightHanded_ = false;
};
goog.inherits(ol.render.canvas.PolygonReplay, ol.render.canvas.Replay);
@@ -1290,7 +1292,9 @@ ol.render.canvas.PolygonReplay.prototype.drawPolygonGeometry =
state.miterLimit, state.lineDash]);
}
var ends = polygonGeometry.getEnds();
var flatCoordinates = polygonGeometry.getOrientedFlatCoordinates();
var flatCoordinates = this.rightHanded_ ?
polygonGeometry.getFlatCoordinates() :
polygonGeometry.getOrientedFlatCoordinates();
var stride = polygonGeometry.getStride();
this.drawFlatCoordinatess_(flatCoordinates, 0, ends, stride);
this.endGeometry(polygonGeometry, feature);
@@ -1375,6 +1379,16 @@ ol.render.canvas.PolygonReplay.prototype.getBufferedMaxExtent = function() {
};
/**
* @param {boolean} rightHanded Whether polygons are assumed to follow
* the right-hand rule.
*/
ol.render.canvas.PolygonReplay.prototype.setRightHanded =
function(rightHanded) {
this.rightHanded_ = rightHanded;
};
/**
* @inheritDoc
*/
@@ -1793,10 +1807,13 @@ ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle) {
* @param {ol.Extent} maxExtent Max extent.
* @param {number} resolution Resolution.
* @param {number=} opt_renderBuffer Optional rendering buffer.
* @param {boolean=} opt_rightHandedPolygons Assume that polygons follow the
* right-hand rule.
* @struct
*/
ol.render.canvas.ReplayGroup = function(
tolerance, maxExtent, resolution, opt_renderBuffer) {
tolerance, maxExtent, resolution, opt_renderBuffer,
opt_rightHandedPolygons) {
/**
* @private
@@ -1841,6 +1858,13 @@ ol.render.canvas.ReplayGroup = function(
*/
this.hitDetectionTransform_ = goog.vec.Mat4.createNumber();
/**
* @private
* @type {boolean}
*/
this.rightHandedPolygons_ = goog.isDef(opt_rightHandedPolygons) ?
opt_rightHandedPolygons : false;
};
@@ -1928,6 +1952,10 @@ ol.render.canvas.ReplayGroup.prototype.getReplay =
' constructor missing from ol.render.canvas.BATCH_CONSTRUCTORS_');
replay = new Constructor(this.tolerance_, this.maxExtent_,
this.resolution_);
if (replayType == ol.render.ReplayType.POLYGON) {
goog.asserts.assertInstanceof(replay, ol.render.canvas.PolygonReplay);
replay.setRightHanded(this.rightHandedPolygons_);
}
replays[replayType] = replay;
}
return replay;