Rename _ol_render_Feature_ to RenderFeature

This commit is contained in:
Tim Schaub
2018-01-11 13:45:50 -07:00
parent 8cba211ecd
commit b7718fb0ed
5 changed files with 38 additions and 38 deletions

View File

@@ -19,7 +19,7 @@ import Polygon from '../geom/Polygon.js';
import _ol_geom_flat_orient_ from '../geom/flat/orient.js'; import _ol_geom_flat_orient_ from '../geom/flat/orient.js';
import Projection from '../proj/Projection.js'; import Projection from '../proj/Projection.js';
import Units from '../proj/Units.js'; import Units from '../proj/Units.js';
import _ol_render_Feature_ from '../render/Feature.js'; import RenderFeature from '../render/Feature.js';
/** /**
* @classdesc * @classdesc
@@ -51,7 +51,7 @@ var MVT = function(opt_options) {
* (Array.<number>|Array.<Array.<number>>),Object.<string,*>,number)} * (Array.<number>|Array.<Array.<number>>),Object.<string,*>,number)}
*/ */
this.featureClass_ = options.featureClass ? this.featureClass_ = options.featureClass ?
options.featureClass : _ol_render_Feature_; options.featureClass : RenderFeature;
/** /**
* @private * @private
@@ -287,7 +287,7 @@ MVT.prototype.createFeature_ = function(pbf, rawFeature, opt_options) {
var geometryType = MVT.getGeometryType_(type, ends.length); var geometryType = MVT.getGeometryType_(type, ends.length);
if (this.featureClass_ === _ol_render_Feature_) { if (this.featureClass_ === RenderFeature) {
feature = new this.featureClass_(geometryType, flatCoordinates, ends, values, id); feature = new this.featureClass_(geometryType, flatCoordinates, ends, values, id);
} else { } else {
var geom; var geom;

View File

@@ -24,7 +24,7 @@ import _ol_transform_ from '../transform.js';
* @param {Object.<string, *>} properties Properties. * @param {Object.<string, *>} properties Properties.
* @param {number|string|undefined} id Feature id. * @param {number|string|undefined} id Feature id.
*/ */
var _ol_render_Feature_ = function(type, flatCoordinates, ends, properties, id) { var RenderFeature = function(type, flatCoordinates, ends, properties, id) {
/** /**
* @private * @private
* @type {ol.Extent|undefined} * @type {ol.Extent|undefined}
@@ -88,7 +88,7 @@ var _ol_render_Feature_ = function(type, flatCoordinates, ends, properties, id)
* @return {*} Value for the requested key. * @return {*} Value for the requested key.
* @api * @api
*/ */
_ol_render_Feature_.prototype.get = function(key) { RenderFeature.prototype.get = function(key) {
return this.properties_[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. * @return {Array.<number>|Array.<Array.<number>>} Ends or endss.
*/ */
_ol_render_Feature_.prototype.getEnds = RenderFeature.prototype.getEnds =
_ol_render_Feature_.prototype.getEndss = function() { RenderFeature.prototype.getEndss = function() {
return this.ends_; return this.ends_;
}; };
@@ -107,7 +107,7 @@ _ol_render_Feature_.prototype.getEndss = function() {
* @return {ol.Extent} Extent. * @return {ol.Extent} Extent.
* @api * @api
*/ */
_ol_render_Feature_.prototype.getExtent = function() { RenderFeature.prototype.getExtent = function() {
if (!this.extent_) { if (!this.extent_) {
this.extent_ = this.type_ === GeometryType.POINT ? this.extent_ = this.type_ === GeometryType.POINT ?
createOrUpdateFromCoordinate(this.flatCoordinates_) : createOrUpdateFromCoordinate(this.flatCoordinates_) :
@@ -122,7 +122,7 @@ _ol_render_Feature_.prototype.getExtent = function() {
/** /**
* @return {Array.<number>} Flat interior points. * @return {Array.<number>} Flat interior points.
*/ */
_ol_render_Feature_.prototype.getFlatInteriorPoint = function() { RenderFeature.prototype.getFlatInteriorPoint = function() {
if (!this.flatInteriorPoints_) { if (!this.flatInteriorPoints_) {
var flatCenter = getCenter(this.getExtent()); var flatCenter = getCenter(this.getExtent());
this.flatInteriorPoints_ = _ol_geom_flat_interiorpoint_.linearRings( this.flatInteriorPoints_ = _ol_geom_flat_interiorpoint_.linearRings(
@@ -135,7 +135,7 @@ _ol_render_Feature_.prototype.getFlatInteriorPoint = function() {
/** /**
* @return {Array.<number>} Flat interior points. * @return {Array.<number>} Flat interior points.
*/ */
_ol_render_Feature_.prototype.getFlatInteriorPoints = function() { RenderFeature.prototype.getFlatInteriorPoints = function() {
if (!this.flatInteriorPoints_) { if (!this.flatInteriorPoints_) {
var flatCenters = _ol_geom_flat_center_.linearRingss( var flatCenters = _ol_geom_flat_center_.linearRingss(
this.flatCoordinates_, 0, this.ends_, 2); this.flatCoordinates_, 0, this.ends_, 2);
@@ -149,7 +149,7 @@ _ol_render_Feature_.prototype.getFlatInteriorPoints = function() {
/** /**
* @return {Array.<number>} Flat midpoint. * @return {Array.<number>} Flat midpoint.
*/ */
_ol_render_Feature_.prototype.getFlatMidpoint = function() { RenderFeature.prototype.getFlatMidpoint = function() {
if (!this.flatMidpoints_) { 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); this.flatCoordinates_, 0, this.flatCoordinates_.length, 2, 0.5);
@@ -161,7 +161,7 @@ _ol_render_Feature_.prototype.getFlatMidpoint = function() {
/** /**
* @return {Array.<number>} Flat midpoints. * @return {Array.<number>} Flat midpoints.
*/ */
_ol_render_Feature_.prototype.getFlatMidpoints = function() { RenderFeature.prototype.getFlatMidpoints = function() {
if (!this.flatMidpoints_) { if (!this.flatMidpoints_) {
this.flatMidpoints_ = []; this.flatMidpoints_ = [];
var flatCoordinates = this.flatCoordinates_; var flatCoordinates = this.flatCoordinates_;
@@ -184,7 +184,7 @@ _ol_render_Feature_.prototype.getFlatMidpoints = function() {
* @return {number|string|undefined} Id. * @return {number|string|undefined} Id.
* @api * @api
*/ */
_ol_render_Feature_.prototype.getId = function() { RenderFeature.prototype.getId = function() {
return this.id_; return this.id_;
}; };
@@ -192,7 +192,7 @@ _ol_render_Feature_.prototype.getId = function() {
/** /**
* @return {Array.<number>} Flat coordinates. * @return {Array.<number>} Flat coordinates.
*/ */
_ol_render_Feature_.prototype.getOrientedFlatCoordinates = function() { RenderFeature.prototype.getOrientedFlatCoordinates = function() {
return this.flatCoordinates_; return this.flatCoordinates_;
}; };
@@ -200,8 +200,8 @@ _ol_render_Feature_.prototype.getOrientedFlatCoordinates = function() {
/** /**
* @return {Array.<number>} Flat coordinates. * @return {Array.<number>} Flat coordinates.
*/ */
_ol_render_Feature_.prototype.getFlatCoordinates = RenderFeature.prototype.getFlatCoordinates =
_ol_render_Feature_.prototype.getOrientedFlatCoordinates; RenderFeature.prototype.getOrientedFlatCoordinates;
/** /**
@@ -210,7 +210,7 @@ _ol_render_Feature_.prototype.getFlatCoordinates =
* @return {ol.render.Feature} Feature. * @return {ol.render.Feature} Feature.
* @api * @api
*/ */
_ol_render_Feature_.prototype.getGeometry = function() { RenderFeature.prototype.getGeometry = function() {
return this; return this;
}; };
@@ -220,7 +220,7 @@ _ol_render_Feature_.prototype.getGeometry = function() {
* @return {Object.<string, *>} Feature properties. * @return {Object.<string, *>} Feature properties.
* @api * @api
*/ */
_ol_render_Feature_.prototype.getProperties = function() { RenderFeature.prototype.getProperties = function() {
return this.properties_; return this.properties_;
}; };
@@ -229,14 +229,14 @@ _ol_render_Feature_.prototype.getProperties = function() {
* Get the feature for working with its geometry. * Get the feature for working with its geometry.
* @return {ol.render.Feature} Feature. * @return {ol.render.Feature} Feature.
*/ */
_ol_render_Feature_.prototype.getSimplifiedGeometry = RenderFeature.prototype.getSimplifiedGeometry =
_ol_render_Feature_.prototype.getGeometry; RenderFeature.prototype.getGeometry;
/** /**
* @return {number} Stride. * @return {number} Stride.
*/ */
_ol_render_Feature_.prototype.getStride = function() { RenderFeature.prototype.getStride = function() {
return 2; return 2;
}; };
@@ -244,7 +244,7 @@ _ol_render_Feature_.prototype.getStride = function() {
/** /**
* @return {undefined} * @return {undefined}
*/ */
_ol_render_Feature_.prototype.getStyleFunction = nullFunction; RenderFeature.prototype.getStyleFunction = nullFunction;
/** /**
@@ -252,7 +252,7 @@ _ol_render_Feature_.prototype.getStyleFunction = nullFunction;
* @return {ol.geom.GeometryType} Geometry type. * @return {ol.geom.GeometryType} Geometry type.
* @api * @api
*/ */
_ol_render_Feature_.prototype.getType = function() { RenderFeature.prototype.getType = function() {
return this.type_; return this.type_;
}; };
@@ -263,7 +263,7 @@ _ol_render_Feature_.prototype.getType = function() {
* @param {ol.ProjectionLike} source The current projection * @param {ol.ProjectionLike} source The current projection
* @param {ol.ProjectionLike} destination The desired projection. * @param {ol.ProjectionLike} destination The desired projection.
*/ */
_ol_render_Feature_.prototype.transform = function(source, destination) { RenderFeature.prototype.transform = function(source, destination) {
var pixelExtent = source.getExtent(); var pixelExtent = source.getExtent();
var projectedExtent = source.getWorldExtent(); var projectedExtent = source.getWorldExtent();
var scale = getHeight(projectedExtent) / getHeight(pixelExtent); var scale = getHeight(projectedExtent) / getHeight(pixelExtent);
@@ -275,4 +275,4 @@ _ol_render_Feature_.prototype.transform = function(source, destination) {
_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_); transform, this.flatCoordinates_);
}; };
export default _ol_render_Feature_; export default RenderFeature;

View File

@@ -4,7 +4,7 @@ import MVT from '../../../../src/ol/format/MVT.js';
import Point from '../../../../src/ol/geom/Point.js'; import Point from '../../../../src/ol/geom/Point.js';
import Polygon from '../../../../src/ol/geom/Polygon.js'; import Polygon from '../../../../src/ol/geom/Polygon.js';
import MultiPolygon from '../../../../src/ol/geom/MultiPolygon.js'; import MultiPolygon from '../../../../src/ol/geom/MultiPolygon.js';
import _ol_render_Feature_ from '../../../../src/ol/render/Feature.js'; import RenderFeature from '../../../../src/ol/render/Feature.js';
where('ArrayBuffer.isView').describe('ol.format.MVT', function() { where('ArrayBuffer.isView').describe('ol.format.MVT', function() {
@@ -25,7 +25,7 @@ where('ArrayBuffer.isView').describe('ol.format.MVT', function() {
it('uses ol.render.Feature as feature class by default', function() { it('uses ol.render.Feature as feature class by default', function() {
var format = new MVT({layers: ['water']}); var format = new MVT({layers: ['water']});
var features = format.readFeatures(data); var features = format.readFeatures(data);
expect(features[0]).to.be.a(_ol_render_Feature_); expect(features[0]).to.be.a(RenderFeature);
}); });
it('parses only specified layers', function() { it('parses only specified layers', function() {
@@ -185,7 +185,7 @@ describe('ol.format.MVT', function() {
}; };
var feature = format.createFeature_({}, rawFeature); var feature = format.createFeature_({}, rawFeature);
MVT.readRawGeometry_ = readRawGeometry_; MVT.readRawGeometry_ = readRawGeometry_;
expect(feature).to.be.a(_ol_render_Feature_); expect(feature).to.be.a(RenderFeature);
expect(feature.getType()).to.be('Polygon'); expect(feature.getType()).to.be('Polygon');
expect(feature.getFlatCoordinates()).to.equal(createdFlatCoordinates); expect(feature.getFlatCoordinates()).to.equal(createdFlatCoordinates);
expect(feature.getEnds()).to.equal(createdEnds); expect(feature.getEnds()).to.equal(createdEnds);

View File

@@ -2,7 +2,7 @@ import LineString from '../../../../src/ol/geom/LineString.js';
import MultiLineString from '../../../../src/ol/geom/MultiLineString.js'; import MultiLineString from '../../../../src/ol/geom/MultiLineString.js';
import MultiPolygon from '../../../../src/ol/geom/MultiPolygon.js'; import MultiPolygon from '../../../../src/ol/geom/MultiPolygon.js';
import Polygon from '../../../../src/ol/geom/Polygon.js'; import Polygon from '../../../../src/ol/geom/Polygon.js';
import _ol_render_Feature_ from '../../../../src/ol/render/Feature.js'; import RenderFeature from '../../../../src/ol/render/Feature.js';
describe('ol.render.Feature', function() { describe('ol.render.Feature', function() {
@@ -16,8 +16,8 @@ describe('ol.render.Feature', function() {
describe('Constructor', function() { describe('Constructor', function() {
it('creates an instance', function() { it('creates an instance', function() {
renderFeature = renderFeature =
new _ol_render_Feature_(type, flatCoordinates, ends, properties, 'foo'); new RenderFeature(type, flatCoordinates, ends, properties, 'foo');
expect(renderFeature).to.be.a(_ol_render_Feature_); expect(renderFeature).to.be.a(RenderFeature);
}); });
}); });
@@ -42,7 +42,7 @@ describe('ol.render.Feature', function() {
}); });
it('returns the correct extent for a linestring', function() { it('returns the correct extent for a linestring', function() {
var feature = var feature =
new _ol_render_Feature_('LineString', [-1, -2, 2, 1], null, {}); new RenderFeature('LineString', [-1, -2, 2, 1], null, {});
expect(feature.getExtent()).to.eql([-1, -2, 2, 1]); expect(feature.getExtent()).to.eql([-1, -2, 2, 1]);
}); });
}); });
@@ -56,7 +56,7 @@ describe('ol.render.Feature', function() {
describe('#getFlatInteriorPoint()', function() { describe('#getFlatInteriorPoint()', function() {
it('returns correct point and caches it', function() { it('returns correct point and caches it', function() {
var polygon = new Polygon([[[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]]); var polygon = new Polygon([[[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]]);
var feature = new _ol_render_Feature_('Polygon', polygon.getOrientedFlatCoordinates(), var feature = new RenderFeature('Polygon', polygon.getOrientedFlatCoordinates(),
polygon.getEnds()); polygon.getEnds());
expect(feature.getFlatInteriorPoint()).to.eql([5, 5, 10]); expect(feature.getFlatInteriorPoint()).to.eql([5, 5, 10]);
expect(feature.getFlatInteriorPoint()).to.be(feature.flatInteriorPoints_); expect(feature.getFlatInteriorPoint()).to.be(feature.flatInteriorPoints_);
@@ -69,7 +69,7 @@ describe('ol.render.Feature', function() {
[[[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]], [[[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]],
[[[10, 0], [10, 10], [20, 10], [20, 0], [10, 0]]] [[[10, 0], [10, 10], [20, 10], [20, 0], [10, 0]]]
]); ]);
var feature = new _ol_render_Feature_('MultiPolygon', polygon.getOrientedFlatCoordinates(), var feature = new RenderFeature('MultiPolygon', polygon.getOrientedFlatCoordinates(),
polygon.getEndss()); polygon.getEndss());
expect(feature.getFlatInteriorPoints()).to.eql([5, 5, 10, 15, 5, 10]); expect(feature.getFlatInteriorPoints()).to.eql([5, 5, 10, 15, 5, 10]);
expect(feature.getFlatInteriorPoints()).to.be(feature.flatInteriorPoints_); expect(feature.getFlatInteriorPoints()).to.be(feature.flatInteriorPoints_);
@@ -79,7 +79,7 @@ describe('ol.render.Feature', function() {
describe('#getFlatMidpoint()', function() { describe('#getFlatMidpoint()', function() {
it('returns correct point', function() { it('returns correct point', function() {
var line = new LineString([[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]); var line = new LineString([[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]]);
var feature = new _ol_render_Feature_('LineString', line.getFlatCoordinates()); var feature = new RenderFeature('LineString', line.getFlatCoordinates());
expect(feature.getFlatMidpoint()).to.eql([10, 10]); expect(feature.getFlatMidpoint()).to.eql([10, 10]);
expect(feature.getFlatMidpoint()).to.eql(feature.flatMidpoints_); expect(feature.getFlatMidpoint()).to.eql(feature.flatMidpoints_);
}); });
@@ -91,7 +91,7 @@ describe('ol.render.Feature', function() {
[[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]], [[0, 0], [0, 10], [10, 10], [10, 0], [0, 0]],
[[10, 0], [10, 10], [20, 10], [20, 0], [10, 0]] [[10, 0], [10, 10], [20, 10], [20, 0], [10, 0]]
]); ]);
var feature = new _ol_render_Feature_('MultiLineString', line.getFlatCoordinates(), var feature = new RenderFeature('MultiLineString', line.getFlatCoordinates(),
line.getEnds()); line.getEnds());
expect(feature.getFlatMidpoints()).to.eql([10, 10, 20, 10]); expect(feature.getFlatMidpoints()).to.eql([10, 10, 20, 10]);
expect(feature.getFlatMidpoints()).to.be(feature.flatMidpoints_); expect(feature.getFlatMidpoints()).to.be(feature.flatMidpoints_);

View File

@@ -13,7 +13,7 @@ import VectorTileLayer from '../../../../../src/ol/layer/VectorTile.js';
import {get as getProjection, fromLonLat} from '../../../../../src/ol/proj.js'; import {get as getProjection, fromLonLat} from '../../../../../src/ol/proj.js';
import Projection from '../../../../../src/ol/proj/Projection.js'; import Projection from '../../../../../src/ol/proj/Projection.js';
import _ol_render_canvas_ from '../../../../../src/ol/render/canvas.js'; import _ol_render_canvas_ from '../../../../../src/ol/render/canvas.js';
import _ol_render_Feature_ from '../../../../../src/ol/render/Feature.js'; import RenderFeature from '../../../../../src/ol/render/Feature.js';
import CanvasVectorTileLayerRenderer from '../../../../../src/ol/renderer/canvas/VectorTileLayer.js'; import CanvasVectorTileLayerRenderer from '../../../../../src/ol/renderer/canvas/VectorTileLayer.js';
import VectorTileSource from '../../../../../src/ol/source/VectorTile.js'; import VectorTileSource from '../../../../../src/ol/source/VectorTile.js';
import Style from '../../../../../src/ol/style/Style.js'; import Style from '../../../../../src/ol/style/Style.js';
@@ -57,7 +57,7 @@ describe('ol.renderer.canvas.VectorTileLayer', function() {
})]; })];
feature1 = new Feature(new Point([1, -1])); feature1 = new Feature(new Point([1, -1]));
feature2 = new Feature(new Point([0, 0])); feature2 = new Feature(new Point([0, 0]));
feature3 = new _ol_render_Feature_('Point', [1, -1], []); feature3 = new RenderFeature('Point', [1, -1], []);
feature2.setStyle(featureStyle); feature2.setStyle(featureStyle);
var TileClass = function() { var TileClass = function() {
VectorTile.apply(this, arguments); VectorTile.apply(this, arguments);