Transformed
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
/**
|
||||
* @module ol/render/Box
|
||||
*/
|
||||
// FIXME add rotation
|
||||
|
||||
goog.provide('ol.render.Box');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.Disposable');
|
||||
goog.require('ol.geom.Polygon');
|
||||
|
||||
import _ol_ from '../index.js';
|
||||
import _ol_Disposable_ from '../Disposable.js';
|
||||
import _ol_geom_Polygon_ from '../geom/Polygon.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.Disposable}
|
||||
* @param {string} className CSS class name.
|
||||
*/
|
||||
ol.render.Box = function(className) {
|
||||
var _ol_render_Box_ = function(className) {
|
||||
|
||||
/**
|
||||
* @type {ol.geom.Polygon}
|
||||
@@ -47,13 +47,14 @@ ol.render.Box = function(className) {
|
||||
this.endPixel_ = null;
|
||||
|
||||
};
|
||||
ol.inherits(ol.render.Box, ol.Disposable);
|
||||
|
||||
_ol_.inherits(_ol_render_Box_, _ol_Disposable_);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.Box.prototype.disposeInternal = function() {
|
||||
_ol_render_Box_.prototype.disposeInternal = function() {
|
||||
this.setMap(null);
|
||||
};
|
||||
|
||||
@@ -61,7 +62,7 @@ ol.render.Box.prototype.disposeInternal = function() {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
ol.render.Box.prototype.render_ = function() {
|
||||
_ol_render_Box_.prototype.render_ = function() {
|
||||
var startPixel = this.startPixel_;
|
||||
var endPixel = this.endPixel_;
|
||||
var px = 'px';
|
||||
@@ -76,7 +77,7 @@ ol.render.Box.prototype.render_ = function() {
|
||||
/**
|
||||
* @param {ol.PluggableMap} map Map.
|
||||
*/
|
||||
ol.render.Box.prototype.setMap = function(map) {
|
||||
_ol_render_Box_.prototype.setMap = function(map) {
|
||||
if (this.map_) {
|
||||
this.map_.getOverlayContainer().removeChild(this.element_);
|
||||
var style = this.element_.style;
|
||||
@@ -93,7 +94,7 @@ ol.render.Box.prototype.setMap = function(map) {
|
||||
* @param {ol.Pixel} startPixel Start pixel.
|
||||
* @param {ol.Pixel} endPixel End pixel.
|
||||
*/
|
||||
ol.render.Box.prototype.setPixels = function(startPixel, endPixel) {
|
||||
_ol_render_Box_.prototype.setPixels = function(startPixel, endPixel) {
|
||||
this.startPixel_ = startPixel;
|
||||
this.endPixel_ = endPixel;
|
||||
this.createOrUpdateGeometry();
|
||||
@@ -104,7 +105,7 @@ ol.render.Box.prototype.setPixels = function(startPixel, endPixel) {
|
||||
/**
|
||||
* Creates or updates the cached geometry.
|
||||
*/
|
||||
ol.render.Box.prototype.createOrUpdateGeometry = function() {
|
||||
_ol_render_Box_.prototype.createOrUpdateGeometry = function() {
|
||||
var startPixel = this.startPixel_;
|
||||
var endPixel = this.endPixel_;
|
||||
var pixels = [
|
||||
@@ -117,7 +118,7 @@ ol.render.Box.prototype.createOrUpdateGeometry = function() {
|
||||
// close the polygon
|
||||
coordinates[4] = coordinates[0].slice();
|
||||
if (!this.geometry_) {
|
||||
this.geometry_ = new ol.geom.Polygon([coordinates]);
|
||||
this.geometry_ = new _ol_geom_Polygon_([coordinates]);
|
||||
} else {
|
||||
this.geometry_.setCoordinates([coordinates]);
|
||||
}
|
||||
@@ -127,6 +128,7 @@ ol.render.Box.prototype.createOrUpdateGeometry = function() {
|
||||
/**
|
||||
* @return {ol.geom.Polygon} Geometry.
|
||||
*/
|
||||
ol.render.Box.prototype.getGeometry = function() {
|
||||
_ol_render_Box_.prototype.getGeometry = function() {
|
||||
return this.geometry_;
|
||||
};
|
||||
export default _ol_render_Box_;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
goog.provide('ol.render.Event');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.events.Event');
|
||||
|
||||
/**
|
||||
* @module ol/render/Event
|
||||
*/
|
||||
import _ol_ from '../index.js';
|
||||
import _ol_events_Event_ from '../events/Event.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -14,11 +14,11 @@ goog.require('ol.events.Event');
|
||||
* @param {?CanvasRenderingContext2D=} opt_context Context.
|
||||
* @param {?ol.webgl.Context=} opt_glContext WebGL Context.
|
||||
*/
|
||||
ol.render.Event = function(
|
||||
var _ol_render_Event_ = function(
|
||||
type, opt_vectorContext, opt_frameState, opt_context,
|
||||
opt_glContext) {
|
||||
|
||||
ol.events.Event.call(this, type);
|
||||
_ol_events_Event_.call(this, type);
|
||||
|
||||
/**
|
||||
* For canvas, this is an instance of {@link ol.render.canvas.Immediate}.
|
||||
@@ -51,4 +51,6 @@ ol.render.Event = function(
|
||||
this.glContext = opt_glContext;
|
||||
|
||||
};
|
||||
ol.inherits(ol.render.Event, ol.events.Event);
|
||||
|
||||
_ol_.inherits(_ol_render_Event_, _ol_events_Event_);
|
||||
export default _ol_render_Event_;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
goog.provide('ol.render.EventType');
|
||||
|
||||
/**
|
||||
* @module ol/render/EventType
|
||||
*/
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.render.EventType = {
|
||||
var _ol_render_EventType_ = {
|
||||
/**
|
||||
* @event ol.render.Event#postcompose
|
||||
* @api
|
||||
@@ -20,3 +21,5 @@ ol.render.EventType = {
|
||||
*/
|
||||
RENDER: 'render'
|
||||
};
|
||||
|
||||
export default _ol_render_EventType_;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
goog.provide('ol.render.Feature');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
goog.require('ol.geom.flat.center');
|
||||
goog.require('ol.geom.flat.interiorpoint');
|
||||
goog.require('ol.geom.flat.interpolate');
|
||||
goog.require('ol.geom.flat.transform');
|
||||
goog.require('ol.transform');
|
||||
|
||||
/**
|
||||
* @module ol/render/Feature
|
||||
*/
|
||||
import _ol_ from '../index.js';
|
||||
import _ol_array_ from '../array.js';
|
||||
import _ol_extent_ from '../extent.js';
|
||||
import _ol_geom_GeometryType_ from '../geom/GeometryType.js';
|
||||
import _ol_geom_flat_center_ from '../geom/flat/center.js';
|
||||
import _ol_geom_flat_interiorpoint_ from '../geom/flat/interiorpoint.js';
|
||||
import _ol_geom_flat_interpolate_ from '../geom/flat/interpolate.js';
|
||||
import _ol_geom_flat_transform_ from '../geom/flat/transform.js';
|
||||
import _ol_transform_ from '../transform.js';
|
||||
|
||||
/**
|
||||
* Lightweight, read-only, {@link ol.Feature} and {@link ol.geom.Geometry} like
|
||||
@@ -24,7 +24,7 @@ goog.require('ol.transform');
|
||||
* @param {Object.<string, *>} properties Properties.
|
||||
* @param {number|string|undefined} id Feature id.
|
||||
*/
|
||||
ol.render.Feature = function(type, flatCoordinates, ends, properties, id) {
|
||||
var _ol_render_Feature_ = function(type, flatCoordinates, ends, properties, id) {
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.Extent|undefined}
|
||||
@@ -78,7 +78,7 @@ ol.render.Feature = function(type, flatCoordinates, ends, properties, id) {
|
||||
* @private
|
||||
* @type {ol.Transform}
|
||||
*/
|
||||
this.tmpTransform_ = ol.transform.create();
|
||||
this.tmpTransform_ = _ol_transform_.create();
|
||||
};
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ ol.render.Feature = function(type, flatCoordinates, ends, properties, id) {
|
||||
* @return {*} Value for the requested key.
|
||||
* @api
|
||||
*/
|
||||
ol.render.Feature.prototype.get = function(key) {
|
||||
_ol_render_Feature_.prototype.get = function(key) {
|
||||
return this.properties_[key];
|
||||
};
|
||||
|
||||
@@ -96,8 +96,8 @@ ol.render.Feature.prototype.get = function(key) {
|
||||
/**
|
||||
* @return {Array.<number>|Array.<Array.<number>>} Ends or endss.
|
||||
*/
|
||||
ol.render.Feature.prototype.getEnds =
|
||||
ol.render.Feature.prototype.getEndss = function() {
|
||||
_ol_render_Feature_.prototype.getEnds =
|
||||
_ol_render_Feature_.prototype.getEndss = function() {
|
||||
return this.ends_;
|
||||
};
|
||||
|
||||
@@ -107,11 +107,11 @@ ol.render.Feature.prototype.getEndss = function() {
|
||||
* @return {ol.Extent} Extent.
|
||||
* @api
|
||||
*/
|
||||
ol.render.Feature.prototype.getExtent = function() {
|
||||
_ol_render_Feature_.prototype.getExtent = function() {
|
||||
if (!this.extent_) {
|
||||
this.extent_ = this.type_ === ol.geom.GeometryType.POINT ?
|
||||
ol.extent.createOrUpdateFromCoordinate(this.flatCoordinates_) :
|
||||
ol.extent.createOrUpdateFromFlatCoordinates(
|
||||
this.extent_ = this.type_ === _ol_geom_GeometryType_.POINT ?
|
||||
_ol_extent_.createOrUpdateFromCoordinate(this.flatCoordinates_) :
|
||||
_ol_extent_.createOrUpdateFromFlatCoordinates(
|
||||
this.flatCoordinates_, 0, this.flatCoordinates_.length, 2);
|
||||
|
||||
}
|
||||
@@ -122,10 +122,10 @@ ol.render.Feature.prototype.getExtent = function() {
|
||||
/**
|
||||
* @return {Array.<number>} Flat interior points.
|
||||
*/
|
||||
ol.render.Feature.prototype.getFlatInteriorPoint = function() {
|
||||
_ol_render_Feature_.prototype.getFlatInteriorPoint = function() {
|
||||
if (!this.flatInteriorPoints_) {
|
||||
var flatCenter = ol.extent.getCenter(this.getExtent());
|
||||
this.flatInteriorPoints_ = ol.geom.flat.interiorpoint.linearRings(
|
||||
var flatCenter = _ol_extent_.getCenter(this.getExtent());
|
||||
this.flatInteriorPoints_ = _ol_geom_flat_interiorpoint_.linearRings(
|
||||
this.flatCoordinates_, 0, this.ends_, 2, flatCenter, 0);
|
||||
}
|
||||
return this.flatInteriorPoints_;
|
||||
@@ -135,11 +135,11 @@ ol.render.Feature.prototype.getFlatInteriorPoint = function() {
|
||||
/**
|
||||
* @return {Array.<number>} Flat interior points.
|
||||
*/
|
||||
ol.render.Feature.prototype.getFlatInteriorPoints = function() {
|
||||
_ol_render_Feature_.prototype.getFlatInteriorPoints = function() {
|
||||
if (!this.flatInteriorPoints_) {
|
||||
var flatCenters = ol.geom.flat.center.linearRingss(
|
||||
var flatCenters = _ol_geom_flat_center_.linearRingss(
|
||||
this.flatCoordinates_, 0, this.ends_, 2);
|
||||
this.flatInteriorPoints_ = ol.geom.flat.interiorpoint.linearRingss(
|
||||
this.flatInteriorPoints_ = _ol_geom_flat_interiorpoint_.linearRingss(
|
||||
this.flatCoordinates_, 0, this.ends_, 2, flatCenters);
|
||||
}
|
||||
return this.flatInteriorPoints_;
|
||||
@@ -149,9 +149,9 @@ ol.render.Feature.prototype.getFlatInteriorPoints = function() {
|
||||
/**
|
||||
* @return {Array.<number>} Flat midpoint.
|
||||
*/
|
||||
ol.render.Feature.prototype.getFlatMidpoint = function() {
|
||||
_ol_render_Feature_.prototype.getFlatMidpoint = function() {
|
||||
if (!this.flatMidpoints_) {
|
||||
this.flatMidpoints_ = ol.geom.flat.interpolate.lineString(
|
||||
this.flatMidpoints_ = _ol_geom_flat_interpolate_.lineString(
|
||||
this.flatCoordinates_, 0, this.flatCoordinates_.length, 2, 0.5);
|
||||
}
|
||||
return this.flatMidpoints_;
|
||||
@@ -161,7 +161,7 @@ ol.render.Feature.prototype.getFlatMidpoint = function() {
|
||||
/**
|
||||
* @return {Array.<number>} Flat midpoints.
|
||||
*/
|
||||
ol.render.Feature.prototype.getFlatMidpoints = function() {
|
||||
_ol_render_Feature_.prototype.getFlatMidpoints = function() {
|
||||
if (!this.flatMidpoints_) {
|
||||
this.flatMidpoints_ = [];
|
||||
var flatCoordinates = this.flatCoordinates_;
|
||||
@@ -169,9 +169,9 @@ ol.render.Feature.prototype.getFlatMidpoints = function() {
|
||||
var ends = this.ends_;
|
||||
for (var i = 0, ii = ends.length; i < ii; ++i) {
|
||||
var end = ends[i];
|
||||
var midpoint = ol.geom.flat.interpolate.lineString(
|
||||
var midpoint = _ol_geom_flat_interpolate_.lineString(
|
||||
flatCoordinates, offset, end, 2, 0.5);
|
||||
ol.array.extend(this.flatMidpoints_, midpoint);
|
||||
_ol_array_.extend(this.flatMidpoints_, midpoint);
|
||||
offset = end;
|
||||
}
|
||||
}
|
||||
@@ -184,7 +184,7 @@ ol.render.Feature.prototype.getFlatMidpoints = function() {
|
||||
* @return {number|string|undefined} Id.
|
||||
* @api
|
||||
*/
|
||||
ol.render.Feature.prototype.getId = function() {
|
||||
_ol_render_Feature_.prototype.getId = function() {
|
||||
return this.id_;
|
||||
};
|
||||
|
||||
@@ -192,7 +192,7 @@ ol.render.Feature.prototype.getId = function() {
|
||||
/**
|
||||
* @return {Array.<number>} Flat coordinates.
|
||||
*/
|
||||
ol.render.Feature.prototype.getOrientedFlatCoordinates = function() {
|
||||
_ol_render_Feature_.prototype.getOrientedFlatCoordinates = function() {
|
||||
return this.flatCoordinates_;
|
||||
};
|
||||
|
||||
@@ -200,8 +200,8 @@ ol.render.Feature.prototype.getOrientedFlatCoordinates = function() {
|
||||
/**
|
||||
* @return {Array.<number>} Flat coordinates.
|
||||
*/
|
||||
ol.render.Feature.prototype.getFlatCoordinates =
|
||||
ol.render.Feature.prototype.getOrientedFlatCoordinates;
|
||||
_ol_render_Feature_.prototype.getFlatCoordinates =
|
||||
_ol_render_Feature_.prototype.getOrientedFlatCoordinates;
|
||||
|
||||
|
||||
/**
|
||||
@@ -210,7 +210,7 @@ ol.render.Feature.prototype.getFlatCoordinates =
|
||||
* @return {ol.render.Feature} Feature.
|
||||
* @api
|
||||
*/
|
||||
ol.render.Feature.prototype.getGeometry = function() {
|
||||
_ol_render_Feature_.prototype.getGeometry = function() {
|
||||
return this;
|
||||
};
|
||||
|
||||
@@ -220,7 +220,7 @@ ol.render.Feature.prototype.getGeometry = function() {
|
||||
* @return {Object.<string, *>} Feature properties.
|
||||
* @api
|
||||
*/
|
||||
ol.render.Feature.prototype.getProperties = function() {
|
||||
_ol_render_Feature_.prototype.getProperties = function() {
|
||||
return this.properties_;
|
||||
};
|
||||
|
||||
@@ -229,14 +229,14 @@ ol.render.Feature.prototype.getProperties = function() {
|
||||
* Get the feature for working with its geometry.
|
||||
* @return {ol.render.Feature} Feature.
|
||||
*/
|
||||
ol.render.Feature.prototype.getSimplifiedGeometry =
|
||||
ol.render.Feature.prototype.getGeometry;
|
||||
_ol_render_Feature_.prototype.getSimplifiedGeometry =
|
||||
_ol_render_Feature_.prototype.getGeometry;
|
||||
|
||||
|
||||
/**
|
||||
* @return {number} Stride.
|
||||
*/
|
||||
ol.render.Feature.prototype.getStride = function() {
|
||||
_ol_render_Feature_.prototype.getStride = function() {
|
||||
return 2;
|
||||
};
|
||||
|
||||
@@ -244,7 +244,7 @@ ol.render.Feature.prototype.getStride = function() {
|
||||
/**
|
||||
* @return {undefined}
|
||||
*/
|
||||
ol.render.Feature.prototype.getStyleFunction = ol.nullFunction;
|
||||
_ol_render_Feature_.prototype.getStyleFunction = _ol_.nullFunction;
|
||||
|
||||
|
||||
/**
|
||||
@@ -252,7 +252,7 @@ ol.render.Feature.prototype.getStyleFunction = ol.nullFunction;
|
||||
* @return {ol.geom.GeometryType} Geometry type.
|
||||
* @api
|
||||
*/
|
||||
ol.render.Feature.prototype.getType = function() {
|
||||
_ol_render_Feature_.prototype.getType = function() {
|
||||
return this.type_;
|
||||
};
|
||||
|
||||
@@ -263,15 +263,16 @@ ol.render.Feature.prototype.getType = function() {
|
||||
* @param {ol.ProjectionLike} source The current projection
|
||||
* @param {ol.ProjectionLike} destination The desired projection.
|
||||
*/
|
||||
ol.render.Feature.prototype.transform = function(source, destination) {
|
||||
_ol_render_Feature_.prototype.transform = function(source, destination) {
|
||||
var pixelExtent = source.getExtent();
|
||||
var projectedExtent = source.getWorldExtent();
|
||||
var scale = ol.extent.getHeight(projectedExtent) / ol.extent.getHeight(pixelExtent);
|
||||
var scale = _ol_extent_.getHeight(projectedExtent) / _ol_extent_.getHeight(pixelExtent);
|
||||
var transform = this.tmpTransform_;
|
||||
ol.transform.compose(transform,
|
||||
_ol_transform_.compose(transform,
|
||||
projectedExtent[0], projectedExtent[3],
|
||||
scale, -scale, 0,
|
||||
0, 0);
|
||||
ol.geom.flat.transform.transform2D(this.flatCoordinates_, 0, this.flatCoordinates_.length, 2,
|
||||
_ol_geom_flat_transform_.transform2D(this.flatCoordinates_, 0, this.flatCoordinates_.length, 2,
|
||||
transform, this.flatCoordinates_);
|
||||
};
|
||||
export default _ol_render_Feature_;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
goog.provide('ol.render.ReplayGroup');
|
||||
|
||||
|
||||
/**
|
||||
* @module ol/render/ReplayGroup
|
||||
*/
|
||||
/**
|
||||
* Base class for replay groups.
|
||||
* @constructor
|
||||
* @abstract
|
||||
*/
|
||||
ol.render.ReplayGroup = function() {};
|
||||
var _ol_render_ReplayGroup_ = function() {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -15,11 +15,12 @@ ol.render.ReplayGroup = function() {};
|
||||
* @param {ol.render.ReplayType} replayType Replay type.
|
||||
* @return {ol.render.VectorContext} Replay.
|
||||
*/
|
||||
ol.render.ReplayGroup.prototype.getReplay = function(zIndex, replayType) {};
|
||||
_ol_render_ReplayGroup_.prototype.getReplay = function(zIndex, replayType) {};
|
||||
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @return {boolean} Is empty.
|
||||
*/
|
||||
ol.render.ReplayGroup.prototype.isEmpty = function() {};
|
||||
_ol_render_ReplayGroup_.prototype.isEmpty = function() {};
|
||||
export default _ol_render_ReplayGroup_;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
goog.provide('ol.render.ReplayType');
|
||||
|
||||
|
||||
/**
|
||||
* @module ol/render/ReplayType
|
||||
*/
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.render.ReplayType = {
|
||||
var _ol_render_ReplayType_ = {
|
||||
CIRCLE: 'Circle',
|
||||
DEFAULT: 'Default',
|
||||
IMAGE: 'Image',
|
||||
@@ -12,3 +12,5 @@ ol.render.ReplayType = {
|
||||
POLYGON: 'Polygon',
|
||||
TEXT: 'Text'
|
||||
};
|
||||
|
||||
export default _ol_render_ReplayType_;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
goog.provide('ol.render.VectorContext');
|
||||
|
||||
|
||||
/**
|
||||
* @module ol/render/VectorContext
|
||||
*/
|
||||
/**
|
||||
* Context for drawing geometries. A vector context is available on render
|
||||
* events and does not need to be constructed directly.
|
||||
@@ -9,7 +9,7 @@ goog.provide('ol.render.VectorContext');
|
||||
* @struct
|
||||
* @api
|
||||
*/
|
||||
ol.render.VectorContext = function() {
|
||||
var _ol_render_VectorContext_ = function() {
|
||||
};
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ ol.render.VectorContext = function() {
|
||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||
* @param {Function} renderer Renderer.
|
||||
*/
|
||||
ol.render.VectorContext.prototype.drawCustom = function(geometry, feature, renderer) {};
|
||||
_ol_render_VectorContext_.prototype.drawCustom = function(geometry, feature, renderer) {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -28,7 +28,7 @@ ol.render.VectorContext.prototype.drawCustom = function(geometry, feature, rende
|
||||
*
|
||||
* @param {ol.geom.Geometry} geometry The geometry to render.
|
||||
*/
|
||||
ol.render.VectorContext.prototype.drawGeometry = function(geometry) {};
|
||||
_ol_render_VectorContext_.prototype.drawGeometry = function(geometry) {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -36,21 +36,21 @@ ol.render.VectorContext.prototype.drawGeometry = function(geometry) {};
|
||||
*
|
||||
* @param {ol.style.Style} style The rendering style.
|
||||
*/
|
||||
ol.render.VectorContext.prototype.setStyle = function(style) {};
|
||||
_ol_render_VectorContext_.prototype.setStyle = function(style) {};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Circle} circleGeometry Circle geometry.
|
||||
* @param {ol.Feature} feature Feature.
|
||||
*/
|
||||
ol.render.VectorContext.prototype.drawCircle = function(circleGeometry, feature) {};
|
||||
_ol_render_VectorContext_.prototype.drawCircle = function(circleGeometry, feature) {};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Feature} feature Feature.
|
||||
* @param {ol.style.Style} style Style.
|
||||
*/
|
||||
ol.render.VectorContext.prototype.drawFeature = function(feature, style) {};
|
||||
_ol_render_VectorContext_.prototype.drawFeature = function(feature, style) {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -58,7 +58,7 @@ ol.render.VectorContext.prototype.drawFeature = function(feature, style) {};
|
||||
* collection.
|
||||
* @param {ol.Feature} feature Feature.
|
||||
*/
|
||||
ol.render.VectorContext.prototype.drawGeometryCollection = function(geometryCollectionGeometry, feature) {};
|
||||
_ol_render_VectorContext_.prototype.drawGeometryCollection = function(geometryCollectionGeometry, feature) {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ ol.render.VectorContext.prototype.drawGeometryCollection = function(geometryColl
|
||||
* string geometry.
|
||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||
*/
|
||||
ol.render.VectorContext.prototype.drawLineString = function(lineStringGeometry, feature) {};
|
||||
_ol_render_VectorContext_.prototype.drawLineString = function(lineStringGeometry, feature) {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -74,7 +74,7 @@ ol.render.VectorContext.prototype.drawLineString = function(lineStringGeometry,
|
||||
* MultiLineString geometry.
|
||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||
*/
|
||||
ol.render.VectorContext.prototype.drawMultiLineString = function(multiLineStringGeometry, feature) {};
|
||||
_ol_render_VectorContext_.prototype.drawMultiLineString = function(multiLineStringGeometry, feature) {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -82,21 +82,21 @@ ol.render.VectorContext.prototype.drawMultiLineString = function(multiLineString
|
||||
* geometry.
|
||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||
*/
|
||||
ol.render.VectorContext.prototype.drawMultiPoint = function(multiPointGeometry, feature) {};
|
||||
_ol_render_VectorContext_.prototype.drawMultiPoint = function(multiPointGeometry, feature) {};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.MultiPolygon} multiPolygonGeometry MultiPolygon geometry.
|
||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||
*/
|
||||
ol.render.VectorContext.prototype.drawMultiPolygon = function(multiPolygonGeometry, feature) {};
|
||||
_ol_render_VectorContext_.prototype.drawMultiPolygon = function(multiPolygonGeometry, feature) {};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Point|ol.render.Feature} pointGeometry Point geometry.
|
||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||
*/
|
||||
ol.render.VectorContext.prototype.drawPoint = function(pointGeometry, feature) {};
|
||||
_ol_render_VectorContext_.prototype.drawPoint = function(pointGeometry, feature) {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -104,32 +104,33 @@ ol.render.VectorContext.prototype.drawPoint = function(pointGeometry, feature) {
|
||||
* geometry.
|
||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||
*/
|
||||
ol.render.VectorContext.prototype.drawPolygon = function(polygonGeometry, feature) {};
|
||||
_ol_render_VectorContext_.prototype.drawPolygon = function(polygonGeometry, feature) {};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry.
|
||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||
*/
|
||||
ol.render.VectorContext.prototype.drawText = function(geometry, feature) {};
|
||||
_ol_render_VectorContext_.prototype.drawText = function(geometry, feature) {};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.style.Fill} fillStyle Fill style.
|
||||
* @param {ol.style.Stroke} strokeStyle Stroke style.
|
||||
*/
|
||||
ol.render.VectorContext.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {};
|
||||
_ol_render_VectorContext_.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.style.Image} imageStyle Image style.
|
||||
* @param {ol.DeclutterGroup=} opt_declutterGroup Declutter.
|
||||
*/
|
||||
ol.render.VectorContext.prototype.setImageStyle = function(imageStyle, opt_declutterGroup) {};
|
||||
_ol_render_VectorContext_.prototype.setImageStyle = function(imageStyle, opt_declutterGroup) {};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.style.Text} textStyle Text style.
|
||||
* @param {ol.DeclutterGroup=} opt_declutterGroup Declutter.
|
||||
*/
|
||||
ol.render.VectorContext.prototype.setTextStyle = function(textStyle, opt_declutterGroup) {};
|
||||
_ol_render_VectorContext_.prototype.setTextStyle = function(textStyle, opt_declutterGroup) {};
|
||||
export default _ol_render_VectorContext_;
|
||||
|
||||
@@ -1,135 +1,136 @@
|
||||
goog.provide('ol.render.canvas');
|
||||
|
||||
|
||||
goog.require('ol.css');
|
||||
goog.require('ol.dom');
|
||||
goog.require('ol.obj');
|
||||
goog.require('ol.structs.LRUCache');
|
||||
goog.require('ol.transform');
|
||||
/**
|
||||
* @module ol/render/canvas
|
||||
*/
|
||||
import _ol_css_ from '../css.js';
|
||||
import _ol_dom_ from '../dom.js';
|
||||
import _ol_obj_ from '../obj.js';
|
||||
import _ol_structs_LRUCache_ from '../structs/LRUCache.js';
|
||||
import _ol_transform_ from '../transform.js';
|
||||
var _ol_render_canvas_ = {};
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
ol.render.canvas.defaultFont = '10px sans-serif';
|
||||
_ol_render_canvas_.defaultFont = '10px sans-serif';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {ol.Color}
|
||||
*/
|
||||
ol.render.canvas.defaultFillStyle = [0, 0, 0, 1];
|
||||
_ol_render_canvas_.defaultFillStyle = [0, 0, 0, 1];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
ol.render.canvas.defaultLineCap = 'round';
|
||||
_ol_render_canvas_.defaultLineCap = 'round';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<number>}
|
||||
*/
|
||||
ol.render.canvas.defaultLineDash = [];
|
||||
_ol_render_canvas_.defaultLineDash = [];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
ol.render.canvas.defaultLineDashOffset = 0;
|
||||
_ol_render_canvas_.defaultLineDashOffset = 0;
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
ol.render.canvas.defaultLineJoin = 'round';
|
||||
_ol_render_canvas_.defaultLineJoin = 'round';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
ol.render.canvas.defaultMiterLimit = 10;
|
||||
_ol_render_canvas_.defaultMiterLimit = 10;
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {ol.Color}
|
||||
*/
|
||||
ol.render.canvas.defaultStrokeStyle = [0, 0, 0, 1];
|
||||
_ol_render_canvas_.defaultStrokeStyle = [0, 0, 0, 1];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
ol.render.canvas.defaultTextAlign = 'center';
|
||||
_ol_render_canvas_.defaultTextAlign = 'center';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
ol.render.canvas.defaultTextBaseline = 'middle';
|
||||
_ol_render_canvas_.defaultTextBaseline = 'middle';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<number>}
|
||||
*/
|
||||
ol.render.canvas.defaultPadding = [0, 0, 0, 0];
|
||||
_ol_render_canvas_.defaultPadding = [0, 0, 0, 0];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
ol.render.canvas.defaultLineWidth = 1;
|
||||
_ol_render_canvas_.defaultLineWidth = 1;
|
||||
|
||||
|
||||
/**
|
||||
* @type {ol.structs.LRUCache.<HTMLCanvasElement>}
|
||||
*/
|
||||
ol.render.canvas.labelCache = new ol.structs.LRUCache();
|
||||
_ol_render_canvas_.labelCache = new _ol_structs_LRUCache_();
|
||||
|
||||
|
||||
/**
|
||||
* @type {!Object.<string, number>}
|
||||
*/
|
||||
ol.render.canvas.checkedFonts_ = {};
|
||||
_ol_render_canvas_.checkedFonts_ = {};
|
||||
|
||||
|
||||
/**
|
||||
* @type {CanvasRenderingContext2D}
|
||||
*/
|
||||
ol.render.canvas.measureContext_ = null;
|
||||
_ol_render_canvas_.measureContext_ = null;
|
||||
|
||||
|
||||
/**
|
||||
* @type {!Object.<string, number>}
|
||||
*/
|
||||
ol.render.canvas.textHeights_ = {};
|
||||
_ol_render_canvas_.textHeights_ = {};
|
||||
|
||||
|
||||
/**
|
||||
* Clears the label cache when a font becomes available.
|
||||
* @param {string} fontSpec CSS font spec.
|
||||
*/
|
||||
ol.render.canvas.checkFont = (function() {
|
||||
_ol_render_canvas_.checkFont = (function() {
|
||||
var retries = 60;
|
||||
var checked = ol.render.canvas.checkedFonts_;
|
||||
var labelCache = ol.render.canvas.labelCache;
|
||||
var checked = _ol_render_canvas_.checkedFonts_;
|
||||
var labelCache = _ol_render_canvas_.labelCache;
|
||||
var font = '32px monospace';
|
||||
var text = 'wmytzilWMYTZIL@#/&?$%10';
|
||||
var interval, referenceWidth;
|
||||
|
||||
function isAvailable(fontFamily) {
|
||||
var context = ol.render.canvas.getMeasureContext();
|
||||
var context = _ol_render_canvas_.getMeasureContext();
|
||||
context.font = font;
|
||||
referenceWidth = context.measureText(text).width;
|
||||
var available = true;
|
||||
@@ -150,9 +151,9 @@ ol.render.canvas.checkFont = (function() {
|
||||
if (checked[font] < retries) {
|
||||
if (isAvailable(font)) {
|
||||
checked[font] = retries;
|
||||
ol.obj.clear(ol.render.canvas.textHeights_);
|
||||
_ol_obj_.clear(_ol_render_canvas_.textHeights_);
|
||||
// Make sure that loaded fonts are picked up by Safari
|
||||
ol.render.canvas.measureContext_ = null;
|
||||
_ol_render_canvas_.measureContext_ = null;
|
||||
labelCache.clear();
|
||||
} else {
|
||||
++checked[font];
|
||||
@@ -167,7 +168,7 @@ ol.render.canvas.checkFont = (function() {
|
||||
}
|
||||
|
||||
return function(fontSpec) {
|
||||
var fontFamilies = ol.css.getFontFamilies(fontSpec);
|
||||
var fontFamilies = _ol_css_.getFontFamilies(fontSpec);
|
||||
if (!fontFamilies) {
|
||||
return;
|
||||
}
|
||||
@@ -190,10 +191,10 @@ ol.render.canvas.checkFont = (function() {
|
||||
/**
|
||||
* @return {CanvasRenderingContext2D} Measure context.
|
||||
*/
|
||||
ol.render.canvas.getMeasureContext = function() {
|
||||
var context = ol.render.canvas.measureContext_;
|
||||
_ol_render_canvas_.getMeasureContext = function() {
|
||||
var context = _ol_render_canvas_.measureContext_;
|
||||
if (!context) {
|
||||
context = ol.render.canvas.measureContext_ = ol.dom.createCanvasContext2D(1, 1);
|
||||
context = _ol_render_canvas_.measureContext_ = _ol_dom_.createCanvasContext2D(1, 1);
|
||||
}
|
||||
return context;
|
||||
};
|
||||
@@ -203,9 +204,9 @@ ol.render.canvas.getMeasureContext = function() {
|
||||
* @param {string} font Font to use for measuring.
|
||||
* @return {ol.Size} Measurement.
|
||||
*/
|
||||
ol.render.canvas.measureTextHeight = (function() {
|
||||
_ol_render_canvas_.measureTextHeight = (function() {
|
||||
var span;
|
||||
var heights = ol.render.canvas.textHeights_;
|
||||
var heights = _ol_render_canvas_.textHeights_;
|
||||
return function(font) {
|
||||
var height = heights[font];
|
||||
if (height == undefined) {
|
||||
@@ -231,8 +232,8 @@ ol.render.canvas.measureTextHeight = (function() {
|
||||
* @param {string} text Text.
|
||||
* @return {number} Width.
|
||||
*/
|
||||
ol.render.canvas.measureTextWidth = function(font, text) {
|
||||
var measureContext = ol.render.canvas.getMeasureContext();
|
||||
_ol_render_canvas_.measureTextWidth = function(font, text) {
|
||||
var measureContext = _ol_render_canvas_.getMeasureContext();
|
||||
if (font != measureContext.font) {
|
||||
measureContext.font = font;
|
||||
}
|
||||
@@ -246,7 +247,7 @@ ol.render.canvas.measureTextWidth = function(font, text) {
|
||||
* @param {number} offsetX X offset.
|
||||
* @param {number} offsetY Y offset.
|
||||
*/
|
||||
ol.render.canvas.rotateAtOffset = function(context, rotation, offsetX, offsetY) {
|
||||
_ol_render_canvas_.rotateAtOffset = function(context, rotation, offsetX, offsetY) {
|
||||
if (rotation !== 0) {
|
||||
context.translate(offsetX, offsetY);
|
||||
context.rotate(rotation);
|
||||
@@ -255,7 +256,7 @@ ol.render.canvas.rotateAtOffset = function(context, rotation, offsetX, offsetY)
|
||||
};
|
||||
|
||||
|
||||
ol.render.canvas.resetTransform_ = ol.transform.create();
|
||||
_ol_render_canvas_.resetTransform_ = _ol_transform_.create();
|
||||
|
||||
|
||||
/**
|
||||
@@ -271,7 +272,7 @@ ol.render.canvas.resetTransform_ = ol.transform.create();
|
||||
* @param {number} y Y.
|
||||
* @param {number} scale Scale.
|
||||
*/
|
||||
ol.render.canvas.drawImage = function(context,
|
||||
_ol_render_canvas_.drawImage = function(context,
|
||||
transform, opacity, image, originX, originY, w, h, x, y, scale) {
|
||||
var alpha;
|
||||
if (opacity != 1) {
|
||||
@@ -288,6 +289,7 @@ ol.render.canvas.drawImage = function(context,
|
||||
context.globalAlpha = alpha;
|
||||
}
|
||||
if (transform) {
|
||||
context.setTransform.apply(context, ol.render.canvas.resetTransform_);
|
||||
context.setTransform.apply(context, _ol_render_canvas_.resetTransform_);
|
||||
}
|
||||
};
|
||||
export default _ol_render_canvas_;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
goog.provide('ol.render.canvas.ImageReplay');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.render.canvas.Instruction');
|
||||
goog.require('ol.render.canvas.Replay');
|
||||
|
||||
/**
|
||||
* @module ol/render/canvas/ImageReplay
|
||||
*/
|
||||
import _ol_ from '../../index.js';
|
||||
import _ol_render_canvas_Instruction_ from '../canvas/Instruction.js';
|
||||
import _ol_render_canvas_Replay_ from '../canvas/Replay.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -16,9 +16,9 @@ goog.require('ol.render.canvas.Replay');
|
||||
* @param {?} declutterTree Declutter tree.
|
||||
* @struct
|
||||
*/
|
||||
ol.render.canvas.ImageReplay = function(
|
||||
var _ol_render_canvas_ImageReplay_ = function(
|
||||
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
|
||||
ol.render.canvas.Replay.call(this,
|
||||
_ol_render_canvas_Replay_.call(this,
|
||||
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree);
|
||||
|
||||
/**
|
||||
@@ -106,7 +106,8 @@ ol.render.canvas.ImageReplay = function(
|
||||
this.width_ = undefined;
|
||||
|
||||
};
|
||||
ol.inherits(ol.render.canvas.ImageReplay, ol.render.canvas.Replay);
|
||||
|
||||
_ol_.inherits(_ol_render_canvas_ImageReplay_, _ol_render_canvas_Replay_);
|
||||
|
||||
|
||||
/**
|
||||
@@ -117,7 +118,7 @@ ol.inherits(ol.render.canvas.ImageReplay, ol.render.canvas.Replay);
|
||||
* @private
|
||||
* @return {number} My end.
|
||||
*/
|
||||
ol.render.canvas.ImageReplay.prototype.drawCoordinates_ = function(flatCoordinates, offset, end, stride) {
|
||||
_ol_render_canvas_ImageReplay_.prototype.drawCoordinates_ = function(flatCoordinates, offset, end, stride) {
|
||||
return this.appendFlatCoordinates(
|
||||
flatCoordinates, offset, end, stride, false, false);
|
||||
};
|
||||
@@ -126,7 +127,7 @@ ol.render.canvas.ImageReplay.prototype.drawCoordinates_ = function(flatCoordinat
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.canvas.ImageReplay.prototype.drawPoint = function(pointGeometry, feature) {
|
||||
_ol_render_canvas_ImageReplay_.prototype.drawPoint = function(pointGeometry, feature) {
|
||||
if (!this.image_) {
|
||||
return;
|
||||
}
|
||||
@@ -137,14 +138,14 @@ ol.render.canvas.ImageReplay.prototype.drawPoint = function(pointGeometry, featu
|
||||
var myEnd = this.drawCoordinates_(
|
||||
flatCoordinates, 0, flatCoordinates.length, stride);
|
||||
this.instructions.push([
|
||||
ol.render.canvas.Instruction.DRAW_IMAGE, myBegin, myEnd, this.image_,
|
||||
_ol_render_canvas_Instruction_.DRAW_IMAGE, myBegin, myEnd, this.image_,
|
||||
// Remaining arguments to DRAW_IMAGE are in alphabetical order
|
||||
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
|
||||
this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
|
||||
this.scale_ * this.pixelRatio, this.snapToPixel_, this.width_
|
||||
]);
|
||||
this.hitDetectionInstructions.push([
|
||||
ol.render.canvas.Instruction.DRAW_IMAGE, myBegin, myEnd,
|
||||
_ol_render_canvas_Instruction_.DRAW_IMAGE, myBegin, myEnd,
|
||||
this.hitDetectionImage_,
|
||||
// Remaining arguments to DRAW_IMAGE are in alphabetical order
|
||||
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
|
||||
@@ -158,7 +159,7 @@ ol.render.canvas.ImageReplay.prototype.drawPoint = function(pointGeometry, featu
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.canvas.ImageReplay.prototype.drawMultiPoint = function(multiPointGeometry, feature) {
|
||||
_ol_render_canvas_ImageReplay_.prototype.drawMultiPoint = function(multiPointGeometry, feature) {
|
||||
if (!this.image_) {
|
||||
return;
|
||||
}
|
||||
@@ -169,14 +170,14 @@ ol.render.canvas.ImageReplay.prototype.drawMultiPoint = function(multiPointGeome
|
||||
var myEnd = this.drawCoordinates_(
|
||||
flatCoordinates, 0, flatCoordinates.length, stride);
|
||||
this.instructions.push([
|
||||
ol.render.canvas.Instruction.DRAW_IMAGE, myBegin, myEnd, this.image_,
|
||||
_ol_render_canvas_Instruction_.DRAW_IMAGE, myBegin, myEnd, this.image_,
|
||||
// Remaining arguments to DRAW_IMAGE are in alphabetical order
|
||||
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
|
||||
this.originX_, this.originY_, this.rotateWithView_, this.rotation_,
|
||||
this.scale_ * this.pixelRatio, this.snapToPixel_, this.width_
|
||||
]);
|
||||
this.hitDetectionInstructions.push([
|
||||
ol.render.canvas.Instruction.DRAW_IMAGE, myBegin, myEnd,
|
||||
_ol_render_canvas_Instruction_.DRAW_IMAGE, myBegin, myEnd,
|
||||
this.hitDetectionImage_,
|
||||
// Remaining arguments to DRAW_IMAGE are in alphabetical order
|
||||
this.anchorX_, this.anchorY_, this.declutterGroup_, this.height_, this.opacity_,
|
||||
@@ -190,7 +191,7 @@ ol.render.canvas.ImageReplay.prototype.drawMultiPoint = function(multiPointGeome
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.canvas.ImageReplay.prototype.finish = function() {
|
||||
_ol_render_canvas_ImageReplay_.prototype.finish = function() {
|
||||
this.reverseHitDetectionInstructions();
|
||||
// FIXME this doesn't really protect us against further calls to draw*Geometry
|
||||
this.anchorX_ = undefined;
|
||||
@@ -212,7 +213,7 @@ ol.render.canvas.ImageReplay.prototype.finish = function() {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.canvas.ImageReplay.prototype.setImageStyle = function(imageStyle, declutterGroup) {
|
||||
_ol_render_canvas_ImageReplay_.prototype.setImageStyle = function(imageStyle, declutterGroup) {
|
||||
var anchor = imageStyle.getAnchor();
|
||||
var size = imageStyle.getSize();
|
||||
var hitDetectionImage = imageStyle.getHitDetectionImage(1);
|
||||
@@ -233,3 +234,4 @@ ol.render.canvas.ImageReplay.prototype.setImageStyle = function(imageStyle, decl
|
||||
this.snapToPixel_ = imageStyle.getSnapToPixel();
|
||||
this.width_ = size[0];
|
||||
};
|
||||
export default _ol_render_canvas_ImageReplay_;
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
/**
|
||||
* @module ol/render/canvas/Immediate
|
||||
*/
|
||||
// FIXME test, especially polygons with holes and multipolygons
|
||||
// FIXME need to handle large thick features (where pixel size matters)
|
||||
// FIXME add offset and end to ol.geom.flat.transform.transform2D?
|
||||
|
||||
goog.provide('ol.render.canvas.Immediate');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.colorlike');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
goog.require('ol.geom.SimpleGeometry');
|
||||
goog.require('ol.geom.flat.transform');
|
||||
goog.require('ol.has');
|
||||
goog.require('ol.render.VectorContext');
|
||||
goog.require('ol.render.canvas');
|
||||
goog.require('ol.transform');
|
||||
|
||||
import _ol_ from '../../index.js';
|
||||
import _ol_array_ from '../../array.js';
|
||||
import _ol_colorlike_ from '../../colorlike.js';
|
||||
import _ol_extent_ from '../../extent.js';
|
||||
import _ol_geom_GeometryType_ from '../../geom/GeometryType.js';
|
||||
import _ol_geom_SimpleGeometry_ from '../../geom/SimpleGeometry.js';
|
||||
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
|
||||
import _ol_has_ from '../../has.js';
|
||||
import _ol_render_VectorContext_ from '../VectorContext.js';
|
||||
import _ol_render_canvas_ from '../canvas.js';
|
||||
import _ol_transform_ from '../../transform.js';
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
@@ -35,8 +35,8 @@ goog.require('ol.transform');
|
||||
* @param {number} viewRotation View rotation.
|
||||
* @struct
|
||||
*/
|
||||
ol.render.canvas.Immediate = function(context, pixelRatio, extent, transform, viewRotation) {
|
||||
ol.render.VectorContext.call(this);
|
||||
var _ol_render_canvas_Immediate_ = function(context, pixelRatio, extent, transform, viewRotation) {
|
||||
_ol_render_VectorContext_.call(this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -234,10 +234,11 @@ ol.render.canvas.Immediate = function(context, pixelRatio, extent, transform, vi
|
||||
* @private
|
||||
* @type {ol.Transform}
|
||||
*/
|
||||
this.tmpLocalTransform_ = ol.transform.create();
|
||||
this.tmpLocalTransform_ = _ol_transform_.create();
|
||||
|
||||
};
|
||||
ol.inherits(ol.render.canvas.Immediate, ol.render.VectorContext);
|
||||
|
||||
_ol_.inherits(_ol_render_canvas_Immediate_, _ol_render_VectorContext_);
|
||||
|
||||
|
||||
/**
|
||||
@@ -247,11 +248,11 @@ ol.inherits(ol.render.canvas.Immediate, ol.render.VectorContext);
|
||||
* @param {number} stride Stride.
|
||||
* @private
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.drawImages_ = function(flatCoordinates, offset, end, stride) {
|
||||
_ol_render_canvas_Immediate_.prototype.drawImages_ = function(flatCoordinates, offset, end, stride) {
|
||||
if (!this.image_) {
|
||||
return;
|
||||
}
|
||||
var pixelCoordinates = ol.geom.flat.transform.transform2D(
|
||||
var pixelCoordinates = _ol_geom_flat_transform_.transform2D(
|
||||
flatCoordinates, offset, end, 2, this.transform_,
|
||||
this.pixelCoordinates_);
|
||||
var context = this.context_;
|
||||
@@ -275,7 +276,7 @@ ol.render.canvas.Immediate.prototype.drawImages_ = function(flatCoordinates, off
|
||||
if (rotation !== 0 || this.imageScale_ != 1) {
|
||||
var centerX = x + this.imageAnchorX_;
|
||||
var centerY = y + this.imageAnchorY_;
|
||||
ol.transform.compose(localTransform,
|
||||
_ol_transform_.compose(localTransform,
|
||||
centerX, centerY,
|
||||
this.imageScale_, this.imageScale_,
|
||||
rotation,
|
||||
@@ -302,7 +303,7 @@ ol.render.canvas.Immediate.prototype.drawImages_ = function(flatCoordinates, off
|
||||
* @param {number} stride Stride.
|
||||
* @private
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.drawText_ = function(flatCoordinates, offset, end, stride) {
|
||||
_ol_render_canvas_Immediate_.prototype.drawText_ = function(flatCoordinates, offset, end, stride) {
|
||||
if (!this.textState_ || this.text_ === '') {
|
||||
return;
|
||||
}
|
||||
@@ -313,7 +314,7 @@ ol.render.canvas.Immediate.prototype.drawText_ = function(flatCoordinates, offse
|
||||
this.setContextStrokeState_(this.textStrokeState_);
|
||||
}
|
||||
this.setContextTextState_(this.textState_);
|
||||
var pixelCoordinates = ol.geom.flat.transform.transform2D(
|
||||
var pixelCoordinates = _ol_geom_flat_transform_.transform2D(
|
||||
flatCoordinates, offset, end, stride, this.transform_,
|
||||
this.pixelCoordinates_);
|
||||
var context = this.context_;
|
||||
@@ -325,7 +326,7 @@ ol.render.canvas.Immediate.prototype.drawText_ = function(flatCoordinates, offse
|
||||
var x = pixelCoordinates[offset] + this.textOffsetX_;
|
||||
var y = pixelCoordinates[offset + 1] + this.textOffsetY_;
|
||||
if (rotation !== 0 || this.textScale_ != 1) {
|
||||
var localTransform = ol.transform.compose(this.tmpLocalTransform_,
|
||||
var localTransform = _ol_transform_.compose(this.tmpLocalTransform_,
|
||||
x, y,
|
||||
this.textScale_, this.textScale_,
|
||||
rotation,
|
||||
@@ -354,9 +355,9 @@ ol.render.canvas.Immediate.prototype.drawText_ = function(flatCoordinates, offse
|
||||
* @private
|
||||
* @return {number} end End.
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.moveToLineTo_ = function(flatCoordinates, offset, end, stride, close) {
|
||||
_ol_render_canvas_Immediate_.prototype.moveToLineTo_ = function(flatCoordinates, offset, end, stride, close) {
|
||||
var context = this.context_;
|
||||
var pixelCoordinates = ol.geom.flat.transform.transform2D(
|
||||
var pixelCoordinates = _ol_geom_flat_transform_.transform2D(
|
||||
flatCoordinates, offset, end, stride, this.transform_,
|
||||
this.pixelCoordinates_);
|
||||
context.moveTo(pixelCoordinates[0], pixelCoordinates[1]);
|
||||
@@ -382,7 +383,7 @@ ol.render.canvas.Immediate.prototype.moveToLineTo_ = function(flatCoordinates, o
|
||||
* @private
|
||||
* @return {number} End.
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.drawRings_ = function(flatCoordinates, offset, ends, stride) {
|
||||
_ol_render_canvas_Immediate_.prototype.drawRings_ = function(flatCoordinates, offset, ends, stride) {
|
||||
var i, ii;
|
||||
for (i = 0, ii = ends.length; i < ii; ++i) {
|
||||
offset = this.moveToLineTo_(
|
||||
@@ -400,8 +401,8 @@ ol.render.canvas.Immediate.prototype.drawRings_ = function(flatCoordinates, offs
|
||||
* @override
|
||||
* @api
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.drawCircle = function(geometry) {
|
||||
if (!ol.extent.intersects(this.extent_, geometry.getExtent())) {
|
||||
_ol_render_canvas_Immediate_.prototype.drawCircle = function(geometry) {
|
||||
if (!_ol_extent_.intersects(this.extent_, geometry.getExtent())) {
|
||||
return;
|
||||
}
|
||||
if (this.fillState_ || this.strokeState_) {
|
||||
@@ -411,7 +412,7 @@ ol.render.canvas.Immediate.prototype.drawCircle = function(geometry) {
|
||||
if (this.strokeState_) {
|
||||
this.setContextStrokeState_(this.strokeState_);
|
||||
}
|
||||
var pixelCoordinates = ol.geom.SimpleGeometry.transform2D(
|
||||
var pixelCoordinates = _ol_geom_SimpleGeometry_.transform2D(
|
||||
geometry, this.transform_, this.pixelCoordinates_);
|
||||
var dx = pixelCoordinates[2] - pixelCoordinates[0];
|
||||
var dy = pixelCoordinates[3] - pixelCoordinates[1];
|
||||
@@ -441,7 +442,7 @@ ol.render.canvas.Immediate.prototype.drawCircle = function(geometry) {
|
||||
* @override
|
||||
* @api
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.setStyle = function(style) {
|
||||
_ol_render_canvas_Immediate_.prototype.setStyle = function(style) {
|
||||
this.setFillStrokeStyle(style.getFill(), style.getStroke());
|
||||
this.setImageStyle(style.getImage());
|
||||
this.setTextStyle(style.getText());
|
||||
@@ -456,31 +457,31 @@ ol.render.canvas.Immediate.prototype.setStyle = function(style) {
|
||||
* @override
|
||||
* @api
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.drawGeometry = function(geometry) {
|
||||
_ol_render_canvas_Immediate_.prototype.drawGeometry = function(geometry) {
|
||||
var type = geometry.getType();
|
||||
switch (type) {
|
||||
case ol.geom.GeometryType.POINT:
|
||||
case _ol_geom_GeometryType_.POINT:
|
||||
this.drawPoint(/** @type {ol.geom.Point} */ (geometry));
|
||||
break;
|
||||
case ol.geom.GeometryType.LINE_STRING:
|
||||
case _ol_geom_GeometryType_.LINE_STRING:
|
||||
this.drawLineString(/** @type {ol.geom.LineString} */ (geometry));
|
||||
break;
|
||||
case ol.geom.GeometryType.POLYGON:
|
||||
case _ol_geom_GeometryType_.POLYGON:
|
||||
this.drawPolygon(/** @type {ol.geom.Polygon} */ (geometry));
|
||||
break;
|
||||
case ol.geom.GeometryType.MULTI_POINT:
|
||||
case _ol_geom_GeometryType_.MULTI_POINT:
|
||||
this.drawMultiPoint(/** @type {ol.geom.MultiPoint} */ (geometry));
|
||||
break;
|
||||
case ol.geom.GeometryType.MULTI_LINE_STRING:
|
||||
case _ol_geom_GeometryType_.MULTI_LINE_STRING:
|
||||
this.drawMultiLineString(/** @type {ol.geom.MultiLineString} */ (geometry));
|
||||
break;
|
||||
case ol.geom.GeometryType.MULTI_POLYGON:
|
||||
case _ol_geom_GeometryType_.MULTI_POLYGON:
|
||||
this.drawMultiPolygon(/** @type {ol.geom.MultiPolygon} */ (geometry));
|
||||
break;
|
||||
case ol.geom.GeometryType.GEOMETRY_COLLECTION:
|
||||
case _ol_geom_GeometryType_.GEOMETRY_COLLECTION:
|
||||
this.drawGeometryCollection(/** @type {ol.geom.GeometryCollection} */ (geometry));
|
||||
break;
|
||||
case ol.geom.GeometryType.CIRCLE:
|
||||
case _ol_geom_GeometryType_.CIRCLE:
|
||||
this.drawCircle(/** @type {ol.geom.Circle} */ (geometry));
|
||||
break;
|
||||
default:
|
||||
@@ -499,10 +500,10 @@ ol.render.canvas.Immediate.prototype.drawGeometry = function(geometry) {
|
||||
* @override
|
||||
* @api
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.drawFeature = function(feature, style) {
|
||||
_ol_render_canvas_Immediate_.prototype.drawFeature = function(feature, style) {
|
||||
var geometry = style.getGeometryFunction()(feature);
|
||||
if (!geometry ||
|
||||
!ol.extent.intersects(this.extent_, geometry.getExtent())) {
|
||||
!_ol_extent_.intersects(this.extent_, geometry.getExtent())) {
|
||||
return;
|
||||
}
|
||||
this.setStyle(style);
|
||||
@@ -517,7 +518,7 @@ ol.render.canvas.Immediate.prototype.drawFeature = function(feature, style) {
|
||||
* @param {ol.geom.GeometryCollection} geometry Geometry collection.
|
||||
* @override
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.drawGeometryCollection = function(geometry) {
|
||||
_ol_render_canvas_Immediate_.prototype.drawGeometryCollection = function(geometry) {
|
||||
var geometries = geometry.getGeometriesArray();
|
||||
var i, ii;
|
||||
for (i = 0, ii = geometries.length; i < ii; ++i) {
|
||||
@@ -533,7 +534,7 @@ ol.render.canvas.Immediate.prototype.drawGeometryCollection = function(geometry)
|
||||
* @param {ol.geom.Point|ol.render.Feature} geometry Point geometry.
|
||||
* @override
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.drawPoint = function(geometry) {
|
||||
_ol_render_canvas_Immediate_.prototype.drawPoint = function(geometry) {
|
||||
var flatCoordinates = geometry.getFlatCoordinates();
|
||||
var stride = geometry.getStride();
|
||||
if (this.image_) {
|
||||
@@ -552,7 +553,7 @@ ol.render.canvas.Immediate.prototype.drawPoint = function(geometry) {
|
||||
* @param {ol.geom.MultiPoint|ol.render.Feature} geometry MultiPoint geometry.
|
||||
* @override
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.drawMultiPoint = function(geometry) {
|
||||
_ol_render_canvas_Immediate_.prototype.drawMultiPoint = function(geometry) {
|
||||
var flatCoordinates = geometry.getFlatCoordinates();
|
||||
var stride = geometry.getStride();
|
||||
if (this.image_) {
|
||||
@@ -571,8 +572,8 @@ ol.render.canvas.Immediate.prototype.drawMultiPoint = function(geometry) {
|
||||
* @param {ol.geom.LineString|ol.render.Feature} geometry LineString geometry.
|
||||
* @override
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.drawLineString = function(geometry) {
|
||||
if (!ol.extent.intersects(this.extent_, geometry.getExtent())) {
|
||||
_ol_render_canvas_Immediate_.prototype.drawLineString = function(geometry) {
|
||||
if (!_ol_extent_.intersects(this.extent_, geometry.getExtent())) {
|
||||
return;
|
||||
}
|
||||
if (this.strokeState_) {
|
||||
@@ -599,9 +600,9 @@ ol.render.canvas.Immediate.prototype.drawLineString = function(geometry) {
|
||||
* geometry.
|
||||
* @override
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.drawMultiLineString = function(geometry) {
|
||||
_ol_render_canvas_Immediate_.prototype.drawMultiLineString = function(geometry) {
|
||||
var geometryExtent = geometry.getExtent();
|
||||
if (!ol.extent.intersects(this.extent_, geometryExtent)) {
|
||||
if (!_ol_extent_.intersects(this.extent_, geometryExtent)) {
|
||||
return;
|
||||
}
|
||||
if (this.strokeState_) {
|
||||
@@ -633,8 +634,8 @@ ol.render.canvas.Immediate.prototype.drawMultiLineString = function(geometry) {
|
||||
* @param {ol.geom.Polygon|ol.render.Feature} geometry Polygon geometry.
|
||||
* @override
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.drawPolygon = function(geometry) {
|
||||
if (!ol.extent.intersects(this.extent_, geometry.getExtent())) {
|
||||
_ol_render_canvas_Immediate_.prototype.drawPolygon = function(geometry) {
|
||||
if (!_ol_extent_.intersects(this.extent_, geometry.getExtent())) {
|
||||
return;
|
||||
}
|
||||
if (this.strokeState_ || this.fillState_) {
|
||||
@@ -668,8 +669,8 @@ ol.render.canvas.Immediate.prototype.drawPolygon = function(geometry) {
|
||||
* @param {ol.geom.MultiPolygon} geometry MultiPolygon geometry.
|
||||
* @override
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.drawMultiPolygon = function(geometry) {
|
||||
if (!ol.extent.intersects(this.extent_, geometry.getExtent())) {
|
||||
_ol_render_canvas_Immediate_.prototype.drawMultiPolygon = function(geometry) {
|
||||
if (!_ol_extent_.intersects(this.extent_, geometry.getExtent())) {
|
||||
return;
|
||||
}
|
||||
if (this.strokeState_ || this.fillState_) {
|
||||
@@ -708,7 +709,7 @@ ol.render.canvas.Immediate.prototype.drawMultiPolygon = function(geometry) {
|
||||
* @param {ol.CanvasFillState} fillState Fill state.
|
||||
* @private
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.setContextFillState_ = function(fillState) {
|
||||
_ol_render_canvas_Immediate_.prototype.setContextFillState_ = function(fillState) {
|
||||
var context = this.context_;
|
||||
var contextFillState = this.contextFillState_;
|
||||
if (!contextFillState) {
|
||||
@@ -728,12 +729,12 @@ ol.render.canvas.Immediate.prototype.setContextFillState_ = function(fillState)
|
||||
* @param {ol.CanvasStrokeState} strokeState Stroke state.
|
||||
* @private
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.setContextStrokeState_ = function(strokeState) {
|
||||
_ol_render_canvas_Immediate_.prototype.setContextStrokeState_ = function(strokeState) {
|
||||
var context = this.context_;
|
||||
var contextStrokeState = this.contextStrokeState_;
|
||||
if (!contextStrokeState) {
|
||||
context.lineCap = strokeState.lineCap;
|
||||
if (ol.has.CANVAS_LINE_DASH) {
|
||||
if (_ol_has_.CANVAS_LINE_DASH) {
|
||||
context.setLineDash(strokeState.lineDash);
|
||||
context.lineDashOffset = strokeState.lineDashOffset;
|
||||
}
|
||||
@@ -754,8 +755,8 @@ ol.render.canvas.Immediate.prototype.setContextStrokeState_ = function(strokeSta
|
||||
if (contextStrokeState.lineCap != strokeState.lineCap) {
|
||||
contextStrokeState.lineCap = context.lineCap = strokeState.lineCap;
|
||||
}
|
||||
if (ol.has.CANVAS_LINE_DASH) {
|
||||
if (!ol.array.equals(
|
||||
if (_ol_has_.CANVAS_LINE_DASH) {
|
||||
if (!_ol_array_.equals(
|
||||
contextStrokeState.lineDash, strokeState.lineDash)) {
|
||||
context.setLineDash(contextStrokeState.lineDash = strokeState.lineDash);
|
||||
}
|
||||
@@ -786,11 +787,11 @@ ol.render.canvas.Immediate.prototype.setContextStrokeState_ = function(strokeSta
|
||||
* @param {ol.CanvasTextState} textState Text state.
|
||||
* @private
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.setContextTextState_ = function(textState) {
|
||||
_ol_render_canvas_Immediate_.prototype.setContextTextState_ = function(textState) {
|
||||
var context = this.context_;
|
||||
var contextTextState = this.contextTextState_;
|
||||
var textAlign = textState.textAlign ?
|
||||
textState.textAlign : ol.render.canvas.defaultTextAlign;
|
||||
textState.textAlign : _ol_render_canvas_.defaultTextAlign;
|
||||
if (!contextTextState) {
|
||||
context.font = textState.font;
|
||||
context.textAlign = textAlign;
|
||||
@@ -823,14 +824,14 @@ ol.render.canvas.Immediate.prototype.setContextTextState_ = function(textState)
|
||||
* @param {ol.style.Stroke} strokeStyle Stroke style.
|
||||
* @override
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
||||
_ol_render_canvas_Immediate_.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
||||
if (!fillStyle) {
|
||||
this.fillState_ = null;
|
||||
} else {
|
||||
var fillStyleColor = fillStyle.getColor();
|
||||
this.fillState_ = {
|
||||
fillStyle: ol.colorlike.asColorLike(fillStyleColor ?
|
||||
fillStyleColor : ol.render.canvas.defaultFillStyle)
|
||||
fillStyle: _ol_colorlike_.asColorLike(fillStyleColor ?
|
||||
fillStyleColor : _ol_render_canvas_.defaultFillStyle)
|
||||
};
|
||||
}
|
||||
if (!strokeStyle) {
|
||||
@@ -845,19 +846,19 @@ ol.render.canvas.Immediate.prototype.setFillStrokeStyle = function(fillStyle, st
|
||||
var strokeStyleMiterLimit = strokeStyle.getMiterLimit();
|
||||
this.strokeState_ = {
|
||||
lineCap: strokeStyleLineCap !== undefined ?
|
||||
strokeStyleLineCap : ol.render.canvas.defaultLineCap,
|
||||
strokeStyleLineCap : _ol_render_canvas_.defaultLineCap,
|
||||
lineDash: strokeStyleLineDash ?
|
||||
strokeStyleLineDash : ol.render.canvas.defaultLineDash,
|
||||
strokeStyleLineDash : _ol_render_canvas_.defaultLineDash,
|
||||
lineDashOffset: strokeStyleLineDashOffset ?
|
||||
strokeStyleLineDashOffset : ol.render.canvas.defaultLineDashOffset,
|
||||
strokeStyleLineDashOffset : _ol_render_canvas_.defaultLineDashOffset,
|
||||
lineJoin: strokeStyleLineJoin !== undefined ?
|
||||
strokeStyleLineJoin : ol.render.canvas.defaultLineJoin,
|
||||
strokeStyleLineJoin : _ol_render_canvas_.defaultLineJoin,
|
||||
lineWidth: this.pixelRatio_ * (strokeStyleWidth !== undefined ?
|
||||
strokeStyleWidth : ol.render.canvas.defaultLineWidth),
|
||||
strokeStyleWidth : _ol_render_canvas_.defaultLineWidth),
|
||||
miterLimit: strokeStyleMiterLimit !== undefined ?
|
||||
strokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit,
|
||||
strokeStyle: ol.colorlike.asColorLike(strokeStyleColor ?
|
||||
strokeStyleColor : ol.render.canvas.defaultStrokeStyle)
|
||||
strokeStyleMiterLimit : _ol_render_canvas_.defaultMiterLimit,
|
||||
strokeStyle: _ol_colorlike_.asColorLike(strokeStyleColor ?
|
||||
strokeStyleColor : _ol_render_canvas_.defaultStrokeStyle)
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -870,7 +871,7 @@ ol.render.canvas.Immediate.prototype.setFillStrokeStyle = function(fillStyle, st
|
||||
* @param {ol.style.Image} imageStyle Image style.
|
||||
* @override
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.setImageStyle = function(imageStyle) {
|
||||
_ol_render_canvas_Immediate_.prototype.setImageStyle = function(imageStyle) {
|
||||
if (!imageStyle) {
|
||||
this.image_ = null;
|
||||
} else {
|
||||
@@ -902,7 +903,7 @@ ol.render.canvas.Immediate.prototype.setImageStyle = function(imageStyle) {
|
||||
* @param {ol.style.Text} textStyle Text style.
|
||||
* @override
|
||||
*/
|
||||
ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) {
|
||||
_ol_render_canvas_Immediate_.prototype.setTextStyle = function(textStyle) {
|
||||
if (!textStyle) {
|
||||
this.text_ = '';
|
||||
} else {
|
||||
@@ -912,8 +913,8 @@ ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) {
|
||||
} else {
|
||||
var textFillStyleColor = textFillStyle.getColor();
|
||||
this.textFillState_ = {
|
||||
fillStyle: ol.colorlike.asColorLike(textFillStyleColor ?
|
||||
textFillStyleColor : ol.render.canvas.defaultFillStyle)
|
||||
fillStyle: _ol_colorlike_.asColorLike(textFillStyleColor ?
|
||||
textFillStyleColor : _ol_render_canvas_.defaultFillStyle)
|
||||
};
|
||||
}
|
||||
var textStrokeStyle = textStyle.getStroke();
|
||||
@@ -929,19 +930,19 @@ ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) {
|
||||
var textStrokeStyleMiterLimit = textStrokeStyle.getMiterLimit();
|
||||
this.textStrokeState_ = {
|
||||
lineCap: textStrokeStyleLineCap !== undefined ?
|
||||
textStrokeStyleLineCap : ol.render.canvas.defaultLineCap,
|
||||
textStrokeStyleLineCap : _ol_render_canvas_.defaultLineCap,
|
||||
lineDash: textStrokeStyleLineDash ?
|
||||
textStrokeStyleLineDash : ol.render.canvas.defaultLineDash,
|
||||
textStrokeStyleLineDash : _ol_render_canvas_.defaultLineDash,
|
||||
lineDashOffset: textStrokeStyleLineDashOffset ?
|
||||
textStrokeStyleLineDashOffset : ol.render.canvas.defaultLineDashOffset,
|
||||
textStrokeStyleLineDashOffset : _ol_render_canvas_.defaultLineDashOffset,
|
||||
lineJoin: textStrokeStyleLineJoin !== undefined ?
|
||||
textStrokeStyleLineJoin : ol.render.canvas.defaultLineJoin,
|
||||
textStrokeStyleLineJoin : _ol_render_canvas_.defaultLineJoin,
|
||||
lineWidth: textStrokeStyleWidth !== undefined ?
|
||||
textStrokeStyleWidth : ol.render.canvas.defaultLineWidth,
|
||||
textStrokeStyleWidth : _ol_render_canvas_.defaultLineWidth,
|
||||
miterLimit: textStrokeStyleMiterLimit !== undefined ?
|
||||
textStrokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit,
|
||||
strokeStyle: ol.colorlike.asColorLike(textStrokeStyleColor ?
|
||||
textStrokeStyleColor : ol.render.canvas.defaultStrokeStyle)
|
||||
textStrokeStyleMiterLimit : _ol_render_canvas_.defaultMiterLimit,
|
||||
strokeStyle: _ol_colorlike_.asColorLike(textStrokeStyleColor ?
|
||||
textStrokeStyleColor : _ol_render_canvas_.defaultStrokeStyle)
|
||||
};
|
||||
}
|
||||
var textFont = textStyle.getFont();
|
||||
@@ -955,11 +956,11 @@ ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) {
|
||||
var textTextBaseline = textStyle.getTextBaseline();
|
||||
this.textState_ = {
|
||||
font: textFont !== undefined ?
|
||||
textFont : ol.render.canvas.defaultFont,
|
||||
textFont : _ol_render_canvas_.defaultFont,
|
||||
textAlign: textTextAlign !== undefined ?
|
||||
textTextAlign : ol.render.canvas.defaultTextAlign,
|
||||
textTextAlign : _ol_render_canvas_.defaultTextAlign,
|
||||
textBaseline: textTextBaseline !== undefined ?
|
||||
textTextBaseline : ol.render.canvas.defaultTextBaseline
|
||||
textTextBaseline : _ol_render_canvas_.defaultTextBaseline
|
||||
};
|
||||
this.text_ = textText !== undefined ? textText : '';
|
||||
this.textOffsetX_ =
|
||||
@@ -972,3 +973,4 @@ ol.render.canvas.Immediate.prototype.setTextStyle = function(textStyle) {
|
||||
textScale : 1);
|
||||
}
|
||||
};
|
||||
export default _ol_render_canvas_Immediate_;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
goog.provide('ol.render.canvas.Instruction');
|
||||
|
||||
/**
|
||||
* @module ol/render/canvas/Instruction
|
||||
*/
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
ol.render.canvas.Instruction = {
|
||||
var _ol_render_canvas_Instruction_ = {
|
||||
BEGIN_GEOMETRY: 0,
|
||||
BEGIN_PATH: 1,
|
||||
CIRCLE: 2,
|
||||
@@ -18,3 +19,5 @@ ol.render.canvas.Instruction = {
|
||||
SET_STROKE_STYLE: 11,
|
||||
STROKE: 12
|
||||
};
|
||||
|
||||
export default _ol_render_canvas_Instruction_;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
goog.provide('ol.render.canvas.LineStringReplay');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.render.canvas.Instruction');
|
||||
goog.require('ol.render.canvas.Replay');
|
||||
|
||||
/**
|
||||
* @module ol/render/canvas/LineStringReplay
|
||||
*/
|
||||
import _ol_ from '../../index.js';
|
||||
import _ol_render_canvas_Instruction_ from '../canvas/Instruction.js';
|
||||
import _ol_render_canvas_Replay_ from '../canvas/Replay.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -16,12 +16,13 @@ goog.require('ol.render.canvas.Replay');
|
||||
* @param {?} declutterTree Declutter tree.
|
||||
* @struct
|
||||
*/
|
||||
ol.render.canvas.LineStringReplay = function(
|
||||
var _ol_render_canvas_LineStringReplay_ = function(
|
||||
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
|
||||
ol.render.canvas.Replay.call(this,
|
||||
_ol_render_canvas_Replay_.call(this,
|
||||
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree);
|
||||
};
|
||||
ol.inherits(ol.render.canvas.LineStringReplay, ol.render.canvas.Replay);
|
||||
|
||||
_ol_.inherits(_ol_render_canvas_LineStringReplay_, _ol_render_canvas_Replay_);
|
||||
|
||||
|
||||
/**
|
||||
@@ -32,12 +33,12 @@ ol.inherits(ol.render.canvas.LineStringReplay, ol.render.canvas.Replay);
|
||||
* @private
|
||||
* @return {number} end.
|
||||
*/
|
||||
ol.render.canvas.LineStringReplay.prototype.drawFlatCoordinates_ = function(flatCoordinates, offset, end, stride) {
|
||||
_ol_render_canvas_LineStringReplay_.prototype.drawFlatCoordinates_ = function(flatCoordinates, offset, end, stride) {
|
||||
var myBegin = this.coordinates.length;
|
||||
var myEnd = this.appendFlatCoordinates(
|
||||
flatCoordinates, offset, end, stride, false, false);
|
||||
var moveToLineToInstruction =
|
||||
[ol.render.canvas.Instruction.MOVE_TO_LINE_TO, myBegin, myEnd];
|
||||
[_ol_render_canvas_Instruction_.MOVE_TO_LINE_TO, myBegin, myEnd];
|
||||
this.instructions.push(moveToLineToInstruction);
|
||||
this.hitDetectionInstructions.push(moveToLineToInstruction);
|
||||
return end;
|
||||
@@ -47,7 +48,7 @@ ol.render.canvas.LineStringReplay.prototype.drawFlatCoordinates_ = function(flat
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.canvas.LineStringReplay.prototype.drawLineString = function(lineStringGeometry, feature) {
|
||||
_ol_render_canvas_LineStringReplay_.prototype.drawLineString = function(lineStringGeometry, feature) {
|
||||
var state = this.state;
|
||||
var strokeStyle = state.strokeStyle;
|
||||
var lineWidth = state.lineWidth;
|
||||
@@ -57,16 +58,16 @@ ol.render.canvas.LineStringReplay.prototype.drawLineString = function(lineString
|
||||
this.updateStrokeStyle(state, this.applyStroke);
|
||||
this.beginGeometry(lineStringGeometry, feature);
|
||||
this.hitDetectionInstructions.push([
|
||||
ol.render.canvas.Instruction.SET_STROKE_STYLE,
|
||||
_ol_render_canvas_Instruction_.SET_STROKE_STYLE,
|
||||
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
|
||||
state.miterLimit, state.lineDash, state.lineDashOffset
|
||||
], [
|
||||
ol.render.canvas.Instruction.BEGIN_PATH
|
||||
_ol_render_canvas_Instruction_.BEGIN_PATH
|
||||
]);
|
||||
var flatCoordinates = lineStringGeometry.getFlatCoordinates();
|
||||
var stride = lineStringGeometry.getStride();
|
||||
this.drawFlatCoordinates_(flatCoordinates, 0, flatCoordinates.length, stride);
|
||||
this.hitDetectionInstructions.push([ol.render.canvas.Instruction.STROKE]);
|
||||
this.hitDetectionInstructions.push([_ol_render_canvas_Instruction_.STROKE]);
|
||||
this.endGeometry(lineStringGeometry, feature);
|
||||
};
|
||||
|
||||
@@ -74,7 +75,7 @@ ol.render.canvas.LineStringReplay.prototype.drawLineString = function(lineString
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.canvas.LineStringReplay.prototype.drawMultiLineString = function(multiLineStringGeometry, feature) {
|
||||
_ol_render_canvas_LineStringReplay_.prototype.drawMultiLineString = function(multiLineStringGeometry, feature) {
|
||||
var state = this.state;
|
||||
var strokeStyle = state.strokeStyle;
|
||||
var lineWidth = state.lineWidth;
|
||||
@@ -84,11 +85,11 @@ ol.render.canvas.LineStringReplay.prototype.drawMultiLineString = function(multi
|
||||
this.updateStrokeStyle(state, this.applyStroke);
|
||||
this.beginGeometry(multiLineStringGeometry, feature);
|
||||
this.hitDetectionInstructions.push([
|
||||
ol.render.canvas.Instruction.SET_STROKE_STYLE,
|
||||
_ol_render_canvas_Instruction_.SET_STROKE_STYLE,
|
||||
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
|
||||
state.miterLimit, state.lineDash, state.lineDashOffset
|
||||
], [
|
||||
ol.render.canvas.Instruction.BEGIN_PATH
|
||||
_ol_render_canvas_Instruction_.BEGIN_PATH
|
||||
]);
|
||||
var ends = multiLineStringGeometry.getEnds();
|
||||
var flatCoordinates = multiLineStringGeometry.getFlatCoordinates();
|
||||
@@ -99,7 +100,7 @@ ol.render.canvas.LineStringReplay.prototype.drawMultiLineString = function(multi
|
||||
offset = this.drawFlatCoordinates_(
|
||||
flatCoordinates, offset, ends[i], stride);
|
||||
}
|
||||
this.hitDetectionInstructions.push([ol.render.canvas.Instruction.STROKE]);
|
||||
this.hitDetectionInstructions.push([_ol_render_canvas_Instruction_.STROKE]);
|
||||
this.endGeometry(multiLineStringGeometry, feature);
|
||||
};
|
||||
|
||||
@@ -107,10 +108,10 @@ ol.render.canvas.LineStringReplay.prototype.drawMultiLineString = function(multi
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.canvas.LineStringReplay.prototype.finish = function() {
|
||||
_ol_render_canvas_LineStringReplay_.prototype.finish = function() {
|
||||
var state = this.state;
|
||||
if (state.lastStroke != undefined && state.lastStroke != this.coordinates.length) {
|
||||
this.instructions.push([ol.render.canvas.Instruction.STROKE]);
|
||||
this.instructions.push([_ol_render_canvas_Instruction_.STROKE]);
|
||||
}
|
||||
this.reverseHitDetectionInstructions();
|
||||
this.state = null;
|
||||
@@ -120,12 +121,13 @@ ol.render.canvas.LineStringReplay.prototype.finish = function() {
|
||||
/**
|
||||
* @inheritDoc.
|
||||
*/
|
||||
ol.render.canvas.LineStringReplay.prototype.applyStroke = function(state) {
|
||||
_ol_render_canvas_LineStringReplay_.prototype.applyStroke = function(state) {
|
||||
if (state.lastStroke != undefined && state.lastStroke != this.coordinates.length) {
|
||||
this.instructions.push([ol.render.canvas.Instruction.STROKE]);
|
||||
this.instructions.push([_ol_render_canvas_Instruction_.STROKE]);
|
||||
state.lastStroke = this.coordinates.length;
|
||||
}
|
||||
state.lastStroke = 0;
|
||||
ol.render.canvas.Replay.prototype.applyStroke.call(this, state);
|
||||
this.instructions.push([ol.render.canvas.Instruction.BEGIN_PATH]);
|
||||
_ol_render_canvas_Replay_.prototype.applyStroke.call(this, state);
|
||||
this.instructions.push([_ol_render_canvas_Instruction_.BEGIN_PATH]);
|
||||
};
|
||||
export default _ol_render_canvas_LineStringReplay_;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
goog.provide('ol.render.canvas.PolygonReplay');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.color');
|
||||
goog.require('ol.geom.flat.simplify');
|
||||
goog.require('ol.render.canvas');
|
||||
goog.require('ol.render.canvas.Instruction');
|
||||
goog.require('ol.render.canvas.Replay');
|
||||
|
||||
/**
|
||||
* @module ol/render/canvas/PolygonReplay
|
||||
*/
|
||||
import _ol_ from '../../index.js';
|
||||
import _ol_color_ from '../../color.js';
|
||||
import _ol_geom_flat_simplify_ from '../../geom/flat/simplify.js';
|
||||
import _ol_render_canvas_ from '../canvas.js';
|
||||
import _ol_render_canvas_Instruction_ from '../canvas/Instruction.js';
|
||||
import _ol_render_canvas_Replay_ from '../canvas/Replay.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -19,12 +19,13 @@ goog.require('ol.render.canvas.Replay');
|
||||
* @param {?} declutterTree Declutter tree.
|
||||
* @struct
|
||||
*/
|
||||
ol.render.canvas.PolygonReplay = function(
|
||||
var _ol_render_canvas_PolygonReplay_ = function(
|
||||
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
|
||||
ol.render.canvas.Replay.call(this,
|
||||
_ol_render_canvas_Replay_.call(this,
|
||||
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree);
|
||||
};
|
||||
ol.inherits(ol.render.canvas.PolygonReplay, ol.render.canvas.Replay);
|
||||
|
||||
_ol_.inherits(_ol_render_canvas_PolygonReplay_, _ol_render_canvas_Replay_);
|
||||
|
||||
|
||||
/**
|
||||
@@ -35,12 +36,12 @@ ol.inherits(ol.render.canvas.PolygonReplay, ol.render.canvas.Replay);
|
||||
* @private
|
||||
* @return {number} End.
|
||||
*/
|
||||
ol.render.canvas.PolygonReplay.prototype.drawFlatCoordinatess_ = function(flatCoordinates, offset, ends, stride) {
|
||||
_ol_render_canvas_PolygonReplay_.prototype.drawFlatCoordinatess_ = function(flatCoordinates, offset, ends, stride) {
|
||||
var state = this.state;
|
||||
var fill = state.fillStyle !== undefined;
|
||||
var stroke = state.strokeStyle != undefined;
|
||||
var numEnds = ends.length;
|
||||
var beginPathInstruction = [ol.render.canvas.Instruction.BEGIN_PATH];
|
||||
var beginPathInstruction = [_ol_render_canvas_Instruction_.BEGIN_PATH];
|
||||
this.instructions.push(beginPathInstruction);
|
||||
this.hitDetectionInstructions.push(beginPathInstruction);
|
||||
for (var i = 0; i < numEnds; ++i) {
|
||||
@@ -49,25 +50,25 @@ ol.render.canvas.PolygonReplay.prototype.drawFlatCoordinatess_ = function(flatCo
|
||||
var myEnd = this.appendFlatCoordinates(
|
||||
flatCoordinates, offset, end, stride, true, !stroke);
|
||||
var moveToLineToInstruction =
|
||||
[ol.render.canvas.Instruction.MOVE_TO_LINE_TO, myBegin, myEnd];
|
||||
[_ol_render_canvas_Instruction_.MOVE_TO_LINE_TO, myBegin, myEnd];
|
||||
this.instructions.push(moveToLineToInstruction);
|
||||
this.hitDetectionInstructions.push(moveToLineToInstruction);
|
||||
if (stroke) {
|
||||
// Performance optimization: only call closePath() when we have a stroke.
|
||||
// Otherwise the ring is closed already (see appendFlatCoordinates above).
|
||||
var closePathInstruction = [ol.render.canvas.Instruction.CLOSE_PATH];
|
||||
var closePathInstruction = [_ol_render_canvas_Instruction_.CLOSE_PATH];
|
||||
this.instructions.push(closePathInstruction);
|
||||
this.hitDetectionInstructions.push(closePathInstruction);
|
||||
}
|
||||
offset = end;
|
||||
}
|
||||
var fillInstruction = [ol.render.canvas.Instruction.FILL];
|
||||
var fillInstruction = [_ol_render_canvas_Instruction_.FILL];
|
||||
this.hitDetectionInstructions.push(fillInstruction);
|
||||
if (fill) {
|
||||
this.instructions.push(fillInstruction);
|
||||
}
|
||||
if (stroke) {
|
||||
var strokeInstruction = [ol.render.canvas.Instruction.STROKE];
|
||||
var strokeInstruction = [_ol_render_canvas_Instruction_.STROKE];
|
||||
this.instructions.push(strokeInstruction);
|
||||
this.hitDetectionInstructions.push(strokeInstruction);
|
||||
}
|
||||
@@ -78,7 +79,7 @@ ol.render.canvas.PolygonReplay.prototype.drawFlatCoordinatess_ = function(flatCo
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.canvas.PolygonReplay.prototype.drawCircle = function(circleGeometry, feature) {
|
||||
_ol_render_canvas_PolygonReplay_.prototype.drawCircle = function(circleGeometry, feature) {
|
||||
var state = this.state;
|
||||
var fillStyle = state.fillStyle;
|
||||
var strokeStyle = state.strokeStyle;
|
||||
@@ -89,12 +90,12 @@ ol.render.canvas.PolygonReplay.prototype.drawCircle = function(circleGeometry, f
|
||||
this.beginGeometry(circleGeometry, feature);
|
||||
// always fill the circle for hit detection
|
||||
this.hitDetectionInstructions.push([
|
||||
ol.render.canvas.Instruction.SET_FILL_STYLE,
|
||||
ol.color.asString(ol.render.canvas.defaultFillStyle)
|
||||
_ol_render_canvas_Instruction_.SET_FILL_STYLE,
|
||||
_ol_color_.asString(_ol_render_canvas_.defaultFillStyle)
|
||||
]);
|
||||
if (state.strokeStyle !== undefined) {
|
||||
this.hitDetectionInstructions.push([
|
||||
ol.render.canvas.Instruction.SET_STROKE_STYLE,
|
||||
_ol_render_canvas_Instruction_.SET_STROKE_STYLE,
|
||||
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
|
||||
state.miterLimit, state.lineDash, state.lineDashOffset
|
||||
]);
|
||||
@@ -104,17 +105,17 @@ ol.render.canvas.PolygonReplay.prototype.drawCircle = function(circleGeometry, f
|
||||
var myBegin = this.coordinates.length;
|
||||
this.appendFlatCoordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, stride, false, false);
|
||||
var beginPathInstruction = [ol.render.canvas.Instruction.BEGIN_PATH];
|
||||
var circleInstruction = [ol.render.canvas.Instruction.CIRCLE, myBegin];
|
||||
var beginPathInstruction = [_ol_render_canvas_Instruction_.BEGIN_PATH];
|
||||
var circleInstruction = [_ol_render_canvas_Instruction_.CIRCLE, myBegin];
|
||||
this.instructions.push(beginPathInstruction, circleInstruction);
|
||||
this.hitDetectionInstructions.push(beginPathInstruction, circleInstruction);
|
||||
var fillInstruction = [ol.render.canvas.Instruction.FILL];
|
||||
var fillInstruction = [_ol_render_canvas_Instruction_.FILL];
|
||||
this.hitDetectionInstructions.push(fillInstruction);
|
||||
if (state.fillStyle !== undefined) {
|
||||
this.instructions.push(fillInstruction);
|
||||
}
|
||||
if (state.strokeStyle !== undefined) {
|
||||
var strokeInstruction = [ol.render.canvas.Instruction.STROKE];
|
||||
var strokeInstruction = [_ol_render_canvas_Instruction_.STROKE];
|
||||
this.instructions.push(strokeInstruction);
|
||||
this.hitDetectionInstructions.push(strokeInstruction);
|
||||
}
|
||||
@@ -125,18 +126,18 @@ ol.render.canvas.PolygonReplay.prototype.drawCircle = function(circleGeometry, f
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.canvas.PolygonReplay.prototype.drawPolygon = function(polygonGeometry, feature) {
|
||||
_ol_render_canvas_PolygonReplay_.prototype.drawPolygon = function(polygonGeometry, feature) {
|
||||
var state = this.state;
|
||||
this.setFillStrokeStyles_(polygonGeometry);
|
||||
this.beginGeometry(polygonGeometry, feature);
|
||||
// always fill the polygon for hit detection
|
||||
this.hitDetectionInstructions.push([
|
||||
ol.render.canvas.Instruction.SET_FILL_STYLE,
|
||||
ol.color.asString(ol.render.canvas.defaultFillStyle)]
|
||||
_ol_render_canvas_Instruction_.SET_FILL_STYLE,
|
||||
_ol_color_.asString(_ol_render_canvas_.defaultFillStyle)]
|
||||
);
|
||||
if (state.strokeStyle !== undefined) {
|
||||
this.hitDetectionInstructions.push([
|
||||
ol.render.canvas.Instruction.SET_STROKE_STYLE,
|
||||
_ol_render_canvas_Instruction_.SET_STROKE_STYLE,
|
||||
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
|
||||
state.miterLimit, state.lineDash, state.lineDashOffset
|
||||
]);
|
||||
@@ -152,7 +153,7 @@ ol.render.canvas.PolygonReplay.prototype.drawPolygon = function(polygonGeometry,
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.canvas.PolygonReplay.prototype.drawMultiPolygon = function(multiPolygonGeometry, feature) {
|
||||
_ol_render_canvas_PolygonReplay_.prototype.drawMultiPolygon = function(multiPolygonGeometry, feature) {
|
||||
var state = this.state;
|
||||
var fillStyle = state.fillStyle;
|
||||
var strokeStyle = state.strokeStyle;
|
||||
@@ -163,12 +164,12 @@ ol.render.canvas.PolygonReplay.prototype.drawMultiPolygon = function(multiPolygo
|
||||
this.beginGeometry(multiPolygonGeometry, feature);
|
||||
// always fill the multi-polygon for hit detection
|
||||
this.hitDetectionInstructions.push([
|
||||
ol.render.canvas.Instruction.SET_FILL_STYLE,
|
||||
ol.color.asString(ol.render.canvas.defaultFillStyle)
|
||||
_ol_render_canvas_Instruction_.SET_FILL_STYLE,
|
||||
_ol_color_.asString(_ol_render_canvas_.defaultFillStyle)
|
||||
]);
|
||||
if (state.strokeStyle !== undefined) {
|
||||
this.hitDetectionInstructions.push([
|
||||
ol.render.canvas.Instruction.SET_STROKE_STYLE,
|
||||
_ol_render_canvas_Instruction_.SET_STROKE_STYLE,
|
||||
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
|
||||
state.miterLimit, state.lineDash, state.lineDashOffset
|
||||
]);
|
||||
@@ -189,7 +190,7 @@ ol.render.canvas.PolygonReplay.prototype.drawMultiPolygon = function(multiPolygo
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.canvas.PolygonReplay.prototype.finish = function() {
|
||||
_ol_render_canvas_PolygonReplay_.prototype.finish = function() {
|
||||
this.reverseHitDetectionInstructions();
|
||||
this.state = null;
|
||||
// We want to preserve topology when drawing polygons. Polygons are
|
||||
@@ -201,7 +202,7 @@ ol.render.canvas.PolygonReplay.prototype.finish = function() {
|
||||
var coordinates = this.coordinates;
|
||||
var i, ii;
|
||||
for (i = 0, ii = coordinates.length; i < ii; ++i) {
|
||||
coordinates[i] = ol.geom.flat.simplify.snap(coordinates[i], tolerance);
|
||||
coordinates[i] = _ol_geom_flat_simplify_.snap(coordinates[i], tolerance);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -211,7 +212,7 @@ ol.render.canvas.PolygonReplay.prototype.finish = function() {
|
||||
* @private
|
||||
* @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry.
|
||||
*/
|
||||
ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyles_ = function(geometry) {
|
||||
_ol_render_canvas_PolygonReplay_.prototype.setFillStrokeStyles_ = function(geometry) {
|
||||
var state = this.state;
|
||||
var fillStyle = state.fillStyle;
|
||||
if (fillStyle !== undefined) {
|
||||
@@ -221,3 +222,4 @@ ol.render.canvas.PolygonReplay.prototype.setFillStrokeStyles_ = function(geometr
|
||||
this.updateStrokeStyle(state, this.applyStroke);
|
||||
}
|
||||
};
|
||||
export default _ol_render_canvas_PolygonReplay_;
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
goog.provide('ol.render.canvas.Replay');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.colorlike');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.extent.Relationship');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
goog.require('ol.geom.flat.inflate');
|
||||
goog.require('ol.geom.flat.length');
|
||||
goog.require('ol.geom.flat.textpath');
|
||||
goog.require('ol.geom.flat.transform');
|
||||
goog.require('ol.has');
|
||||
goog.require('ol.obj');
|
||||
goog.require('ol.render.VectorContext');
|
||||
goog.require('ol.render.canvas');
|
||||
goog.require('ol.render.canvas.Instruction');
|
||||
goog.require('ol.render.replay');
|
||||
goog.require('ol.transform');
|
||||
|
||||
/**
|
||||
* @module ol/render/canvas/Replay
|
||||
*/
|
||||
import _ol_ from '../../index.js';
|
||||
import _ol_array_ from '../../array.js';
|
||||
import _ol_colorlike_ from '../../colorlike.js';
|
||||
import _ol_extent_ from '../../extent.js';
|
||||
import _ol_extent_Relationship_ from '../../extent/Relationship.js';
|
||||
import _ol_geom_GeometryType_ from '../../geom/GeometryType.js';
|
||||
import _ol_geom_flat_inflate_ from '../../geom/flat/inflate.js';
|
||||
import _ol_geom_flat_length_ from '../../geom/flat/length.js';
|
||||
import _ol_geom_flat_textpath_ from '../../geom/flat/textpath.js';
|
||||
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
|
||||
import _ol_has_ from '../../has.js';
|
||||
import _ol_obj_ from '../../obj.js';
|
||||
import _ol_render_VectorContext_ from '../VectorContext.js';
|
||||
import _ol_render_canvas_ from '../canvas.js';
|
||||
import _ol_render_canvas_Instruction_ from '../canvas/Instruction.js';
|
||||
import _ol_render_replay_ from '../replay.js';
|
||||
import _ol_transform_ from '../../transform.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -30,8 +30,8 @@ goog.require('ol.transform');
|
||||
* @param {?} declutterTree Declutter tree.
|
||||
* @struct
|
||||
*/
|
||||
ol.render.canvas.Replay = function(tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
|
||||
ol.render.VectorContext.call(this);
|
||||
var _ol_render_canvas_Replay_ = function(tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
|
||||
_ol_render_VectorContext_.call(this);
|
||||
|
||||
/**
|
||||
* @type {?}
|
||||
@@ -42,7 +42,7 @@ ol.render.canvas.Replay = function(tolerance, maxExtent, resolution, pixelRatio,
|
||||
* @private
|
||||
* @type {ol.Extent}
|
||||
*/
|
||||
this.tmpExtent_ = ol.extent.createEmpty();
|
||||
this.tmpExtent_ = _ol_extent_.createEmpty();
|
||||
|
||||
/**
|
||||
* @protected
|
||||
@@ -128,7 +128,7 @@ ol.render.canvas.Replay = function(tolerance, maxExtent, resolution, pixelRatio,
|
||||
* @private
|
||||
* @type {!ol.Transform}
|
||||
*/
|
||||
this.renderedTransform_ = ol.transform.create();
|
||||
this.renderedTransform_ = _ol_transform_.create();
|
||||
|
||||
/**
|
||||
* @protected
|
||||
@@ -158,15 +158,16 @@ ol.render.canvas.Replay = function(tolerance, maxExtent, resolution, pixelRatio,
|
||||
* @private
|
||||
* @type {!ol.Transform}
|
||||
*/
|
||||
this.tmpLocalTransform_ = ol.transform.create();
|
||||
this.tmpLocalTransform_ = _ol_transform_.create();
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!ol.Transform}
|
||||
*/
|
||||
this.resetTransform_ = ol.transform.create();
|
||||
this.resetTransform_ = _ol_transform_.create();
|
||||
};
|
||||
ol.inherits(ol.render.canvas.Replay, ol.render.VectorContext);
|
||||
|
||||
_ol_.inherits(_ol_render_canvas_Replay_, _ol_render_VectorContext_);
|
||||
|
||||
|
||||
/**
|
||||
@@ -178,7 +179,7 @@ ol.inherits(ol.render.canvas.Replay, ol.render.VectorContext);
|
||||
* @param {Array.<*>} fillInstruction Fill instruction.
|
||||
* @param {Array.<*>} strokeInstruction Stroke instruction.
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.replayTextBackground_ = function(context, p1, p2, p3, p4,
|
||||
_ol_render_canvas_Replay_.prototype.replayTextBackground_ = function(context, p1, p2, p3, p4,
|
||||
fillInstruction, strokeInstruction) {
|
||||
context.beginPath();
|
||||
context.moveTo.apply(context, p1);
|
||||
@@ -217,7 +218,7 @@ ol.render.canvas.Replay.prototype.replayTextBackground_ = function(context, p1,
|
||||
* @param {Array.<*>} fillInstruction Fill instruction.
|
||||
* @param {Array.<*>} strokeInstruction Stroke instruction.
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.replayImage_ = function(context, x, y, image,
|
||||
_ol_render_canvas_Replay_.prototype.replayImage_ = function(context, x, y, image,
|
||||
anchorX, anchorY, declutterGroup, height, opacity, originX, originY,
|
||||
rotation, scale, snapToPixel, width, padding, fillInstruction, strokeInstruction) {
|
||||
var fillStroke = fillInstruction || strokeInstruction;
|
||||
@@ -254,16 +255,16 @@ ol.render.canvas.Replay.prototype.replayImage_ = function(context, x, y, image,
|
||||
if (rotation !== 0) {
|
||||
var centerX = x + anchorX;
|
||||
var centerY = y + anchorY;
|
||||
transform = ol.transform.compose(localTransform,
|
||||
transform = _ol_transform_.compose(localTransform,
|
||||
centerX, centerY, 1, 1, rotation, -centerX, -centerY);
|
||||
|
||||
ol.extent.createOrUpdateEmpty(box);
|
||||
ol.extent.extendCoordinate(box, ol.transform.apply(localTransform, p1));
|
||||
ol.extent.extendCoordinate(box, ol.transform.apply(localTransform, p2));
|
||||
ol.extent.extendCoordinate(box, ol.transform.apply(localTransform, p3));
|
||||
ol.extent.extendCoordinate(box, ol.transform.apply(localTransform, p4));
|
||||
_ol_extent_.createOrUpdateEmpty(box);
|
||||
_ol_extent_.extendCoordinate(box, _ol_transform_.apply(localTransform, p1));
|
||||
_ol_extent_.extendCoordinate(box, _ol_transform_.apply(localTransform, p2));
|
||||
_ol_extent_.extendCoordinate(box, _ol_transform_.apply(localTransform, p3));
|
||||
_ol_extent_.extendCoordinate(box, _ol_transform_.apply(localTransform, p4));
|
||||
} else {
|
||||
ol.extent.createOrUpdate(boxX, boxY, boxX + boxW, boxY + boxH, box);
|
||||
_ol_extent_.createOrUpdate(boxX, boxY, boxX + boxW, boxY + boxH, box);
|
||||
}
|
||||
var canvas = context.canvas;
|
||||
var intersects = box[0] <= canvas.width && box[2] >= 0 && box[1] <= canvas.height && box[3] >= 0;
|
||||
@@ -277,7 +278,7 @@ ol.render.canvas.Replay.prototype.replayImage_ = function(context, x, y, image,
|
||||
if (!intersects && declutterGroup[4] == 1) {
|
||||
return;
|
||||
}
|
||||
ol.extent.extend(declutterGroup, box);
|
||||
_ol_extent_.extend(declutterGroup, box);
|
||||
var declutterArgs = intersects ?
|
||||
[context, transform ? transform.slice(0) : null, opacity, image, originX, originY, w, h, x, y, scale] :
|
||||
null;
|
||||
@@ -291,7 +292,7 @@ ol.render.canvas.Replay.prototype.replayImage_ = function(context, x, y, image,
|
||||
/** @type {Array.<*>} */ (fillInstruction),
|
||||
/** @type {Array.<*>} */ (strokeInstruction));
|
||||
}
|
||||
ol.render.canvas.drawImage(context, transform, opacity, image, originX, originY, w, h, x, y, scale);
|
||||
_ol_render_canvas_.drawImage(context, transform, opacity, image, originX, originY, w, h, x, y, scale);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -301,7 +302,7 @@ ol.render.canvas.Replay.prototype.replayImage_ = function(context, x, y, image,
|
||||
* @param {Array.<number>} dashArray Dash array.
|
||||
* @return {Array.<number>} Dash array with pixel ratio applied
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.applyPixelRatio = function(dashArray) {
|
||||
_ol_render_canvas_Replay_.prototype.applyPixelRatio = function(dashArray) {
|
||||
var pixelRatio = this.pixelRatio;
|
||||
return pixelRatio == 1 ? dashArray : dashArray.map(function(dash) {
|
||||
return dash * pixelRatio;
|
||||
@@ -319,7 +320,7 @@ ol.render.canvas.Replay.prototype.applyPixelRatio = function(dashArray) {
|
||||
* @protected
|
||||
* @return {number} My end.
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.appendFlatCoordinates = function(flatCoordinates, offset, end, stride, closed, skipFirst) {
|
||||
_ol_render_canvas_Replay_.prototype.appendFlatCoordinates = function(flatCoordinates, offset, end, stride, closed, skipFirst) {
|
||||
|
||||
var myEnd = this.coordinates.length;
|
||||
var extent = this.getBufferedMaxExtent();
|
||||
@@ -334,7 +335,7 @@ ol.render.canvas.Replay.prototype.appendFlatCoordinates = function(flatCoordinat
|
||||
for (i = offset + stride; i < end; i += stride) {
|
||||
nextCoord[0] = flatCoordinates[i];
|
||||
nextCoord[1] = flatCoordinates[i + 1];
|
||||
nextRel = ol.extent.coordinateRelationship(extent, nextCoord);
|
||||
nextRel = _ol_extent_.coordinateRelationship(extent, nextCoord);
|
||||
if (nextRel !== lastRel) {
|
||||
if (skipped) {
|
||||
this.coordinates[myEnd++] = lastCoord[0];
|
||||
@@ -343,7 +344,7 @@ ol.render.canvas.Replay.prototype.appendFlatCoordinates = function(flatCoordinat
|
||||
this.coordinates[myEnd++] = nextCoord[0];
|
||||
this.coordinates[myEnd++] = nextCoord[1];
|
||||
skipped = false;
|
||||
} else if (nextRel === ol.extent.Relationship.INTERSECTING) {
|
||||
} else if (nextRel === _ol_extent_Relationship_.INTERSECTING) {
|
||||
this.coordinates[myEnd++] = nextCoord[0];
|
||||
this.coordinates[myEnd++] = nextCoord[1];
|
||||
skipped = false;
|
||||
@@ -372,7 +373,7 @@ ol.render.canvas.Replay.prototype.appendFlatCoordinates = function(flatCoordinat
|
||||
* @param {Array.<number>} replayEnds Replay ends.
|
||||
* @return {number} Offset.
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.drawCustomCoordinates_ = function(flatCoordinates, offset, ends, stride, replayEnds) {
|
||||
_ol_render_canvas_Replay_.prototype.drawCustomCoordinates_ = function(flatCoordinates, offset, ends, stride, replayEnds) {
|
||||
for (var i = 0, ii = ends.length; i < ii; ++i) {
|
||||
var end = ends[i];
|
||||
var replayEnd = this.appendFlatCoordinates(flatCoordinates, offset, end, stride, false, false);
|
||||
@@ -386,14 +387,14 @@ ol.render.canvas.Replay.prototype.drawCustomCoordinates_ = function(flatCoordina
|
||||
/**
|
||||
* @inheritDoc.
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.drawCustom = function(geometry, feature, renderer) {
|
||||
_ol_render_canvas_Replay_.prototype.drawCustom = function(geometry, feature, renderer) {
|
||||
this.beginGeometry(geometry, feature);
|
||||
var type = geometry.getType();
|
||||
var stride = geometry.getStride();
|
||||
var replayBegin = this.coordinates.length;
|
||||
var flatCoordinates, replayEnd, replayEnds, replayEndss;
|
||||
var offset;
|
||||
if (type == ol.geom.GeometryType.MULTI_POLYGON) {
|
||||
if (type == _ol_geom_GeometryType_.MULTI_POLYGON) {
|
||||
geometry = /** @type {ol.geom.MultiPolygon} */ (geometry);
|
||||
flatCoordinates = geometry.getOrientedFlatCoordinates();
|
||||
replayEndss = [];
|
||||
@@ -404,29 +405,29 @@ ol.render.canvas.Replay.prototype.drawCustom = function(geometry, feature, rende
|
||||
offset = this.drawCustomCoordinates_(flatCoordinates, offset, endss[i], stride, myEnds);
|
||||
replayEndss.push(myEnds);
|
||||
}
|
||||
this.instructions.push([ol.render.canvas.Instruction.CUSTOM,
|
||||
replayBegin, replayEndss, geometry, renderer, ol.geom.flat.inflate.coordinatesss]);
|
||||
} else if (type == ol.geom.GeometryType.POLYGON || type == ol.geom.GeometryType.MULTI_LINE_STRING) {
|
||||
this.instructions.push([_ol_render_canvas_Instruction_.CUSTOM,
|
||||
replayBegin, replayEndss, geometry, renderer, _ol_geom_flat_inflate_.coordinatesss]);
|
||||
} else if (type == _ol_geom_GeometryType_.POLYGON || type == _ol_geom_GeometryType_.MULTI_LINE_STRING) {
|
||||
replayEnds = [];
|
||||
flatCoordinates = (type == ol.geom.GeometryType.POLYGON) ?
|
||||
flatCoordinates = (type == _ol_geom_GeometryType_.POLYGON) ?
|
||||
/** @type {ol.geom.Polygon} */ (geometry).getOrientedFlatCoordinates() :
|
||||
geometry.getFlatCoordinates();
|
||||
offset = this.drawCustomCoordinates_(flatCoordinates, 0,
|
||||
/** @type {ol.geom.Polygon|ol.geom.MultiLineString} */ (geometry).getEnds(),
|
||||
stride, replayEnds);
|
||||
this.instructions.push([ol.render.canvas.Instruction.CUSTOM,
|
||||
replayBegin, replayEnds, geometry, renderer, ol.geom.flat.inflate.coordinatess]);
|
||||
} else if (type == ol.geom.GeometryType.LINE_STRING || type == ol.geom.GeometryType.MULTI_POINT) {
|
||||
this.instructions.push([_ol_render_canvas_Instruction_.CUSTOM,
|
||||
replayBegin, replayEnds, geometry, renderer, _ol_geom_flat_inflate_.coordinatess]);
|
||||
} else if (type == _ol_geom_GeometryType_.LINE_STRING || type == _ol_geom_GeometryType_.MULTI_POINT) {
|
||||
flatCoordinates = geometry.getFlatCoordinates();
|
||||
replayEnd = this.appendFlatCoordinates(
|
||||
flatCoordinates, 0, flatCoordinates.length, stride, false, false);
|
||||
this.instructions.push([ol.render.canvas.Instruction.CUSTOM,
|
||||
replayBegin, replayEnd, geometry, renderer, ol.geom.flat.inflate.coordinates]);
|
||||
} else if (type == ol.geom.GeometryType.POINT) {
|
||||
this.instructions.push([_ol_render_canvas_Instruction_.CUSTOM,
|
||||
replayBegin, replayEnd, geometry, renderer, _ol_geom_flat_inflate_.coordinates]);
|
||||
} else if (type == _ol_geom_GeometryType_.POINT) {
|
||||
flatCoordinates = geometry.getFlatCoordinates();
|
||||
this.coordinates.push(flatCoordinates[0], flatCoordinates[1]);
|
||||
replayEnd = this.coordinates.length;
|
||||
this.instructions.push([ol.render.canvas.Instruction.CUSTOM,
|
||||
this.instructions.push([_ol_render_canvas_Instruction_.CUSTOM,
|
||||
replayBegin, replayEnd, geometry, renderer]);
|
||||
}
|
||||
this.endGeometry(geometry, feature);
|
||||
@@ -438,12 +439,12 @@ ol.render.canvas.Replay.prototype.drawCustom = function(geometry, feature, rende
|
||||
* @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry.
|
||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.beginGeometry = function(geometry, feature) {
|
||||
_ol_render_canvas_Replay_.prototype.beginGeometry = function(geometry, feature) {
|
||||
this.beginGeometryInstruction1_ =
|
||||
[ol.render.canvas.Instruction.BEGIN_GEOMETRY, feature, 0];
|
||||
[_ol_render_canvas_Instruction_.BEGIN_GEOMETRY, feature, 0];
|
||||
this.instructions.push(this.beginGeometryInstruction1_);
|
||||
this.beginGeometryInstruction2_ =
|
||||
[ol.render.canvas.Instruction.BEGIN_GEOMETRY, feature, 0];
|
||||
[_ol_render_canvas_Instruction_.BEGIN_GEOMETRY, feature, 0];
|
||||
this.hitDetectionInstructions.push(this.beginGeometryInstruction2_);
|
||||
};
|
||||
|
||||
@@ -452,15 +453,15 @@ ol.render.canvas.Replay.prototype.beginGeometry = function(geometry, feature) {
|
||||
* @private
|
||||
* @param {CanvasRenderingContext2D} context Context.
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.fill_ = function(context) {
|
||||
_ol_render_canvas_Replay_.prototype.fill_ = function(context) {
|
||||
if (this.fillOrigin_) {
|
||||
var origin = ol.transform.apply(this.renderedTransform_, this.fillOrigin_.slice());
|
||||
var origin = _ol_transform_.apply(this.renderedTransform_, this.fillOrigin_.slice());
|
||||
context.translate(origin[0], origin[1]);
|
||||
context.rotate(this.viewRotation_);
|
||||
}
|
||||
context.fill();
|
||||
if (this.fillOrigin_) {
|
||||
context.setTransform.apply(context, ol.render.canvas.resetTransform_);
|
||||
context.setTransform.apply(context, _ol_render_canvas_.resetTransform_);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -470,13 +471,13 @@ ol.render.canvas.Replay.prototype.fill_ = function(context) {
|
||||
* @param {CanvasRenderingContext2D} context Context.
|
||||
* @param {Array.<*>} instruction Instruction.
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.setStrokeStyle_ = function(context, instruction) {
|
||||
_ol_render_canvas_Replay_.prototype.setStrokeStyle_ = function(context, instruction) {
|
||||
context.strokeStyle = /** @type {ol.ColorLike} */ (instruction[1]);
|
||||
context.lineWidth = /** @type {number} */ (instruction[2]);
|
||||
context.lineCap = /** @type {string} */ (instruction[3]);
|
||||
context.lineJoin = /** @type {string} */ (instruction[4]);
|
||||
context.miterLimit = /** @type {number} */ (instruction[5]);
|
||||
if (ol.has.CANVAS_LINE_DASH) {
|
||||
if (_ol_has_.CANVAS_LINE_DASH) {
|
||||
context.lineDashOffset = /** @type {number} */ (instruction[7]);
|
||||
context.setLineDash(/** @type {Array.<number>} */ (instruction[6]));
|
||||
}
|
||||
@@ -487,7 +488,7 @@ ol.render.canvas.Replay.prototype.setStrokeStyle_ = function(context, instructio
|
||||
* @param {ol.DeclutterGroup} declutterGroup Declutter group.
|
||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.renderDeclutter_ = function(declutterGroup, feature) {
|
||||
_ol_render_canvas_Replay_.prototype.renderDeclutter_ = function(declutterGroup, feature) {
|
||||
if (declutterGroup && declutterGroup.length > 5) {
|
||||
var groupCount = declutterGroup[4];
|
||||
if (groupCount == 1 || groupCount == declutterGroup.length - 5) {
|
||||
@@ -501,7 +502,7 @@ ol.render.canvas.Replay.prototype.renderDeclutter_ = function(declutterGroup, fe
|
||||
};
|
||||
if (!this.declutterTree.collides(box)) {
|
||||
this.declutterTree.insert(box);
|
||||
var drawImage = ol.render.canvas.drawImage;
|
||||
var drawImage = _ol_render_canvas_.drawImage;
|
||||
for (var j = 5, jj = declutterGroup.length; j < jj; ++j) {
|
||||
var declutterData = /** @type {Array} */ (declutterGroup[j]);
|
||||
if (declutterData) {
|
||||
@@ -515,7 +516,7 @@ ol.render.canvas.Replay.prototype.renderDeclutter_ = function(declutterGroup, fe
|
||||
}
|
||||
}
|
||||
declutterGroup.length = 5;
|
||||
ol.extent.createOrUpdateEmpty(declutterGroup);
|
||||
_ol_extent_.createOrUpdateEmpty(declutterGroup);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -535,23 +536,23 @@ ol.render.canvas.Replay.prototype.renderDeclutter_ = function(declutterGroup, fe
|
||||
* @return {T|undefined} Callback result.
|
||||
* @template T
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
_ol_render_canvas_Replay_.prototype.replay_ = function(
|
||||
context, transform, skippedFeaturesHash,
|
||||
instructions, featureCallback, opt_hitExtent) {
|
||||
/** @type {Array.<number>} */
|
||||
var pixelCoordinates;
|
||||
if (this.pixelCoordinates_ && ol.array.equals(transform, this.renderedTransform_)) {
|
||||
if (this.pixelCoordinates_ && _ol_array_.equals(transform, this.renderedTransform_)) {
|
||||
pixelCoordinates = this.pixelCoordinates_;
|
||||
} else {
|
||||
if (!this.pixelCoordinates_) {
|
||||
this.pixelCoordinates_ = [];
|
||||
}
|
||||
pixelCoordinates = ol.geom.flat.transform.transform2D(
|
||||
pixelCoordinates = _ol_geom_flat_transform_.transform2D(
|
||||
this.coordinates, 0, this.coordinates.length, 2,
|
||||
transform, this.pixelCoordinates_);
|
||||
ol.transform.setFromArray(this.renderedTransform_, transform);
|
||||
_ol_transform_.setFromArray(this.renderedTransform_, transform);
|
||||
}
|
||||
var skipFeatures = !ol.obj.isEmpty(skippedFeaturesHash);
|
||||
var skipFeatures = !_ol_obj_.isEmpty(skippedFeaturesHash);
|
||||
var i = 0; // instruction index
|
||||
var ii = instructions.length; // end of instructions
|
||||
var d = 0; // data index
|
||||
@@ -580,20 +581,20 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
var type = /** @type {ol.render.canvas.Instruction} */ (instruction[0]);
|
||||
var /** @type {ol.Feature|ol.render.Feature} */ feature, x, y;
|
||||
switch (type) {
|
||||
case ol.render.canvas.Instruction.BEGIN_GEOMETRY:
|
||||
case _ol_render_canvas_Instruction_.BEGIN_GEOMETRY:
|
||||
feature = /** @type {ol.Feature|ol.render.Feature} */ (instruction[1]);
|
||||
if ((skipFeatures &&
|
||||
skippedFeaturesHash[ol.getUid(feature).toString()]) ||
|
||||
skippedFeaturesHash[_ol_.getUid(feature).toString()]) ||
|
||||
!feature.getGeometry()) {
|
||||
i = /** @type {number} */ (instruction[2]);
|
||||
} else if (opt_hitExtent !== undefined && !ol.extent.intersects(
|
||||
} else if (opt_hitExtent !== undefined && !_ol_extent_.intersects(
|
||||
opt_hitExtent, feature.getGeometry().getExtent())) {
|
||||
i = /** @type {number} */ (instruction[2]) + 1;
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
break;
|
||||
case ol.render.canvas.Instruction.BEGIN_PATH:
|
||||
case _ol_render_canvas_Instruction_.BEGIN_PATH:
|
||||
if (pendingFill > batchSize) {
|
||||
this.fill_(context);
|
||||
pendingFill = 0;
|
||||
@@ -608,7 +609,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
}
|
||||
++i;
|
||||
break;
|
||||
case ol.render.canvas.Instruction.CIRCLE:
|
||||
case _ol_render_canvas_Instruction_.CIRCLE:
|
||||
d = /** @type {number} */ (instruction[1]);
|
||||
var x1 = pixelCoordinates[d];
|
||||
var y1 = pixelCoordinates[d + 1];
|
||||
@@ -621,11 +622,11 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
context.arc(x1, y1, r, 0, 2 * Math.PI, true);
|
||||
++i;
|
||||
break;
|
||||
case ol.render.canvas.Instruction.CLOSE_PATH:
|
||||
case _ol_render_canvas_Instruction_.CLOSE_PATH:
|
||||
context.closePath();
|
||||
++i;
|
||||
break;
|
||||
case ol.render.canvas.Instruction.CUSTOM:
|
||||
case _ol_render_canvas_Instruction_.CUSTOM:
|
||||
d = /** @type {number} */ (instruction[1]);
|
||||
dd = instruction[2];
|
||||
var geometry = /** @type {ol.geom.SimpleGeometry} */ (instruction[3]);
|
||||
@@ -647,7 +648,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
renderer(coords, state);
|
||||
++i;
|
||||
break;
|
||||
case ol.render.canvas.Instruction.DRAW_IMAGE:
|
||||
case _ol_render_canvas_Instruction_.DRAW_IMAGE:
|
||||
d = /** @type {number} */ (instruction[1]);
|
||||
dd = /** @type {number} */ (instruction[2]);
|
||||
image = /** @type {HTMLCanvasElement|HTMLVideoElement|Image} */
|
||||
@@ -672,7 +673,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
backgroundFill = /** @type {boolean} */ (instruction[17]);
|
||||
backgroundStroke = /** @type {boolean} */ (instruction[18]);
|
||||
} else {
|
||||
padding = ol.render.canvas.defaultPadding;
|
||||
padding = _ol_render_canvas_.defaultPadding;
|
||||
backgroundFill = backgroundStroke = false;
|
||||
}
|
||||
|
||||
@@ -690,7 +691,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
this.renderDeclutter_(declutterGroup, feature);
|
||||
++i;
|
||||
break;
|
||||
case ol.render.canvas.Instruction.DRAW_CHARS:
|
||||
case _ol_render_canvas_Instruction_.DRAW_CHARS:
|
||||
var begin = /** @type {number} */ (instruction[1]);
|
||||
var end = /** @type {number} */ (instruction[2]);
|
||||
var baseline = /** @type {number} */ (instruction[3]);
|
||||
@@ -706,12 +707,12 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
var textKey = /** @type {string} */ (instruction[13]);
|
||||
var textScale = /** @type {number} */ (instruction[14]);
|
||||
|
||||
var pathLength = ol.geom.flat.length.lineString(pixelCoordinates, begin, end, 2);
|
||||
var pathLength = _ol_geom_flat_length_.lineString(pixelCoordinates, begin, end, 2);
|
||||
var textLength = measure(text);
|
||||
if (overflow || textLength <= pathLength) {
|
||||
var textAlign = /** @type {ol.render.canvas.TextReplay} */ (this).textStates[textKey].textAlign;
|
||||
var startM = (pathLength - textLength) * ol.render.replay.TEXT_ALIGN[textAlign];
|
||||
var parts = ol.geom.flat.textpath.lineString(
|
||||
var startM = (pathLength - textLength) * _ol_render_replay_.TEXT_ALIGN[textAlign];
|
||||
var parts = _ol_geom_flat_textpath_.lineString(
|
||||
pixelCoordinates, begin, end, 2, text, measure, startM, maxAngle);
|
||||
if (parts) {
|
||||
var c, cc, chars, label, part;
|
||||
@@ -726,7 +727,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
/** @type {number} */ (part[0]), /** @type {number} */ (part[1]), label,
|
||||
anchorX, anchorY, declutterGroup, label.height, 1, 0, 0,
|
||||
/** @type {number} */ (part[3]), textScale, false, label.width,
|
||||
ol.render.canvas.defaultPadding, null, null);
|
||||
_ol_render_canvas_.defaultPadding, null, null);
|
||||
}
|
||||
}
|
||||
if (fillKey) {
|
||||
@@ -740,7 +741,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
/** @type {number} */ (part[0]), /** @type {number} */ (part[1]), label,
|
||||
anchorX, anchorY, declutterGroup, label.height, 1, 0, 0,
|
||||
/** @type {number} */ (part[3]), textScale, false, label.width,
|
||||
ol.render.canvas.defaultPadding, null, null);
|
||||
_ol_render_canvas_.defaultPadding, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -748,7 +749,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
this.renderDeclutter_(declutterGroup, feature);
|
||||
++i;
|
||||
break;
|
||||
case ol.render.canvas.Instruction.END_GEOMETRY:
|
||||
case _ol_render_canvas_Instruction_.END_GEOMETRY:
|
||||
if (featureCallback !== undefined) {
|
||||
feature = /** @type {ol.Feature|ol.render.Feature} */ (instruction[1]);
|
||||
var result = featureCallback(feature);
|
||||
@@ -758,7 +759,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
}
|
||||
++i;
|
||||
break;
|
||||
case ol.render.canvas.Instruction.FILL:
|
||||
case _ol_render_canvas_Instruction_.FILL:
|
||||
if (batchSize) {
|
||||
pendingFill++;
|
||||
} else {
|
||||
@@ -766,7 +767,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
}
|
||||
++i;
|
||||
break;
|
||||
case ol.render.canvas.Instruction.MOVE_TO_LINE_TO:
|
||||
case _ol_render_canvas_Instruction_.MOVE_TO_LINE_TO:
|
||||
d = /** @type {number} */ (instruction[1]);
|
||||
dd = /** @type {number} */ (instruction[2]);
|
||||
x = pixelCoordinates[d];
|
||||
@@ -791,7 +792,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
}
|
||||
++i;
|
||||
break;
|
||||
case ol.render.canvas.Instruction.SET_FILL_STYLE:
|
||||
case _ol_render_canvas_Instruction_.SET_FILL_STYLE:
|
||||
lastFillInstruction = instruction;
|
||||
this.fillOrigin_ = instruction[2];
|
||||
|
||||
@@ -807,7 +808,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
context.fillStyle = /** @type {ol.ColorLike} */ (instruction[1]);
|
||||
++i;
|
||||
break;
|
||||
case ol.render.canvas.Instruction.SET_STROKE_STYLE:
|
||||
case _ol_render_canvas_Instruction_.SET_STROKE_STYLE:
|
||||
lastStrokeInstruction = instruction;
|
||||
if (pendingStroke) {
|
||||
context.stroke();
|
||||
@@ -816,7 +817,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
this.setStrokeStyle_(context, /** @type {Array.<*>} */ (instruction));
|
||||
++i;
|
||||
break;
|
||||
case ol.render.canvas.Instruction.STROKE:
|
||||
case _ol_render_canvas_Instruction_.STROKE:
|
||||
if (batchSize) {
|
||||
pendingStroke++;
|
||||
} else {
|
||||
@@ -846,7 +847,7 @@ ol.render.canvas.Replay.prototype.replay_ = function(
|
||||
* @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
|
||||
* to skip.
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.replay = function(
|
||||
_ol_render_canvas_Replay_.prototype.replay = function(
|
||||
context, transform, viewRotation, skippedFeaturesHash) {
|
||||
this.viewRotation_ = viewRotation;
|
||||
this.replay_(context, transform,
|
||||
@@ -867,7 +868,7 @@ ol.render.canvas.Replay.prototype.replay = function(
|
||||
* @return {T|undefined} Callback result.
|
||||
* @template T
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.replayHitDetection = function(
|
||||
_ol_render_canvas_Replay_.prototype.replayHitDetection = function(
|
||||
context, transform, viewRotation, skippedFeaturesHash,
|
||||
opt_featureCallback, opt_hitExtent) {
|
||||
this.viewRotation_ = viewRotation;
|
||||
@@ -879,7 +880,7 @@ ol.render.canvas.Replay.prototype.replayHitDetection = function(
|
||||
/**
|
||||
* Reverse the hit detection instructions.
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.reverseHitDetectionInstructions = function() {
|
||||
_ol_render_canvas_Replay_.prototype.reverseHitDetectionInstructions = function() {
|
||||
var hitDetectionInstructions = this.hitDetectionInstructions;
|
||||
// step 1 - reverse array
|
||||
hitDetectionInstructions.reverse();
|
||||
@@ -892,11 +893,11 @@ ol.render.canvas.Replay.prototype.reverseHitDetectionInstructions = function() {
|
||||
for (i = 0; i < n; ++i) {
|
||||
instruction = hitDetectionInstructions[i];
|
||||
type = /** @type {ol.render.canvas.Instruction} */ (instruction[0]);
|
||||
if (type == ol.render.canvas.Instruction.END_GEOMETRY) {
|
||||
if (type == _ol_render_canvas_Instruction_.END_GEOMETRY) {
|
||||
begin = i;
|
||||
} else if (type == ol.render.canvas.Instruction.BEGIN_GEOMETRY) {
|
||||
} else if (type == _ol_render_canvas_Instruction_.BEGIN_GEOMETRY) {
|
||||
instruction[2] = i;
|
||||
ol.array.reverseSubArray(this.hitDetectionInstructions, begin, i);
|
||||
_ol_array_.reverseSubArray(this.hitDetectionInstructions, begin, i);
|
||||
begin = -1;
|
||||
}
|
||||
}
|
||||
@@ -906,37 +907,37 @@ ol.render.canvas.Replay.prototype.reverseHitDetectionInstructions = function() {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
||||
_ol_render_canvas_Replay_.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
||||
var state = this.state;
|
||||
if (fillStyle) {
|
||||
var fillStyleColor = fillStyle.getColor();
|
||||
state.fillStyle = ol.colorlike.asColorLike(fillStyleColor ?
|
||||
fillStyleColor : ol.render.canvas.defaultFillStyle);
|
||||
state.fillStyle = _ol_colorlike_.asColorLike(fillStyleColor ?
|
||||
fillStyleColor : _ol_render_canvas_.defaultFillStyle);
|
||||
} else {
|
||||
state.fillStyle = undefined;
|
||||
}
|
||||
if (strokeStyle) {
|
||||
var strokeStyleColor = strokeStyle.getColor();
|
||||
state.strokeStyle = ol.colorlike.asColorLike(strokeStyleColor ?
|
||||
strokeStyleColor : ol.render.canvas.defaultStrokeStyle);
|
||||
state.strokeStyle = _ol_colorlike_.asColorLike(strokeStyleColor ?
|
||||
strokeStyleColor : _ol_render_canvas_.defaultStrokeStyle);
|
||||
var strokeStyleLineCap = strokeStyle.getLineCap();
|
||||
state.lineCap = strokeStyleLineCap !== undefined ?
|
||||
strokeStyleLineCap : ol.render.canvas.defaultLineCap;
|
||||
strokeStyleLineCap : _ol_render_canvas_.defaultLineCap;
|
||||
var strokeStyleLineDash = strokeStyle.getLineDash();
|
||||
state.lineDash = strokeStyleLineDash ?
|
||||
strokeStyleLineDash.slice() : ol.render.canvas.defaultLineDash;
|
||||
strokeStyleLineDash.slice() : _ol_render_canvas_.defaultLineDash;
|
||||
var strokeStyleLineDashOffset = strokeStyle.getLineDashOffset();
|
||||
state.lineDashOffset = strokeStyleLineDashOffset ?
|
||||
strokeStyleLineDashOffset : ol.render.canvas.defaultLineDashOffset;
|
||||
strokeStyleLineDashOffset : _ol_render_canvas_.defaultLineDashOffset;
|
||||
var strokeStyleLineJoin = strokeStyle.getLineJoin();
|
||||
state.lineJoin = strokeStyleLineJoin !== undefined ?
|
||||
strokeStyleLineJoin : ol.render.canvas.defaultLineJoin;
|
||||
strokeStyleLineJoin : _ol_render_canvas_.defaultLineJoin;
|
||||
var strokeStyleWidth = strokeStyle.getWidth();
|
||||
state.lineWidth = strokeStyleWidth !== undefined ?
|
||||
strokeStyleWidth : ol.render.canvas.defaultLineWidth;
|
||||
strokeStyleWidth : _ol_render_canvas_.defaultLineWidth;
|
||||
var strokeStyleMiterLimit = strokeStyle.getMiterLimit();
|
||||
state.miterLimit = strokeStyleMiterLimit !== undefined ?
|
||||
strokeStyleMiterLimit : ol.render.canvas.defaultMiterLimit;
|
||||
strokeStyleMiterLimit : _ol_render_canvas_.defaultMiterLimit;
|
||||
|
||||
if (state.lineWidth > this.maxLineWidth) {
|
||||
this.maxLineWidth = state.lineWidth;
|
||||
@@ -959,9 +960,9 @@ ol.render.canvas.Replay.prototype.setFillStrokeStyle = function(fillStyle, strok
|
||||
* @param {ol.CanvasFillStrokeState} state State.
|
||||
* @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry.
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.applyFill = function(state, geometry) {
|
||||
_ol_render_canvas_Replay_.prototype.applyFill = function(state, geometry) {
|
||||
var fillStyle = state.fillStyle;
|
||||
var fillInstruction = [ol.render.canvas.Instruction.SET_FILL_STYLE, fillStyle];
|
||||
var fillInstruction = [_ol_render_canvas_Instruction_.SET_FILL_STYLE, fillStyle];
|
||||
if (typeof fillStyle !== 'string') {
|
||||
var fillExtent = geometry.getExtent();
|
||||
fillInstruction.push([fillExtent[0], fillExtent[3]]);
|
||||
@@ -973,9 +974,9 @@ ol.render.canvas.Replay.prototype.applyFill = function(state, geometry) {
|
||||
/**
|
||||
* @param {ol.CanvasFillStrokeState} state State.
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.applyStroke = function(state) {
|
||||
_ol_render_canvas_Replay_.prototype.applyStroke = function(state) {
|
||||
this.instructions.push([
|
||||
ol.render.canvas.Instruction.SET_STROKE_STYLE,
|
||||
_ol_render_canvas_Instruction_.SET_STROKE_STYLE,
|
||||
state.strokeStyle, state.lineWidth * this.pixelRatio, state.lineCap,
|
||||
state.lineJoin, state.miterLimit,
|
||||
this.applyPixelRatio(state.lineDash), state.lineDashOffset * this.pixelRatio
|
||||
@@ -988,7 +989,7 @@ ol.render.canvas.Replay.prototype.applyStroke = function(state) {
|
||||
* @param {function(this:ol.render.canvas.Replay, ol.CanvasFillStrokeState, (ol.geom.Geometry|ol.render.Feature))} applyFill Apply fill.
|
||||
* @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry.
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.updateFillStyle = function(state, applyFill, geometry) {
|
||||
_ol_render_canvas_Replay_.prototype.updateFillStyle = function(state, applyFill, geometry) {
|
||||
var fillStyle = state.fillStyle;
|
||||
if (typeof fillStyle !== 'string' || state.currentFillStyle != fillStyle) {
|
||||
applyFill.call(this, state, geometry);
|
||||
@@ -1001,7 +1002,7 @@ ol.render.canvas.Replay.prototype.updateFillStyle = function(state, applyFill, g
|
||||
* @param {ol.CanvasFillStrokeState} state State.
|
||||
* @param {function(this:ol.render.canvas.Replay, ol.CanvasFillStrokeState)} applyStroke Apply stroke.
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.updateStrokeStyle = function(state, applyStroke) {
|
||||
_ol_render_canvas_Replay_.prototype.updateStrokeStyle = function(state, applyStroke) {
|
||||
var strokeStyle = state.strokeStyle;
|
||||
var lineCap = state.lineCap;
|
||||
var lineDash = state.lineDash;
|
||||
@@ -1011,7 +1012,7 @@ ol.render.canvas.Replay.prototype.updateStrokeStyle = function(state, applyStrok
|
||||
var miterLimit = state.miterLimit;
|
||||
if (state.currentStrokeStyle != strokeStyle ||
|
||||
state.currentLineCap != lineCap ||
|
||||
(lineDash != state.currentLineDash && !ol.array.equals(state.currentLineDash, lineDash)) ||
|
||||
(lineDash != state.currentLineDash && !_ol_array_.equals(state.currentLineDash, lineDash)) ||
|
||||
state.currentLineDashOffset != lineDashOffset ||
|
||||
state.currentLineJoin != lineJoin ||
|
||||
state.currentLineWidth != lineWidth ||
|
||||
@@ -1032,13 +1033,13 @@ ol.render.canvas.Replay.prototype.updateStrokeStyle = function(state, applyStrok
|
||||
* @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry.
|
||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.endGeometry = function(geometry, feature) {
|
||||
_ol_render_canvas_Replay_.prototype.endGeometry = function(geometry, feature) {
|
||||
this.beginGeometryInstruction1_[2] = this.instructions.length;
|
||||
this.beginGeometryInstruction1_ = null;
|
||||
this.beginGeometryInstruction2_[2] = this.hitDetectionInstructions.length;
|
||||
this.beginGeometryInstruction2_ = null;
|
||||
var endGeometryInstruction =
|
||||
[ol.render.canvas.Instruction.END_GEOMETRY, feature];
|
||||
[_ol_render_canvas_Instruction_.END_GEOMETRY, feature];
|
||||
this.instructions.push(endGeometryInstruction);
|
||||
this.hitDetectionInstructions.push(endGeometryInstruction);
|
||||
};
|
||||
@@ -1047,7 +1048,7 @@ ol.render.canvas.Replay.prototype.endGeometry = function(geometry, feature) {
|
||||
/**
|
||||
* FIXME empty description for jsdoc
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.finish = ol.nullFunction;
|
||||
_ol_render_canvas_Replay_.prototype.finish = _ol_.nullFunction;
|
||||
|
||||
|
||||
/**
|
||||
@@ -1057,13 +1058,14 @@ ol.render.canvas.Replay.prototype.finish = ol.nullFunction;
|
||||
* @return {ol.Extent} The buffered rendering extent.
|
||||
* @protected
|
||||
*/
|
||||
ol.render.canvas.Replay.prototype.getBufferedMaxExtent = function() {
|
||||
_ol_render_canvas_Replay_.prototype.getBufferedMaxExtent = function() {
|
||||
if (!this.bufferedMaxExtent_) {
|
||||
this.bufferedMaxExtent_ = ol.extent.clone(this.maxExtent);
|
||||
this.bufferedMaxExtent_ = _ol_extent_.clone(this.maxExtent);
|
||||
if (this.maxLineWidth > 0) {
|
||||
var width = this.resolution * (this.maxLineWidth + 1) / 2;
|
||||
ol.extent.buffer(this.bufferedMaxExtent_, width, this.bufferedMaxExtent_);
|
||||
_ol_extent_.buffer(this.bufferedMaxExtent_, width, this.bufferedMaxExtent_);
|
||||
}
|
||||
}
|
||||
return this.bufferedMaxExtent_;
|
||||
};
|
||||
export default _ol_render_canvas_Replay_;
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
goog.provide('ol.render.canvas.ReplayGroup');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.dom');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.flat.transform');
|
||||
goog.require('ol.obj');
|
||||
goog.require('ol.render.ReplayGroup');
|
||||
goog.require('ol.render.ReplayType');
|
||||
goog.require('ol.render.canvas.Replay');
|
||||
goog.require('ol.render.canvas.ImageReplay');
|
||||
goog.require('ol.render.canvas.LineStringReplay');
|
||||
goog.require('ol.render.canvas.PolygonReplay');
|
||||
goog.require('ol.render.canvas.TextReplay');
|
||||
goog.require('ol.render.replay');
|
||||
goog.require('ol.transform');
|
||||
|
||||
/**
|
||||
* @module ol/render/canvas/ReplayGroup
|
||||
*/
|
||||
import _ol_ from '../../index.js';
|
||||
import _ol_array_ from '../../array.js';
|
||||
import _ol_dom_ from '../../dom.js';
|
||||
import _ol_extent_ from '../../extent.js';
|
||||
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
|
||||
import _ol_obj_ from '../../obj.js';
|
||||
import _ol_render_ReplayGroup_ from '../ReplayGroup.js';
|
||||
import _ol_render_ReplayType_ from '../ReplayType.js';
|
||||
import _ol_render_canvas_Replay_ from '../canvas/Replay.js';
|
||||
import _ol_render_canvas_ImageReplay_ from '../canvas/ImageReplay.js';
|
||||
import _ol_render_canvas_LineStringReplay_ from '../canvas/LineStringReplay.js';
|
||||
import _ol_render_canvas_PolygonReplay_ from '../canvas/PolygonReplay.js';
|
||||
import _ol_render_canvas_TextReplay_ from '../canvas/TextReplay.js';
|
||||
import _ol_render_replay_ from '../replay.js';
|
||||
import _ol_transform_ from '../../transform.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -30,9 +30,9 @@ goog.require('ol.transform');
|
||||
* @param {number=} opt_renderBuffer Optional rendering buffer.
|
||||
* @struct
|
||||
*/
|
||||
ol.render.canvas.ReplayGroup = function(
|
||||
var _ol_render_canvas_ReplayGroup_ = function(
|
||||
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree, opt_renderBuffer) {
|
||||
ol.render.ReplayGroup.call(this);
|
||||
_ol_render_ReplayGroup_.call(this);
|
||||
|
||||
/**
|
||||
* Declutter tree.
|
||||
@@ -93,15 +93,16 @@ ol.render.canvas.ReplayGroup = function(
|
||||
* @private
|
||||
* @type {CanvasRenderingContext2D}
|
||||
*/
|
||||
this.hitDetectionContext_ = ol.dom.createCanvasContext2D(1, 1);
|
||||
this.hitDetectionContext_ = _ol_dom_.createCanvasContext2D(1, 1);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.Transform}
|
||||
*/
|
||||
this.hitDetectionTransform_ = ol.transform.create();
|
||||
this.hitDetectionTransform_ = _ol_transform_.create();
|
||||
};
|
||||
ol.inherits(ol.render.canvas.ReplayGroup, ol.render.ReplayGroup);
|
||||
|
||||
_ol_.inherits(_ol_render_canvas_ReplayGroup_, _ol_render_ReplayGroup_);
|
||||
|
||||
|
||||
/**
|
||||
@@ -110,7 +111,7 @@ ol.inherits(ol.render.canvas.ReplayGroup, ol.render.ReplayGroup);
|
||||
* @type {Object.<number, Array.<Array.<(boolean|undefined)>>>}
|
||||
* @private
|
||||
*/
|
||||
ol.render.canvas.ReplayGroup.circleArrayCache_ = {
|
||||
_ol_render_canvas_ReplayGroup_.circleArrayCache_ = {
|
||||
0: [[true]]
|
||||
};
|
||||
|
||||
@@ -123,7 +124,7 @@ ol.render.canvas.ReplayGroup.circleArrayCache_ = {
|
||||
* @param {number} y Y coordinate.
|
||||
* @private
|
||||
*/
|
||||
ol.render.canvas.ReplayGroup.fillCircleArrayRowToMiddle_ = function(array, x, y) {
|
||||
_ol_render_canvas_ReplayGroup_.fillCircleArrayRowToMiddle_ = function(array, x, y) {
|
||||
var i;
|
||||
var radius = Math.floor(array.length / 2);
|
||||
if (x >= radius) {
|
||||
@@ -147,9 +148,9 @@ ol.render.canvas.ReplayGroup.fillCircleArrayRowToMiddle_ = function(array, x, y)
|
||||
* @returns {Array.<Array.<(boolean|undefined)>>} An array with marked circle points.
|
||||
* @private
|
||||
*/
|
||||
ol.render.canvas.ReplayGroup.getCircleArray_ = function(radius) {
|
||||
if (ol.render.canvas.ReplayGroup.circleArrayCache_[radius] !== undefined) {
|
||||
return ol.render.canvas.ReplayGroup.circleArrayCache_[radius];
|
||||
_ol_render_canvas_ReplayGroup_.getCircleArray_ = function(radius) {
|
||||
if (_ol_render_canvas_ReplayGroup_.circleArrayCache_[radius] !== undefined) {
|
||||
return _ol_render_canvas_ReplayGroup_.circleArrayCache_[radius];
|
||||
}
|
||||
|
||||
var arraySize = radius * 2 + 1;
|
||||
@@ -163,14 +164,14 @@ ol.render.canvas.ReplayGroup.getCircleArray_ = function(radius) {
|
||||
var error = 0;
|
||||
|
||||
while (x >= y) {
|
||||
ol.render.canvas.ReplayGroup.fillCircleArrayRowToMiddle_(arr, radius + x, radius + y);
|
||||
ol.render.canvas.ReplayGroup.fillCircleArrayRowToMiddle_(arr, radius + y, radius + x);
|
||||
ol.render.canvas.ReplayGroup.fillCircleArrayRowToMiddle_(arr, radius - y, radius + x);
|
||||
ol.render.canvas.ReplayGroup.fillCircleArrayRowToMiddle_(arr, radius - x, radius + y);
|
||||
ol.render.canvas.ReplayGroup.fillCircleArrayRowToMiddle_(arr, radius - x, radius - y);
|
||||
ol.render.canvas.ReplayGroup.fillCircleArrayRowToMiddle_(arr, radius - y, radius - x);
|
||||
ol.render.canvas.ReplayGroup.fillCircleArrayRowToMiddle_(arr, radius + y, radius - x);
|
||||
ol.render.canvas.ReplayGroup.fillCircleArrayRowToMiddle_(arr, radius + x, radius - y);
|
||||
_ol_render_canvas_ReplayGroup_.fillCircleArrayRowToMiddle_(arr, radius + x, radius + y);
|
||||
_ol_render_canvas_ReplayGroup_.fillCircleArrayRowToMiddle_(arr, radius + y, radius + x);
|
||||
_ol_render_canvas_ReplayGroup_.fillCircleArrayRowToMiddle_(arr, radius - y, radius + x);
|
||||
_ol_render_canvas_ReplayGroup_.fillCircleArrayRowToMiddle_(arr, radius - x, radius + y);
|
||||
_ol_render_canvas_ReplayGroup_.fillCircleArrayRowToMiddle_(arr, radius - x, radius - y);
|
||||
_ol_render_canvas_ReplayGroup_.fillCircleArrayRowToMiddle_(arr, radius - y, radius - x);
|
||||
_ol_render_canvas_ReplayGroup_.fillCircleArrayRowToMiddle_(arr, radius + y, radius - x);
|
||||
_ol_render_canvas_ReplayGroup_.fillCircleArrayRowToMiddle_(arr, radius + x, radius - y);
|
||||
|
||||
y++;
|
||||
error += 1 + 2 * y;
|
||||
@@ -180,7 +181,7 @@ ol.render.canvas.ReplayGroup.getCircleArray_ = function(radius) {
|
||||
}
|
||||
}
|
||||
|
||||
ol.render.canvas.ReplayGroup.circleArrayCache_[radius] = arr;
|
||||
_ol_render_canvas_ReplayGroup_.circleArrayCache_[radius] = arr;
|
||||
return arr;
|
||||
};
|
||||
|
||||
@@ -190,8 +191,8 @@ ol.render.canvas.ReplayGroup.getCircleArray_ = function(radius) {
|
||||
* @param {CanvasRenderingContext2D} context Context.
|
||||
* @param {number} rotation Rotation.
|
||||
*/
|
||||
ol.render.canvas.ReplayGroup.replayDeclutter = function(declutterReplays, context, rotation) {
|
||||
var zs = Object.keys(declutterReplays).map(Number).sort(ol.array.numberSafeCompareFunction);
|
||||
_ol_render_canvas_ReplayGroup_.replayDeclutter = function(declutterReplays, context, rotation) {
|
||||
var zs = Object.keys(declutterReplays).map(Number).sort(_ol_array_.numberSafeCompareFunction);
|
||||
var skippedFeatureUids = {};
|
||||
for (var z = 0, zz = zs.length; z < zz; ++z) {
|
||||
var replayData = declutterReplays[zs[z].toString()];
|
||||
@@ -208,14 +209,14 @@ ol.render.canvas.ReplayGroup.replayDeclutter = function(declutterReplays, contex
|
||||
* @param {boolean} group Group with previous replay.
|
||||
* @return {ol.DeclutterGroup} Declutter instruction group.
|
||||
*/
|
||||
ol.render.canvas.ReplayGroup.prototype.addDeclutter = function(group) {
|
||||
_ol_render_canvas_ReplayGroup_.prototype.addDeclutter = function(group) {
|
||||
var declutter = null;
|
||||
if (this.declutterTree_) {
|
||||
if (group) {
|
||||
declutter = this.declutterGroup_;
|
||||
/** @type {number} */ (declutter[4])++;
|
||||
} else {
|
||||
declutter = this.declutterGroup_ = ol.extent.createEmpty();
|
||||
declutter = this.declutterGroup_ = _ol_extent_.createEmpty();
|
||||
declutter.push(1);
|
||||
}
|
||||
}
|
||||
@@ -227,7 +228,7 @@ ol.render.canvas.ReplayGroup.prototype.addDeclutter = function(group) {
|
||||
* @param {CanvasRenderingContext2D} context Context.
|
||||
* @param {ol.Transform} transform Transform.
|
||||
*/
|
||||
ol.render.canvas.ReplayGroup.prototype.clip = function(context, transform) {
|
||||
_ol_render_canvas_ReplayGroup_.prototype.clip = function(context, transform) {
|
||||
var flatClipCoords = this.getClipCoords(transform);
|
||||
context.beginPath();
|
||||
context.moveTo(flatClipCoords[0], flatClipCoords[1]);
|
||||
@@ -242,7 +243,7 @@ ol.render.canvas.ReplayGroup.prototype.clip = function(context, transform) {
|
||||
* @param {Array.<ol.render.ReplayType>} replays Replays.
|
||||
* @return {boolean} Has replays of the provided types.
|
||||
*/
|
||||
ol.render.canvas.ReplayGroup.prototype.hasReplays = function(replays) {
|
||||
_ol_render_canvas_ReplayGroup_.prototype.hasReplays = function(replays) {
|
||||
for (var zIndex in this.replaysByZIndex_) {
|
||||
var candidates = this.replaysByZIndex_[zIndex];
|
||||
for (var i = 0, ii = replays.length; i < ii; ++i) {
|
||||
@@ -258,7 +259,7 @@ ol.render.canvas.ReplayGroup.prototype.hasReplays = function(replays) {
|
||||
/**
|
||||
* FIXME empty description for jsdoc
|
||||
*/
|
||||
ol.render.canvas.ReplayGroup.prototype.finish = function() {
|
||||
_ol_render_canvas_ReplayGroup_.prototype.finish = function() {
|
||||
var zKey;
|
||||
for (zKey in this.replaysByZIndex_) {
|
||||
var replays = this.replaysByZIndex_[zKey];
|
||||
@@ -284,12 +285,12 @@ ol.render.canvas.ReplayGroup.prototype.finish = function() {
|
||||
* @return {T|undefined} Callback result.
|
||||
* @template T
|
||||
*/
|
||||
ol.render.canvas.ReplayGroup.prototype.forEachFeatureAtCoordinate = function(
|
||||
_ol_render_canvas_ReplayGroup_.prototype.forEachFeatureAtCoordinate = function(
|
||||
coordinate, resolution, rotation, hitTolerance, skippedFeaturesHash, callback, declutterReplays) {
|
||||
|
||||
hitTolerance = Math.round(hitTolerance);
|
||||
var contextSize = hitTolerance * 2 + 1;
|
||||
var transform = ol.transform.compose(this.hitDetectionTransform_,
|
||||
var transform = _ol_transform_.compose(this.hitDetectionTransform_,
|
||||
hitTolerance + 0.5, hitTolerance + 0.5,
|
||||
1 / resolution, -1 / resolution,
|
||||
-rotation,
|
||||
@@ -308,12 +309,12 @@ ol.render.canvas.ReplayGroup.prototype.forEachFeatureAtCoordinate = function(
|
||||
*/
|
||||
var hitExtent;
|
||||
if (this.renderBuffer_ !== undefined) {
|
||||
hitExtent = ol.extent.createEmpty();
|
||||
ol.extent.extendCoordinate(hitExtent, coordinate);
|
||||
ol.extent.buffer(hitExtent, resolution * (this.renderBuffer_ + hitTolerance), hitExtent);
|
||||
hitExtent = _ol_extent_.createEmpty();
|
||||
_ol_extent_.extendCoordinate(hitExtent, coordinate);
|
||||
_ol_extent_.buffer(hitExtent, resolution * (this.renderBuffer_ + hitTolerance), hitExtent);
|
||||
}
|
||||
|
||||
var mask = ol.render.canvas.ReplayGroup.getCircleArray_(hitTolerance);
|
||||
var mask = _ol_render_canvas_ReplayGroup_.getCircleArray_(hitTolerance);
|
||||
var declutteredFeatures;
|
||||
if (this.declutterTree_) {
|
||||
declutteredFeatures = this.declutterTree_.all().map(function(entry) {
|
||||
@@ -356,14 +357,14 @@ ol.render.canvas.ReplayGroup.prototype.forEachFeatureAtCoordinate = function(
|
||||
* @param {ol.Transform} transform Transform.
|
||||
* @return {Array.<number>} Clip coordinates.
|
||||
*/
|
||||
ol.render.canvas.ReplayGroup.prototype.getClipCoords = function(transform) {
|
||||
_ol_render_canvas_ReplayGroup_.prototype.getClipCoords = function(transform) {
|
||||
var maxExtent = this.maxExtent_;
|
||||
var minX = maxExtent[0];
|
||||
var minY = maxExtent[1];
|
||||
var maxX = maxExtent[2];
|
||||
var maxY = maxExtent[3];
|
||||
var flatClipCoords = [minX, minY, minX, maxY, maxX, maxY, maxX, minY];
|
||||
ol.geom.flat.transform.transform2D(
|
||||
_ol_geom_flat_transform_.transform2D(
|
||||
flatClipCoords, 0, 8, 2, transform, flatClipCoords);
|
||||
return flatClipCoords;
|
||||
};
|
||||
@@ -372,7 +373,7 @@ ol.render.canvas.ReplayGroup.prototype.getClipCoords = function(transform) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.canvas.ReplayGroup.prototype.getReplay = function(zIndex, replayType) {
|
||||
_ol_render_canvas_ReplayGroup_.prototype.getReplay = function(zIndex, replayType) {
|
||||
var zIndexKey = zIndex !== undefined ? zIndex.toString() : '0';
|
||||
var replays = this.replaysByZIndex_[zIndexKey];
|
||||
if (replays === undefined) {
|
||||
@@ -381,7 +382,7 @@ ol.render.canvas.ReplayGroup.prototype.getReplay = function(zIndex, replayType)
|
||||
}
|
||||
var replay = replays[replayType];
|
||||
if (replay === undefined) {
|
||||
var Constructor = ol.render.canvas.ReplayGroup.BATCH_CONSTRUCTORS_[replayType];
|
||||
var Constructor = _ol_render_canvas_ReplayGroup_.BATCH_CONSTRUCTORS_[replayType];
|
||||
replay = new Constructor(this.tolerance_, this.maxExtent_,
|
||||
this.resolution_, this.pixelRatio_, this.overlaps_, this.declutterTree_);
|
||||
replays[replayType] = replay;
|
||||
@@ -393,7 +394,7 @@ ol.render.canvas.ReplayGroup.prototype.getReplay = function(zIndex, replayType)
|
||||
/**
|
||||
* @return {Object.<string, Object.<ol.render.ReplayType, ol.render.canvas.Replay>>} Replays.
|
||||
*/
|
||||
ol.render.canvas.ReplayGroup.prototype.getReplays = function() {
|
||||
_ol_render_canvas_ReplayGroup_.prototype.getReplays = function() {
|
||||
return this.replaysByZIndex_;
|
||||
};
|
||||
|
||||
@@ -401,8 +402,8 @@ ol.render.canvas.ReplayGroup.prototype.getReplays = function() {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.canvas.ReplayGroup.prototype.isEmpty = function() {
|
||||
return ol.obj.isEmpty(this.replaysByZIndex_);
|
||||
_ol_render_canvas_ReplayGroup_.prototype.isEmpty = function() {
|
||||
return _ol_obj_.isEmpty(this.replaysByZIndex_);
|
||||
};
|
||||
|
||||
|
||||
@@ -417,19 +418,19 @@ ol.render.canvas.ReplayGroup.prototype.isEmpty = function() {
|
||||
* @param {Object.<string, ol.DeclutterGroup>=} opt_declutterReplays Declutter
|
||||
* replays.
|
||||
*/
|
||||
ol.render.canvas.ReplayGroup.prototype.replay = function(context,
|
||||
_ol_render_canvas_ReplayGroup_.prototype.replay = function(context,
|
||||
transform, viewRotation, skippedFeaturesHash, opt_replayTypes, opt_declutterReplays) {
|
||||
|
||||
/** @type {Array.<number>} */
|
||||
var zs = Object.keys(this.replaysByZIndex_).map(Number);
|
||||
zs.sort(ol.array.numberSafeCompareFunction);
|
||||
zs.sort(_ol_array_.numberSafeCompareFunction);
|
||||
|
||||
// setup clipping so that the parts of over-simplified geometries are not
|
||||
// visible outside the current extent when panning
|
||||
context.save();
|
||||
this.clip(context, transform);
|
||||
|
||||
var replayTypes = opt_replayTypes ? opt_replayTypes : ol.render.replay.ORDER;
|
||||
var replayTypes = opt_replayTypes ? opt_replayTypes : _ol_render_replay_.ORDER;
|
||||
var i, ii, j, jj, replays, replay;
|
||||
for (i = 0, ii = zs.length; i < ii; ++i) {
|
||||
var zIndexKey = zs[i].toString();
|
||||
@@ -439,7 +440,7 @@ ol.render.canvas.ReplayGroup.prototype.replay = function(context,
|
||||
replay = replays[replayType];
|
||||
if (replay !== undefined) {
|
||||
if (opt_declutterReplays &&
|
||||
(replayType == ol.render.ReplayType.IMAGE || replayType == ol.render.ReplayType.TEXT)) {
|
||||
(replayType == _ol_render_ReplayType_.IMAGE || replayType == _ol_render_ReplayType_.TEXT)) {
|
||||
var declutter = opt_declutterReplays[zIndexKey];
|
||||
if (!declutter) {
|
||||
opt_declutterReplays[zIndexKey] = [replay, transform.slice(0)];
|
||||
@@ -473,23 +474,23 @@ ol.render.canvas.ReplayGroup.prototype.replay = function(context,
|
||||
* @return {T|undefined} Callback result.
|
||||
* @template T
|
||||
*/
|
||||
ol.render.canvas.ReplayGroup.prototype.replayHitDetection_ = function(
|
||||
_ol_render_canvas_ReplayGroup_.prototype.replayHitDetection_ = function(
|
||||
context, transform, viewRotation, skippedFeaturesHash,
|
||||
featureCallback, opt_hitExtent, opt_declutterReplays) {
|
||||
/** @type {Array.<number>} */
|
||||
var zs = Object.keys(this.replaysByZIndex_).map(Number);
|
||||
zs.sort(ol.array.numberSafeCompareFunction);
|
||||
zs.sort(_ol_array_.numberSafeCompareFunction);
|
||||
|
||||
var i, j, replays, replay, result;
|
||||
for (i = zs.length - 1; i >= 0; --i) {
|
||||
var zIndexKey = zs[i].toString();
|
||||
replays = this.replaysByZIndex_[zIndexKey];
|
||||
for (j = ol.render.replay.ORDER.length - 1; j >= 0; --j) {
|
||||
var replayType = ol.render.replay.ORDER[j];
|
||||
for (j = _ol_render_replay_.ORDER.length - 1; j >= 0; --j) {
|
||||
var replayType = _ol_render_replay_.ORDER[j];
|
||||
replay = replays[replayType];
|
||||
if (replay !== undefined) {
|
||||
if (opt_declutterReplays &&
|
||||
(replayType == ol.render.ReplayType.IMAGE || replayType == ol.render.ReplayType.TEXT)) {
|
||||
(replayType == _ol_render_ReplayType_.IMAGE || replayType == _ol_render_ReplayType_.TEXT)) {
|
||||
var declutter = opt_declutterReplays[zIndexKey];
|
||||
if (!declutter) {
|
||||
opt_declutterReplays[zIndexKey] = [replay, transform.slice(0)];
|
||||
@@ -517,11 +518,12 @@ ol.render.canvas.ReplayGroup.prototype.replayHitDetection_ = function(
|
||||
* function(new: ol.render.canvas.Replay, number, ol.Extent,
|
||||
* number, number, boolean, Array.<ol.DeclutterGroup>)>}
|
||||
*/
|
||||
ol.render.canvas.ReplayGroup.BATCH_CONSTRUCTORS_ = {
|
||||
'Circle': ol.render.canvas.PolygonReplay,
|
||||
'Default': ol.render.canvas.Replay,
|
||||
'Image': ol.render.canvas.ImageReplay,
|
||||
'LineString': ol.render.canvas.LineStringReplay,
|
||||
'Polygon': ol.render.canvas.PolygonReplay,
|
||||
'Text': ol.render.canvas.TextReplay
|
||||
_ol_render_canvas_ReplayGroup_.BATCH_CONSTRUCTORS_ = {
|
||||
'Circle': _ol_render_canvas_PolygonReplay_,
|
||||
'Default': _ol_render_canvas_Replay_,
|
||||
'Image': _ol_render_canvas_ImageReplay_,
|
||||
'LineString': _ol_render_canvas_LineStringReplay_,
|
||||
'Polygon': _ol_render_canvas_PolygonReplay_,
|
||||
'Text': _ol_render_canvas_TextReplay_
|
||||
};
|
||||
export default _ol_render_canvas_ReplayGroup_;
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
goog.provide('ol.render.canvas.TextReplay');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.colorlike');
|
||||
goog.require('ol.dom');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.flat.straightchunk');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
goog.require('ol.has');
|
||||
goog.require('ol.render.canvas');
|
||||
goog.require('ol.render.canvas.Instruction');
|
||||
goog.require('ol.render.canvas.Replay');
|
||||
goog.require('ol.render.replay');
|
||||
goog.require('ol.style.TextPlacement');
|
||||
|
||||
/**
|
||||
* @module ol/render/canvas/TextReplay
|
||||
*/
|
||||
import _ol_ from '../../index.js';
|
||||
import _ol_colorlike_ from '../../colorlike.js';
|
||||
import _ol_dom_ from '../../dom.js';
|
||||
import _ol_extent_ from '../../extent.js';
|
||||
import _ol_geom_flat_straightchunk_ from '../../geom/flat/straightchunk.js';
|
||||
import _ol_geom_GeometryType_ from '../../geom/GeometryType.js';
|
||||
import _ol_has_ from '../../has.js';
|
||||
import _ol_render_canvas_ from '../canvas.js';
|
||||
import _ol_render_canvas_Instruction_ from '../canvas/Instruction.js';
|
||||
import _ol_render_canvas_Replay_ from '../canvas/Replay.js';
|
||||
import _ol_render_replay_ from '../replay.js';
|
||||
import _ol_style_TextPlacement_ from '../../style/TextPlacement.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -25,9 +25,9 @@ goog.require('ol.style.TextPlacement');
|
||||
* @param {?} declutterTree Declutter tree.
|
||||
* @struct
|
||||
*/
|
||||
ol.render.canvas.TextReplay = function(
|
||||
var _ol_render_canvas_TextReplay_ = function(
|
||||
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree) {
|
||||
ol.render.canvas.Replay.call(this,
|
||||
_ol_render_canvas_Replay_.call(this,
|
||||
tolerance, maxExtent, resolution, pixelRatio, overlaps, declutterTree);
|
||||
|
||||
/**
|
||||
@@ -129,11 +129,12 @@ ol.render.canvas.TextReplay = function(
|
||||
*/
|
||||
this.widths_ = {};
|
||||
|
||||
var labelCache = ol.render.canvas.labelCache;
|
||||
var labelCache = _ol_render_canvas_.labelCache;
|
||||
labelCache.prune();
|
||||
|
||||
};
|
||||
ol.inherits(ol.render.canvas.TextReplay, ol.render.canvas.Replay);
|
||||
|
||||
_ol_.inherits(_ol_render_canvas_TextReplay_, _ol_render_canvas_Replay_);
|
||||
|
||||
|
||||
/**
|
||||
@@ -143,12 +144,12 @@ ol.inherits(ol.render.canvas.TextReplay, ol.render.canvas.Replay);
|
||||
* each line.
|
||||
* @return {number} Width of the whole text.
|
||||
*/
|
||||
ol.render.canvas.TextReplay.measureTextWidths = function(font, lines, widths) {
|
||||
_ol_render_canvas_TextReplay_.measureTextWidths = function(font, lines, widths) {
|
||||
var numLines = lines.length;
|
||||
var width = 0;
|
||||
var currentWidth, i;
|
||||
for (i = 0; i < numLines; ++i) {
|
||||
currentWidth = ol.render.canvas.measureTextWidth(font, lines[i]);
|
||||
currentWidth = _ol_render_canvas_.measureTextWidth(font, lines[i]);
|
||||
width = Math.max(width, currentWidth);
|
||||
widths.push(currentWidth);
|
||||
}
|
||||
@@ -159,7 +160,7 @@ ol.render.canvas.TextReplay.measureTextWidths = function(font, lines, widths) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.canvas.TextReplay.prototype.drawText = function(geometry, feature) {
|
||||
_ol_render_canvas_TextReplay_.prototype.drawText = function(geometry, feature) {
|
||||
var fillState = this.textFillState_;
|
||||
var strokeState = this.textStrokeState_;
|
||||
var textState = this.textState_;
|
||||
@@ -175,20 +176,20 @@ ol.render.canvas.TextReplay.prototype.drawText = function(geometry, feature) {
|
||||
var stride = 2;
|
||||
var i, ii;
|
||||
|
||||
if (textState.placement === ol.style.TextPlacement.LINE) {
|
||||
if (!ol.extent.intersects(this.getBufferedMaxExtent(), geometry.getExtent())) {
|
||||
if (textState.placement === _ol_style_TextPlacement_.LINE) {
|
||||
if (!_ol_extent_.intersects(this.getBufferedMaxExtent(), geometry.getExtent())) {
|
||||
return;
|
||||
}
|
||||
var ends;
|
||||
flatCoordinates = geometry.getFlatCoordinates();
|
||||
stride = geometry.getStride();
|
||||
if (geometryType == ol.geom.GeometryType.LINE_STRING) {
|
||||
if (geometryType == _ol_geom_GeometryType_.LINE_STRING) {
|
||||
ends = [flatCoordinates.length];
|
||||
} else if (geometryType == ol.geom.GeometryType.MULTI_LINE_STRING) {
|
||||
} else if (geometryType == _ol_geom_GeometryType_.MULTI_LINE_STRING) {
|
||||
ends = geometry.getEnds();
|
||||
} else if (geometryType == ol.geom.GeometryType.POLYGON) {
|
||||
} else if (geometryType == _ol_geom_GeometryType_.POLYGON) {
|
||||
ends = geometry.getEnds().slice(0, 1);
|
||||
} else if (geometryType == ol.geom.GeometryType.MULTI_POLYGON) {
|
||||
} else if (geometryType == _ol_geom_GeometryType_.MULTI_POLYGON) {
|
||||
var endss = geometry.getEndss();
|
||||
ends = [];
|
||||
for (i = 0, ii = endss.length; i < ii; ++i) {
|
||||
@@ -201,7 +202,7 @@ ol.render.canvas.TextReplay.prototype.drawText = function(geometry, feature) {
|
||||
var flatEnd;
|
||||
for (var o = 0, oo = ends.length; o < oo; ++o) {
|
||||
if (textAlign == undefined) {
|
||||
var range = ol.geom.flat.straightchunk.lineString(
|
||||
var range = _ol_geom_flat_straightchunk_.lineString(
|
||||
textState.maxAngle, flatCoordinates, flatOffset, ends[o], stride);
|
||||
flatOffset = range[0];
|
||||
flatEnd = range[1];
|
||||
@@ -222,29 +223,29 @@ ol.render.canvas.TextReplay.prototype.drawText = function(geometry, feature) {
|
||||
var label = this.getImage(this.text_, this.textKey_, this.fillKey_, this.strokeKey_);
|
||||
var width = label.width / this.pixelRatio;
|
||||
switch (geometryType) {
|
||||
case ol.geom.GeometryType.POINT:
|
||||
case ol.geom.GeometryType.MULTI_POINT:
|
||||
case _ol_geom_GeometryType_.POINT:
|
||||
case _ol_geom_GeometryType_.MULTI_POINT:
|
||||
flatCoordinates = geometry.getFlatCoordinates();
|
||||
end = flatCoordinates.length;
|
||||
break;
|
||||
case ol.geom.GeometryType.LINE_STRING:
|
||||
case _ol_geom_GeometryType_.LINE_STRING:
|
||||
flatCoordinates = /** @type {ol.geom.LineString} */ (geometry).getFlatMidpoint();
|
||||
break;
|
||||
case ol.geom.GeometryType.CIRCLE:
|
||||
case _ol_geom_GeometryType_.CIRCLE:
|
||||
flatCoordinates = /** @type {ol.geom.Circle} */ (geometry).getCenter();
|
||||
break;
|
||||
case ol.geom.GeometryType.MULTI_LINE_STRING:
|
||||
case _ol_geom_GeometryType_.MULTI_LINE_STRING:
|
||||
flatCoordinates = /** @type {ol.geom.MultiLineString} */ (geometry).getFlatMidpoints();
|
||||
end = flatCoordinates.length;
|
||||
break;
|
||||
case ol.geom.GeometryType.POLYGON:
|
||||
case _ol_geom_GeometryType_.POLYGON:
|
||||
flatCoordinates = /** @type {ol.geom.Polygon} */ (geometry).getFlatInteriorPoint();
|
||||
if (!textState.overflow && flatCoordinates[2] / this.resolution < width) {
|
||||
return;
|
||||
}
|
||||
stride = 3;
|
||||
break;
|
||||
case ol.geom.GeometryType.MULTI_POLYGON:
|
||||
case _ol_geom_GeometryType_.MULTI_POLYGON:
|
||||
var interiorPoints = /** @type {ol.geom.MultiPolygon} */ (geometry).getFlatInteriorPoints();
|
||||
flatCoordinates = [];
|
||||
for (i = 0, ii = interiorPoints.length; i < ii; i += 3) {
|
||||
@@ -279,28 +280,28 @@ ol.render.canvas.TextReplay.prototype.drawText = function(geometry, feature) {
|
||||
* @param {string} strokeKey Stroke style key.
|
||||
* @return {HTMLCanvasElement} Image.
|
||||
*/
|
||||
ol.render.canvas.TextReplay.prototype.getImage = function(text, textKey, fillKey, strokeKey) {
|
||||
_ol_render_canvas_TextReplay_.prototype.getImage = function(text, textKey, fillKey, strokeKey) {
|
||||
var label;
|
||||
var key = strokeKey + textKey + text + fillKey + this.pixelRatio;
|
||||
|
||||
var labelCache = ol.render.canvas.labelCache;
|
||||
var labelCache = _ol_render_canvas_.labelCache;
|
||||
if (!labelCache.containsKey(key)) {
|
||||
var strokeState = strokeKey ? this.strokeStates[strokeKey] || this.textStrokeState_ : null;
|
||||
var fillState = fillKey ? this.fillStates[fillKey] || this.textFillState_ : null;
|
||||
var textState = this.textStates[textKey] || this.textState_;
|
||||
var pixelRatio = this.pixelRatio;
|
||||
var scale = textState.scale * pixelRatio;
|
||||
var align = ol.render.replay.TEXT_ALIGN[textState.textAlign || ol.render.canvas.defaultTextAlign];
|
||||
var align = _ol_render_replay_.TEXT_ALIGN[textState.textAlign || _ol_render_canvas_.defaultTextAlign];
|
||||
var strokeWidth = strokeKey && strokeState.lineWidth ? strokeState.lineWidth : 0;
|
||||
|
||||
var lines = text.split('\n');
|
||||
var numLines = lines.length;
|
||||
var widths = [];
|
||||
var width = ol.render.canvas.TextReplay.measureTextWidths(textState.font, lines, widths);
|
||||
var lineHeight = ol.render.canvas.measureTextHeight(textState.font);
|
||||
var width = _ol_render_canvas_TextReplay_.measureTextWidths(textState.font, lines, widths);
|
||||
var lineHeight = _ol_render_canvas_.measureTextHeight(textState.font);
|
||||
var height = lineHeight * numLines;
|
||||
var renderWidth = (width + strokeWidth);
|
||||
var context = ol.dom.createCanvasContext2D(
|
||||
var context = _ol_dom_.createCanvasContext2D(
|
||||
Math.ceil(renderWidth * scale),
|
||||
Math.ceil((height + strokeWidth) * scale));
|
||||
label = context.canvas;
|
||||
@@ -311,11 +312,11 @@ ol.render.canvas.TextReplay.prototype.getImage = function(text, textKey, fillKey
|
||||
context.font = textState.font;
|
||||
if (strokeKey) {
|
||||
context.strokeStyle = strokeState.strokeStyle;
|
||||
context.lineWidth = strokeWidth * (ol.has.SAFARI ? scale : 1);
|
||||
context.lineWidth = strokeWidth * (_ol_has_.SAFARI ? scale : 1);
|
||||
context.lineCap = strokeState.lineCap;
|
||||
context.lineJoin = strokeState.lineJoin;
|
||||
context.miterLimit = strokeState.miterLimit;
|
||||
if (ol.has.CANVAS_LINE_DASH && strokeState.lineDash.length) {
|
||||
if (_ol_has_.CANVAS_LINE_DASH && strokeState.lineDash.length) {
|
||||
context.setLineDash(strokeState.lineDash);
|
||||
context.lineDashOffset = strokeState.lineDashOffset;
|
||||
}
|
||||
@@ -349,27 +350,27 @@ ol.render.canvas.TextReplay.prototype.getImage = function(text, textKey, fillKey
|
||||
* @param {number} begin Begin.
|
||||
* @param {number} end End.
|
||||
*/
|
||||
ol.render.canvas.TextReplay.prototype.drawTextImage_ = function(label, begin, end) {
|
||||
_ol_render_canvas_TextReplay_.prototype.drawTextImage_ = function(label, begin, end) {
|
||||
var textState = this.textState_;
|
||||
var strokeState = this.textStrokeState_;
|
||||
var pixelRatio = this.pixelRatio;
|
||||
var align = ol.render.replay.TEXT_ALIGN[textState.textAlign || ol.render.canvas.defaultTextAlign];
|
||||
var baseline = ol.render.replay.TEXT_ALIGN[textState.textBaseline];
|
||||
var align = _ol_render_replay_.TEXT_ALIGN[textState.textAlign || _ol_render_canvas_.defaultTextAlign];
|
||||
var baseline = _ol_render_replay_.TEXT_ALIGN[textState.textBaseline];
|
||||
var strokeWidth = strokeState && strokeState.lineWidth ? strokeState.lineWidth : 0;
|
||||
|
||||
var anchorX = align * label.width / pixelRatio + 2 * (0.5 - align) * strokeWidth;
|
||||
var anchorY = baseline * label.height / pixelRatio + 2 * (0.5 - baseline) * strokeWidth;
|
||||
this.instructions.push([ol.render.canvas.Instruction.DRAW_IMAGE, begin, end,
|
||||
this.instructions.push([_ol_render_canvas_Instruction_.DRAW_IMAGE, begin, end,
|
||||
label, (anchorX - this.textOffsetX_) * pixelRatio, (anchorY - this.textOffsetY_) * pixelRatio,
|
||||
this.declutterGroup_, label.height, 1, 0, 0, this.textRotateWithView_, this.textRotation_,
|
||||
1, true, label.width,
|
||||
textState.padding == ol.render.canvas.defaultPadding ?
|
||||
ol.render.canvas.defaultPadding : textState.padding.map(function(p) {
|
||||
textState.padding == _ol_render_canvas_.defaultPadding ?
|
||||
_ol_render_canvas_.defaultPadding : textState.padding.map(function(p) {
|
||||
return p * pixelRatio;
|
||||
}),
|
||||
!!textState.backgroundFill, !!textState.backgroundStroke
|
||||
]);
|
||||
this.hitDetectionInstructions.push([ol.render.canvas.Instruction.DRAW_IMAGE, begin, end,
|
||||
this.hitDetectionInstructions.push([_ol_render_canvas_Instruction_.DRAW_IMAGE, begin, end,
|
||||
label, (anchorX - this.textOffsetX_) * pixelRatio, (anchorY - this.textOffsetY_) * pixelRatio,
|
||||
this.declutterGroup_, label.height, 1, 0, 0, this.textRotateWithView_, this.textRotation_,
|
||||
1 / pixelRatio, true, label.width, textState.padding,
|
||||
@@ -384,7 +385,7 @@ ol.render.canvas.TextReplay.prototype.drawTextImage_ = function(label, begin, en
|
||||
* @param {number} end End.
|
||||
* @param {ol.DeclutterGroup} declutterGroup Declutter group.
|
||||
*/
|
||||
ol.render.canvas.TextReplay.prototype.drawChars_ = function(begin, end, declutterGroup) {
|
||||
_ol_render_canvas_TextReplay_.prototype.drawChars_ = function(begin, end, declutterGroup) {
|
||||
var strokeState = this.textStrokeState_;
|
||||
var textState = this.textState_;
|
||||
var fillState = this.textFillState_;
|
||||
@@ -407,7 +408,7 @@ ol.render.canvas.TextReplay.prototype.drawChars_ = function(begin, end, declutte
|
||||
if (!(this.textKey_ in this.textStates)) {
|
||||
this.textStates[this.textKey_] = /** @type {ol.CanvasTextState} */ ({
|
||||
font: textState.font,
|
||||
textAlign: textState.textAlign || ol.render.canvas.defaultTextAlign,
|
||||
textAlign: textState.textAlign || _ol_render_canvas_.defaultTextAlign,
|
||||
scale: textState.scale
|
||||
});
|
||||
}
|
||||
@@ -421,7 +422,7 @@ ol.render.canvas.TextReplay.prototype.drawChars_ = function(begin, end, declutte
|
||||
}
|
||||
|
||||
var pixelRatio = this.pixelRatio;
|
||||
var baseline = ol.render.replay.TEXT_ALIGN[textState.textBaseline];
|
||||
var baseline = _ol_render_replay_.TEXT_ALIGN[textState.textBaseline];
|
||||
|
||||
var offsetY = this.textOffsetY_ * pixelRatio;
|
||||
var text = this.text_;
|
||||
@@ -432,25 +433,25 @@ ol.render.canvas.TextReplay.prototype.drawChars_ = function(begin, end, declutte
|
||||
if (!widths) {
|
||||
this.widths_[font] = widths = {};
|
||||
}
|
||||
this.instructions.push([ol.render.canvas.Instruction.DRAW_CHARS,
|
||||
this.instructions.push([_ol_render_canvas_Instruction_.DRAW_CHARS,
|
||||
begin, end, baseline, declutterGroup,
|
||||
textState.overflow, fillKey, textState.maxAngle,
|
||||
function(text) {
|
||||
var width = widths[text];
|
||||
if (!width) {
|
||||
width = widths[text] = ol.render.canvas.measureTextWidth(font, text);
|
||||
width = widths[text] = _ol_render_canvas_.measureTextWidth(font, text);
|
||||
}
|
||||
return width * textScale * pixelRatio;
|
||||
},
|
||||
offsetY, strokeKey, strokeWidth * pixelRatio, text, textKey, 1
|
||||
]);
|
||||
this.hitDetectionInstructions.push([ol.render.canvas.Instruction.DRAW_CHARS,
|
||||
this.hitDetectionInstructions.push([_ol_render_canvas_Instruction_.DRAW_CHARS,
|
||||
begin, end, baseline, declutterGroup,
|
||||
textState.overflow, fillKey, textState.maxAngle,
|
||||
function(text) {
|
||||
var width = widths[text];
|
||||
if (!width) {
|
||||
width = widths[text] = ol.render.canvas.measureTextWidth(font, text);
|
||||
width = widths[text] = _ol_render_canvas_.measureTextWidth(font, text);
|
||||
}
|
||||
return width * textScale;
|
||||
},
|
||||
@@ -462,7 +463,7 @@ ol.render.canvas.TextReplay.prototype.drawChars_ = function(begin, end, declutte
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle, declutterGroup) {
|
||||
_ol_render_canvas_TextReplay_.prototype.setTextStyle = function(textStyle, declutterGroup) {
|
||||
var textState, fillState, strokeState;
|
||||
if (!textStyle) {
|
||||
this.text_ = '';
|
||||
@@ -477,8 +478,8 @@ ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle, declutt
|
||||
if (!fillState) {
|
||||
fillState = this.textFillState_ = /** @type {ol.CanvasFillState} */ ({});
|
||||
}
|
||||
fillState.fillStyle = ol.colorlike.asColorLike(
|
||||
textFillStyle.getColor() || ol.render.canvas.defaultFillStyle);
|
||||
fillState.fillStyle = _ol_colorlike_.asColorLike(
|
||||
textFillStyle.getColor() || _ol_render_canvas_.defaultFillStyle);
|
||||
}
|
||||
|
||||
var textStrokeStyle = textStyle.getStroke();
|
||||
@@ -493,32 +494,32 @@ ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle, declutt
|
||||
var lineDashOffset = textStrokeStyle.getLineDashOffset();
|
||||
var lineWidth = textStrokeStyle.getWidth();
|
||||
var miterLimit = textStrokeStyle.getMiterLimit();
|
||||
strokeState.lineCap = textStrokeStyle.getLineCap() || ol.render.canvas.defaultLineCap;
|
||||
strokeState.lineDash = lineDash ? lineDash.slice() : ol.render.canvas.defaultLineDash;
|
||||
strokeState.lineCap = textStrokeStyle.getLineCap() || _ol_render_canvas_.defaultLineCap;
|
||||
strokeState.lineDash = lineDash ? lineDash.slice() : _ol_render_canvas_.defaultLineDash;
|
||||
strokeState.lineDashOffset =
|
||||
lineDashOffset === undefined ? ol.render.canvas.defaultLineDashOffset : lineDashOffset;
|
||||
strokeState.lineJoin = textStrokeStyle.getLineJoin() || ol.render.canvas.defaultLineJoin;
|
||||
lineDashOffset === undefined ? _ol_render_canvas_.defaultLineDashOffset : lineDashOffset;
|
||||
strokeState.lineJoin = textStrokeStyle.getLineJoin() || _ol_render_canvas_.defaultLineJoin;
|
||||
strokeState.lineWidth =
|
||||
lineWidth === undefined ? ol.render.canvas.defaultLineWidth : lineWidth;
|
||||
lineWidth === undefined ? _ol_render_canvas_.defaultLineWidth : lineWidth;
|
||||
strokeState.miterLimit =
|
||||
miterLimit === undefined ? ol.render.canvas.defaultMiterLimit : miterLimit;
|
||||
strokeState.strokeStyle = ol.colorlike.asColorLike(
|
||||
textStrokeStyle.getColor() || ol.render.canvas.defaultStrokeStyle);
|
||||
miterLimit === undefined ? _ol_render_canvas_.defaultMiterLimit : miterLimit;
|
||||
strokeState.strokeStyle = _ol_colorlike_.asColorLike(
|
||||
textStrokeStyle.getColor() || _ol_render_canvas_.defaultStrokeStyle);
|
||||
}
|
||||
|
||||
textState = this.textState_;
|
||||
var font = textStyle.getFont() || ol.render.canvas.defaultFont;
|
||||
ol.render.canvas.checkFont(font);
|
||||
var font = textStyle.getFont() || _ol_render_canvas_.defaultFont;
|
||||
_ol_render_canvas_.checkFont(font);
|
||||
var textScale = textStyle.getScale();
|
||||
textState.overflow = textStyle.getOverflow();
|
||||
textState.font = font;
|
||||
textState.maxAngle = textStyle.getMaxAngle();
|
||||
textState.placement = textStyle.getPlacement();
|
||||
textState.textAlign = textStyle.getTextAlign();
|
||||
textState.textBaseline = textStyle.getTextBaseline() || ol.render.canvas.defaultTextBaseline;
|
||||
textState.textBaseline = textStyle.getTextBaseline() || _ol_render_canvas_.defaultTextBaseline;
|
||||
textState.backgroundFill = textStyle.getBackgroundFill();
|
||||
textState.backgroundStroke = textStyle.getBackgroundStroke();
|
||||
textState.padding = textStyle.getPadding() || ol.render.canvas.defaultPadding;
|
||||
textState.padding = textStyle.getPadding() || _ol_render_canvas_.defaultPadding;
|
||||
textState.scale = textScale === undefined ? 1 : textScale;
|
||||
|
||||
var textOffsetX = textStyle.getOffsetX();
|
||||
@@ -532,13 +533,14 @@ ol.render.canvas.TextReplay.prototype.setTextStyle = function(textStyle, declutt
|
||||
this.textRotation_ = textRotation === undefined ? 0 : textRotation;
|
||||
|
||||
this.strokeKey_ = strokeState ?
|
||||
(typeof strokeState.strokeStyle == 'string' ? strokeState.strokeStyle : ol.getUid(strokeState.strokeStyle)) +
|
||||
(typeof strokeState.strokeStyle == 'string' ? strokeState.strokeStyle : _ol_.getUid(strokeState.strokeStyle)) +
|
||||
strokeState.lineCap + strokeState.lineDashOffset + '|' + strokeState.lineWidth +
|
||||
strokeState.lineJoin + strokeState.miterLimit + '[' + strokeState.lineDash.join() + ']' :
|
||||
'';
|
||||
this.textKey_ = textState.font + textState.scale + (textState.textAlign || '?');
|
||||
this.fillKey_ = fillState ?
|
||||
(typeof fillState.fillStyle == 'string' ? fillState.fillStyle : ('|' + ol.getUid(fillState.fillStyle))) :
|
||||
(typeof fillState.fillStyle == 'string' ? fillState.fillStyle : ('|' + _ol_.getUid(fillState.fillStyle))) :
|
||||
'';
|
||||
}
|
||||
};
|
||||
export default _ol_render_canvas_TextReplay_;
|
||||
|
||||
@@ -1,34 +1,37 @@
|
||||
goog.provide('ol.render.replay');
|
||||
|
||||
goog.require('ol.render.ReplayType');
|
||||
/**
|
||||
* @module ol/render/replay
|
||||
*/
|
||||
import _ol_render_ReplayType_ from '../render/ReplayType.js';
|
||||
var _ol_render_replay_ = {};
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<ol.render.ReplayType>}
|
||||
*/
|
||||
ol.render.replay.ORDER = [
|
||||
ol.render.ReplayType.POLYGON,
|
||||
ol.render.ReplayType.CIRCLE,
|
||||
ol.render.ReplayType.LINE_STRING,
|
||||
ol.render.ReplayType.IMAGE,
|
||||
ol.render.ReplayType.TEXT,
|
||||
ol.render.ReplayType.DEFAULT
|
||||
_ol_render_replay_.ORDER = [
|
||||
_ol_render_ReplayType_.POLYGON,
|
||||
_ol_render_ReplayType_.CIRCLE,
|
||||
_ol_render_ReplayType_.LINE_STRING,
|
||||
_ol_render_ReplayType_.IMAGE,
|
||||
_ol_render_ReplayType_.TEXT,
|
||||
_ol_render_ReplayType_.DEFAULT
|
||||
];
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @enum {number}
|
||||
*/
|
||||
ol.render.replay.TEXT_ALIGN = {};
|
||||
ol.render.replay.TEXT_ALIGN['left'] = 0;
|
||||
ol.render.replay.TEXT_ALIGN['end'] = 0;
|
||||
ol.render.replay.TEXT_ALIGN['center'] = 0.5;
|
||||
ol.render.replay.TEXT_ALIGN['right'] = 1;
|
||||
ol.render.replay.TEXT_ALIGN['start'] = 1;
|
||||
ol.render.replay.TEXT_ALIGN['top'] = 0;
|
||||
ol.render.replay.TEXT_ALIGN['middle'] = 0.5;
|
||||
ol.render.replay.TEXT_ALIGN['hanging'] = 0.2;
|
||||
ol.render.replay.TEXT_ALIGN['alphabetic'] = 0.8;
|
||||
ol.render.replay.TEXT_ALIGN['ideographic'] = 0.8;
|
||||
ol.render.replay.TEXT_ALIGN['bottom'] = 1;
|
||||
_ol_render_replay_.TEXT_ALIGN = {};
|
||||
_ol_render_replay_.TEXT_ALIGN['left'] = 0;
|
||||
_ol_render_replay_.TEXT_ALIGN['end'] = 0;
|
||||
_ol_render_replay_.TEXT_ALIGN['center'] = 0.5;
|
||||
_ol_render_replay_.TEXT_ALIGN['right'] = 1;
|
||||
_ol_render_replay_.TEXT_ALIGN['start'] = 1;
|
||||
_ol_render_replay_.TEXT_ALIGN['top'] = 0;
|
||||
_ol_render_replay_.TEXT_ALIGN['middle'] = 0.5;
|
||||
_ol_render_replay_.TEXT_ALIGN['hanging'] = 0.2;
|
||||
_ol_render_replay_.TEXT_ALIGN['alphabetic'] = 0.8;
|
||||
_ol_render_replay_.TEXT_ALIGN['ideographic'] = 0.8;
|
||||
_ol_render_replay_.TEXT_ALIGN['bottom'] = 1;
|
||||
export default _ol_render_replay_;
|
||||
|
||||
@@ -1,80 +1,83 @@
|
||||
goog.provide('ol.render.webgl');
|
||||
/**
|
||||
* @module ol/render/webgl
|
||||
*/
|
||||
var _ol_render_webgl_ = {};
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
ol.render.webgl.defaultFont = '10px sans-serif';
|
||||
_ol_render_webgl_.defaultFont = '10px sans-serif';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {ol.Color}
|
||||
*/
|
||||
ol.render.webgl.defaultFillStyle = [0.0, 0.0, 0.0, 1.0];
|
||||
_ol_render_webgl_.defaultFillStyle = [0.0, 0.0, 0.0, 1.0];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
ol.render.webgl.defaultLineCap = 'round';
|
||||
_ol_render_webgl_.defaultLineCap = 'round';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {Array.<number>}
|
||||
*/
|
||||
ol.render.webgl.defaultLineDash = [];
|
||||
_ol_render_webgl_.defaultLineDash = [];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
ol.render.webgl.defaultLineDashOffset = 0;
|
||||
_ol_render_webgl_.defaultLineDashOffset = 0;
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
ol.render.webgl.defaultLineJoin = 'round';
|
||||
_ol_render_webgl_.defaultLineJoin = 'round';
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
ol.render.webgl.defaultMiterLimit = 10;
|
||||
_ol_render_webgl_.defaultMiterLimit = 10;
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {ol.Color}
|
||||
*/
|
||||
ol.render.webgl.defaultStrokeStyle = [0.0, 0.0, 0.0, 1.0];
|
||||
_ol_render_webgl_.defaultStrokeStyle = [0.0, 0.0, 0.0, 1.0];
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
ol.render.webgl.defaultTextAlign = 0.5;
|
||||
_ol_render_webgl_.defaultTextAlign = 0.5;
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
ol.render.webgl.defaultTextBaseline = 0.5;
|
||||
_ol_render_webgl_.defaultTextBaseline = 0.5;
|
||||
|
||||
|
||||
/**
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
ol.render.webgl.defaultLineWidth = 1;
|
||||
_ol_render_webgl_.defaultLineWidth = 1;
|
||||
|
||||
/**
|
||||
* Calculates the orientation of a triangle based on the determinant method.
|
||||
@@ -86,9 +89,9 @@ ol.render.webgl.defaultLineWidth = 1;
|
||||
* @param {number} y3 Third Y coordinate.
|
||||
* @return {boolean|undefined} Triangle is clockwise.
|
||||
*/
|
||||
ol.render.webgl.triangleIsCounterClockwise = function(x1, y1, x2, y2, x3, y3) {
|
||||
_ol_render_webgl_.triangleIsCounterClockwise = function(x1, y1, x2, y2, x3, y3) {
|
||||
var area = (x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1);
|
||||
return (area <= ol.render.webgl.EPSILON && area >= -ol.render.webgl.EPSILON) ?
|
||||
return (area <= _ol_render_webgl_.EPSILON && area >= -_ol_render_webgl_.EPSILON) ?
|
||||
undefined : area > 0;
|
||||
};
|
||||
|
||||
@@ -96,4 +99,5 @@ ol.render.webgl.triangleIsCounterClockwise = function(x1, y1, x2, y2, x3, y3) {
|
||||
* @const
|
||||
* @type {number}
|
||||
*/
|
||||
ol.render.webgl.EPSILON = Number.EPSILON || 2.220446049250313e-16;
|
||||
_ol_render_webgl_.EPSILON = Number.EPSILON || 2.220446049250313e-16;
|
||||
export default _ol_render_webgl_;
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
goog.provide('ol.render.webgl.CircleReplay');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.color');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.obj');
|
||||
goog.require('ol.geom.flat.transform');
|
||||
goog.require('ol.render.webgl.circlereplay.defaultshader');
|
||||
goog.require('ol.render.webgl.circlereplay.defaultshader.Locations');
|
||||
goog.require('ol.render.webgl.Replay');
|
||||
goog.require('ol.render.webgl');
|
||||
goog.require('ol.webgl');
|
||||
goog.require('ol.webgl.Buffer');
|
||||
|
||||
/**
|
||||
* @module ol/render/webgl/CircleReplay
|
||||
*/
|
||||
import _ol_ from '../../index.js';
|
||||
import _ol_array_ from '../../array.js';
|
||||
import _ol_color_ from '../../color.js';
|
||||
import _ol_extent_ from '../../extent.js';
|
||||
import _ol_obj_ from '../../obj.js';
|
||||
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
|
||||
import _ol_render_webgl_circlereplay_defaultshader_ from '../webgl/circlereplay/defaultshader.js';
|
||||
import _ol_render_webgl_circlereplay_defaultshader_Locations_ from '../webgl/circlereplay/defaultshader/Locations.js';
|
||||
import _ol_render_webgl_Replay_ from '../webgl/Replay.js';
|
||||
import _ol_render_webgl_ from '../webgl.js';
|
||||
import _ol_webgl_ from '../../webgl.js';
|
||||
import _ol_webgl_Buffer_ from '../../webgl/Buffer.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -21,8 +21,8 @@ goog.require('ol.webgl.Buffer');
|
||||
* @param {ol.Extent} maxExtent Max extent.
|
||||
* @struct
|
||||
*/
|
||||
ol.render.webgl.CircleReplay = function(tolerance, maxExtent) {
|
||||
ol.render.webgl.Replay.call(this, tolerance, maxExtent);
|
||||
var _ol_render_webgl_CircleReplay_ = function(tolerance, maxExtent) {
|
||||
_ol_render_webgl_Replay_.call(this, tolerance, maxExtent);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -67,7 +67,8 @@ ol.render.webgl.CircleReplay = function(tolerance, maxExtent) {
|
||||
};
|
||||
|
||||
};
|
||||
ol.inherits(ol.render.webgl.CircleReplay, ol.render.webgl.Replay);
|
||||
|
||||
_ol_.inherits(_ol_render_webgl_CircleReplay_, _ol_render_webgl_Replay_);
|
||||
|
||||
|
||||
/**
|
||||
@@ -77,7 +78,7 @@ ol.inherits(ol.render.webgl.CircleReplay, ol.render.webgl.Replay);
|
||||
* @param {number} end End.
|
||||
* @param {number} stride Stride.
|
||||
*/
|
||||
ol.render.webgl.CircleReplay.prototype.drawCoordinates_ = function(
|
||||
_ol_render_webgl_CircleReplay_.prototype.drawCoordinates_ = function(
|
||||
flatCoordinates, offset, end, stride) {
|
||||
var numVertices = this.vertices.length;
|
||||
var numIndices = this.indices.length;
|
||||
@@ -120,7 +121,7 @@ ol.render.webgl.CircleReplay.prototype.drawCoordinates_ = function(
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.CircleReplay.prototype.drawCircle = function(circleGeometry, feature) {
|
||||
_ol_render_webgl_CircleReplay_.prototype.drawCircle = function(circleGeometry, feature) {
|
||||
var radius = circleGeometry.getRadius();
|
||||
var stride = circleGeometry.getStride();
|
||||
if (radius) {
|
||||
@@ -133,7 +134,7 @@ ol.render.webgl.CircleReplay.prototype.drawCircle = function(circleGeometry, fea
|
||||
|
||||
this.radius_ = radius;
|
||||
var flatCoordinates = circleGeometry.getFlatCoordinates();
|
||||
flatCoordinates = ol.geom.flat.transform.translate(flatCoordinates, 0, 2,
|
||||
flatCoordinates = _ol_geom_flat_transform_.translate(flatCoordinates, 0, 2,
|
||||
stride, -this.origin[0], -this.origin[1]);
|
||||
this.drawCoordinates_(flatCoordinates, 0, 2, stride);
|
||||
} else {
|
||||
@@ -154,12 +155,12 @@ ol.render.webgl.CircleReplay.prototype.drawCircle = function(circleGeometry, fea
|
||||
/**
|
||||
* @inheritDoc
|
||||
**/
|
||||
ol.render.webgl.CircleReplay.prototype.finish = function(context) {
|
||||
_ol_render_webgl_CircleReplay_.prototype.finish = function(context) {
|
||||
// create, bind, and populate the vertices buffer
|
||||
this.verticesBuffer = new ol.webgl.Buffer(this.vertices);
|
||||
this.verticesBuffer = new _ol_webgl_Buffer_(this.vertices);
|
||||
|
||||
// create, bind, and populate the indices buffer
|
||||
this.indicesBuffer = new ol.webgl.Buffer(this.indices);
|
||||
this.indicesBuffer = new _ol_webgl_Buffer_(this.indices);
|
||||
|
||||
this.startIndices.push(this.indices.length);
|
||||
|
||||
@@ -176,7 +177,7 @@ ol.render.webgl.CircleReplay.prototype.finish = function(context) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.CircleReplay.prototype.getDeleteResourcesFunction = function(context) {
|
||||
_ol_render_webgl_CircleReplay_.prototype.getDeleteResourcesFunction = function(context) {
|
||||
// We only delete our stuff here. The shaders and the program may
|
||||
// be used by other CircleReplay instances (for other layers). And
|
||||
// they will be deleted when disposing of the ol.webgl.Context
|
||||
@@ -193,17 +194,17 @@ ol.render.webgl.CircleReplay.prototype.getDeleteResourcesFunction = function(con
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.CircleReplay.prototype.setUpProgram = function(gl, context, size, pixelRatio) {
|
||||
_ol_render_webgl_CircleReplay_.prototype.setUpProgram = function(gl, context, size, pixelRatio) {
|
||||
// get the program
|
||||
var fragmentShader, vertexShader;
|
||||
fragmentShader = ol.render.webgl.circlereplay.defaultshader.fragment;
|
||||
vertexShader = ol.render.webgl.circlereplay.defaultshader.vertex;
|
||||
fragmentShader = _ol_render_webgl_circlereplay_defaultshader_.fragment;
|
||||
vertexShader = _ol_render_webgl_circlereplay_defaultshader_.vertex;
|
||||
var program = context.getProgram(fragmentShader, vertexShader);
|
||||
|
||||
// get the locations
|
||||
var locations;
|
||||
if (!this.defaultLocations_) {
|
||||
locations = new ol.render.webgl.circlereplay.defaultshader.Locations(gl, program);
|
||||
locations = new _ol_render_webgl_circlereplay_defaultshader_Locations_(gl, program);
|
||||
this.defaultLocations_ = locations;
|
||||
} else {
|
||||
locations = this.defaultLocations_;
|
||||
@@ -213,15 +214,15 @@ ol.render.webgl.CircleReplay.prototype.setUpProgram = function(gl, context, size
|
||||
|
||||
// enable the vertex attrib arrays
|
||||
gl.enableVertexAttribArray(locations.a_position);
|
||||
gl.vertexAttribPointer(locations.a_position, 2, ol.webgl.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_position, 2, _ol_webgl_.FLOAT,
|
||||
false, 16, 0);
|
||||
|
||||
gl.enableVertexAttribArray(locations.a_instruction);
|
||||
gl.vertexAttribPointer(locations.a_instruction, 1, ol.webgl.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_instruction, 1, _ol_webgl_.FLOAT,
|
||||
false, 16, 8);
|
||||
|
||||
gl.enableVertexAttribArray(locations.a_radius);
|
||||
gl.vertexAttribPointer(locations.a_radius, 1, ol.webgl.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_radius, 1, _ol_webgl_.FLOAT,
|
||||
false, 16, 12);
|
||||
|
||||
// Enable renderer specific uniforms.
|
||||
@@ -235,7 +236,7 @@ ol.render.webgl.CircleReplay.prototype.setUpProgram = function(gl, context, size
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.CircleReplay.prototype.shutDownProgram = function(gl, locations) {
|
||||
_ol_render_webgl_CircleReplay_.prototype.shutDownProgram = function(gl, locations) {
|
||||
gl.disableVertexAttribArray(locations.a_position);
|
||||
gl.disableVertexAttribArray(locations.a_instruction);
|
||||
gl.disableVertexAttribArray(locations.a_radius);
|
||||
@@ -245,8 +246,8 @@ ol.render.webgl.CircleReplay.prototype.shutDownProgram = function(gl, locations)
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.CircleReplay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {
|
||||
if (!ol.obj.isEmpty(skippedFeaturesHash)) {
|
||||
_ol_render_webgl_CircleReplay_.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {
|
||||
if (!_ol_obj_.isEmpty(skippedFeaturesHash)) {
|
||||
this.drawReplaySkipping_(gl, context, skippedFeaturesHash);
|
||||
} else {
|
||||
//Draw by style groups to minimize drawElements() calls.
|
||||
@@ -268,7 +269,7 @@ ol.render.webgl.CircleReplay.prototype.drawReplay = function(gl, context, skippe
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.CircleReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash,
|
||||
_ol_render_webgl_CircleReplay_.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash,
|
||||
featureCallback, opt_hitExtent) {
|
||||
var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex;
|
||||
featureIndex = this.startIndices.length - 2;
|
||||
@@ -284,11 +285,11 @@ ol.render.webgl.CircleReplay.prototype.drawHitDetectionReplayOneByOne = function
|
||||
this.startIndices[featureIndex] >= groupStart) {
|
||||
start = this.startIndices[featureIndex];
|
||||
feature = this.startIndicesFeature[featureIndex];
|
||||
featureUid = ol.getUid(feature).toString();
|
||||
featureUid = _ol_.getUid(feature).toString();
|
||||
|
||||
if (skippedFeaturesHash[featureUid] === undefined &&
|
||||
feature.getGeometry() &&
|
||||
(opt_hitExtent === undefined || ol.extent.intersects(
|
||||
(opt_hitExtent === undefined || _ol_extent_.intersects(
|
||||
/** @type {Array<number>} */ (opt_hitExtent),
|
||||
feature.getGeometry().getExtent()))) {
|
||||
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
||||
@@ -315,7 +316,7 @@ ol.render.webgl.CircleReplay.prototype.drawHitDetectionReplayOneByOne = function
|
||||
* @param {ol.webgl.Context} context Context.
|
||||
* @param {Object} skippedFeaturesHash Ids of features to skip.
|
||||
*/
|
||||
ol.render.webgl.CircleReplay.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash) {
|
||||
_ol_render_webgl_CircleReplay_.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash) {
|
||||
var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex, featureStart;
|
||||
featureIndex = this.startIndices.length - 2;
|
||||
end = start = this.startIndices[featureIndex + 1];
|
||||
@@ -330,7 +331,7 @@ ol.render.webgl.CircleReplay.prototype.drawReplaySkipping_ = function(gl, contex
|
||||
this.startIndices[featureIndex] >= groupStart) {
|
||||
featureStart = this.startIndices[featureIndex];
|
||||
feature = this.startIndicesFeature[featureIndex];
|
||||
featureUid = ol.getUid(feature).toString();
|
||||
featureUid = _ol_.getUid(feature).toString();
|
||||
|
||||
if (skippedFeaturesHash[featureUid]) {
|
||||
if (start !== end) {
|
||||
@@ -354,7 +355,7 @@ ol.render.webgl.CircleReplay.prototype.drawReplaySkipping_ = function(gl, contex
|
||||
* @param {WebGLRenderingContext} gl gl.
|
||||
* @param {Array.<number>} color Color.
|
||||
*/
|
||||
ol.render.webgl.CircleReplay.prototype.setFillStyle_ = function(gl, color) {
|
||||
_ol_render_webgl_CircleReplay_.prototype.setFillStyle_ = function(gl, color) {
|
||||
gl.uniform4fv(this.defaultLocations_.u_fillColor, color);
|
||||
};
|
||||
|
||||
@@ -365,7 +366,7 @@ ol.render.webgl.CircleReplay.prototype.setFillStyle_ = function(gl, color) {
|
||||
* @param {Array.<number>} color Color.
|
||||
* @param {number} lineWidth Line width.
|
||||
*/
|
||||
ol.render.webgl.CircleReplay.prototype.setStrokeStyle_ = function(gl, color, lineWidth) {
|
||||
_ol_render_webgl_CircleReplay_.prototype.setStrokeStyle_ = function(gl, color, lineWidth) {
|
||||
gl.uniform4fv(this.defaultLocations_.u_strokeColor, color);
|
||||
gl.uniform1f(this.defaultLocations_.u_lineWidth, lineWidth);
|
||||
};
|
||||
@@ -374,27 +375,27 @@ ol.render.webgl.CircleReplay.prototype.setStrokeStyle_ = function(gl, color, lin
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.CircleReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
||||
_ol_render_webgl_CircleReplay_.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
||||
var strokeStyleColor, strokeStyleWidth;
|
||||
if (strokeStyle) {
|
||||
var strokeStyleLineDash = strokeStyle.getLineDash();
|
||||
this.state_.lineDash = strokeStyleLineDash ?
|
||||
strokeStyleLineDash : ol.render.webgl.defaultLineDash;
|
||||
strokeStyleLineDash : _ol_render_webgl_.defaultLineDash;
|
||||
var strokeStyleLineDashOffset = strokeStyle.getLineDashOffset();
|
||||
this.state_.lineDashOffset = strokeStyleLineDashOffset ?
|
||||
strokeStyleLineDashOffset : ol.render.webgl.defaultLineDashOffset;
|
||||
strokeStyleLineDashOffset : _ol_render_webgl_.defaultLineDashOffset;
|
||||
strokeStyleColor = strokeStyle.getColor();
|
||||
if (!(strokeStyleColor instanceof CanvasGradient) &&
|
||||
!(strokeStyleColor instanceof CanvasPattern)) {
|
||||
strokeStyleColor = ol.color.asArray(strokeStyleColor).map(function(c, i) {
|
||||
strokeStyleColor = _ol_color_.asArray(strokeStyleColor).map(function(c, i) {
|
||||
return i != 3 ? c / 255 : c;
|
||||
}) || ol.render.webgl.defaultStrokeStyle;
|
||||
}) || _ol_render_webgl_.defaultStrokeStyle;
|
||||
} else {
|
||||
strokeStyleColor = ol.render.webgl.defaultStrokeStyle;
|
||||
strokeStyleColor = _ol_render_webgl_.defaultStrokeStyle;
|
||||
}
|
||||
strokeStyleWidth = strokeStyle.getWidth();
|
||||
strokeStyleWidth = strokeStyleWidth !== undefined ?
|
||||
strokeStyleWidth : ol.render.webgl.defaultLineWidth;
|
||||
strokeStyleWidth : _ol_render_webgl_.defaultLineWidth;
|
||||
} else {
|
||||
strokeStyleColor = [0, 0, 0, 0];
|
||||
strokeStyleWidth = 0;
|
||||
@@ -402,14 +403,14 @@ ol.render.webgl.CircleReplay.prototype.setFillStrokeStyle = function(fillStyle,
|
||||
var fillStyleColor = fillStyle ? fillStyle.getColor() : [0, 0, 0, 0];
|
||||
if (!(fillStyleColor instanceof CanvasGradient) &&
|
||||
!(fillStyleColor instanceof CanvasPattern)) {
|
||||
fillStyleColor = ol.color.asArray(fillStyleColor).map(function(c, i) {
|
||||
fillStyleColor = _ol_color_.asArray(fillStyleColor).map(function(c, i) {
|
||||
return i != 3 ? c / 255 : c;
|
||||
}) || ol.render.webgl.defaultFillStyle;
|
||||
}) || _ol_render_webgl_.defaultFillStyle;
|
||||
} else {
|
||||
fillStyleColor = ol.render.webgl.defaultFillStyle;
|
||||
fillStyleColor = _ol_render_webgl_.defaultFillStyle;
|
||||
}
|
||||
if (!this.state_.strokeColor || !ol.array.equals(this.state_.strokeColor, strokeStyleColor) ||
|
||||
!this.state_.fillColor || !ol.array.equals(this.state_.fillColor, fillStyleColor) ||
|
||||
if (!this.state_.strokeColor || !_ol_array_.equals(this.state_.strokeColor, strokeStyleColor) ||
|
||||
!this.state_.fillColor || !_ol_array_.equals(this.state_.fillColor, fillStyleColor) ||
|
||||
this.state_.lineWidth !== strokeStyleWidth) {
|
||||
this.state_.changed = true;
|
||||
this.state_.fillColor = fillStyleColor;
|
||||
@@ -418,3 +419,4 @@ ol.render.webgl.CircleReplay.prototype.setFillStrokeStyle = function(fillStyle,
|
||||
this.styles_.push([fillStyleColor, strokeStyleColor, strokeStyleWidth]);
|
||||
}
|
||||
};
|
||||
export default _ol_render_webgl_CircleReplay_;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
goog.provide('ol.render.webgl.ImageReplay');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.render.webgl.TextureReplay');
|
||||
goog.require('ol.webgl.Buffer');
|
||||
|
||||
/**
|
||||
* @module ol/render/webgl/ImageReplay
|
||||
*/
|
||||
import _ol_ from '../../index.js';
|
||||
import _ol_render_webgl_TextureReplay_ from '../webgl/TextureReplay.js';
|
||||
import _ol_webgl_Buffer_ from '../../webgl/Buffer.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -12,8 +12,8 @@ goog.require('ol.webgl.Buffer');
|
||||
* @param {ol.Extent} maxExtent Max extent.
|
||||
* @struct
|
||||
*/
|
||||
ol.render.webgl.ImageReplay = function(tolerance, maxExtent) {
|
||||
ol.render.webgl.TextureReplay.call(this, tolerance, maxExtent);
|
||||
var _ol_render_webgl_ImageReplay_ = function(tolerance, maxExtent) {
|
||||
_ol_render_webgl_TextureReplay_.call(this, tolerance, maxExtent);
|
||||
|
||||
/**
|
||||
* @type {Array.<HTMLCanvasElement|HTMLImageElement|HTMLVideoElement>}
|
||||
@@ -40,13 +40,14 @@ ol.render.webgl.ImageReplay = function(tolerance, maxExtent) {
|
||||
this.hitDetectionTextures_ = [];
|
||||
|
||||
};
|
||||
ol.inherits(ol.render.webgl.ImageReplay, ol.render.webgl.TextureReplay);
|
||||
|
||||
_ol_.inherits(_ol_render_webgl_ImageReplay_, _ol_render_webgl_TextureReplay_);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.ImageReplay.prototype.drawMultiPoint = function(multiPointGeometry, feature) {
|
||||
_ol_render_webgl_ImageReplay_.prototype.drawMultiPoint = function(multiPointGeometry, feature) {
|
||||
this.startIndices.push(this.indices.length);
|
||||
this.startIndicesFeature.push(feature);
|
||||
var flatCoordinates = multiPointGeometry.getFlatCoordinates();
|
||||
@@ -59,7 +60,7 @@ ol.render.webgl.ImageReplay.prototype.drawMultiPoint = function(multiPointGeomet
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.ImageReplay.prototype.drawPoint = function(pointGeometry, feature) {
|
||||
_ol_render_webgl_ImageReplay_.prototype.drawPoint = function(pointGeometry, feature) {
|
||||
this.startIndices.push(this.indices.length);
|
||||
this.startIndicesFeature.push(feature);
|
||||
var flatCoordinates = pointGeometry.getFlatCoordinates();
|
||||
@@ -72,19 +73,19 @@ ol.render.webgl.ImageReplay.prototype.drawPoint = function(pointGeometry, featur
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.ImageReplay.prototype.finish = function(context) {
|
||||
_ol_render_webgl_ImageReplay_.prototype.finish = function(context) {
|
||||
var gl = context.getGL();
|
||||
|
||||
this.groupIndices.push(this.indices.length);
|
||||
this.hitDetectionGroupIndices.push(this.indices.length);
|
||||
|
||||
// create, bind, and populate the vertices buffer
|
||||
this.verticesBuffer = new ol.webgl.Buffer(this.vertices);
|
||||
this.verticesBuffer = new _ol_webgl_Buffer_(this.vertices);
|
||||
|
||||
var indices = this.indices;
|
||||
|
||||
// create, bind, and populate the indices buffer
|
||||
this.indicesBuffer = new ol.webgl.Buffer(indices);
|
||||
this.indicesBuffer = new _ol_webgl_Buffer_(indices);
|
||||
|
||||
// create textures
|
||||
/** @type {Object.<string, WebGLTexture>} */
|
||||
@@ -97,14 +98,14 @@ ol.render.webgl.ImageReplay.prototype.finish = function(context) {
|
||||
|
||||
this.images_ = null;
|
||||
this.hitDetectionImages_ = null;
|
||||
ol.render.webgl.TextureReplay.prototype.finish.call(this, context);
|
||||
_ol_render_webgl_TextureReplay_.prototype.finish.call(this, context);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.ImageReplay.prototype.setImageStyle = function(imageStyle) {
|
||||
_ol_render_webgl_ImageReplay_.prototype.setImageStyle = function(imageStyle) {
|
||||
var anchor = imageStyle.getAnchor();
|
||||
var image = imageStyle.getImage(1);
|
||||
var imageSize = imageStyle.getImageSize();
|
||||
@@ -121,7 +122,7 @@ ol.render.webgl.ImageReplay.prototype.setImageStyle = function(imageStyle) {
|
||||
this.images_.push(image);
|
||||
} else {
|
||||
currentImage = this.images_[this.images_.length - 1];
|
||||
if (ol.getUid(currentImage) != ol.getUid(image)) {
|
||||
if (_ol_.getUid(currentImage) != _ol_.getUid(image)) {
|
||||
this.groupIndices.push(this.indices.length);
|
||||
this.images_.push(image);
|
||||
}
|
||||
@@ -132,7 +133,7 @@ ol.render.webgl.ImageReplay.prototype.setImageStyle = function(imageStyle) {
|
||||
} else {
|
||||
currentImage =
|
||||
this.hitDetectionImages_[this.hitDetectionImages_.length - 1];
|
||||
if (ol.getUid(currentImage) != ol.getUid(hitDetectionImage)) {
|
||||
if (_ol_.getUid(currentImage) != _ol_.getUid(hitDetectionImage)) {
|
||||
this.hitDetectionGroupIndices.push(this.indices.length);
|
||||
this.hitDetectionImages_.push(hitDetectionImage);
|
||||
}
|
||||
@@ -156,7 +157,7 @@ ol.render.webgl.ImageReplay.prototype.setImageStyle = function(imageStyle) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.ImageReplay.prototype.getTextures = function(opt_all) {
|
||||
_ol_render_webgl_ImageReplay_.prototype.getTextures = function(opt_all) {
|
||||
return opt_all ? this.textures_.concat(this.hitDetectionTextures_) : this.textures_;
|
||||
};
|
||||
|
||||
@@ -164,6 +165,7 @@ ol.render.webgl.ImageReplay.prototype.getTextures = function(opt_all) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.ImageReplay.prototype.getHitDetectionTextures = function() {
|
||||
_ol_render_webgl_ImageReplay_.prototype.getHitDetectionTextures = function() {
|
||||
return this.hitDetectionTextures_;
|
||||
};
|
||||
export default _ol_render_webgl_ImageReplay_;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
goog.provide('ol.render.webgl.Immediate');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
goog.require('ol.render.ReplayType');
|
||||
goog.require('ol.render.VectorContext');
|
||||
goog.require('ol.render.webgl.ReplayGroup');
|
||||
|
||||
/**
|
||||
* @module ol/render/webgl/Immediate
|
||||
*/
|
||||
import _ol_ from '../../index.js';
|
||||
import _ol_extent_ from '../../extent.js';
|
||||
import _ol_geom_GeometryType_ from '../../geom/GeometryType.js';
|
||||
import _ol_render_ReplayType_ from '../ReplayType.js';
|
||||
import _ol_render_VectorContext_ from '../VectorContext.js';
|
||||
import _ol_render_webgl_ReplayGroup_ from '../webgl/ReplayGroup.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -20,8 +20,8 @@ goog.require('ol.render.webgl.ReplayGroup');
|
||||
* @param {number} pixelRatio Pixel ratio.
|
||||
* @struct
|
||||
*/
|
||||
ol.render.webgl.Immediate = function(context, center, resolution, rotation, size, extent, pixelRatio) {
|
||||
ol.render.VectorContext.call(this);
|
||||
var _ol_render_webgl_Immediate_ = function(context, center, resolution, rotation, size, extent, pixelRatio) {
|
||||
_ol_render_VectorContext_.call(this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -83,7 +83,8 @@ ol.render.webgl.Immediate = function(context, center, resolution, rotation, size
|
||||
this.textStyle_ = null;
|
||||
|
||||
};
|
||||
ol.inherits(ol.render.webgl.Immediate, ol.render.VectorContext);
|
||||
|
||||
_ol_.inherits(_ol_render_webgl_Immediate_, _ol_render_VectorContext_);
|
||||
|
||||
|
||||
/**
|
||||
@@ -91,10 +92,10 @@ ol.inherits(ol.render.webgl.Immediate, ol.render.VectorContext);
|
||||
* @param {ol.geom.Geometry|ol.render.Feature} geometry Geometry.
|
||||
* @private
|
||||
*/
|
||||
ol.render.webgl.Immediate.prototype.drawText_ = function(replayGroup, geometry) {
|
||||
_ol_render_webgl_Immediate_.prototype.drawText_ = function(replayGroup, geometry) {
|
||||
var context = this.context_;
|
||||
var replay = /** @type {ol.render.webgl.TextReplay} */ (
|
||||
replayGroup.getReplay(0, ol.render.ReplayType.TEXT));
|
||||
replayGroup.getReplay(0, _ol_render_ReplayType_.TEXT));
|
||||
replay.setTextStyle(this.textStyle_);
|
||||
replay.drawText(geometry, null);
|
||||
replay.finish(context);
|
||||
@@ -118,7 +119,7 @@ ol.render.webgl.Immediate.prototype.drawText_ = function(replayGroup, geometry)
|
||||
* @override
|
||||
* @api
|
||||
*/
|
||||
ol.render.webgl.Immediate.prototype.setStyle = function(style) {
|
||||
_ol_render_webgl_Immediate_.prototype.setStyle = function(style) {
|
||||
this.setFillStrokeStyle(style.getFill(), style.getStroke());
|
||||
this.setImageStyle(style.getImage());
|
||||
this.setTextStyle(style.getText());
|
||||
@@ -133,31 +134,31 @@ ol.render.webgl.Immediate.prototype.setStyle = function(style) {
|
||||
* @override
|
||||
* @api
|
||||
*/
|
||||
ol.render.webgl.Immediate.prototype.drawGeometry = function(geometry) {
|
||||
_ol_render_webgl_Immediate_.prototype.drawGeometry = function(geometry) {
|
||||
var type = geometry.getType();
|
||||
switch (type) {
|
||||
case ol.geom.GeometryType.POINT:
|
||||
case _ol_geom_GeometryType_.POINT:
|
||||
this.drawPoint(/** @type {ol.geom.Point} */ (geometry), null);
|
||||
break;
|
||||
case ol.geom.GeometryType.LINE_STRING:
|
||||
case _ol_geom_GeometryType_.LINE_STRING:
|
||||
this.drawLineString(/** @type {ol.geom.LineString} */ (geometry), null);
|
||||
break;
|
||||
case ol.geom.GeometryType.POLYGON:
|
||||
case _ol_geom_GeometryType_.POLYGON:
|
||||
this.drawPolygon(/** @type {ol.geom.Polygon} */ (geometry), null);
|
||||
break;
|
||||
case ol.geom.GeometryType.MULTI_POINT:
|
||||
case _ol_geom_GeometryType_.MULTI_POINT:
|
||||
this.drawMultiPoint(/** @type {ol.geom.MultiPoint} */ (geometry), null);
|
||||
break;
|
||||
case ol.geom.GeometryType.MULTI_LINE_STRING:
|
||||
case _ol_geom_GeometryType_.MULTI_LINE_STRING:
|
||||
this.drawMultiLineString(/** @type {ol.geom.MultiLineString} */ (geometry), null);
|
||||
break;
|
||||
case ol.geom.GeometryType.MULTI_POLYGON:
|
||||
case _ol_geom_GeometryType_.MULTI_POLYGON:
|
||||
this.drawMultiPolygon(/** @type {ol.geom.MultiPolygon} */ (geometry), null);
|
||||
break;
|
||||
case ol.geom.GeometryType.GEOMETRY_COLLECTION:
|
||||
case _ol_geom_GeometryType_.GEOMETRY_COLLECTION:
|
||||
this.drawGeometryCollection(/** @type {ol.geom.GeometryCollection} */ (geometry), null);
|
||||
break;
|
||||
case ol.geom.GeometryType.CIRCLE:
|
||||
case _ol_geom_GeometryType_.CIRCLE:
|
||||
this.drawCircle(/** @type {ol.geom.Circle} */ (geometry), null);
|
||||
break;
|
||||
default:
|
||||
@@ -170,10 +171,10 @@ ol.render.webgl.Immediate.prototype.drawGeometry = function(geometry) {
|
||||
* @inheritDoc
|
||||
* @api
|
||||
*/
|
||||
ol.render.webgl.Immediate.prototype.drawFeature = function(feature, style) {
|
||||
_ol_render_webgl_Immediate_.prototype.drawFeature = function(feature, style) {
|
||||
var geometry = style.getGeometryFunction()(feature);
|
||||
if (!geometry ||
|
||||
!ol.extent.intersects(this.extent_, geometry.getExtent())) {
|
||||
!_ol_extent_.intersects(this.extent_, geometry.getExtent())) {
|
||||
return;
|
||||
}
|
||||
this.setStyle(style);
|
||||
@@ -184,7 +185,7 @@ ol.render.webgl.Immediate.prototype.drawFeature = function(feature, style) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.Immediate.prototype.drawGeometryCollection = function(geometry, data) {
|
||||
_ol_render_webgl_Immediate_.prototype.drawGeometryCollection = function(geometry, data) {
|
||||
var geometries = geometry.getGeometriesArray();
|
||||
var i, ii;
|
||||
for (i = 0, ii = geometries.length; i < ii; ++i) {
|
||||
@@ -196,11 +197,11 @@ ol.render.webgl.Immediate.prototype.drawGeometryCollection = function(geometry,
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.Immediate.prototype.drawPoint = function(geometry, data) {
|
||||
_ol_render_webgl_Immediate_.prototype.drawPoint = function(geometry, data) {
|
||||
var context = this.context_;
|
||||
var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_);
|
||||
var replayGroup = new _ol_render_webgl_ReplayGroup_(1, this.extent_);
|
||||
var replay = /** @type {ol.render.webgl.ImageReplay} */ (
|
||||
replayGroup.getReplay(0, ol.render.ReplayType.IMAGE));
|
||||
replayGroup.getReplay(0, _ol_render_ReplayType_.IMAGE));
|
||||
replay.setImageStyle(this.imageStyle_);
|
||||
replay.drawPoint(geometry, data);
|
||||
replay.finish(context);
|
||||
@@ -223,11 +224,11 @@ ol.render.webgl.Immediate.prototype.drawPoint = function(geometry, data) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.Immediate.prototype.drawMultiPoint = function(geometry, data) {
|
||||
_ol_render_webgl_Immediate_.prototype.drawMultiPoint = function(geometry, data) {
|
||||
var context = this.context_;
|
||||
var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_);
|
||||
var replayGroup = new _ol_render_webgl_ReplayGroup_(1, this.extent_);
|
||||
var replay = /** @type {ol.render.webgl.ImageReplay} */ (
|
||||
replayGroup.getReplay(0, ol.render.ReplayType.IMAGE));
|
||||
replayGroup.getReplay(0, _ol_render_ReplayType_.IMAGE));
|
||||
replay.setImageStyle(this.imageStyle_);
|
||||
replay.drawMultiPoint(geometry, data);
|
||||
replay.finish(context);
|
||||
@@ -249,11 +250,11 @@ ol.render.webgl.Immediate.prototype.drawMultiPoint = function(geometry, data) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.Immediate.prototype.drawLineString = function(geometry, data) {
|
||||
_ol_render_webgl_Immediate_.prototype.drawLineString = function(geometry, data) {
|
||||
var context = this.context_;
|
||||
var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_);
|
||||
var replayGroup = new _ol_render_webgl_ReplayGroup_(1, this.extent_);
|
||||
var replay = /** @type {ol.render.webgl.LineStringReplay} */ (
|
||||
replayGroup.getReplay(0, ol.render.ReplayType.LINE_STRING));
|
||||
replayGroup.getReplay(0, _ol_render_ReplayType_.LINE_STRING));
|
||||
replay.setFillStrokeStyle(null, this.strokeStyle_);
|
||||
replay.drawLineString(geometry, data);
|
||||
replay.finish(context);
|
||||
@@ -275,11 +276,11 @@ ol.render.webgl.Immediate.prototype.drawLineString = function(geometry, data) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.Immediate.prototype.drawMultiLineString = function(geometry, data) {
|
||||
_ol_render_webgl_Immediate_.prototype.drawMultiLineString = function(geometry, data) {
|
||||
var context = this.context_;
|
||||
var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_);
|
||||
var replayGroup = new _ol_render_webgl_ReplayGroup_(1, this.extent_);
|
||||
var replay = /** @type {ol.render.webgl.LineStringReplay} */ (
|
||||
replayGroup.getReplay(0, ol.render.ReplayType.LINE_STRING));
|
||||
replayGroup.getReplay(0, _ol_render_ReplayType_.LINE_STRING));
|
||||
replay.setFillStrokeStyle(null, this.strokeStyle_);
|
||||
replay.drawMultiLineString(geometry, data);
|
||||
replay.finish(context);
|
||||
@@ -301,11 +302,11 @@ ol.render.webgl.Immediate.prototype.drawMultiLineString = function(geometry, dat
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.Immediate.prototype.drawPolygon = function(geometry, data) {
|
||||
_ol_render_webgl_Immediate_.prototype.drawPolygon = function(geometry, data) {
|
||||
var context = this.context_;
|
||||
var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_);
|
||||
var replayGroup = new _ol_render_webgl_ReplayGroup_(1, this.extent_);
|
||||
var replay = /** @type {ol.render.webgl.PolygonReplay} */ (
|
||||
replayGroup.getReplay(0, ol.render.ReplayType.POLYGON));
|
||||
replayGroup.getReplay(0, _ol_render_ReplayType_.POLYGON));
|
||||
replay.setFillStrokeStyle(this.fillStyle_, this.strokeStyle_);
|
||||
replay.drawPolygon(geometry, data);
|
||||
replay.finish(context);
|
||||
@@ -327,11 +328,11 @@ ol.render.webgl.Immediate.prototype.drawPolygon = function(geometry, data) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.Immediate.prototype.drawMultiPolygon = function(geometry, data) {
|
||||
_ol_render_webgl_Immediate_.prototype.drawMultiPolygon = function(geometry, data) {
|
||||
var context = this.context_;
|
||||
var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_);
|
||||
var replayGroup = new _ol_render_webgl_ReplayGroup_(1, this.extent_);
|
||||
var replay = /** @type {ol.render.webgl.PolygonReplay} */ (
|
||||
replayGroup.getReplay(0, ol.render.ReplayType.POLYGON));
|
||||
replayGroup.getReplay(0, _ol_render_ReplayType_.POLYGON));
|
||||
replay.setFillStrokeStyle(this.fillStyle_, this.strokeStyle_);
|
||||
replay.drawMultiPolygon(geometry, data);
|
||||
replay.finish(context);
|
||||
@@ -353,11 +354,11 @@ ol.render.webgl.Immediate.prototype.drawMultiPolygon = function(geometry, data)
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.Immediate.prototype.drawCircle = function(geometry, data) {
|
||||
_ol_render_webgl_Immediate_.prototype.drawCircle = function(geometry, data) {
|
||||
var context = this.context_;
|
||||
var replayGroup = new ol.render.webgl.ReplayGroup(1, this.extent_);
|
||||
var replayGroup = new _ol_render_webgl_ReplayGroup_(1, this.extent_);
|
||||
var replay = /** @type {ol.render.webgl.CircleReplay} */ (
|
||||
replayGroup.getReplay(0, ol.render.ReplayType.CIRCLE));
|
||||
replayGroup.getReplay(0, _ol_render_ReplayType_.CIRCLE));
|
||||
replay.setFillStrokeStyle(this.fillStyle_, this.strokeStyle_);
|
||||
replay.drawCircle(geometry, data);
|
||||
replay.finish(context);
|
||||
@@ -379,7 +380,7 @@ ol.render.webgl.Immediate.prototype.drawCircle = function(geometry, data) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.Immediate.prototype.setImageStyle = function(imageStyle) {
|
||||
_ol_render_webgl_Immediate_.prototype.setImageStyle = function(imageStyle) {
|
||||
this.imageStyle_ = imageStyle;
|
||||
};
|
||||
|
||||
@@ -387,7 +388,7 @@ ol.render.webgl.Immediate.prototype.setImageStyle = function(imageStyle) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.Immediate.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
||||
_ol_render_webgl_Immediate_.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
||||
this.fillStyle_ = fillStyle;
|
||||
this.strokeStyle_ = strokeStyle;
|
||||
};
|
||||
@@ -396,6 +397,7 @@ ol.render.webgl.Immediate.prototype.setFillStrokeStyle = function(fillStyle, str
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.Immediate.prototype.setTextStyle = function(textStyle) {
|
||||
_ol_render_webgl_Immediate_.prototype.setTextStyle = function(textStyle) {
|
||||
this.textStyle_ = textStyle;
|
||||
};
|
||||
export default _ol_render_webgl_Immediate_;
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
goog.provide('ol.render.webgl.LineStringReplay');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.color');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.geom.flat.orient');
|
||||
goog.require('ol.geom.flat.transform');
|
||||
goog.require('ol.geom.flat.topology');
|
||||
goog.require('ol.obj');
|
||||
goog.require('ol.render.webgl');
|
||||
goog.require('ol.render.webgl.Replay');
|
||||
goog.require('ol.render.webgl.linestringreplay.defaultshader');
|
||||
goog.require('ol.render.webgl.linestringreplay.defaultshader.Locations');
|
||||
goog.require('ol.webgl');
|
||||
goog.require('ol.webgl.Buffer');
|
||||
|
||||
/**
|
||||
* @module ol/render/webgl/LineStringReplay
|
||||
*/
|
||||
import _ol_ from '../../index.js';
|
||||
import _ol_array_ from '../../array.js';
|
||||
import _ol_color_ from '../../color.js';
|
||||
import _ol_extent_ from '../../extent.js';
|
||||
import _ol_geom_flat_orient_ from '../../geom/flat/orient.js';
|
||||
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
|
||||
import _ol_geom_flat_topology_ from '../../geom/flat/topology.js';
|
||||
import _ol_obj_ from '../../obj.js';
|
||||
import _ol_render_webgl_ from '../webgl.js';
|
||||
import _ol_render_webgl_Replay_ from '../webgl/Replay.js';
|
||||
import _ol_render_webgl_linestringreplay_defaultshader_ from '../webgl/linestringreplay/defaultshader.js';
|
||||
import _ol_render_webgl_linestringreplay_defaultshader_Locations_ from '../webgl/linestringreplay/defaultshader/Locations.js';
|
||||
import _ol_webgl_ from '../../webgl.js';
|
||||
import _ol_webgl_Buffer_ from '../../webgl/Buffer.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -23,8 +23,8 @@ goog.require('ol.webgl.Buffer');
|
||||
* @param {ol.Extent} maxExtent Max extent.
|
||||
* @struct
|
||||
*/
|
||||
ol.render.webgl.LineStringReplay = function(tolerance, maxExtent) {
|
||||
ol.render.webgl.Replay.call(this, tolerance, maxExtent);
|
||||
var _ol_render_webgl_LineStringReplay_ = function(tolerance, maxExtent) {
|
||||
_ol_render_webgl_Replay_.call(this, tolerance, maxExtent);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -67,7 +67,8 @@ ol.render.webgl.LineStringReplay = function(tolerance, maxExtent) {
|
||||
};
|
||||
|
||||
};
|
||||
ol.inherits(ol.render.webgl.LineStringReplay, ol.render.webgl.Replay);
|
||||
|
||||
_ol_.inherits(_ol_render_webgl_LineStringReplay_, _ol_render_webgl_Replay_);
|
||||
|
||||
|
||||
/**
|
||||
@@ -78,7 +79,7 @@ ol.inherits(ol.render.webgl.LineStringReplay, ol.render.webgl.Replay);
|
||||
* @param {number} end End.
|
||||
* @param {number} stride Stride.
|
||||
*/
|
||||
ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoordinates, offset, end, stride) {
|
||||
_ol_render_webgl_LineStringReplay_.prototype.drawCoordinates_ = function(flatCoordinates, offset, end, stride) {
|
||||
|
||||
var i, ii;
|
||||
var numVertices = this.vertices.length;
|
||||
@@ -90,7 +91,7 @@ ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoord
|
||||
this.state_.lineJoin === 'miter' ? 1 : 2;
|
||||
var lineCap = this.state_.lineCap === 'butt' ? 0 :
|
||||
this.state_.lineCap === 'square' ? 1 : 2;
|
||||
var closed = ol.geom.flat.topology.lineStringIsClosed(flatCoordinates, offset, end, stride);
|
||||
var closed = _ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, offset, end, stride);
|
||||
var startCoords, sign, n;
|
||||
var lastIndex = numIndices;
|
||||
var lastSign = 1;
|
||||
@@ -106,7 +107,7 @@ ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoord
|
||||
//First vertex.
|
||||
if (i === offset) {
|
||||
p2 = [flatCoordinates[i + stride], flatCoordinates[i + stride + 1]];
|
||||
if (end - offset === stride * 2 && ol.array.equals(p1, p2)) {
|
||||
if (end - offset === stride * 2 && _ol_array_.equals(p1, p2)) {
|
||||
break;
|
||||
}
|
||||
if (closed) {
|
||||
@@ -120,10 +121,10 @@ ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoord
|
||||
|
||||
if (lineCap) {
|
||||
numVertices = this.addVertices_([0, 0], p1, p2,
|
||||
lastSign * ol.render.webgl.LineStringReplay.Instruction_.BEGIN_LINE_CAP * lineCap, numVertices);
|
||||
lastSign * _ol_render_webgl_LineStringReplay_.Instruction_.BEGIN_LINE_CAP * lineCap, numVertices);
|
||||
|
||||
numVertices = this.addVertices_([0, 0], p1, p2,
|
||||
-lastSign * ol.render.webgl.LineStringReplay.Instruction_.BEGIN_LINE_CAP * lineCap, numVertices);
|
||||
-lastSign * _ol_render_webgl_LineStringReplay_.Instruction_.BEGIN_LINE_CAP * lineCap, numVertices);
|
||||
|
||||
this.indices[numIndices++] = n + 2;
|
||||
this.indices[numIndices++] = n;
|
||||
@@ -136,10 +137,10 @@ ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoord
|
||||
}
|
||||
|
||||
numVertices = this.addVertices_([0, 0], p1, p2,
|
||||
lastSign * ol.render.webgl.LineStringReplay.Instruction_.BEGIN_LINE * (lineCap || 1), numVertices);
|
||||
lastSign * _ol_render_webgl_LineStringReplay_.Instruction_.BEGIN_LINE * (lineCap || 1), numVertices);
|
||||
|
||||
numVertices = this.addVertices_([0, 0], p1, p2,
|
||||
-lastSign * ol.render.webgl.LineStringReplay.Instruction_.BEGIN_LINE * (lineCap || 1), numVertices);
|
||||
-lastSign * _ol_render_webgl_LineStringReplay_.Instruction_.BEGIN_LINE * (lineCap || 1), numVertices);
|
||||
|
||||
lastIndex = numVertices / 7 - 1;
|
||||
|
||||
@@ -155,10 +156,10 @@ ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoord
|
||||
p0 = p0 || [0, 0];
|
||||
|
||||
numVertices = this.addVertices_(p0, p1, [0, 0],
|
||||
lastSign * ol.render.webgl.LineStringReplay.Instruction_.END_LINE * (lineCap || 1), numVertices);
|
||||
lastSign * _ol_render_webgl_LineStringReplay_.Instruction_.END_LINE * (lineCap || 1), numVertices);
|
||||
|
||||
numVertices = this.addVertices_(p0, p1, [0, 0],
|
||||
-lastSign * ol.render.webgl.LineStringReplay.Instruction_.END_LINE * (lineCap || 1), numVertices);
|
||||
-lastSign * _ol_render_webgl_LineStringReplay_.Instruction_.END_LINE * (lineCap || 1), numVertices);
|
||||
|
||||
this.indices[numIndices++] = n;
|
||||
this.indices[numIndices++] = lastIndex - 1;
|
||||
@@ -170,10 +171,10 @@ ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoord
|
||||
|
||||
if (lineCap) {
|
||||
numVertices = this.addVertices_(p0, p1, [0, 0],
|
||||
lastSign * ol.render.webgl.LineStringReplay.Instruction_.END_LINE_CAP * lineCap, numVertices);
|
||||
lastSign * _ol_render_webgl_LineStringReplay_.Instruction_.END_LINE_CAP * lineCap, numVertices);
|
||||
|
||||
numVertices = this.addVertices_(p0, p1, [0, 0],
|
||||
-lastSign * ol.render.webgl.LineStringReplay.Instruction_.END_LINE_CAP * lineCap, numVertices);
|
||||
-lastSign * _ol_render_webgl_LineStringReplay_.Instruction_.END_LINE_CAP * lineCap, numVertices);
|
||||
|
||||
this.indices[numIndices++] = n + 2;
|
||||
this.indices[numIndices++] = n;
|
||||
@@ -192,17 +193,17 @@ ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoord
|
||||
}
|
||||
|
||||
// We group CW and straight lines, thus the not so inituitive CCW checking function.
|
||||
sign = ol.render.webgl.triangleIsCounterClockwise(p0[0], p0[1], p1[0], p1[1], p2[0], p2[1])
|
||||
sign = _ol_render_webgl_.triangleIsCounterClockwise(p0[0], p0[1], p1[0], p1[1], p2[0], p2[1])
|
||||
? -1 : 1;
|
||||
|
||||
numVertices = this.addVertices_(p0, p1, p2,
|
||||
sign * ol.render.webgl.LineStringReplay.Instruction_.BEVEL_FIRST * (lineJoin || 1), numVertices);
|
||||
sign * _ol_render_webgl_LineStringReplay_.Instruction_.BEVEL_FIRST * (lineJoin || 1), numVertices);
|
||||
|
||||
numVertices = this.addVertices_(p0, p1, p2,
|
||||
sign * ol.render.webgl.LineStringReplay.Instruction_.BEVEL_SECOND * (lineJoin || 1), numVertices);
|
||||
sign * _ol_render_webgl_LineStringReplay_.Instruction_.BEVEL_SECOND * (lineJoin || 1), numVertices);
|
||||
|
||||
numVertices = this.addVertices_(p0, p1, p2,
|
||||
-sign * ol.render.webgl.LineStringReplay.Instruction_.MITER_BOTTOM * (lineJoin || 1), numVertices);
|
||||
-sign * _ol_render_webgl_LineStringReplay_.Instruction_.MITER_BOTTOM * (lineJoin || 1), numVertices);
|
||||
|
||||
if (i > offset) {
|
||||
this.indices[numIndices++] = n;
|
||||
@@ -224,7 +225,7 @@ ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoord
|
||||
//Add miter
|
||||
if (lineJoin) {
|
||||
numVertices = this.addVertices_(p0, p1, p2,
|
||||
sign * ol.render.webgl.LineStringReplay.Instruction_.MITER_TOP * lineJoin, numVertices);
|
||||
sign * _ol_render_webgl_LineStringReplay_.Instruction_.MITER_TOP * lineJoin, numVertices);
|
||||
|
||||
this.indices[numIndices++] = n + 1;
|
||||
this.indices[numIndices++] = n + 3;
|
||||
@@ -234,14 +235,14 @@ ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoord
|
||||
|
||||
if (closed) {
|
||||
n = n || numVertices / 7;
|
||||
sign = ol.geom.flat.orient.linearRingIsClockwise([p0[0], p0[1], p1[0], p1[1], p2[0], p2[1]], 0, 6, 2)
|
||||
sign = _ol_geom_flat_orient_.linearRingIsClockwise([p0[0], p0[1], p1[0], p1[1], p2[0], p2[1]], 0, 6, 2)
|
||||
? 1 : -1;
|
||||
|
||||
numVertices = this.addVertices_(p0, p1, p2,
|
||||
sign * ol.render.webgl.LineStringReplay.Instruction_.BEVEL_FIRST * (lineJoin || 1), numVertices);
|
||||
sign * _ol_render_webgl_LineStringReplay_.Instruction_.BEVEL_FIRST * (lineJoin || 1), numVertices);
|
||||
|
||||
numVertices = this.addVertices_(p0, p1, p2,
|
||||
-sign * ol.render.webgl.LineStringReplay.Instruction_.MITER_BOTTOM * (lineJoin || 1), numVertices);
|
||||
-sign * _ol_render_webgl_LineStringReplay_.Instruction_.MITER_BOTTOM * (lineJoin || 1), numVertices);
|
||||
|
||||
this.indices[numIndices++] = n;
|
||||
this.indices[numIndices++] = lastIndex - 1;
|
||||
@@ -262,7 +263,7 @@ ol.render.webgl.LineStringReplay.prototype.drawCoordinates_ = function(flatCoord
|
||||
* @return {number} Vertex counter.
|
||||
* @private
|
||||
*/
|
||||
ol.render.webgl.LineStringReplay.prototype.addVertices_ = function(p0, p1, p2, product, numVertices) {
|
||||
_ol_render_webgl_LineStringReplay_.prototype.addVertices_ = function(p0, p1, p2, product, numVertices) {
|
||||
this.vertices[numVertices++] = p0[0];
|
||||
this.vertices[numVertices++] = p0[1];
|
||||
this.vertices[numVertices++] = p1[0];
|
||||
@@ -283,14 +284,14 @@ ol.render.webgl.LineStringReplay.prototype.addVertices_ = function(p0, p1, p2, p
|
||||
* @return {boolean} The linestring can be drawn.
|
||||
* @private
|
||||
*/
|
||||
ol.render.webgl.LineStringReplay.prototype.isValid_ = function(flatCoordinates, offset, end, stride) {
|
||||
_ol_render_webgl_LineStringReplay_.prototype.isValid_ = function(flatCoordinates, offset, end, stride) {
|
||||
var range = end - offset;
|
||||
if (range < stride * 2) {
|
||||
return false;
|
||||
} else if (range === stride * 2) {
|
||||
var firstP = [flatCoordinates[offset], flatCoordinates[offset + 1]];
|
||||
var lastP = [flatCoordinates[offset + stride], flatCoordinates[offset + stride + 1]];
|
||||
return !ol.array.equals(firstP, lastP);
|
||||
return !_ol_array_.equals(firstP, lastP);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -300,11 +301,11 @@ ol.render.webgl.LineStringReplay.prototype.isValid_ = function(flatCoordinates,
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.LineStringReplay.prototype.drawLineString = function(lineStringGeometry, feature) {
|
||||
_ol_render_webgl_LineStringReplay_.prototype.drawLineString = function(lineStringGeometry, feature) {
|
||||
var flatCoordinates = lineStringGeometry.getFlatCoordinates();
|
||||
var stride = lineStringGeometry.getStride();
|
||||
if (this.isValid_(flatCoordinates, 0, flatCoordinates.length, stride)) {
|
||||
flatCoordinates = ol.geom.flat.transform.translate(flatCoordinates, 0, flatCoordinates.length,
|
||||
flatCoordinates = _ol_geom_flat_transform_.translate(flatCoordinates, 0, flatCoordinates.length,
|
||||
stride, -this.origin[0], -this.origin[1]);
|
||||
if (this.state_.changed) {
|
||||
this.styleIndices_.push(this.indices.length);
|
||||
@@ -321,7 +322,7 @@ ol.render.webgl.LineStringReplay.prototype.drawLineString = function(lineStringG
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.LineStringReplay.prototype.drawMultiLineString = function(multiLineStringGeometry, feature) {
|
||||
_ol_render_webgl_LineStringReplay_.prototype.drawMultiLineString = function(multiLineStringGeometry, feature) {
|
||||
var indexCount = this.indices.length;
|
||||
var ends = multiLineStringGeometry.getEnds();
|
||||
ends.unshift(0);
|
||||
@@ -331,7 +332,7 @@ ol.render.webgl.LineStringReplay.prototype.drawMultiLineString = function(multiL
|
||||
if (ends.length > 1) {
|
||||
for (i = 1, ii = ends.length; i < ii; ++i) {
|
||||
if (this.isValid_(flatCoordinates, ends[i - 1], ends[i], stride)) {
|
||||
var lineString = ol.geom.flat.transform.translate(flatCoordinates, ends[i - 1], ends[i],
|
||||
var lineString = _ol_geom_flat_transform_.translate(flatCoordinates, ends[i - 1], ends[i],
|
||||
stride, -this.origin[0], -this.origin[1]);
|
||||
this.drawCoordinates_(
|
||||
lineString, 0, lineString.length, stride);
|
||||
@@ -354,9 +355,9 @@ ol.render.webgl.LineStringReplay.prototype.drawMultiLineString = function(multiL
|
||||
* @param {Array.<Array.<number>>} holeFlatCoordinates Hole flat coordinates.
|
||||
* @param {number} stride Stride.
|
||||
*/
|
||||
ol.render.webgl.LineStringReplay.prototype.drawPolygonCoordinates = function(
|
||||
_ol_render_webgl_LineStringReplay_.prototype.drawPolygonCoordinates = function(
|
||||
flatCoordinates, holeFlatCoordinates, stride) {
|
||||
if (!ol.geom.flat.topology.lineStringIsClosed(flatCoordinates, 0,
|
||||
if (!_ol_geom_flat_topology_.lineStringIsClosed(flatCoordinates, 0,
|
||||
flatCoordinates.length, stride)) {
|
||||
flatCoordinates.push(flatCoordinates[0]);
|
||||
flatCoordinates.push(flatCoordinates[1]);
|
||||
@@ -365,7 +366,7 @@ ol.render.webgl.LineStringReplay.prototype.drawPolygonCoordinates = function(
|
||||
if (holeFlatCoordinates.length) {
|
||||
var i, ii;
|
||||
for (i = 0, ii = holeFlatCoordinates.length; i < ii; ++i) {
|
||||
if (!ol.geom.flat.topology.lineStringIsClosed(holeFlatCoordinates[i], 0,
|
||||
if (!_ol_geom_flat_topology_.lineStringIsClosed(holeFlatCoordinates[i], 0,
|
||||
holeFlatCoordinates[i].length, stride)) {
|
||||
holeFlatCoordinates[i].push(holeFlatCoordinates[i][0]);
|
||||
holeFlatCoordinates[i].push(holeFlatCoordinates[i][1]);
|
||||
@@ -381,7 +382,7 @@ ol.render.webgl.LineStringReplay.prototype.drawPolygonCoordinates = function(
|
||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||
* @param {number=} opt_index Index count.
|
||||
*/
|
||||
ol.render.webgl.LineStringReplay.prototype.setPolygonStyle = function(feature, opt_index) {
|
||||
_ol_render_webgl_LineStringReplay_.prototype.setPolygonStyle = function(feature, opt_index) {
|
||||
var index = opt_index === undefined ? this.indices.length : opt_index;
|
||||
this.startIndices.push(index);
|
||||
this.startIndicesFeature.push(feature);
|
||||
@@ -395,7 +396,7 @@ ol.render.webgl.LineStringReplay.prototype.setPolygonStyle = function(feature, o
|
||||
/**
|
||||
* @return {number} Current index.
|
||||
*/
|
||||
ol.render.webgl.LineStringReplay.prototype.getCurrentIndex = function() {
|
||||
_ol_render_webgl_LineStringReplay_.prototype.getCurrentIndex = function() {
|
||||
return this.indices.length;
|
||||
};
|
||||
|
||||
@@ -403,12 +404,12 @@ ol.render.webgl.LineStringReplay.prototype.getCurrentIndex = function() {
|
||||
/**
|
||||
* @inheritDoc
|
||||
**/
|
||||
ol.render.webgl.LineStringReplay.prototype.finish = function(context) {
|
||||
_ol_render_webgl_LineStringReplay_.prototype.finish = function(context) {
|
||||
// create, bind, and populate the vertices buffer
|
||||
this.verticesBuffer = new ol.webgl.Buffer(this.vertices);
|
||||
this.verticesBuffer = new _ol_webgl_Buffer_(this.vertices);
|
||||
|
||||
// create, bind, and populate the indices buffer
|
||||
this.indicesBuffer = new ol.webgl.Buffer(this.indices);
|
||||
this.indicesBuffer = new _ol_webgl_Buffer_(this.indices);
|
||||
|
||||
this.startIndices.push(this.indices.length);
|
||||
|
||||
@@ -425,7 +426,7 @@ ol.render.webgl.LineStringReplay.prototype.finish = function(context) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.LineStringReplay.prototype.getDeleteResourcesFunction = function(context) {
|
||||
_ol_render_webgl_LineStringReplay_.prototype.getDeleteResourcesFunction = function(context) {
|
||||
var verticesBuffer = this.verticesBuffer;
|
||||
var indicesBuffer = this.indicesBuffer;
|
||||
return function() {
|
||||
@@ -438,17 +439,17 @@ ol.render.webgl.LineStringReplay.prototype.getDeleteResourcesFunction = function
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.LineStringReplay.prototype.setUpProgram = function(gl, context, size, pixelRatio) {
|
||||
_ol_render_webgl_LineStringReplay_.prototype.setUpProgram = function(gl, context, size, pixelRatio) {
|
||||
// get the program
|
||||
var fragmentShader, vertexShader;
|
||||
fragmentShader = ol.render.webgl.linestringreplay.defaultshader.fragment;
|
||||
vertexShader = ol.render.webgl.linestringreplay.defaultshader.vertex;
|
||||
fragmentShader = _ol_render_webgl_linestringreplay_defaultshader_.fragment;
|
||||
vertexShader = _ol_render_webgl_linestringreplay_defaultshader_.vertex;
|
||||
var program = context.getProgram(fragmentShader, vertexShader);
|
||||
|
||||
// get the locations
|
||||
var locations;
|
||||
if (!this.defaultLocations_) {
|
||||
locations = new ol.render.webgl.linestringreplay.defaultshader.Locations(gl, program);
|
||||
locations = new _ol_render_webgl_linestringreplay_defaultshader_Locations_(gl, program);
|
||||
this.defaultLocations_ = locations;
|
||||
} else {
|
||||
locations = this.defaultLocations_;
|
||||
@@ -458,19 +459,19 @@ ol.render.webgl.LineStringReplay.prototype.setUpProgram = function(gl, context,
|
||||
|
||||
// enable the vertex attrib arrays
|
||||
gl.enableVertexAttribArray(locations.a_lastPos);
|
||||
gl.vertexAttribPointer(locations.a_lastPos, 2, ol.webgl.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_lastPos, 2, _ol_webgl_.FLOAT,
|
||||
false, 28, 0);
|
||||
|
||||
gl.enableVertexAttribArray(locations.a_position);
|
||||
gl.vertexAttribPointer(locations.a_position, 2, ol.webgl.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_position, 2, _ol_webgl_.FLOAT,
|
||||
false, 28, 8);
|
||||
|
||||
gl.enableVertexAttribArray(locations.a_nextPos);
|
||||
gl.vertexAttribPointer(locations.a_nextPos, 2, ol.webgl.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_nextPos, 2, _ol_webgl_.FLOAT,
|
||||
false, 28, 16);
|
||||
|
||||
gl.enableVertexAttribArray(locations.a_direction);
|
||||
gl.vertexAttribPointer(locations.a_direction, 1, ol.webgl.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_direction, 1, _ol_webgl_.FLOAT,
|
||||
false, 28, 24);
|
||||
|
||||
// Enable renderer specific uniforms.
|
||||
@@ -484,7 +485,7 @@ ol.render.webgl.LineStringReplay.prototype.setUpProgram = function(gl, context,
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.LineStringReplay.prototype.shutDownProgram = function(gl, locations) {
|
||||
_ol_render_webgl_LineStringReplay_.prototype.shutDownProgram = function(gl, locations) {
|
||||
gl.disableVertexAttribArray(locations.a_lastPos);
|
||||
gl.disableVertexAttribArray(locations.a_position);
|
||||
gl.disableVertexAttribArray(locations.a_nextPos);
|
||||
@@ -495,7 +496,7 @@ ol.render.webgl.LineStringReplay.prototype.shutDownProgram = function(gl, locati
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.LineStringReplay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {
|
||||
_ol_render_webgl_LineStringReplay_.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {
|
||||
//Save GL parameters.
|
||||
var tmpDepthFunc = /** @type {number} */ (gl.getParameter(gl.DEPTH_FUNC));
|
||||
var tmpDepthMask = /** @type {boolean} */ (gl.getParameter(gl.DEPTH_WRITEMASK));
|
||||
@@ -506,7 +507,7 @@ ol.render.webgl.LineStringReplay.prototype.drawReplay = function(gl, context, sk
|
||||
gl.depthFunc(gl.NOTEQUAL);
|
||||
}
|
||||
|
||||
if (!ol.obj.isEmpty(skippedFeaturesHash)) {
|
||||
if (!_ol_obj_.isEmpty(skippedFeaturesHash)) {
|
||||
this.drawReplaySkipping_(gl, context, skippedFeaturesHash);
|
||||
} else {
|
||||
//Draw by style groups to minimize drawElements() calls.
|
||||
@@ -537,7 +538,7 @@ ol.render.webgl.LineStringReplay.prototype.drawReplay = function(gl, context, sk
|
||||
* @param {ol.webgl.Context} context Context.
|
||||
* @param {Object} skippedFeaturesHash Ids of features to skip.
|
||||
*/
|
||||
ol.render.webgl.LineStringReplay.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash) {
|
||||
_ol_render_webgl_LineStringReplay_.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash) {
|
||||
var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex, featureStart;
|
||||
featureIndex = this.startIndices.length - 2;
|
||||
end = start = this.startIndices[featureIndex + 1];
|
||||
@@ -550,7 +551,7 @@ ol.render.webgl.LineStringReplay.prototype.drawReplaySkipping_ = function(gl, co
|
||||
this.startIndices[featureIndex] >= groupStart) {
|
||||
featureStart = this.startIndices[featureIndex];
|
||||
feature = this.startIndicesFeature[featureIndex];
|
||||
featureUid = ol.getUid(feature).toString();
|
||||
featureUid = _ol_.getUid(feature).toString();
|
||||
|
||||
if (skippedFeaturesHash[featureUid]) {
|
||||
if (start !== end) {
|
||||
@@ -574,7 +575,7 @@ ol.render.webgl.LineStringReplay.prototype.drawReplaySkipping_ = function(gl, co
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.LineStringReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash,
|
||||
_ol_render_webgl_LineStringReplay_.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash,
|
||||
featureCallback, opt_hitExtent) {
|
||||
var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex;
|
||||
featureIndex = this.startIndices.length - 2;
|
||||
@@ -588,11 +589,11 @@ ol.render.webgl.LineStringReplay.prototype.drawHitDetectionReplayOneByOne = func
|
||||
this.startIndices[featureIndex] >= groupStart) {
|
||||
start = this.startIndices[featureIndex];
|
||||
feature = this.startIndicesFeature[featureIndex];
|
||||
featureUid = ol.getUid(feature).toString();
|
||||
featureUid = _ol_.getUid(feature).toString();
|
||||
|
||||
if (skippedFeaturesHash[featureUid] === undefined &&
|
||||
feature.getGeometry() &&
|
||||
(opt_hitExtent === undefined || ol.extent.intersects(
|
||||
(opt_hitExtent === undefined || _ol_extent_.intersects(
|
||||
/** @type {Array<number>} */ (opt_hitExtent),
|
||||
feature.getGeometry().getExtent()))) {
|
||||
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
||||
@@ -620,7 +621,7 @@ ol.render.webgl.LineStringReplay.prototype.drawHitDetectionReplayOneByOne = func
|
||||
* @param {number} lineWidth Line width.
|
||||
* @param {number} miterLimit Miter limit.
|
||||
*/
|
||||
ol.render.webgl.LineStringReplay.prototype.setStrokeStyle_ = function(gl, color, lineWidth, miterLimit) {
|
||||
_ol_render_webgl_LineStringReplay_.prototype.setStrokeStyle_ = function(gl, color, lineWidth, miterLimit) {
|
||||
gl.uniform4fv(this.defaultLocations_.u_color, color);
|
||||
gl.uniform1f(this.defaultLocations_.u_lineWidth, lineWidth);
|
||||
gl.uniform1f(this.defaultLocations_.u_miterLimit, miterLimit);
|
||||
@@ -630,35 +631,35 @@ ol.render.webgl.LineStringReplay.prototype.setStrokeStyle_ = function(gl, color,
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.LineStringReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
||||
_ol_render_webgl_LineStringReplay_.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
||||
var strokeStyleLineCap = strokeStyle.getLineCap();
|
||||
this.state_.lineCap = strokeStyleLineCap !== undefined ?
|
||||
strokeStyleLineCap : ol.render.webgl.defaultLineCap;
|
||||
strokeStyleLineCap : _ol_render_webgl_.defaultLineCap;
|
||||
var strokeStyleLineDash = strokeStyle.getLineDash();
|
||||
this.state_.lineDash = strokeStyleLineDash ?
|
||||
strokeStyleLineDash : ol.render.webgl.defaultLineDash;
|
||||
strokeStyleLineDash : _ol_render_webgl_.defaultLineDash;
|
||||
var strokeStyleLineDashOffset = strokeStyle.getLineDashOffset();
|
||||
this.state_.lineDashOffset = strokeStyleLineDashOffset ?
|
||||
strokeStyleLineDashOffset : ol.render.webgl.defaultLineDashOffset;
|
||||
strokeStyleLineDashOffset : _ol_render_webgl_.defaultLineDashOffset;
|
||||
var strokeStyleLineJoin = strokeStyle.getLineJoin();
|
||||
this.state_.lineJoin = strokeStyleLineJoin !== undefined ?
|
||||
strokeStyleLineJoin : ol.render.webgl.defaultLineJoin;
|
||||
strokeStyleLineJoin : _ol_render_webgl_.defaultLineJoin;
|
||||
var strokeStyleColor = strokeStyle.getColor();
|
||||
if (!(strokeStyleColor instanceof CanvasGradient) &&
|
||||
!(strokeStyleColor instanceof CanvasPattern)) {
|
||||
strokeStyleColor = ol.color.asArray(strokeStyleColor).map(function(c, i) {
|
||||
strokeStyleColor = _ol_color_.asArray(strokeStyleColor).map(function(c, i) {
|
||||
return i != 3 ? c / 255 : c;
|
||||
}) || ol.render.webgl.defaultStrokeStyle;
|
||||
}) || _ol_render_webgl_.defaultStrokeStyle;
|
||||
} else {
|
||||
strokeStyleColor = ol.render.webgl.defaultStrokeStyle;
|
||||
strokeStyleColor = _ol_render_webgl_.defaultStrokeStyle;
|
||||
}
|
||||
var strokeStyleWidth = strokeStyle.getWidth();
|
||||
strokeStyleWidth = strokeStyleWidth !== undefined ?
|
||||
strokeStyleWidth : ol.render.webgl.defaultLineWidth;
|
||||
strokeStyleWidth : _ol_render_webgl_.defaultLineWidth;
|
||||
var strokeStyleMiterLimit = strokeStyle.getMiterLimit();
|
||||
strokeStyleMiterLimit = strokeStyleMiterLimit !== undefined ?
|
||||
strokeStyleMiterLimit : ol.render.webgl.defaultMiterLimit;
|
||||
if (!this.state_.strokeColor || !ol.array.equals(this.state_.strokeColor, strokeStyleColor) ||
|
||||
strokeStyleMiterLimit : _ol_render_webgl_.defaultMiterLimit;
|
||||
if (!this.state_.strokeColor || !_ol_array_.equals(this.state_.strokeColor, strokeStyleColor) ||
|
||||
this.state_.lineWidth !== strokeStyleWidth || this.state_.miterLimit !== strokeStyleMiterLimit) {
|
||||
this.state_.changed = true;
|
||||
this.state_.strokeColor = strokeStyleColor;
|
||||
@@ -672,7 +673,7 @@ ol.render.webgl.LineStringReplay.prototype.setFillStrokeStyle = function(fillSty
|
||||
* @enum {number}
|
||||
* @private
|
||||
*/
|
||||
ol.render.webgl.LineStringReplay.Instruction_ = {
|
||||
_ol_render_webgl_LineStringReplay_.Instruction_ = {
|
||||
ROUND: 2,
|
||||
BEGIN_LINE: 3,
|
||||
END_LINE: 5,
|
||||
@@ -683,3 +684,4 @@ ol.render.webgl.LineStringReplay.Instruction_ = {
|
||||
MITER_BOTTOM: 19,
|
||||
MITER_TOP: 23
|
||||
};
|
||||
export default _ol_render_webgl_LineStringReplay_;
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
goog.provide('ol.render.webgl.PolygonReplay');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.color');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.obj');
|
||||
goog.require('ol.geom.flat.contains');
|
||||
goog.require('ol.geom.flat.orient');
|
||||
goog.require('ol.geom.flat.transform');
|
||||
goog.require('ol.render.webgl.polygonreplay.defaultshader');
|
||||
goog.require('ol.render.webgl.polygonreplay.defaultshader.Locations');
|
||||
goog.require('ol.render.webgl.LineStringReplay');
|
||||
goog.require('ol.render.webgl.Replay');
|
||||
goog.require('ol.render.webgl');
|
||||
goog.require('ol.style.Stroke');
|
||||
goog.require('ol.structs.LinkedList');
|
||||
goog.require('ol.structs.RBush');
|
||||
goog.require('ol.webgl');
|
||||
goog.require('ol.webgl.Buffer');
|
||||
|
||||
/**
|
||||
* @module ol/render/webgl/PolygonReplay
|
||||
*/
|
||||
import _ol_ from '../../index.js';
|
||||
import _ol_array_ from '../../array.js';
|
||||
import _ol_color_ from '../../color.js';
|
||||
import _ol_extent_ from '../../extent.js';
|
||||
import _ol_obj_ from '../../obj.js';
|
||||
import _ol_geom_flat_contains_ from '../../geom/flat/contains.js';
|
||||
import _ol_geom_flat_orient_ from '../../geom/flat/orient.js';
|
||||
import _ol_geom_flat_transform_ from '../../geom/flat/transform.js';
|
||||
import _ol_render_webgl_polygonreplay_defaultshader_ from '../webgl/polygonreplay/defaultshader.js';
|
||||
import _ol_render_webgl_polygonreplay_defaultshader_Locations_ from '../webgl/polygonreplay/defaultshader/Locations.js';
|
||||
import _ol_render_webgl_LineStringReplay_ from '../webgl/LineStringReplay.js';
|
||||
import _ol_render_webgl_Replay_ from '../webgl/Replay.js';
|
||||
import _ol_render_webgl_ from '../webgl.js';
|
||||
import _ol_style_Stroke_ from '../../style/Stroke.js';
|
||||
import _ol_structs_LinkedList_ from '../../structs/LinkedList.js';
|
||||
import _ol_structs_RBush_ from '../../structs/RBush.js';
|
||||
import _ol_webgl_ from '../../webgl.js';
|
||||
import _ol_webgl_Buffer_ from '../../webgl/Buffer.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -27,10 +27,10 @@ goog.require('ol.webgl.Buffer');
|
||||
* @param {ol.Extent} maxExtent Max extent.
|
||||
* @struct
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay = function(tolerance, maxExtent) {
|
||||
ol.render.webgl.Replay.call(this, tolerance, maxExtent);
|
||||
var _ol_render_webgl_PolygonReplay_ = function(tolerance, maxExtent) {
|
||||
_ol_render_webgl_Replay_.call(this, tolerance, maxExtent);
|
||||
|
||||
this.lineStringReplay = new ol.render.webgl.LineStringReplay(
|
||||
this.lineStringReplay = new _ol_render_webgl_LineStringReplay_(
|
||||
tolerance, maxExtent);
|
||||
|
||||
/**
|
||||
@@ -62,7 +62,8 @@ ol.render.webgl.PolygonReplay = function(tolerance, maxExtent) {
|
||||
};
|
||||
|
||||
};
|
||||
ol.inherits(ol.render.webgl.PolygonReplay, ol.render.webgl.Replay);
|
||||
|
||||
_ol_.inherits(_ol_render_webgl_PolygonReplay_, _ol_render_webgl_Replay_);
|
||||
|
||||
|
||||
/**
|
||||
@@ -72,11 +73,11 @@ ol.inherits(ol.render.webgl.PolygonReplay, ol.render.webgl.Replay);
|
||||
* @param {number} stride Stride.
|
||||
* @private
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.drawCoordinates_ = function(
|
||||
_ol_render_webgl_PolygonReplay_.prototype.drawCoordinates_ = function(
|
||||
flatCoordinates, holeFlatCoordinates, stride) {
|
||||
// Triangulate the polygon
|
||||
var outerRing = new ol.structs.LinkedList();
|
||||
var rtree = new ol.structs.RBush();
|
||||
var outerRing = new _ol_structs_LinkedList_();
|
||||
var rtree = new _ol_structs_RBush_();
|
||||
// Initialize the outer ring
|
||||
this.processFlatCoordinates_(flatCoordinates, stride, outerRing, rtree, true);
|
||||
var maxCoords = this.getMaxCoords_(outerRing);
|
||||
@@ -87,9 +88,9 @@ ol.render.webgl.PolygonReplay.prototype.drawCoordinates_ = function(
|
||||
var holeLists = [];
|
||||
for (i = 0, ii = holeFlatCoordinates.length; i < ii; ++i) {
|
||||
var holeList = {
|
||||
list: new ol.structs.LinkedList(),
|
||||
list: new _ol_structs_LinkedList_(),
|
||||
maxCoords: undefined,
|
||||
rtree: new ol.structs.RBush()
|
||||
rtree: new _ol_structs_RBush_()
|
||||
};
|
||||
holeLists.push(holeList);
|
||||
this.processFlatCoordinates_(holeFlatCoordinates[i],
|
||||
@@ -137,9 +138,9 @@ ol.render.webgl.PolygonReplay.prototype.drawCoordinates_ = function(
|
||||
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
||||
* @param {boolean} clockwise Coordinate order should be clockwise.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.processFlatCoordinates_ = function(
|
||||
_ol_render_webgl_PolygonReplay_.prototype.processFlatCoordinates_ = function(
|
||||
flatCoordinates, stride, list, rtree, clockwise) {
|
||||
var isClockwise = ol.geom.flat.orient.linearRingIsClockwise(flatCoordinates,
|
||||
var isClockwise = _ol_geom_flat_orient_.linearRingIsClockwise(flatCoordinates,
|
||||
0, flatCoordinates.length, stride);
|
||||
var i, ii;
|
||||
var n = this.vertices.length / 2;
|
||||
@@ -189,7 +190,7 @@ ol.render.webgl.PolygonReplay.prototype.processFlatCoordinates_ = function(
|
||||
* @param {ol.structs.LinkedList} list Polygons ring.
|
||||
* @return {Array.<number>} Max X coordinates.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.getMaxCoords_ = function(list) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.getMaxCoords_ = function(list) {
|
||||
var start = list.firstItem();
|
||||
var seg = start;
|
||||
var maxCoords = [seg.p0.x, seg.p0.y];
|
||||
@@ -213,15 +214,15 @@ ol.render.webgl.PolygonReplay.prototype.getMaxCoords_ = function(list) {
|
||||
* @param {boolean} ccw The orientation of the polygon is counter-clockwise.
|
||||
* @return {boolean} There were reclassified points.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.classifyPoints_ = function(list, rtree, ccw) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.classifyPoints_ = function(list, rtree, ccw) {
|
||||
var start = list.firstItem();
|
||||
var s0 = start;
|
||||
var s1 = list.nextItem();
|
||||
var pointsReclassified = false;
|
||||
do {
|
||||
var reflex = ccw ? ol.render.webgl.triangleIsCounterClockwise(s1.p1.x,
|
||||
var reflex = ccw ? _ol_render_webgl_.triangleIsCounterClockwise(s1.p1.x,
|
||||
s1.p1.y, s0.p1.x, s0.p1.y, s0.p0.x, s0.p0.y) :
|
||||
ol.render.webgl.triangleIsCounterClockwise(s0.p0.x, s0.p0.y, s0.p1.x,
|
||||
_ol_render_webgl_.triangleIsCounterClockwise(s0.p0.x, s0.p0.y, s0.p1.x,
|
||||
s0.p1.y, s1.p1.x, s1.p1.y);
|
||||
if (reflex === undefined) {
|
||||
this.removeItem_(s0, s1, list, rtree);
|
||||
@@ -251,7 +252,7 @@ ol.render.webgl.PolygonReplay.prototype.classifyPoints_ = function(list, rtree,
|
||||
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
||||
* @return {boolean} Bridging was successful.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.bridgeHole_ = function(hole, holeMaxX,
|
||||
_ol_render_webgl_PolygonReplay_.prototype.bridgeHole_ = function(hole, holeMaxX,
|
||||
list, listMaxX, rtree) {
|
||||
var seg = hole.firstItem();
|
||||
while (seg.p1.x !== holeMaxX) {
|
||||
@@ -272,7 +273,7 @@ ol.render.webgl.PolygonReplay.prototype.bridgeHole_ = function(hole, holeMaxX,
|
||||
var intersection = this.calculateIntersection_(p1, p2, currSeg.p0,
|
||||
currSeg.p1, true);
|
||||
var dist = Math.abs(p1.x - intersection[0]);
|
||||
if (dist < minDist && ol.render.webgl.triangleIsCounterClockwise(p1.x, p1.y,
|
||||
if (dist < minDist && _ol_render_webgl_.triangleIsCounterClockwise(p1.x, p1.y,
|
||||
currSeg.p0.x, currSeg.p0.y, currSeg.p1.x, currSeg.p1.y) !== undefined) {
|
||||
minDist = dist;
|
||||
p5 = {x: intersection[0], y: intersection[1], i: -1};
|
||||
@@ -324,7 +325,7 @@ ol.render.webgl.PolygonReplay.prototype.bridgeHole_ = function(hole, holeMaxX,
|
||||
* @param {ol.structs.LinkedList} list Linked list of the polygon.
|
||||
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.triangulate_ = function(list, rtree) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.triangulate_ = function(list, rtree) {
|
||||
var ccw = false;
|
||||
var simple = this.isSimple_(list, rtree);
|
||||
|
||||
@@ -377,7 +378,7 @@ ol.render.webgl.PolygonReplay.prototype.triangulate_ = function(list, rtree) {
|
||||
* @param {boolean} ccw Orientation of the polygon is counter-clockwise.
|
||||
* @return {boolean} There were processed ears.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.clipEars_ = function(list, rtree, simple, ccw) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.clipEars_ = function(list, rtree, simple, ccw) {
|
||||
var numIndices = this.indices.length;
|
||||
var start = list.firstItem();
|
||||
var s0 = list.getPrevItem();
|
||||
@@ -403,7 +404,7 @@ ol.render.webgl.PolygonReplay.prototype.clipEars_ = function(list, rtree, simple
|
||||
variableCriterion) {
|
||||
//The diagonal is completely inside the polygon
|
||||
if (simple || p0.reflex === false || p2.reflex === false ||
|
||||
ol.geom.flat.orient.linearRingIsClockwise([s0.p0.x, s0.p0.y, p0.x,
|
||||
_ol_geom_flat_orient_.linearRingIsClockwise([s0.p0.x, s0.p0.y, p0.x,
|
||||
p0.y, p1.x, p1.y, p2.x, p2.y, s3.p1.x, s3.p1.y], 0, 10, 2) === !ccw) {
|
||||
//The diagonal is persumably valid, we have an ear
|
||||
this.indices[numIndices++] = p0.i;
|
||||
@@ -435,7 +436,7 @@ ol.render.webgl.PolygonReplay.prototype.clipEars_ = function(list, rtree, simple
|
||||
* @param {boolean=} opt_touch Resolve touching segments.
|
||||
* @return {boolean} There were resolved intersections.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.resolveSelfIntersections_ = function(
|
||||
_ol_render_webgl_PolygonReplay_.prototype.resolveSelfIntersections_ = function(
|
||||
list, rtree, opt_touch) {
|
||||
var start = list.firstItem();
|
||||
list.nextItem();
|
||||
@@ -503,7 +504,7 @@ ol.render.webgl.PolygonReplay.prototype.resolveSelfIntersections_ = function(
|
||||
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
||||
* @return {boolean} The polygon is simple.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.isSimple_ = function(list, rtree) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.isSimple_ = function(list, rtree) {
|
||||
var start = list.firstItem();
|
||||
var seg = start;
|
||||
do {
|
||||
@@ -521,7 +522,7 @@ ol.render.webgl.PolygonReplay.prototype.isSimple_ = function(list, rtree) {
|
||||
* @param {ol.structs.LinkedList} list Linked list of the polygon.
|
||||
* @return {boolean} Orientation is clockwise.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.isClockwise_ = function(list) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.isClockwise_ = function(list) {
|
||||
var length = list.getLength() * 2;
|
||||
var flatCoordinates = new Array(length);
|
||||
var start = list.firstItem();
|
||||
@@ -532,7 +533,7 @@ ol.render.webgl.PolygonReplay.prototype.isClockwise_ = function(list) {
|
||||
flatCoordinates[i++] = seg.p0.y;
|
||||
seg = list.nextItem();
|
||||
} while (seg !== start);
|
||||
return ol.geom.flat.orient.linearRingIsClockwise(flatCoordinates, 0, length, 2);
|
||||
return _ol_geom_flat_orient_.linearRingIsClockwise(flatCoordinates, 0, length, 2);
|
||||
};
|
||||
|
||||
|
||||
@@ -541,7 +542,7 @@ ol.render.webgl.PolygonReplay.prototype.isClockwise_ = function(list) {
|
||||
* @param {ol.structs.LinkedList} list Linked list of the polygon.
|
||||
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.splitPolygon_ = function(list, rtree) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.splitPolygon_ = function(list, rtree) {
|
||||
var start = list.firstItem();
|
||||
var s0 = start;
|
||||
do {
|
||||
@@ -552,8 +553,8 @@ ol.render.webgl.PolygonReplay.prototype.splitPolygon_ = function(list, rtree) {
|
||||
var intersection = this.calculateIntersection_(s0.p0,
|
||||
s0.p1, s1.p0, s1.p1);
|
||||
var p = this.createPoint_(intersection[0], intersection[1], n);
|
||||
var newPolygon = new ol.structs.LinkedList();
|
||||
var newRtree = new ol.structs.RBush();
|
||||
var newPolygon = new _ol_structs_LinkedList_();
|
||||
var newRtree = new _ol_structs_RBush_();
|
||||
this.insertItem_(p, s0.p1, newPolygon, newRtree);
|
||||
s0.p1 = p;
|
||||
rtree.update([Math.min(s0.p0.x, p.x), Math.min(s0.p0.y, p.y),
|
||||
@@ -587,7 +588,7 @@ ol.render.webgl.PolygonReplay.prototype.splitPolygon_ = function(list, rtree) {
|
||||
* @param {number} i Index.
|
||||
* @return {ol.WebglPolygonVertex} List item.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.createPoint_ = function(x, y, i) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.createPoint_ = function(x, y, i) {
|
||||
var numVertices = this.vertices.length;
|
||||
this.vertices[numVertices++] = x;
|
||||
this.vertices[numVertices++] = y;
|
||||
@@ -610,7 +611,7 @@ ol.render.webgl.PolygonReplay.prototype.createPoint_ = function(x, y, i) {
|
||||
* @param {ol.structs.RBush=} opt_rtree Insert the segment into the R-Tree.
|
||||
* @return {ol.WebglPolygonSegment} segment.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.insertItem_ = function(p0, p1, list, opt_rtree) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.insertItem_ = function(p0, p1, list, opt_rtree) {
|
||||
var seg = {
|
||||
p0: p0,
|
||||
p1: p1
|
||||
@@ -631,7 +632,7 @@ ol.render.webgl.PolygonReplay.prototype.insertItem_ = function(p0, p1, list, opt
|
||||
* @param {ol.structs.LinkedList} list Polygon ring.
|
||||
* @param {ol.structs.RBush} rtree R-Tree of the polygon.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.removeItem_ = function(s0, s1, list, rtree) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.removeItem_ = function(s0, s1, list, rtree) {
|
||||
if (list.getCurrItem() === s1) {
|
||||
list.removeItem();
|
||||
s0.p1 = s1.p1;
|
||||
@@ -651,7 +652,7 @@ ol.render.webgl.PolygonReplay.prototype.removeItem_ = function(s0, s1, list, rtr
|
||||
* @param {boolean=} opt_reflex Only include reflex points.
|
||||
* @return {Array.<ol.WebglPolygonVertex>} Points in the triangle.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.getPointsInTriangle_ = function(p0, p1,
|
||||
_ol_render_webgl_PolygonReplay_.prototype.getPointsInTriangle_ = function(p0, p1,
|
||||
p2, rtree, opt_reflex) {
|
||||
var i, ii, j, p;
|
||||
var result = [];
|
||||
@@ -664,7 +665,7 @@ ol.render.webgl.PolygonReplay.prototype.getPointsInTriangle_ = function(p0, p1,
|
||||
if (typeof p === 'object' && (!opt_reflex || p.reflex)) {
|
||||
if ((p.x !== p0.x || p.y !== p0.y) && (p.x !== p1.x || p.y !== p1.y) &&
|
||||
(p.x !== p2.x || p.y !== p2.y) && result.indexOf(p) === -1 &&
|
||||
ol.geom.flat.contains.linearRingContainsXY([p0.x, p0.y, p1.x, p1.y,
|
||||
_ol_geom_flat_contains_.linearRingContainsXY([p0.x, p0.y, p1.x, p1.y,
|
||||
p2.x, p2.y], 0, 6, 2, p.x, p.y)) {
|
||||
result.push(p);
|
||||
}
|
||||
@@ -682,7 +683,7 @@ ol.render.webgl.PolygonReplay.prototype.getPointsInTriangle_ = function(p0, p1,
|
||||
* @param {boolean=} opt_touch Touching segments should be considered an intersection.
|
||||
* @return {Array.<ol.WebglPolygonSegment>} Intersecting segments.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.getIntersections_ = function(segment, rtree, opt_touch) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.getIntersections_ = function(segment, rtree, opt_touch) {
|
||||
var p0 = segment.p0;
|
||||
var p1 = segment.p1;
|
||||
var segmentsInExtent = rtree.getInExtent([Math.min(p0.x, p1.x),
|
||||
@@ -712,14 +713,14 @@ ol.render.webgl.PolygonReplay.prototype.getIntersections_ = function(segment, rt
|
||||
* @param {boolean=} opt_touch Touching segments should be considered an intersection.
|
||||
* @return {Array.<number>|undefined} Intersection coordinates.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.calculateIntersection_ = function(p0,
|
||||
_ol_render_webgl_PolygonReplay_.prototype.calculateIntersection_ = function(p0,
|
||||
p1, p2, p3, opt_touch) {
|
||||
var denom = (p3.y - p2.y) * (p1.x - p0.x) - (p3.x - p2.x) * (p1.y - p0.y);
|
||||
if (denom !== 0) {
|
||||
var ua = ((p3.x - p2.x) * (p0.y - p2.y) - (p3.y - p2.y) * (p0.x - p2.x)) / denom;
|
||||
var ub = ((p1.x - p0.x) * (p0.y - p2.y) - (p1.y - p0.y) * (p0.x - p2.x)) / denom;
|
||||
if ((!opt_touch && ua > ol.render.webgl.EPSILON && ua < 1 - ol.render.webgl.EPSILON &&
|
||||
ub > ol.render.webgl.EPSILON && ub < 1 - ol.render.webgl.EPSILON) || (opt_touch &&
|
||||
if ((!opt_touch && ua > _ol_render_webgl_.EPSILON && ua < 1 - _ol_render_webgl_.EPSILON &&
|
||||
ub > _ol_render_webgl_.EPSILON && ub < 1 - _ol_render_webgl_.EPSILON) || (opt_touch &&
|
||||
ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1)) {
|
||||
return [p0.x + ua * (p1.x - p0.x), p0.y + ua * (p1.y - p0.y)];
|
||||
}
|
||||
@@ -737,7 +738,7 @@ ol.render.webgl.PolygonReplay.prototype.calculateIntersection_ = function(p0,
|
||||
* @param {ol.WebglPolygonVertex} p4 Point after the end of the diagonal.
|
||||
* @return {boolean} Diagonal is inside the polygon.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.diagonalIsInside_ = function(p0, p1, p2, p3, p4) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.diagonalIsInside_ = function(p0, p1, p2, p3, p4) {
|
||||
if (p1.reflex === undefined || p3.reflex === undefined) {
|
||||
return false;
|
||||
}
|
||||
@@ -754,7 +755,7 @@ ol.render.webgl.PolygonReplay.prototype.diagonalIsInside_ = function(p0, p1, p2,
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.drawMultiPolygon = function(multiPolygonGeometry, feature) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.drawMultiPolygon = function(multiPolygonGeometry, feature) {
|
||||
var endss = multiPolygonGeometry.getEndss();
|
||||
var stride = multiPolygonGeometry.getStride();
|
||||
var currIndex = this.indices.length;
|
||||
@@ -765,14 +766,14 @@ ol.render.webgl.PolygonReplay.prototype.drawMultiPolygon = function(multiPolygon
|
||||
for (i = 0, ii = endss.length; i < ii; ++i) {
|
||||
var ends = endss[i];
|
||||
if (ends.length > 0) {
|
||||
var outerRing = ol.geom.flat.transform.translate(flatCoordinates, start, ends[0],
|
||||
var outerRing = _ol_geom_flat_transform_.translate(flatCoordinates, start, ends[0],
|
||||
stride, -this.origin[0], -this.origin[1]);
|
||||
if (outerRing.length) {
|
||||
var holes = [];
|
||||
var holeFlatCoords;
|
||||
for (j = 1, jj = ends.length; j < jj; ++j) {
|
||||
if (ends[j] !== ends[j - 1]) {
|
||||
holeFlatCoords = ol.geom.flat.transform.translate(flatCoordinates, ends[j - 1],
|
||||
holeFlatCoords = _ol_geom_flat_transform_.translate(flatCoordinates, ends[j - 1],
|
||||
ends[j], stride, -this.origin[0], -this.origin[1]);
|
||||
holes.push(holeFlatCoords);
|
||||
}
|
||||
@@ -800,19 +801,19 @@ ol.render.webgl.PolygonReplay.prototype.drawMultiPolygon = function(multiPolygon
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.drawPolygon = function(polygonGeometry, feature) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.drawPolygon = function(polygonGeometry, feature) {
|
||||
var ends = polygonGeometry.getEnds();
|
||||
var stride = polygonGeometry.getStride();
|
||||
if (ends.length > 0) {
|
||||
var flatCoordinates = polygonGeometry.getFlatCoordinates().map(Number);
|
||||
var outerRing = ol.geom.flat.transform.translate(flatCoordinates, 0, ends[0],
|
||||
var outerRing = _ol_geom_flat_transform_.translate(flatCoordinates, 0, ends[0],
|
||||
stride, -this.origin[0], -this.origin[1]);
|
||||
if (outerRing.length) {
|
||||
var holes = [];
|
||||
var i, ii, holeFlatCoords;
|
||||
for (i = 1, ii = ends.length; i < ii; ++i) {
|
||||
if (ends[i] !== ends[i - 1]) {
|
||||
holeFlatCoords = ol.geom.flat.transform.translate(flatCoordinates, ends[i - 1],
|
||||
holeFlatCoords = _ol_geom_flat_transform_.translate(flatCoordinates, ends[i - 1],
|
||||
ends[i], stride, -this.origin[0], -this.origin[1]);
|
||||
holes.push(holeFlatCoords);
|
||||
}
|
||||
@@ -836,12 +837,12 @@ ol.render.webgl.PolygonReplay.prototype.drawPolygon = function(polygonGeometry,
|
||||
/**
|
||||
* @inheritDoc
|
||||
**/
|
||||
ol.render.webgl.PolygonReplay.prototype.finish = function(context) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.finish = function(context) {
|
||||
// create, bind, and populate the vertices buffer
|
||||
this.verticesBuffer = new ol.webgl.Buffer(this.vertices);
|
||||
this.verticesBuffer = new _ol_webgl_Buffer_(this.vertices);
|
||||
|
||||
// create, bind, and populate the indices buffer
|
||||
this.indicesBuffer = new ol.webgl.Buffer(this.indices);
|
||||
this.indicesBuffer = new _ol_webgl_Buffer_(this.indices);
|
||||
|
||||
this.startIndices.push(this.indices.length);
|
||||
|
||||
@@ -860,7 +861,7 @@ ol.render.webgl.PolygonReplay.prototype.finish = function(context) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.getDeleteResourcesFunction = function(context) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.getDeleteResourcesFunction = function(context) {
|
||||
var verticesBuffer = this.verticesBuffer;
|
||||
var indicesBuffer = this.indicesBuffer;
|
||||
var lineDeleter = this.lineStringReplay.getDeleteResourcesFunction(context);
|
||||
@@ -875,17 +876,17 @@ ol.render.webgl.PolygonReplay.prototype.getDeleteResourcesFunction = function(co
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.setUpProgram = function(gl, context, size, pixelRatio) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.setUpProgram = function(gl, context, size, pixelRatio) {
|
||||
// get the program
|
||||
var fragmentShader, vertexShader;
|
||||
fragmentShader = ol.render.webgl.polygonreplay.defaultshader.fragment;
|
||||
vertexShader = ol.render.webgl.polygonreplay.defaultshader.vertex;
|
||||
fragmentShader = _ol_render_webgl_polygonreplay_defaultshader_.fragment;
|
||||
vertexShader = _ol_render_webgl_polygonreplay_defaultshader_.vertex;
|
||||
var program = context.getProgram(fragmentShader, vertexShader);
|
||||
|
||||
// get the locations
|
||||
var locations;
|
||||
if (!this.defaultLocations_) {
|
||||
locations = new ol.render.webgl.polygonreplay.defaultshader.Locations(gl, program);
|
||||
locations = new _ol_render_webgl_polygonreplay_defaultshader_Locations_(gl, program);
|
||||
this.defaultLocations_ = locations;
|
||||
} else {
|
||||
locations = this.defaultLocations_;
|
||||
@@ -895,7 +896,7 @@ ol.render.webgl.PolygonReplay.prototype.setUpProgram = function(gl, context, siz
|
||||
|
||||
// enable the vertex attrib arrays
|
||||
gl.enableVertexAttribArray(locations.a_position);
|
||||
gl.vertexAttribPointer(locations.a_position, 2, ol.webgl.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_position, 2, _ol_webgl_.FLOAT,
|
||||
false, 8, 0);
|
||||
|
||||
return locations;
|
||||
@@ -905,7 +906,7 @@ ol.render.webgl.PolygonReplay.prototype.setUpProgram = function(gl, context, siz
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.shutDownProgram = function(gl, locations) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.shutDownProgram = function(gl, locations) {
|
||||
gl.disableVertexAttribArray(locations.a_position);
|
||||
};
|
||||
|
||||
@@ -913,7 +914,7 @@ ol.render.webgl.PolygonReplay.prototype.shutDownProgram = function(gl, locations
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {
|
||||
//Save GL parameters.
|
||||
var tmpDepthFunc = /** @type {number} */ (gl.getParameter(gl.DEPTH_FUNC));
|
||||
var tmpDepthMask = /** @type {boolean} */ (gl.getParameter(gl.DEPTH_WRITEMASK));
|
||||
@@ -924,7 +925,7 @@ ol.render.webgl.PolygonReplay.prototype.drawReplay = function(gl, context, skipp
|
||||
gl.depthFunc(gl.NOTEQUAL);
|
||||
}
|
||||
|
||||
if (!ol.obj.isEmpty(skippedFeaturesHash)) {
|
||||
if (!_ol_obj_.isEmpty(skippedFeaturesHash)) {
|
||||
this.drawReplaySkipping_(gl, context, skippedFeaturesHash);
|
||||
} else {
|
||||
//Draw by style groups to minimize drawElements() calls.
|
||||
@@ -951,7 +952,7 @@ ol.render.webgl.PolygonReplay.prototype.drawReplay = function(gl, context, skipp
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash,
|
||||
_ol_render_webgl_PolygonReplay_.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash,
|
||||
featureCallback, opt_hitExtent) {
|
||||
var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex;
|
||||
featureIndex = this.startIndices.length - 2;
|
||||
@@ -965,11 +966,11 @@ ol.render.webgl.PolygonReplay.prototype.drawHitDetectionReplayOneByOne = functio
|
||||
this.startIndices[featureIndex] >= groupStart) {
|
||||
start = this.startIndices[featureIndex];
|
||||
feature = this.startIndicesFeature[featureIndex];
|
||||
featureUid = ol.getUid(feature).toString();
|
||||
featureUid = _ol_.getUid(feature).toString();
|
||||
|
||||
if (skippedFeaturesHash[featureUid] === undefined &&
|
||||
feature.getGeometry() &&
|
||||
(opt_hitExtent === undefined || ol.extent.intersects(
|
||||
(opt_hitExtent === undefined || _ol_extent_.intersects(
|
||||
/** @type {Array<number>} */ (opt_hitExtent),
|
||||
feature.getGeometry().getExtent()))) {
|
||||
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
||||
@@ -996,7 +997,7 @@ ol.render.webgl.PolygonReplay.prototype.drawHitDetectionReplayOneByOne = functio
|
||||
* @param {ol.webgl.Context} context Context.
|
||||
* @param {Object} skippedFeaturesHash Ids of features to skip.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.drawReplaySkipping_ = function(gl, context, skippedFeaturesHash) {
|
||||
var i, start, end, nextStyle, groupStart, feature, featureUid, featureIndex, featureStart;
|
||||
featureIndex = this.startIndices.length - 2;
|
||||
end = start = this.startIndices[featureIndex + 1];
|
||||
@@ -1009,7 +1010,7 @@ ol.render.webgl.PolygonReplay.prototype.drawReplaySkipping_ = function(gl, conte
|
||||
this.startIndices[featureIndex] >= groupStart) {
|
||||
featureStart = this.startIndices[featureIndex];
|
||||
feature = this.startIndicesFeature[featureIndex];
|
||||
featureUid = ol.getUid(feature).toString();
|
||||
featureUid = _ol_.getUid(feature).toString();
|
||||
|
||||
if (skippedFeaturesHash[featureUid]) {
|
||||
if (start !== end) {
|
||||
@@ -1035,7 +1036,7 @@ ol.render.webgl.PolygonReplay.prototype.drawReplaySkipping_ = function(gl, conte
|
||||
* @param {WebGLRenderingContext} gl gl.
|
||||
* @param {Array.<number>} color Color.
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.setFillStyle_ = function(gl, color) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.setFillStyle_ = function(gl, color) {
|
||||
gl.uniform4fv(this.defaultLocations_.u_color, color);
|
||||
};
|
||||
|
||||
@@ -1043,17 +1044,17 @@ ol.render.webgl.PolygonReplay.prototype.setFillStyle_ = function(gl, color) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.PolygonReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
||||
_ol_render_webgl_PolygonReplay_.prototype.setFillStrokeStyle = function(fillStyle, strokeStyle) {
|
||||
var fillStyleColor = fillStyle ? fillStyle.getColor() : [0, 0, 0, 0];
|
||||
if (!(fillStyleColor instanceof CanvasGradient) &&
|
||||
!(fillStyleColor instanceof CanvasPattern)) {
|
||||
fillStyleColor = ol.color.asArray(fillStyleColor).map(function(c, i) {
|
||||
fillStyleColor = _ol_color_.asArray(fillStyleColor).map(function(c, i) {
|
||||
return i != 3 ? c / 255 : c;
|
||||
}) || ol.render.webgl.defaultFillStyle;
|
||||
}) || _ol_render_webgl_.defaultFillStyle;
|
||||
} else {
|
||||
fillStyleColor = ol.render.webgl.defaultFillStyle;
|
||||
fillStyleColor = _ol_render_webgl_.defaultFillStyle;
|
||||
}
|
||||
if (!this.state_.fillColor || !ol.array.equals(fillStyleColor, this.state_.fillColor)) {
|
||||
if (!this.state_.fillColor || !_ol_array_.equals(fillStyleColor, this.state_.fillColor)) {
|
||||
this.state_.fillColor = fillStyleColor;
|
||||
this.state_.changed = true;
|
||||
this.styles_.push(fillStyleColor);
|
||||
@@ -1062,10 +1063,11 @@ ol.render.webgl.PolygonReplay.prototype.setFillStrokeStyle = function(fillStyle,
|
||||
if (strokeStyle) {
|
||||
this.lineStringReplay.setFillStrokeStyle(null, strokeStyle);
|
||||
} else {
|
||||
var nullStrokeStyle = new ol.style.Stroke({
|
||||
var nullStrokeStyle = new _ol_style_Stroke_({
|
||||
color: [0, 0, 0, 0],
|
||||
lineWidth: 0
|
||||
});
|
||||
this.lineStringReplay.setFillStrokeStyle(null, nullStrokeStyle);
|
||||
}
|
||||
};
|
||||
export default _ol_render_webgl_PolygonReplay_;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
goog.provide('ol.render.webgl.Replay');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.render.VectorContext');
|
||||
goog.require('ol.transform');
|
||||
goog.require('ol.vec.Mat4');
|
||||
goog.require('ol.webgl');
|
||||
|
||||
/**
|
||||
* @module ol/render/webgl/Replay
|
||||
*/
|
||||
import _ol_ from '../../index.js';
|
||||
import _ol_extent_ from '../../extent.js';
|
||||
import _ol_render_VectorContext_ from '../VectorContext.js';
|
||||
import _ol_transform_ from '../../transform.js';
|
||||
import _ol_vec_Mat4_ from '../../vec/Mat4.js';
|
||||
import _ol_webgl_ from '../../webgl.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -16,8 +16,8 @@ goog.require('ol.webgl');
|
||||
* @param {ol.Extent} maxExtent Max extent.
|
||||
* @struct
|
||||
*/
|
||||
ol.render.webgl.Replay = function(tolerance, maxExtent) {
|
||||
ol.render.VectorContext.call(this);
|
||||
var _ol_render_webgl_Replay_ = function(tolerance, maxExtent) {
|
||||
_ol_render_VectorContext_.call(this);
|
||||
|
||||
/**
|
||||
* @protected
|
||||
@@ -40,31 +40,31 @@ ol.render.webgl.Replay = function(tolerance, maxExtent) {
|
||||
* @protected
|
||||
* @type {ol.Coordinate}
|
||||
*/
|
||||
this.origin = ol.extent.getCenter(maxExtent);
|
||||
this.origin = _ol_extent_.getCenter(maxExtent);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.Transform}
|
||||
*/
|
||||
this.projectionMatrix_ = ol.transform.create();
|
||||
this.projectionMatrix_ = _ol_transform_.create();
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.Transform}
|
||||
*/
|
||||
this.offsetRotateMatrix_ = ol.transform.create();
|
||||
this.offsetRotateMatrix_ = _ol_transform_.create();
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.Transform}
|
||||
*/
|
||||
this.offsetScaleMatrix_ = ol.transform.create();
|
||||
this.offsetScaleMatrix_ = _ol_transform_.create();
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<number>}
|
||||
*/
|
||||
this.tmpMat4_ = ol.vec.Mat4.create();
|
||||
this.tmpMat4_ = _ol_vec_Mat4_.create();
|
||||
|
||||
/**
|
||||
* @protected
|
||||
@@ -112,7 +112,8 @@ ol.render.webgl.Replay = function(tolerance, maxExtent) {
|
||||
this.lineStringReplay = undefined;
|
||||
|
||||
};
|
||||
ol.inherits(ol.render.webgl.Replay, ol.render.VectorContext);
|
||||
|
||||
_ol_.inherits(_ol_render_webgl_Replay_, _ol_render_VectorContext_);
|
||||
|
||||
|
||||
/**
|
||||
@@ -120,14 +121,14 @@ ol.inherits(ol.render.webgl.Replay, ol.render.VectorContext);
|
||||
* @param {ol.webgl.Context} context WebGL context.
|
||||
* @return {function()} Delete resources function.
|
||||
*/
|
||||
ol.render.webgl.Replay.prototype.getDeleteResourcesFunction = function(context) {};
|
||||
_ol_render_webgl_Replay_.prototype.getDeleteResourcesFunction = function(context) {};
|
||||
|
||||
|
||||
/**
|
||||
* @abstract
|
||||
* @param {ol.webgl.Context} context Context.
|
||||
*/
|
||||
ol.render.webgl.Replay.prototype.finish = function(context) {};
|
||||
_ol_render_webgl_Replay_.prototype.finish = function(context) {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -142,7 +143,7 @@ ol.render.webgl.Replay.prototype.finish = function(context) {};
|
||||
ol.render.webgl.polygonreplay.defaultshader.Locations|
|
||||
ol.render.webgl.texturereplay.defaultshader.Locations} Locations.
|
||||
*/
|
||||
ol.render.webgl.Replay.prototype.setUpProgram = function(gl, context, size, pixelRatio) {};
|
||||
_ol_render_webgl_Replay_.prototype.setUpProgram = function(gl, context, size, pixelRatio) {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -154,7 +155,7 @@ ol.render.webgl.Replay.prototype.setUpProgram = function(gl, context, size, pixe
|
||||
ol.render.webgl.polygonreplay.defaultshader.Locations|
|
||||
ol.render.webgl.texturereplay.defaultshader.Locations} locations Locations.
|
||||
*/
|
||||
ol.render.webgl.Replay.prototype.shutDownProgram = function(gl, locations) {};
|
||||
_ol_render_webgl_Replay_.prototype.shutDownProgram = function(gl, locations) {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -166,7 +167,7 @@ ol.render.webgl.Replay.prototype.shutDownProgram = function(gl, locations) {};
|
||||
* to skip.
|
||||
* @param {boolean} hitDetection Hit detection mode.
|
||||
*/
|
||||
ol.render.webgl.Replay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {};
|
||||
_ol_render_webgl_Replay_.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -182,7 +183,7 @@ ol.render.webgl.Replay.prototype.drawReplay = function(gl, context, skippedFeatu
|
||||
* @return {T|undefined} Callback result.
|
||||
* @template T
|
||||
*/
|
||||
ol.render.webgl.Replay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash, featureCallback, opt_hitExtent) {};
|
||||
_ol_render_webgl_Replay_.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash, featureCallback, opt_hitExtent) {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -198,7 +199,7 @@ ol.render.webgl.Replay.prototype.drawHitDetectionReplayOneByOne = function(gl, c
|
||||
* @return {T|undefined} Callback result.
|
||||
* @template T
|
||||
*/
|
||||
ol.render.webgl.Replay.prototype.drawHitDetectionReplay = function(gl, context, skippedFeaturesHash,
|
||||
_ol_render_webgl_Replay_.prototype.drawHitDetectionReplay = function(gl, context, skippedFeaturesHash,
|
||||
featureCallback, oneByOne, opt_hitExtent) {
|
||||
if (!oneByOne) {
|
||||
// draw all hit-detection features in "once" (by texture group)
|
||||
@@ -222,7 +223,7 @@ ol.render.webgl.Replay.prototype.drawHitDetectionReplay = function(gl, context,
|
||||
* @return {T|undefined} Callback result.
|
||||
* @template T
|
||||
*/
|
||||
ol.render.webgl.Replay.prototype.drawHitDetectionReplayAll = function(gl, context, skippedFeaturesHash,
|
||||
_ol_render_webgl_Replay_.prototype.drawHitDetectionReplayAll = function(gl, context, skippedFeaturesHash,
|
||||
featureCallback) {
|
||||
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
||||
this.drawReplay(gl, context, skippedFeaturesHash, true);
|
||||
@@ -253,7 +254,7 @@ ol.render.webgl.Replay.prototype.drawHitDetectionReplayAll = function(gl, contex
|
||||
* @return {T|undefined} Callback result.
|
||||
* @template T
|
||||
*/
|
||||
ol.render.webgl.Replay.prototype.replay = function(context,
|
||||
_ol_render_webgl_Replay_.prototype.replay = function(context,
|
||||
center, resolution, rotation, size, pixelRatio,
|
||||
opacity, skippedFeaturesHash,
|
||||
featureCallback, oneByOne, opt_hitExtent) {
|
||||
@@ -286,32 +287,32 @@ ol.render.webgl.Replay.prototype.replay = function(context,
|
||||
gl.stencilFunc(gl.NOTEQUAL, 1, 255);
|
||||
}
|
||||
|
||||
context.bindBuffer(ol.webgl.ARRAY_BUFFER, this.verticesBuffer);
|
||||
context.bindBuffer(_ol_webgl_.ARRAY_BUFFER, this.verticesBuffer);
|
||||
|
||||
context.bindBuffer(ol.webgl.ELEMENT_ARRAY_BUFFER, this.indicesBuffer);
|
||||
context.bindBuffer(_ol_webgl_.ELEMENT_ARRAY_BUFFER, this.indicesBuffer);
|
||||
|
||||
var locations = this.setUpProgram(gl, context, size, pixelRatio);
|
||||
|
||||
// set the "uniform" values
|
||||
var projectionMatrix = ol.transform.reset(this.projectionMatrix_);
|
||||
ol.transform.scale(projectionMatrix, 2 / (resolution * size[0]), 2 / (resolution * size[1]));
|
||||
ol.transform.rotate(projectionMatrix, -rotation);
|
||||
ol.transform.translate(projectionMatrix, -(center[0] - this.origin[0]), -(center[1] - this.origin[1]));
|
||||
var projectionMatrix = _ol_transform_.reset(this.projectionMatrix_);
|
||||
_ol_transform_.scale(projectionMatrix, 2 / (resolution * size[0]), 2 / (resolution * size[1]));
|
||||
_ol_transform_.rotate(projectionMatrix, -rotation);
|
||||
_ol_transform_.translate(projectionMatrix, -(center[0] - this.origin[0]), -(center[1] - this.origin[1]));
|
||||
|
||||
var offsetScaleMatrix = ol.transform.reset(this.offsetScaleMatrix_);
|
||||
ol.transform.scale(offsetScaleMatrix, 2 / size[0], 2 / size[1]);
|
||||
var offsetScaleMatrix = _ol_transform_.reset(this.offsetScaleMatrix_);
|
||||
_ol_transform_.scale(offsetScaleMatrix, 2 / size[0], 2 / size[1]);
|
||||
|
||||
var offsetRotateMatrix = ol.transform.reset(this.offsetRotateMatrix_);
|
||||
var offsetRotateMatrix = _ol_transform_.reset(this.offsetRotateMatrix_);
|
||||
if (rotation !== 0) {
|
||||
ol.transform.rotate(offsetRotateMatrix, -rotation);
|
||||
_ol_transform_.rotate(offsetRotateMatrix, -rotation);
|
||||
}
|
||||
|
||||
gl.uniformMatrix4fv(locations.u_projectionMatrix, false,
|
||||
ol.vec.Mat4.fromTransform(this.tmpMat4_, projectionMatrix));
|
||||
_ol_vec_Mat4_.fromTransform(this.tmpMat4_, projectionMatrix));
|
||||
gl.uniformMatrix4fv(locations.u_offsetScaleMatrix, false,
|
||||
ol.vec.Mat4.fromTransform(this.tmpMat4_, offsetScaleMatrix));
|
||||
_ol_vec_Mat4_.fromTransform(this.tmpMat4_, offsetScaleMatrix));
|
||||
gl.uniformMatrix4fv(locations.u_offsetRotateMatrix, false,
|
||||
ol.vec.Mat4.fromTransform(this.tmpMat4_, offsetRotateMatrix));
|
||||
_ol_vec_Mat4_.fromTransform(this.tmpMat4_, offsetRotateMatrix));
|
||||
gl.uniform1f(locations.u_opacity, opacity);
|
||||
|
||||
// draw!
|
||||
@@ -349,13 +350,14 @@ ol.render.webgl.Replay.prototype.replay = function(context,
|
||||
* @param {number} start Start index.
|
||||
* @param {number} end End index.
|
||||
*/
|
||||
ol.render.webgl.Replay.prototype.drawElements = function(
|
||||
_ol_render_webgl_Replay_.prototype.drawElements = function(
|
||||
gl, context, start, end) {
|
||||
var elementType = context.hasOESElementIndexUint ?
|
||||
ol.webgl.UNSIGNED_INT : ol.webgl.UNSIGNED_SHORT;
|
||||
_ol_webgl_.UNSIGNED_INT : _ol_webgl_.UNSIGNED_SHORT;
|
||||
var elementSize = context.hasOESElementIndexUint ? 4 : 2;
|
||||
|
||||
var numItems = end - start;
|
||||
var offsetInBytes = start * elementSize;
|
||||
gl.drawElements(ol.webgl.TRIANGLES, numItems, elementType, offsetInBytes);
|
||||
gl.drawElements(_ol_webgl_.TRIANGLES, numItems, elementType, offsetInBytes);
|
||||
};
|
||||
export default _ol_render_webgl_Replay_;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
goog.provide('ol.render.webgl.ReplayGroup');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.array');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.obj');
|
||||
goog.require('ol.render.replay');
|
||||
goog.require('ol.render.ReplayGroup');
|
||||
goog.require('ol.render.webgl.CircleReplay');
|
||||
goog.require('ol.render.webgl.ImageReplay');
|
||||
goog.require('ol.render.webgl.LineStringReplay');
|
||||
goog.require('ol.render.webgl.PolygonReplay');
|
||||
goog.require('ol.render.webgl.TextReplay');
|
||||
|
||||
/**
|
||||
* @module ol/render/webgl/ReplayGroup
|
||||
*/
|
||||
import _ol_ from '../../index.js';
|
||||
import _ol_array_ from '../../array.js';
|
||||
import _ol_extent_ from '../../extent.js';
|
||||
import _ol_obj_ from '../../obj.js';
|
||||
import _ol_render_replay_ from '../replay.js';
|
||||
import _ol_render_ReplayGroup_ from '../ReplayGroup.js';
|
||||
import _ol_render_webgl_CircleReplay_ from '../webgl/CircleReplay.js';
|
||||
import _ol_render_webgl_ImageReplay_ from '../webgl/ImageReplay.js';
|
||||
import _ol_render_webgl_LineStringReplay_ from '../webgl/LineStringReplay.js';
|
||||
import _ol_render_webgl_PolygonReplay_ from '../webgl/PolygonReplay.js';
|
||||
import _ol_render_webgl_TextReplay_ from '../webgl/TextReplay.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -21,8 +21,8 @@ goog.require('ol.render.webgl.TextReplay');
|
||||
* @param {number=} opt_renderBuffer Render buffer.
|
||||
* @struct
|
||||
*/
|
||||
ol.render.webgl.ReplayGroup = function(tolerance, maxExtent, opt_renderBuffer) {
|
||||
ol.render.ReplayGroup.call(this);
|
||||
var _ol_render_webgl_ReplayGroup_ = function(tolerance, maxExtent, opt_renderBuffer) {
|
||||
_ol_render_ReplayGroup_.call(this);
|
||||
|
||||
/**
|
||||
* @type {ol.Extent}
|
||||
@@ -50,21 +50,22 @@ ol.render.webgl.ReplayGroup = function(tolerance, maxExtent, opt_renderBuffer) {
|
||||
this.replaysByZIndex_ = {};
|
||||
|
||||
};
|
||||
ol.inherits(ol.render.webgl.ReplayGroup, ol.render.ReplayGroup);
|
||||
|
||||
_ol_.inherits(_ol_render_webgl_ReplayGroup_, _ol_render_ReplayGroup_);
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.style.Style} style Style.
|
||||
* @param {boolean} group Group with previous replay.
|
||||
*/
|
||||
ol.render.webgl.ReplayGroup.prototype.addDeclutter = function(style, group) {};
|
||||
_ol_render_webgl_ReplayGroup_.prototype.addDeclutter = function(style, group) {};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.webgl.Context} context WebGL context.
|
||||
* @return {function()} Delete resources function.
|
||||
*/
|
||||
ol.render.webgl.ReplayGroup.prototype.getDeleteResourcesFunction = function(context) {
|
||||
_ol_render_webgl_ReplayGroup_.prototype.getDeleteResourcesFunction = function(context) {
|
||||
var functions = [];
|
||||
var zKey;
|
||||
for (zKey in this.replaysByZIndex_) {
|
||||
@@ -89,7 +90,7 @@ ol.render.webgl.ReplayGroup.prototype.getDeleteResourcesFunction = function(cont
|
||||
/**
|
||||
* @param {ol.webgl.Context} context Context.
|
||||
*/
|
||||
ol.render.webgl.ReplayGroup.prototype.finish = function(context) {
|
||||
_ol_render_webgl_ReplayGroup_.prototype.finish = function(context) {
|
||||
var zKey;
|
||||
for (zKey in this.replaysByZIndex_) {
|
||||
var replays = this.replaysByZIndex_[zKey];
|
||||
@@ -104,7 +105,7 @@ ol.render.webgl.ReplayGroup.prototype.finish = function(context) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.ReplayGroup.prototype.getReplay = function(zIndex, replayType) {
|
||||
_ol_render_webgl_ReplayGroup_.prototype.getReplay = function(zIndex, replayType) {
|
||||
var zIndexKey = zIndex !== undefined ? zIndex.toString() : '0';
|
||||
var replays = this.replaysByZIndex_[zIndexKey];
|
||||
if (replays === undefined) {
|
||||
@@ -116,7 +117,7 @@ ol.render.webgl.ReplayGroup.prototype.getReplay = function(zIndex, replayType) {
|
||||
/**
|
||||
* @type {Function}
|
||||
*/
|
||||
var Constructor = ol.render.webgl.ReplayGroup.BATCH_CONSTRUCTORS_[replayType];
|
||||
var Constructor = _ol_render_webgl_ReplayGroup_.BATCH_CONSTRUCTORS_[replayType];
|
||||
replay = new Constructor(this.tolerance_, this.maxExtent_);
|
||||
replays[replayType] = replay;
|
||||
}
|
||||
@@ -127,8 +128,8 @@ ol.render.webgl.ReplayGroup.prototype.getReplay = function(zIndex, replayType) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.ReplayGroup.prototype.isEmpty = function() {
|
||||
return ol.obj.isEmpty(this.replaysByZIndex_);
|
||||
_ol_render_webgl_ReplayGroup_.prototype.isEmpty = function() {
|
||||
return _ol_obj_.isEmpty(this.replaysByZIndex_);
|
||||
};
|
||||
|
||||
|
||||
@@ -143,18 +144,18 @@ ol.render.webgl.ReplayGroup.prototype.isEmpty = function() {
|
||||
* @param {Object.<string, boolean>} skippedFeaturesHash Ids of features
|
||||
* to skip.
|
||||
*/
|
||||
ol.render.webgl.ReplayGroup.prototype.replay = function(context,
|
||||
_ol_render_webgl_ReplayGroup_.prototype.replay = function(context,
|
||||
center, resolution, rotation, size, pixelRatio,
|
||||
opacity, skippedFeaturesHash) {
|
||||
/** @type {Array.<number>} */
|
||||
var zs = Object.keys(this.replaysByZIndex_).map(Number);
|
||||
zs.sort(ol.array.numberSafeCompareFunction);
|
||||
zs.sort(_ol_array_.numberSafeCompareFunction);
|
||||
|
||||
var i, ii, j, jj, replays, replay;
|
||||
for (i = 0, ii = zs.length; i < ii; ++i) {
|
||||
replays = this.replaysByZIndex_[zs[i].toString()];
|
||||
for (j = 0, jj = ol.render.replay.ORDER.length; j < jj; ++j) {
|
||||
replay = replays[ol.render.replay.ORDER[j]];
|
||||
for (j = 0, jj = _ol_render_replay_.ORDER.length; j < jj; ++j) {
|
||||
replay = replays[_ol_render_replay_.ORDER[j]];
|
||||
if (replay !== undefined) {
|
||||
replay.replay(context,
|
||||
center, resolution, rotation, size, pixelRatio,
|
||||
@@ -184,7 +185,7 @@ ol.render.webgl.ReplayGroup.prototype.replay = function(context,
|
||||
* @return {T|undefined} Callback result.
|
||||
* @template T
|
||||
*/
|
||||
ol.render.webgl.ReplayGroup.prototype.replayHitDetection_ = function(context,
|
||||
_ol_render_webgl_ReplayGroup_.prototype.replayHitDetection_ = function(context,
|
||||
center, resolution, rotation, size, pixelRatio, opacity,
|
||||
skippedFeaturesHash, featureCallback, oneByOne, opt_hitExtent) {
|
||||
/** @type {Array.<number>} */
|
||||
@@ -196,8 +197,8 @@ ol.render.webgl.ReplayGroup.prototype.replayHitDetection_ = function(context,
|
||||
var i, ii, j, replays, replay, result;
|
||||
for (i = 0, ii = zs.length; i < ii; ++i) {
|
||||
replays = this.replaysByZIndex_[zs[i].toString()];
|
||||
for (j = ol.render.replay.ORDER.length - 1; j >= 0; --j) {
|
||||
replay = replays[ol.render.replay.ORDER[j]];
|
||||
for (j = _ol_render_replay_.ORDER.length - 1; j >= 0; --j) {
|
||||
replay = replays[_ol_render_replay_.ORDER[j]];
|
||||
if (replay !== undefined) {
|
||||
result = replay.replay(context,
|
||||
center, resolution, rotation, size, pixelRatio, opacity,
|
||||
@@ -227,7 +228,7 @@ ol.render.webgl.ReplayGroup.prototype.replayHitDetection_ = function(context,
|
||||
* @return {T|undefined} Callback result.
|
||||
* @template T
|
||||
*/
|
||||
ol.render.webgl.ReplayGroup.prototype.forEachFeatureAtCoordinate = function(
|
||||
_ol_render_webgl_ReplayGroup_.prototype.forEachFeatureAtCoordinate = function(
|
||||
coordinate, context, center, resolution, rotation, size, pixelRatio,
|
||||
opacity, skippedFeaturesHash,
|
||||
callback) {
|
||||
@@ -243,13 +244,13 @@ ol.render.webgl.ReplayGroup.prototype.forEachFeatureAtCoordinate = function(
|
||||
if (this.renderBuffer_ !== undefined) {
|
||||
// build an extent around the coordinate, so that only features that
|
||||
// intersect this extent are checked
|
||||
hitExtent = ol.extent.buffer(
|
||||
ol.extent.createOrUpdateFromCoordinate(coordinate),
|
||||
hitExtent = _ol_extent_.buffer(
|
||||
_ol_extent_.createOrUpdateFromCoordinate(coordinate),
|
||||
resolution * this.renderBuffer_);
|
||||
}
|
||||
|
||||
return this.replayHitDetection_(context,
|
||||
coordinate, resolution, rotation, ol.render.webgl.ReplayGroup.HIT_DETECTION_SIZE_,
|
||||
coordinate, resolution, rotation, _ol_render_webgl_ReplayGroup_.HIT_DETECTION_SIZE_,
|
||||
pixelRatio, opacity, skippedFeaturesHash,
|
||||
/**
|
||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||
@@ -282,7 +283,7 @@ ol.render.webgl.ReplayGroup.prototype.forEachFeatureAtCoordinate = function(
|
||||
* to skip.
|
||||
* @return {boolean} Is there a feature at the given coordinate?
|
||||
*/
|
||||
ol.render.webgl.ReplayGroup.prototype.hasFeatureAtCoordinate = function(
|
||||
_ol_render_webgl_ReplayGroup_.prototype.hasFeatureAtCoordinate = function(
|
||||
coordinate, context, center, resolution, rotation, size, pixelRatio,
|
||||
opacity, skippedFeaturesHash) {
|
||||
var gl = context.getGL();
|
||||
@@ -290,7 +291,7 @@ ol.render.webgl.ReplayGroup.prototype.hasFeatureAtCoordinate = function(
|
||||
gl.FRAMEBUFFER, context.getHitDetectionFramebuffer());
|
||||
|
||||
var hasFeature = this.replayHitDetection_(context,
|
||||
coordinate, resolution, rotation, ol.render.webgl.ReplayGroup.HIT_DETECTION_SIZE_,
|
||||
coordinate, resolution, rotation, _ol_render_webgl_ReplayGroup_.HIT_DETECTION_SIZE_,
|
||||
pixelRatio, opacity, skippedFeaturesHash,
|
||||
/**
|
||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||
@@ -310,7 +311,7 @@ ol.render.webgl.ReplayGroup.prototype.hasFeatureAtCoordinate = function(
|
||||
* @private
|
||||
* @type {Array.<number>}
|
||||
*/
|
||||
ol.render.webgl.ReplayGroup.HIT_DETECTION_SIZE_ = [1, 1];
|
||||
_ol_render_webgl_ReplayGroup_.HIT_DETECTION_SIZE_ = [1, 1];
|
||||
|
||||
/**
|
||||
* @const
|
||||
@@ -319,10 +320,11 @@ ol.render.webgl.ReplayGroup.HIT_DETECTION_SIZE_ = [1, 1];
|
||||
* function(new: ol.render.webgl.Replay, number,
|
||||
* ol.Extent)>}
|
||||
*/
|
||||
ol.render.webgl.ReplayGroup.BATCH_CONSTRUCTORS_ = {
|
||||
'Circle': ol.render.webgl.CircleReplay,
|
||||
'Image': ol.render.webgl.ImageReplay,
|
||||
'LineString': ol.render.webgl.LineStringReplay,
|
||||
'Polygon': ol.render.webgl.PolygonReplay,
|
||||
'Text': ol.render.webgl.TextReplay
|
||||
_ol_render_webgl_ReplayGroup_.BATCH_CONSTRUCTORS_ = {
|
||||
'Circle': _ol_render_webgl_CircleReplay_,
|
||||
'Image': _ol_render_webgl_ImageReplay_,
|
||||
'LineString': _ol_render_webgl_LineStringReplay_,
|
||||
'Polygon': _ol_render_webgl_PolygonReplay_,
|
||||
'Text': _ol_render_webgl_TextReplay_
|
||||
};
|
||||
export default _ol_render_webgl_ReplayGroup_;
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
goog.provide('ol.render.webgl.TextReplay');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.colorlike');
|
||||
goog.require('ol.dom');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
goog.require('ol.has');
|
||||
goog.require('ol.render.replay');
|
||||
goog.require('ol.render.webgl');
|
||||
goog.require('ol.render.webgl.TextureReplay');
|
||||
goog.require('ol.style.AtlasManager');
|
||||
goog.require('ol.webgl.Buffer');
|
||||
|
||||
/**
|
||||
* @module ol/render/webgl/TextReplay
|
||||
*/
|
||||
import _ol_ from '../../index.js';
|
||||
import _ol_colorlike_ from '../../colorlike.js';
|
||||
import _ol_dom_ from '../../dom.js';
|
||||
import _ol_geom_GeometryType_ from '../../geom/GeometryType.js';
|
||||
import _ol_has_ from '../../has.js';
|
||||
import _ol_render_replay_ from '../replay.js';
|
||||
import _ol_render_webgl_ from '../webgl.js';
|
||||
import _ol_render_webgl_TextureReplay_ from '../webgl/TextureReplay.js';
|
||||
import _ol_style_AtlasManager_ from '../../style/AtlasManager.js';
|
||||
import _ol_webgl_Buffer_ from '../../webgl/Buffer.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -19,8 +19,8 @@ goog.require('ol.webgl.Buffer');
|
||||
* @param {ol.Extent} maxExtent Max extent.
|
||||
* @struct
|
||||
*/
|
||||
ol.render.webgl.TextReplay = function(tolerance, maxExtent) {
|
||||
ol.render.webgl.TextureReplay.call(this, tolerance, maxExtent);
|
||||
var _ol_render_webgl_TextReplay_ = function(tolerance, maxExtent) {
|
||||
_ol_render_webgl_TextureReplay_.call(this, tolerance, maxExtent);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -38,7 +38,7 @@ ol.render.webgl.TextReplay = function(tolerance, maxExtent) {
|
||||
* @private
|
||||
* @type {HTMLCanvasElement}
|
||||
*/
|
||||
this.measureCanvas_ = ol.dom.createCanvasContext2D(0, 0).canvas;
|
||||
this.measureCanvas_ = _ol_dom_.createCanvasContext2D(0, 0).canvas;
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -113,39 +113,40 @@ ol.render.webgl.TextReplay = function(tolerance, maxExtent) {
|
||||
this.opacity = 1;
|
||||
|
||||
};
|
||||
ol.inherits(ol.render.webgl.TextReplay, ol.render.webgl.TextureReplay);
|
||||
|
||||
_ol_.inherits(_ol_render_webgl_TextReplay_, _ol_render_webgl_TextureReplay_);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.TextReplay.prototype.drawText = function(geometry, feature) {
|
||||
_ol_render_webgl_TextReplay_.prototype.drawText = function(geometry, feature) {
|
||||
if (this.text_) {
|
||||
var flatCoordinates = null;
|
||||
var offset = 0;
|
||||
var end = 2;
|
||||
var stride = 2;
|
||||
switch (geometry.getType()) {
|
||||
case ol.geom.GeometryType.POINT:
|
||||
case ol.geom.GeometryType.MULTI_POINT:
|
||||
case _ol_geom_GeometryType_.POINT:
|
||||
case _ol_geom_GeometryType_.MULTI_POINT:
|
||||
flatCoordinates = geometry.getFlatCoordinates();
|
||||
end = flatCoordinates.length;
|
||||
stride = geometry.getStride();
|
||||
break;
|
||||
case ol.geom.GeometryType.CIRCLE:
|
||||
case _ol_geom_GeometryType_.CIRCLE:
|
||||
flatCoordinates = /** @type {ol.geom.Circle} */ (geometry).getCenter();
|
||||
break;
|
||||
case ol.geom.GeometryType.LINE_STRING:
|
||||
case _ol_geom_GeometryType_.LINE_STRING:
|
||||
flatCoordinates = /** @type {ol.geom.LineString} */ (geometry).getFlatMidpoint();
|
||||
break;
|
||||
case ol.geom.GeometryType.MULTI_LINE_STRING:
|
||||
case _ol_geom_GeometryType_.MULTI_LINE_STRING:
|
||||
flatCoordinates = /** @type {ol.geom.MultiLineString} */ (geometry).getFlatMidpoints();
|
||||
end = flatCoordinates.length;
|
||||
break;
|
||||
case ol.geom.GeometryType.POLYGON:
|
||||
case _ol_geom_GeometryType_.POLYGON:
|
||||
flatCoordinates = /** @type {ol.geom.Polygon} */ (geometry).getFlatInteriorPoint();
|
||||
break;
|
||||
case ol.geom.GeometryType.MULTI_POLYGON:
|
||||
case _ol_geom_GeometryType_.MULTI_POLYGON:
|
||||
flatCoordinates = /** @type {ol.geom.MultiPolygon} */ (geometry).getFlatInteriorPoints();
|
||||
end = flatCoordinates.length;
|
||||
break;
|
||||
@@ -188,7 +189,7 @@ ol.render.webgl.TextReplay.prototype.drawText = function(geometry, feature) {
|
||||
this.images_.push(image);
|
||||
} else {
|
||||
currentImage = this.images_[this.images_.length - 1];
|
||||
if (ol.getUid(currentImage) != ol.getUid(image)) {
|
||||
if (_ol_.getUid(currentImage) != _ol_.getUid(image)) {
|
||||
this.groupIndices.push(this.indices.length);
|
||||
this.images_.push(image);
|
||||
}
|
||||
@@ -208,7 +209,7 @@ ol.render.webgl.TextReplay.prototype.drawText = function(geometry, feature) {
|
||||
* @param {Array.<string>} lines Label to draw split to lines.
|
||||
* @return {Array.<number>} Size of the label in pixels.
|
||||
*/
|
||||
ol.render.webgl.TextReplay.prototype.getTextSize_ = function(lines) {
|
||||
_ol_render_webgl_TextReplay_.prototype.getTextSize_ = function(lines) {
|
||||
var self = this;
|
||||
var glyphAtlas = this.currAtlas_;
|
||||
var textHeight = lines.length * glyphAtlas.height;
|
||||
@@ -239,7 +240,7 @@ ol.render.webgl.TextReplay.prototype.getTextSize_ = function(lines) {
|
||||
* @param {number} end End.
|
||||
* @param {number} stride Stride.
|
||||
*/
|
||||
ol.render.webgl.TextReplay.prototype.drawText_ = function(flatCoordinates, offset,
|
||||
_ol_render_webgl_TextReplay_.prototype.drawText_ = function(flatCoordinates, offset,
|
||||
end, stride) {
|
||||
var i, ii;
|
||||
for (i = offset, ii = end; i < ii; i += stride) {
|
||||
@@ -252,7 +253,7 @@ ol.render.webgl.TextReplay.prototype.drawText_ = function(flatCoordinates, offse
|
||||
* @private
|
||||
* @param {string} char Character.
|
||||
*/
|
||||
ol.render.webgl.TextReplay.prototype.addCharToAtlas_ = function(char) {
|
||||
_ol_render_webgl_TextReplay_.prototype.addCharToAtlas_ = function(char) {
|
||||
if (char.length === 1) {
|
||||
var glyphAtlas = this.currAtlas_;
|
||||
var state = this.state_;
|
||||
@@ -272,7 +273,7 @@ ol.render.webgl.TextReplay.prototype.addCharToAtlas_ = function(char) {
|
||||
ctx.miterLimit = /** @type {number} */ (state.miterLimit);
|
||||
ctx.textAlign = 'left';
|
||||
ctx.textBaseline = 'top';
|
||||
if (ol.has.CANVAS_LINE_DASH && state.lineDash) {
|
||||
if (_ol_has_.CANVAS_LINE_DASH && state.lineDash) {
|
||||
//FIXME: use pixelRatio
|
||||
ctx.setLineDash(state.lineDash);
|
||||
ctx.lineDashOffset = /** @type {number} */ (state.lineDashOffset);
|
||||
@@ -302,17 +303,17 @@ ol.render.webgl.TextReplay.prototype.addCharToAtlas_ = function(char) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.TextReplay.prototype.finish = function(context) {
|
||||
_ol_render_webgl_TextReplay_.prototype.finish = function(context) {
|
||||
var gl = context.getGL();
|
||||
|
||||
this.groupIndices.push(this.indices.length);
|
||||
this.hitDetectionGroupIndices = this.groupIndices;
|
||||
|
||||
// create, bind, and populate the vertices buffer
|
||||
this.verticesBuffer = new ol.webgl.Buffer(this.vertices);
|
||||
this.verticesBuffer = new _ol_webgl_Buffer_(this.vertices);
|
||||
|
||||
// create, bind, and populate the indices buffer
|
||||
this.indicesBuffer = new ol.webgl.Buffer(this.indices);
|
||||
this.indicesBuffer = new _ol_webgl_Buffer_(this.indices);
|
||||
|
||||
// create textures
|
||||
/** @type {Object.<string, WebGLTexture>} */
|
||||
@@ -340,14 +341,14 @@ ol.render.webgl.TextReplay.prototype.finish = function(context) {
|
||||
this.images_ = null;
|
||||
this.atlases_ = {};
|
||||
this.currAtlas_ = undefined;
|
||||
ol.render.webgl.TextureReplay.prototype.finish.call(this, context);
|
||||
_ol_render_webgl_TextureReplay_.prototype.finish.call(this, context);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.TextReplay.prototype.setTextStyle = function(textStyle) {
|
||||
_ol_render_webgl_TextReplay_.prototype.setTextStyle = function(textStyle) {
|
||||
var state = this.state_;
|
||||
var textFillStyle = textStyle.getFill();
|
||||
var textStrokeStyle = textStyle.getStroke();
|
||||
@@ -358,33 +359,33 @@ ol.render.webgl.TextReplay.prototype.setTextStyle = function(textStyle) {
|
||||
state.fillColor = null;
|
||||
} else {
|
||||
var textFillStyleColor = textFillStyle.getColor();
|
||||
state.fillColor = ol.colorlike.asColorLike(textFillStyleColor ?
|
||||
textFillStyleColor : ol.render.webgl.defaultFillStyle);
|
||||
state.fillColor = _ol_colorlike_.asColorLike(textFillStyleColor ?
|
||||
textFillStyleColor : _ol_render_webgl_.defaultFillStyle);
|
||||
}
|
||||
if (!textStrokeStyle) {
|
||||
state.strokeColor = null;
|
||||
state.lineWidth = 0;
|
||||
} else {
|
||||
var textStrokeStyleColor = textStrokeStyle.getColor();
|
||||
state.strokeColor = ol.colorlike.asColorLike(textStrokeStyleColor ?
|
||||
textStrokeStyleColor : ol.render.webgl.defaultStrokeStyle);
|
||||
state.lineWidth = textStrokeStyle.getWidth() || ol.render.webgl.defaultLineWidth;
|
||||
state.lineCap = textStrokeStyle.getLineCap() || ol.render.webgl.defaultLineCap;
|
||||
state.lineDashOffset = textStrokeStyle.getLineDashOffset() || ol.render.webgl.defaultLineDashOffset;
|
||||
state.lineJoin = textStrokeStyle.getLineJoin() || ol.render.webgl.defaultLineJoin;
|
||||
state.miterLimit = textStrokeStyle.getMiterLimit() || ol.render.webgl.defaultMiterLimit;
|
||||
state.strokeColor = _ol_colorlike_.asColorLike(textStrokeStyleColor ?
|
||||
textStrokeStyleColor : _ol_render_webgl_.defaultStrokeStyle);
|
||||
state.lineWidth = textStrokeStyle.getWidth() || _ol_render_webgl_.defaultLineWidth;
|
||||
state.lineCap = textStrokeStyle.getLineCap() || _ol_render_webgl_.defaultLineCap;
|
||||
state.lineDashOffset = textStrokeStyle.getLineDashOffset() || _ol_render_webgl_.defaultLineDashOffset;
|
||||
state.lineJoin = textStrokeStyle.getLineJoin() || _ol_render_webgl_.defaultLineJoin;
|
||||
state.miterLimit = textStrokeStyle.getMiterLimit() || _ol_render_webgl_.defaultMiterLimit;
|
||||
var lineDash = textStrokeStyle.getLineDash();
|
||||
state.lineDash = lineDash ? lineDash.slice() : ol.render.webgl.defaultLineDash;
|
||||
state.lineDash = lineDash ? lineDash.slice() : _ol_render_webgl_.defaultLineDash;
|
||||
}
|
||||
state.font = textStyle.getFont() || ol.render.webgl.defaultFont;
|
||||
state.font = textStyle.getFont() || _ol_render_webgl_.defaultFont;
|
||||
state.scale = textStyle.getScale() || 1;
|
||||
this.text_ = /** @type {string} */ (textStyle.getText());
|
||||
var textAlign = ol.render.replay.TEXT_ALIGN[textStyle.getTextAlign()];
|
||||
var textBaseline = ol.render.replay.TEXT_ALIGN[textStyle.getTextBaseline()];
|
||||
var textAlign = _ol_render_replay_.TEXT_ALIGN[textStyle.getTextAlign()];
|
||||
var textBaseline = _ol_render_replay_.TEXT_ALIGN[textStyle.getTextBaseline()];
|
||||
this.textAlign_ = textAlign === undefined ?
|
||||
ol.render.webgl.defaultTextAlign : textAlign;
|
||||
_ol_render_webgl_.defaultTextAlign : textAlign;
|
||||
this.textBaseline_ = textBaseline === undefined ?
|
||||
ol.render.webgl.defaultTextBaseline : textBaseline;
|
||||
_ol_render_webgl_.defaultTextBaseline : textBaseline;
|
||||
this.offsetX_ = textStyle.getOffsetX() || 0;
|
||||
this.offsetY_ = textStyle.getOffsetY() || 0;
|
||||
this.rotateWithView = !!textStyle.getRotateWithView();
|
||||
@@ -400,7 +401,7 @@ ol.render.webgl.TextReplay.prototype.setTextStyle = function(textStyle) {
|
||||
* @param {Object} state Font attributes.
|
||||
* @return {ol.WebglGlyphAtlas} Glyph atlas.
|
||||
*/
|
||||
ol.render.webgl.TextReplay.prototype.getAtlas_ = function(state) {
|
||||
_ol_render_webgl_TextReplay_.prototype.getAtlas_ = function(state) {
|
||||
var params = [];
|
||||
var i;
|
||||
for (i in state) {
|
||||
@@ -420,7 +421,7 @@ ol.render.webgl.TextReplay.prototype.getAtlas_ = function(state) {
|
||||
state.lineWidth / 2) * state.scale);
|
||||
|
||||
this.atlases_[hash] = {
|
||||
atlas: new ol.style.AtlasManager({
|
||||
atlas: new _ol_style_AtlasManager_({
|
||||
space: state.lineWidth + 1
|
||||
}),
|
||||
width: {},
|
||||
@@ -436,7 +437,7 @@ ol.render.webgl.TextReplay.prototype.getAtlas_ = function(state) {
|
||||
* @param {Array.<string|number>} params Array of parameters.
|
||||
* @return {string} Hash string.
|
||||
*/
|
||||
ol.render.webgl.TextReplay.prototype.calculateHash_ = function(params) {
|
||||
_ol_render_webgl_TextReplay_.prototype.calculateHash_ = function(params) {
|
||||
//TODO: Create a more performant, reliable, general hash function.
|
||||
var i, ii;
|
||||
var hash = '';
|
||||
@@ -450,7 +451,7 @@ ol.render.webgl.TextReplay.prototype.calculateHash_ = function(params) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.TextReplay.prototype.getTextures = function(opt_all) {
|
||||
_ol_render_webgl_TextReplay_.prototype.getTextures = function(opt_all) {
|
||||
return this.textures_;
|
||||
};
|
||||
|
||||
@@ -458,6 +459,7 @@ ol.render.webgl.TextReplay.prototype.getTextures = function(opt_all) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.TextReplay.prototype.getHitDetectionTextures = function() {
|
||||
_ol_render_webgl_TextReplay_.prototype.getHitDetectionTextures = function() {
|
||||
return this.textures_;
|
||||
};
|
||||
export default _ol_render_webgl_TextReplay_;
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
goog.provide('ol.render.webgl.TextureReplay');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.obj');
|
||||
goog.require('ol.render.webgl.texturereplay.defaultshader');
|
||||
goog.require('ol.render.webgl.texturereplay.defaultshader.Locations');
|
||||
goog.require('ol.render.webgl.Replay');
|
||||
goog.require('ol.webgl');
|
||||
goog.require('ol.webgl.Context');
|
||||
/**
|
||||
* @module ol/render/webgl/TextureReplay
|
||||
*/
|
||||
import _ol_ from '../../index.js';
|
||||
import _ol_extent_ from '../../extent.js';
|
||||
import _ol_obj_ from '../../obj.js';
|
||||
import _ol_render_webgl_texturereplay_defaultshader_ from '../webgl/texturereplay/defaultshader.js';
|
||||
import _ol_render_webgl_texturereplay_defaultshader_Locations_ from '../webgl/texturereplay/defaultshader/Locations.js';
|
||||
import _ol_render_webgl_Replay_ from '../webgl/Replay.js';
|
||||
import _ol_webgl_ from '../../webgl.js';
|
||||
import _ol_webgl_Context_ from '../../webgl/Context.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -17,8 +18,8 @@ goog.require('ol.webgl.Context');
|
||||
* @param {ol.Extent} maxExtent Max extent.
|
||||
* @struct
|
||||
*/
|
||||
ol.render.webgl.TextureReplay = function(tolerance, maxExtent) {
|
||||
ol.render.webgl.Replay.call(this, tolerance, maxExtent);
|
||||
var _ol_render_webgl_TextureReplay_ = function(tolerance, maxExtent) {
|
||||
_ol_render_webgl_Replay_.call(this, tolerance, maxExtent);
|
||||
|
||||
/**
|
||||
* @type {number|undefined}
|
||||
@@ -110,13 +111,14 @@ ol.render.webgl.TextureReplay = function(tolerance, maxExtent) {
|
||||
*/
|
||||
this.width = undefined;
|
||||
};
|
||||
ol.inherits(ol.render.webgl.TextureReplay, ol.render.webgl.Replay);
|
||||
|
||||
_ol_.inherits(_ol_render_webgl_TextureReplay_, _ol_render_webgl_Replay_);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.TextureReplay.prototype.getDeleteResourcesFunction = function(context) {
|
||||
_ol_render_webgl_TextureReplay_.prototype.getDeleteResourcesFunction = function(context) {
|
||||
var verticesBuffer = this.verticesBuffer;
|
||||
var indicesBuffer = this.indicesBuffer;
|
||||
var textures = this.getTextures(true);
|
||||
@@ -142,7 +144,7 @@ ol.render.webgl.TextureReplay.prototype.getDeleteResourcesFunction = function(co
|
||||
* @return {number} My end.
|
||||
* @protected
|
||||
*/
|
||||
ol.render.webgl.TextureReplay.prototype.drawCoordinates = function(flatCoordinates, offset, end, stride) {
|
||||
_ol_render_webgl_TextureReplay_.prototype.drawCoordinates = function(flatCoordinates, offset, end, stride) {
|
||||
var anchorX = /** @type {number} */ (this.anchorX);
|
||||
var anchorY = /** @type {number} */ (this.anchorY);
|
||||
var height = /** @type {number} */ (this.height);
|
||||
@@ -245,18 +247,18 @@ ol.render.webgl.TextureReplay.prototype.drawCoordinates = function(flatCoordinat
|
||||
* @param {Object.<string, WebGLTexture>} texturePerImage Texture cache.
|
||||
* @param {WebGLRenderingContext} gl Gl.
|
||||
*/
|
||||
ol.render.webgl.TextureReplay.prototype.createTextures = function(textures, images, texturePerImage, gl) {
|
||||
_ol_render_webgl_TextureReplay_.prototype.createTextures = function(textures, images, texturePerImage, gl) {
|
||||
var texture, image, uid, i;
|
||||
var ii = images.length;
|
||||
for (i = 0; i < ii; ++i) {
|
||||
image = images[i];
|
||||
|
||||
uid = ol.getUid(image).toString();
|
||||
uid = _ol_.getUid(image).toString();
|
||||
if (uid in texturePerImage) {
|
||||
texture = texturePerImage[uid];
|
||||
} else {
|
||||
texture = ol.webgl.Context.createTexture(
|
||||
gl, image, ol.webgl.CLAMP_TO_EDGE, ol.webgl.CLAMP_TO_EDGE);
|
||||
texture = _ol_webgl_Context_.createTexture(
|
||||
gl, image, _ol_webgl_.CLAMP_TO_EDGE, _ol_webgl_.CLAMP_TO_EDGE);
|
||||
texturePerImage[uid] = texture;
|
||||
}
|
||||
textures[i] = texture;
|
||||
@@ -267,16 +269,16 @@ ol.render.webgl.TextureReplay.prototype.createTextures = function(textures, imag
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.TextureReplay.prototype.setUpProgram = function(gl, context, size, pixelRatio) {
|
||||
_ol_render_webgl_TextureReplay_.prototype.setUpProgram = function(gl, context, size, pixelRatio) {
|
||||
// get the program
|
||||
var fragmentShader = ol.render.webgl.texturereplay.defaultshader.fragment;
|
||||
var vertexShader = ol.render.webgl.texturereplay.defaultshader.vertex;
|
||||
var fragmentShader = _ol_render_webgl_texturereplay_defaultshader_.fragment;
|
||||
var vertexShader = _ol_render_webgl_texturereplay_defaultshader_.vertex;
|
||||
var program = context.getProgram(fragmentShader, vertexShader);
|
||||
|
||||
// get the locations
|
||||
var locations;
|
||||
if (!this.defaultLocations) {
|
||||
locations = new ol.render.webgl.texturereplay.defaultshader.Locations(gl, program);
|
||||
locations = new _ol_render_webgl_texturereplay_defaultshader_Locations_(gl, program);
|
||||
this.defaultLocations = locations;
|
||||
} else {
|
||||
locations = this.defaultLocations;
|
||||
@@ -287,23 +289,23 @@ ol.render.webgl.TextureReplay.prototype.setUpProgram = function(gl, context, siz
|
||||
|
||||
// enable the vertex attrib arrays
|
||||
gl.enableVertexAttribArray(locations.a_position);
|
||||
gl.vertexAttribPointer(locations.a_position, 2, ol.webgl.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_position, 2, _ol_webgl_.FLOAT,
|
||||
false, 32, 0);
|
||||
|
||||
gl.enableVertexAttribArray(locations.a_offsets);
|
||||
gl.vertexAttribPointer(locations.a_offsets, 2, ol.webgl.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_offsets, 2, _ol_webgl_.FLOAT,
|
||||
false, 32, 8);
|
||||
|
||||
gl.enableVertexAttribArray(locations.a_texCoord);
|
||||
gl.vertexAttribPointer(locations.a_texCoord, 2, ol.webgl.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_texCoord, 2, _ol_webgl_.FLOAT,
|
||||
false, 32, 16);
|
||||
|
||||
gl.enableVertexAttribArray(locations.a_opacity);
|
||||
gl.vertexAttribPointer(locations.a_opacity, 1, ol.webgl.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_opacity, 1, _ol_webgl_.FLOAT,
|
||||
false, 32, 24);
|
||||
|
||||
gl.enableVertexAttribArray(locations.a_rotateWithView);
|
||||
gl.vertexAttribPointer(locations.a_rotateWithView, 1, ol.webgl.FLOAT,
|
||||
gl.vertexAttribPointer(locations.a_rotateWithView, 1, _ol_webgl_.FLOAT,
|
||||
false, 32, 28);
|
||||
|
||||
return locations;
|
||||
@@ -313,7 +315,7 @@ ol.render.webgl.TextureReplay.prototype.setUpProgram = function(gl, context, siz
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.TextureReplay.prototype.shutDownProgram = function(gl, locations) {
|
||||
_ol_render_webgl_TextureReplay_.prototype.shutDownProgram = function(gl, locations) {
|
||||
gl.disableVertexAttribArray(locations.a_position);
|
||||
gl.disableVertexAttribArray(locations.a_offsets);
|
||||
gl.disableVertexAttribArray(locations.a_texCoord);
|
||||
@@ -325,17 +327,17 @@ ol.render.webgl.TextureReplay.prototype.shutDownProgram = function(gl, locations
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.TextureReplay.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {
|
||||
_ol_render_webgl_TextureReplay_.prototype.drawReplay = function(gl, context, skippedFeaturesHash, hitDetection) {
|
||||
var textures = hitDetection ? this.getHitDetectionTextures() : this.getTextures();
|
||||
var groupIndices = hitDetection ? this.hitDetectionGroupIndices : this.groupIndices;
|
||||
|
||||
if (!ol.obj.isEmpty(skippedFeaturesHash)) {
|
||||
if (!_ol_obj_.isEmpty(skippedFeaturesHash)) {
|
||||
this.drawReplaySkipping(
|
||||
gl, context, skippedFeaturesHash, textures, groupIndices);
|
||||
} else {
|
||||
var i, ii, start;
|
||||
for (i = 0, ii = textures.length, start = 0; i < ii; ++i) {
|
||||
gl.bindTexture(ol.webgl.TEXTURE_2D, textures[i]);
|
||||
gl.bindTexture(_ol_webgl_.TEXTURE_2D, textures[i]);
|
||||
var end = groupIndices[i];
|
||||
this.drawElements(gl, context, start, end);
|
||||
start = end;
|
||||
@@ -370,13 +372,13 @@ ol.render.webgl.TextureReplay.prototype.drawReplay = function(gl, context, skipp
|
||||
* @param {Array.<WebGLTexture>} textures Textures.
|
||||
* @param {Array.<number>} groupIndices Texture group indices.
|
||||
*/
|
||||
ol.render.webgl.TextureReplay.prototype.drawReplaySkipping = function(gl, context, skippedFeaturesHash, textures,
|
||||
_ol_render_webgl_TextureReplay_.prototype.drawReplaySkipping = function(gl, context, skippedFeaturesHash, textures,
|
||||
groupIndices) {
|
||||
var featureIndex = 0;
|
||||
|
||||
var i, ii;
|
||||
for (i = 0, ii = textures.length; i < ii; ++i) {
|
||||
gl.bindTexture(ol.webgl.TEXTURE_2D, textures[i]);
|
||||
gl.bindTexture(_ol_webgl_.TEXTURE_2D, textures[i]);
|
||||
var groupStart = (i > 0) ? groupIndices[i - 1] : 0;
|
||||
var groupEnd = groupIndices[i];
|
||||
|
||||
@@ -386,7 +388,7 @@ ol.render.webgl.TextureReplay.prototype.drawReplaySkipping = function(gl, contex
|
||||
this.startIndices[featureIndex] <= groupEnd) {
|
||||
var feature = this.startIndicesFeature[featureIndex];
|
||||
|
||||
var featureUid = ol.getUid(feature).toString();
|
||||
var featureUid = _ol_.getUid(feature).toString();
|
||||
if (skippedFeaturesHash[featureUid] !== undefined) {
|
||||
// feature should be skipped
|
||||
if (start !== end) {
|
||||
@@ -417,13 +419,13 @@ ol.render.webgl.TextureReplay.prototype.drawReplaySkipping = function(gl, contex
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.TextureReplay.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash,
|
||||
_ol_render_webgl_TextureReplay_.prototype.drawHitDetectionReplayOneByOne = function(gl, context, skippedFeaturesHash,
|
||||
featureCallback, opt_hitExtent) {
|
||||
var i, groupStart, start, end, feature, featureUid;
|
||||
var featureIndex = this.startIndices.length - 1;
|
||||
var hitDetectionTextures = this.getHitDetectionTextures();
|
||||
for (i = hitDetectionTextures.length - 1; i >= 0; --i) {
|
||||
gl.bindTexture(ol.webgl.TEXTURE_2D, hitDetectionTextures[i]);
|
||||
gl.bindTexture(_ol_webgl_.TEXTURE_2D, hitDetectionTextures[i]);
|
||||
groupStart = (i > 0) ? this.hitDetectionGroupIndices[i - 1] : 0;
|
||||
end = this.hitDetectionGroupIndices[i];
|
||||
|
||||
@@ -432,11 +434,11 @@ ol.render.webgl.TextureReplay.prototype.drawHitDetectionReplayOneByOne = functio
|
||||
this.startIndices[featureIndex] >= groupStart) {
|
||||
start = this.startIndices[featureIndex];
|
||||
feature = this.startIndicesFeature[featureIndex];
|
||||
featureUid = ol.getUid(feature).toString();
|
||||
featureUid = _ol_.getUid(feature).toString();
|
||||
|
||||
if (skippedFeaturesHash[featureUid] === undefined &&
|
||||
feature.getGeometry() &&
|
||||
(opt_hitExtent === undefined || ol.extent.intersects(
|
||||
(opt_hitExtent === undefined || _ol_extent_.intersects(
|
||||
/** @type {Array<number>} */ (opt_hitExtent),
|
||||
feature.getGeometry().getExtent()))) {
|
||||
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
||||
@@ -459,7 +461,7 @@ ol.render.webgl.TextureReplay.prototype.drawHitDetectionReplayOneByOne = functio
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.render.webgl.TextureReplay.prototype.finish = function(context) {
|
||||
_ol_render_webgl_TextureReplay_.prototype.finish = function(context) {
|
||||
this.anchorX = undefined;
|
||||
this.anchorY = undefined;
|
||||
this.height = undefined;
|
||||
@@ -483,7 +485,7 @@ ol.render.webgl.TextureReplay.prototype.finish = function(context) {
|
||||
* @param {boolean=} opt_all Return hit detection textures with regular ones.
|
||||
* @returns {Array.<WebGLTexture>} Textures.
|
||||
*/
|
||||
ol.render.webgl.TextureReplay.prototype.getTextures = function(opt_all) {};
|
||||
_ol_render_webgl_TextureReplay_.prototype.getTextures = function(opt_all) {};
|
||||
|
||||
|
||||
/**
|
||||
@@ -491,4 +493,5 @@ ol.render.webgl.TextureReplay.prototype.getTextures = function(opt_all) {};
|
||||
* @protected
|
||||
* @returns {Array.<WebGLTexture>} Textures.
|
||||
*/
|
||||
ol.render.webgl.TextureReplay.prototype.getHitDetectionTextures = function() {};
|
||||
_ol_render_webgl_TextureReplay_.prototype.getHitDetectionTextures = function() {};
|
||||
export default _ol_render_webgl_TextureReplay_;
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
/**
|
||||
* @module ol/render/webgl/circlereplay/defaultshader
|
||||
*/
|
||||
// This file is automatically generated, do not edit
|
||||
goog.provide('ol.render.webgl.circlereplay.defaultshader');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.webgl.Fragment');
|
||||
goog.require('ol.webgl.Vertex');
|
||||
import _ol_ from '../../../index.js';
|
||||
import _ol_webgl_Fragment_ from '../../../webgl/Fragment.js';
|
||||
import _ol_webgl_Vertex_ from '../../../webgl/Vertex.js';
|
||||
var _ol_render_webgl_circlereplay_defaultshader_ = {};
|
||||
|
||||
|
||||
ol.render.webgl.circlereplay.defaultshader.fragment = new ol.webgl.Fragment(ol.DEBUG_WEBGL ?
|
||||
_ol_render_webgl_circlereplay_defaultshader_.fragment = new _ol_webgl_Fragment_(_ol_.DEBUG_WEBGL ?
|
||||
'precision mediump float;\nvarying vec2 v_center;\nvarying vec2 v_offset;\nvarying float v_halfWidth;\nvarying float v_pixelRatio;\n\n\n\nuniform float u_opacity;\nuniform vec4 u_fillColor;\nuniform vec4 u_strokeColor;\nuniform vec2 u_size;\n\nvoid main(void) {\n vec2 windowCenter = vec2((v_center.x + 1.0) / 2.0 * u_size.x * v_pixelRatio,\n (v_center.y + 1.0) / 2.0 * u_size.y * v_pixelRatio);\n vec2 windowOffset = vec2((v_offset.x + 1.0) / 2.0 * u_size.x * v_pixelRatio,\n (v_offset.y + 1.0) / 2.0 * u_size.y * v_pixelRatio);\n float radius = length(windowCenter - windowOffset);\n float dist = length(windowCenter - gl_FragCoord.xy);\n if (dist > radius + v_halfWidth) {\n if (u_strokeColor.a == 0.0) {\n gl_FragColor = u_fillColor;\n } else {\n gl_FragColor = u_strokeColor;\n }\n gl_FragColor.a = gl_FragColor.a - (dist - (radius + v_halfWidth));\n } else if (u_fillColor.a == 0.0) {\n // Hooray, no fill, just stroke. We can use real antialiasing.\n gl_FragColor = u_strokeColor;\n if (dist < radius - v_halfWidth) {\n gl_FragColor.a = gl_FragColor.a - (radius - v_halfWidth - dist);\n }\n } else {\n gl_FragColor = u_fillColor;\n float strokeDist = radius - v_halfWidth;\n float antialias = 2.0 * v_pixelRatio;\n if (dist > strokeDist) {\n gl_FragColor = u_strokeColor;\n } else if (dist >= strokeDist - antialias) {\n float step = smoothstep(strokeDist - antialias, strokeDist, dist);\n gl_FragColor = mix(u_fillColor, u_strokeColor, step);\n }\n }\n gl_FragColor.a = gl_FragColor.a * u_opacity;\n if (gl_FragColor.a <= 0.0) {\n discard;\n }\n}\n' :
|
||||
'precision mediump float;varying vec2 a;varying vec2 b;varying float c;varying float d;uniform float m;uniform vec4 n;uniform vec4 o;uniform vec2 p;void main(void){vec2 windowCenter=vec2((a.x+1.0)/2.0*p.x*d,(a.y+1.0)/2.0*p.y*d);vec2 windowOffset=vec2((b.x+1.0)/2.0*p.x*d,(b.y+1.0)/2.0*p.y*d);float radius=length(windowCenter-windowOffset);float dist=length(windowCenter-gl_FragCoord.xy);if(dist>radius+c){if(o.a==0.0){gl_FragColor=n;}else{gl_FragColor=o;}gl_FragColor.a=gl_FragColor.a-(dist-(radius+c));}else if(n.a==0.0){gl_FragColor=o;if(dist<radius-c){gl_FragColor.a=gl_FragColor.a-(radius-c-dist);}} else{gl_FragColor=n;float strokeDist=radius-c;float antialias=2.0*d;if(dist>strokeDist){gl_FragColor=o;}else if(dist>=strokeDist-antialias){float step=smoothstep(strokeDist-antialias,strokeDist,dist);gl_FragColor=mix(n,o,step);}} gl_FragColor.a=gl_FragColor.a*m;if(gl_FragColor.a<=0.0){discard;}}');
|
||||
|
||||
ol.render.webgl.circlereplay.defaultshader.vertex = new ol.webgl.Vertex(ol.DEBUG_WEBGL ?
|
||||
_ol_render_webgl_circlereplay_defaultshader_.vertex = new _ol_webgl_Vertex_(_ol_.DEBUG_WEBGL ?
|
||||
'varying vec2 v_center;\nvarying vec2 v_offset;\nvarying float v_halfWidth;\nvarying float v_pixelRatio;\n\n\nattribute vec2 a_position;\nattribute float a_instruction;\nattribute float a_radius;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\nuniform float u_lineWidth;\nuniform float u_pixelRatio;\n\nvoid main(void) {\n mat4 offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;\n v_center = vec4(u_projectionMatrix * vec4(a_position, 0.0, 1.0)).xy;\n v_pixelRatio = u_pixelRatio;\n float lineWidth = u_lineWidth * u_pixelRatio;\n v_halfWidth = lineWidth / 2.0;\n if (lineWidth == 0.0) {\n lineWidth = 2.0 * u_pixelRatio;\n }\n vec2 offset;\n // Radius with anitaliasing (roughly).\n float radius = a_radius + 3.0 * u_pixelRatio;\n // Until we get gl_VertexID in WebGL, we store an instruction.\n if (a_instruction == 0.0) {\n // Offsetting the edges of the triangle by lineWidth / 2 is necessary, however\n // we should also leave some space for the antialiasing, thus we offset by lineWidth.\n offset = vec2(-1.0, 1.0);\n } else if (a_instruction == 1.0) {\n offset = vec2(-1.0, -1.0);\n } else if (a_instruction == 2.0) {\n offset = vec2(1.0, -1.0);\n } else {\n offset = vec2(1.0, 1.0);\n }\n\n gl_Position = u_projectionMatrix * vec4(a_position + offset * radius, 0.0, 1.0) +\n offsetMatrix * vec4(offset * lineWidth, 0.0, 0.0);\n v_offset = vec4(u_projectionMatrix * vec4(a_position.x + a_radius, a_position.y,\n 0.0, 1.0)).xy;\n\n if (distance(v_center, v_offset) > 20000.0) {\n gl_Position = vec4(v_center, 0.0, 1.0);\n }\n}\n\n\n' :
|
||||
'varying vec2 a;varying vec2 b;varying float c;varying float d;attribute vec2 e;attribute float f;attribute float g;uniform mat4 h;uniform mat4 i;uniform mat4 j;uniform float k;uniform float l;void main(void){mat4 offsetMatrix=i*j;a=vec4(h*vec4(e,0.0,1.0)).xy;d=l;float lineWidth=k*l;c=lineWidth/2.0;if(lineWidth==0.0){lineWidth=2.0*l;}vec2 offset;float radius=g+3.0*l;//Until we get gl_VertexID in WebGL,we store an instruction.if(f==0.0){//Offsetting the edges of the triangle by lineWidth/2 is necessary,however//we should also leave some space for the antialiasing,thus we offset by lineWidth.offset=vec2(-1.0,1.0);}else if(f==1.0){offset=vec2(-1.0,-1.0);}else if(f==2.0){offset=vec2(1.0,-1.0);}else{offset=vec2(1.0,1.0);}gl_Position=h*vec4(e+offset*radius,0.0,1.0)+offsetMatrix*vec4(offset*lineWidth,0.0,0.0);b=vec4(h*vec4(e.x+g,e.y,0.0,1.0)).xy;if(distance(a,b)>20000.0){gl_Position=vec4(a,0.0,1.0);}}');
|
||||
export default _ol_render_webgl_circlereplay_defaultshader_;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* @module ol/render/webgl/circlereplay/defaultshader/Locations
|
||||
*/
|
||||
// This file is automatically generated, do not edit
|
||||
goog.provide('ol.render.webgl.circlereplay.defaultshader.Locations');
|
||||
|
||||
goog.require('ol');
|
||||
|
||||
import _ol_ from '../../../../index.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -10,77 +10,79 @@ goog.require('ol');
|
||||
* @param {WebGLProgram} program Program.
|
||||
* @struct
|
||||
*/
|
||||
ol.render.webgl.circlereplay.defaultshader.Locations = function(gl, program) {
|
||||
var _ol_render_webgl_circlereplay_defaultshader_Locations_ = function(gl, program) {
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_projectionMatrix = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_projectionMatrix' : 'h');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_projectionMatrix' : 'h');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_offsetScaleMatrix = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_offsetScaleMatrix' : 'i');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_offsetScaleMatrix' : 'i');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_offsetRotateMatrix = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_offsetRotateMatrix' : 'j');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_offsetRotateMatrix' : 'j');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_lineWidth = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_lineWidth' : 'k');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_lineWidth' : 'k');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_pixelRatio = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_pixelRatio' : 'l');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_pixelRatio' : 'l');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_opacity = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_opacity' : 'm');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_opacity' : 'm');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_fillColor = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_fillColor' : 'n');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_fillColor' : 'n');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_strokeColor = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_strokeColor' : 'o');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_strokeColor' : 'o');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_size = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_size' : 'p');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_size' : 'p');
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.a_position = gl.getAttribLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'a_position' : 'e');
|
||||
program, _ol_.DEBUG_WEBGL ? 'a_position' : 'e');
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.a_instruction = gl.getAttribLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'a_instruction' : 'f');
|
||||
program, _ol_.DEBUG_WEBGL ? 'a_instruction' : 'f');
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.a_radius = gl.getAttribLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'a_radius' : 'g');
|
||||
program, _ol_.DEBUG_WEBGL ? 'a_radius' : 'g');
|
||||
};
|
||||
|
||||
export default _ol_render_webgl_circlereplay_defaultshader_Locations_;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* @module ol/render/webgl/linestringreplay/defaultshader/Locations
|
||||
*/
|
||||
// This file is automatically generated, do not edit
|
||||
goog.provide('ol.render.webgl.linestringreplay.defaultshader.Locations');
|
||||
|
||||
goog.require('ol');
|
||||
|
||||
import _ol_ from '../../../../index.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -10,83 +10,85 @@ goog.require('ol');
|
||||
* @param {WebGLProgram} program Program.
|
||||
* @struct
|
||||
*/
|
||||
ol.render.webgl.linestringreplay.defaultshader.Locations = function(gl, program) {
|
||||
var _ol_render_webgl_linestringreplay_defaultshader_Locations_ = function(gl, program) {
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_projectionMatrix = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_projectionMatrix' : 'h');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_projectionMatrix' : 'h');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_offsetScaleMatrix = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_offsetScaleMatrix' : 'i');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_offsetScaleMatrix' : 'i');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_offsetRotateMatrix = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_offsetRotateMatrix' : 'j');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_offsetRotateMatrix' : 'j');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_lineWidth = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_lineWidth' : 'k');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_lineWidth' : 'k');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_miterLimit = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_miterLimit' : 'l');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_miterLimit' : 'l');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_opacity = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_opacity' : 'm');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_opacity' : 'm');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_color = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_color' : 'n');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_color' : 'n');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_size = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_size' : 'o');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_size' : 'o');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_pixelRatio = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_pixelRatio' : 'p');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_pixelRatio' : 'p');
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.a_lastPos = gl.getAttribLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'a_lastPos' : 'd');
|
||||
program, _ol_.DEBUG_WEBGL ? 'a_lastPos' : 'd');
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.a_position = gl.getAttribLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'a_position' : 'e');
|
||||
program, _ol_.DEBUG_WEBGL ? 'a_position' : 'e');
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.a_nextPos = gl.getAttribLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'a_nextPos' : 'f');
|
||||
program, _ol_.DEBUG_WEBGL ? 'a_nextPos' : 'f');
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.a_direction = gl.getAttribLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'a_direction' : 'g');
|
||||
program, _ol_.DEBUG_WEBGL ? 'a_direction' : 'g');
|
||||
};
|
||||
|
||||
export default _ol_render_webgl_linestringreplay_defaultshader_Locations_;
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
/**
|
||||
* @module ol/render/webgl/polygonreplay/defaultshader
|
||||
*/
|
||||
// This file is automatically generated, do not edit
|
||||
goog.provide('ol.render.webgl.polygonreplay.defaultshader');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.webgl.Fragment');
|
||||
goog.require('ol.webgl.Vertex');
|
||||
import _ol_ from '../../../index.js';
|
||||
import _ol_webgl_Fragment_ from '../../../webgl/Fragment.js';
|
||||
import _ol_webgl_Vertex_ from '../../../webgl/Vertex.js';
|
||||
var _ol_render_webgl_polygonreplay_defaultshader_ = {};
|
||||
|
||||
|
||||
ol.render.webgl.polygonreplay.defaultshader.fragment = new ol.webgl.Fragment(ol.DEBUG_WEBGL ?
|
||||
_ol_render_webgl_polygonreplay_defaultshader_.fragment = new _ol_webgl_Fragment_(_ol_.DEBUG_WEBGL ?
|
||||
'precision mediump float;\n\n\n\nuniform vec4 u_color;\nuniform float u_opacity;\n\nvoid main(void) {\n gl_FragColor = u_color;\n float alpha = u_color.a * u_opacity;\n if (alpha == 0.0) {\n discard;\n }\n gl_FragColor.a = alpha;\n}\n' :
|
||||
'precision mediump float;uniform vec4 e;uniform float f;void main(void){gl_FragColor=e;float alpha=e.a*f;if(alpha==0.0){discard;}gl_FragColor.a=alpha;}');
|
||||
|
||||
ol.render.webgl.polygonreplay.defaultshader.vertex = new ol.webgl.Vertex(ol.DEBUG_WEBGL ?
|
||||
_ol_render_webgl_polygonreplay_defaultshader_.vertex = new _ol_webgl_Vertex_(_ol_.DEBUG_WEBGL ?
|
||||
'\n\nattribute vec2 a_position;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\n\nvoid main(void) {\n gl_Position = u_projectionMatrix * vec4(a_position, 0.0, 1.0);\n}\n\n\n' :
|
||||
'attribute vec2 a;uniform mat4 b;uniform mat4 c;uniform mat4 d;void main(void){gl_Position=b*vec4(a,0.0,1.0);}');
|
||||
export default _ol_render_webgl_polygonreplay_defaultshader_;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* @module ol/render/webgl/polygonreplay/defaultshader/Locations
|
||||
*/
|
||||
// This file is automatically generated, do not edit
|
||||
goog.provide('ol.render.webgl.polygonreplay.defaultshader.Locations');
|
||||
|
||||
goog.require('ol');
|
||||
|
||||
import _ol_ from '../../../../index.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -10,41 +10,43 @@ goog.require('ol');
|
||||
* @param {WebGLProgram} program Program.
|
||||
* @struct
|
||||
*/
|
||||
ol.render.webgl.polygonreplay.defaultshader.Locations = function(gl, program) {
|
||||
var _ol_render_webgl_polygonreplay_defaultshader_Locations_ = function(gl, program) {
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_projectionMatrix = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_projectionMatrix' : 'b');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_projectionMatrix' : 'b');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_offsetScaleMatrix = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_offsetScaleMatrix' : 'c');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_offsetScaleMatrix' : 'c');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_offsetRotateMatrix = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_offsetRotateMatrix' : 'd');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_offsetRotateMatrix' : 'd');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_color = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_color' : 'e');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_color' : 'e');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_opacity = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_opacity' : 'f');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_opacity' : 'f');
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.a_position = gl.getAttribLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'a_position' : 'a');
|
||||
program, _ol_.DEBUG_WEBGL ? 'a_position' : 'a');
|
||||
};
|
||||
|
||||
export default _ol_render_webgl_polygonreplay_defaultshader_Locations_;
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
/**
|
||||
* @module ol/render/webgl/texturereplay/defaultshader
|
||||
*/
|
||||
// This file is automatically generated, do not edit
|
||||
goog.provide('ol.render.webgl.texturereplay.defaultshader');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.webgl.Fragment');
|
||||
goog.require('ol.webgl.Vertex');
|
||||
import _ol_ from '../../../index.js';
|
||||
import _ol_webgl_Fragment_ from '../../../webgl/Fragment.js';
|
||||
import _ol_webgl_Vertex_ from '../../../webgl/Vertex.js';
|
||||
var _ol_render_webgl_texturereplay_defaultshader_ = {};
|
||||
|
||||
|
||||
ol.render.webgl.texturereplay.defaultshader.fragment = new ol.webgl.Fragment(ol.DEBUG_WEBGL ?
|
||||
_ol_render_webgl_texturereplay_defaultshader_.fragment = new _ol_webgl_Fragment_(_ol_.DEBUG_WEBGL ?
|
||||
'precision mediump float;\nvarying vec2 v_texCoord;\nvarying float v_opacity;\n\nuniform float u_opacity;\nuniform sampler2D u_image;\n\nvoid main(void) {\n vec4 texColor = texture2D(u_image, v_texCoord);\n gl_FragColor.rgb = texColor.rgb;\n float alpha = texColor.a * v_opacity * u_opacity;\n if (alpha == 0.0) {\n discard;\n }\n gl_FragColor.a = alpha;\n}\n' :
|
||||
'precision mediump float;varying vec2 a;varying float b;uniform float k;uniform sampler2D l;void main(void){vec4 texColor=texture2D(l,a);gl_FragColor.rgb=texColor.rgb;float alpha=texColor.a*b*k;if(alpha==0.0){discard;}gl_FragColor.a=alpha;}');
|
||||
|
||||
ol.render.webgl.texturereplay.defaultshader.vertex = new ol.webgl.Vertex(ol.DEBUG_WEBGL ?
|
||||
_ol_render_webgl_texturereplay_defaultshader_.vertex = new _ol_webgl_Vertex_(_ol_.DEBUG_WEBGL ?
|
||||
'varying vec2 v_texCoord;\nvarying float v_opacity;\n\nattribute vec2 a_position;\nattribute vec2 a_texCoord;\nattribute vec2 a_offsets;\nattribute float a_opacity;\nattribute float a_rotateWithView;\n\nuniform mat4 u_projectionMatrix;\nuniform mat4 u_offsetScaleMatrix;\nuniform mat4 u_offsetRotateMatrix;\n\nvoid main(void) {\n mat4 offsetMatrix = u_offsetScaleMatrix;\n if (a_rotateWithView == 1.0) {\n offsetMatrix = u_offsetScaleMatrix * u_offsetRotateMatrix;\n }\n vec4 offsets = offsetMatrix * vec4(a_offsets, 0.0, 0.0);\n gl_Position = u_projectionMatrix * vec4(a_position, 0.0, 1.0) + offsets;\n v_texCoord = a_texCoord;\n v_opacity = a_opacity;\n}\n\n\n' :
|
||||
'varying vec2 a;varying float b;attribute vec2 c;attribute vec2 d;attribute vec2 e;attribute float f;attribute float g;uniform mat4 h;uniform mat4 i;uniform mat4 j;void main(void){mat4 offsetMatrix=i;if(g==1.0){offsetMatrix=i*j;}vec4 offsets=offsetMatrix*vec4(e,0.0,0.0);gl_Position=h*vec4(c,0.0,1.0)+offsets;a=d;b=f;}');
|
||||
export default _ol_render_webgl_texturereplay_defaultshader_;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* @module ol/render/webgl/texturereplay/defaultshader/Locations
|
||||
*/
|
||||
// This file is automatically generated, do not edit
|
||||
goog.provide('ol.render.webgl.texturereplay.defaultshader.Locations');
|
||||
|
||||
goog.require('ol');
|
||||
|
||||
import _ol_ from '../../../../index.js';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -10,65 +10,67 @@ goog.require('ol');
|
||||
* @param {WebGLProgram} program Program.
|
||||
* @struct
|
||||
*/
|
||||
ol.render.webgl.texturereplay.defaultshader.Locations = function(gl, program) {
|
||||
var _ol_render_webgl_texturereplay_defaultshader_Locations_ = function(gl, program) {
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_projectionMatrix = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_projectionMatrix' : 'h');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_projectionMatrix' : 'h');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_offsetScaleMatrix = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_offsetScaleMatrix' : 'i');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_offsetScaleMatrix' : 'i');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_offsetRotateMatrix = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_offsetRotateMatrix' : 'j');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_offsetRotateMatrix' : 'j');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_opacity = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_opacity' : 'k');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_opacity' : 'k');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_image = gl.getUniformLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'u_image' : 'l');
|
||||
program, _ol_.DEBUG_WEBGL ? 'u_image' : 'l');
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.a_position = gl.getAttribLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'a_position' : 'c');
|
||||
program, _ol_.DEBUG_WEBGL ? 'a_position' : 'c');
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.a_texCoord = gl.getAttribLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'a_texCoord' : 'd');
|
||||
program, _ol_.DEBUG_WEBGL ? 'a_texCoord' : 'd');
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.a_offsets = gl.getAttribLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'a_offsets' : 'e');
|
||||
program, _ol_.DEBUG_WEBGL ? 'a_offsets' : 'e');
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.a_opacity = gl.getAttribLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'a_opacity' : 'f');
|
||||
program, _ol_.DEBUG_WEBGL ? 'a_opacity' : 'f');
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.a_rotateWithView = gl.getAttribLocation(
|
||||
program, ol.DEBUG_WEBGL ? 'a_rotateWithView' : 'g');
|
||||
program, _ol_.DEBUG_WEBGL ? 'a_rotateWithView' : 'g');
|
||||
};
|
||||
|
||||
export default _ol_render_webgl_texturereplay_defaultshader_Locations_;
|
||||
|
||||
Reference in New Issue
Block a user