Named exports from ol/renderer/vector
This commit is contained in:
@@ -6,8 +6,6 @@ import RenderFeature from '../../../../src/ol/render/Feature.js';
|
||||
|
||||
|
||||
describe('ol.render.Feature', function() {
|
||||
|
||||
let renderFeature;
|
||||
const type = 'Point';
|
||||
const flatCoordinates = [0, 0];
|
||||
const ends = null;
|
||||
@@ -15,41 +13,46 @@ describe('ol.render.Feature', function() {
|
||||
|
||||
describe('Constructor', function() {
|
||||
it('creates an instance', function() {
|
||||
renderFeature =
|
||||
new RenderFeature(type, flatCoordinates, ends, properties, 'foo');
|
||||
expect(renderFeature).to.be.a(RenderFeature);
|
||||
const feature = new RenderFeature(type, flatCoordinates, ends, properties, 'foo');
|
||||
expect(feature).to.be.a(RenderFeature);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#get()', function() {
|
||||
it('returns a single property', function() {
|
||||
expect(renderFeature.get('foo')).to.be('bar');
|
||||
const feature = new RenderFeature(type, flatCoordinates, ends, properties, 'foo');
|
||||
expect(feature.get('foo')).to.be('bar');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getEnds()', function() {
|
||||
it('returns the ends it was created with', function() {
|
||||
expect(renderFeature.getEnds()).to.equal(ends);
|
||||
const feature = new RenderFeature(type, flatCoordinates, ends, properties, 'foo');
|
||||
expect(feature.getEnds()).to.equal(ends);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getExtent()', function() {
|
||||
it('returns the correct extent for a point', function() {
|
||||
expect(renderFeature.getExtent()).to.eql([0, 0, 0, 0]);
|
||||
const feature = new RenderFeature(type, flatCoordinates, ends, properties, 'foo');
|
||||
expect(feature.getExtent()).to.eql([0, 0, 0, 0]);
|
||||
});
|
||||
|
||||
it('caches the extent', function() {
|
||||
expect(renderFeature.getExtent()).to.equal(renderFeature.extent_);
|
||||
const feature = new RenderFeature(type, flatCoordinates, ends, properties, 'foo');
|
||||
expect(feature.getExtent()).to.equal(feature.extent_);
|
||||
});
|
||||
|
||||
it('returns the correct extent for a linestring', function() {
|
||||
const feature =
|
||||
new RenderFeature('LineString', [-1, -2, 2, 1], null, {});
|
||||
const feature = new RenderFeature('LineString', [-1, -2, 2, 1], null, {});
|
||||
expect(feature.getExtent()).to.eql([-1, -2, 2, 1]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getFlatCoordinates()', function() {
|
||||
it('returns the flat coordinates it was created with', function() {
|
||||
expect(renderFeature.getFlatCoordinates()).to.equal(flatCoordinates);
|
||||
const feature = new RenderFeature(type, flatCoordinates, ends, properties, 'foo');
|
||||
expect(feature.getFlatCoordinates()).to.equal(flatCoordinates);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -100,43 +103,50 @@ describe('ol.render.Feature', function() {
|
||||
|
||||
describe('#getGeometry()', function() {
|
||||
it('returns itself as geometry', function() {
|
||||
expect(renderFeature.getGeometry()).to.equal(renderFeature);
|
||||
const feature = new RenderFeature(type, flatCoordinates, ends, properties, 'foo');
|
||||
expect(feature.getGeometry()).to.equal(feature);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getId()', function() {
|
||||
it('returns the feature id', function() {
|
||||
expect(renderFeature.getId()).to.be('foo');
|
||||
const feature = new RenderFeature(type, flatCoordinates, ends, properties, 'foo');
|
||||
expect(feature.getId()).to.be('foo');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getProperties()', function() {
|
||||
it('returns the properties it was created with', function() {
|
||||
expect(renderFeature.getProperties()).to.equal(properties);
|
||||
const feature = new RenderFeature(type, flatCoordinates, ends, properties, 'foo');
|
||||
expect(feature.getProperties()).to.equal(properties);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getSimplifiedGeometry()', function() {
|
||||
it('returns itself as simplified geometry', function() {
|
||||
expect(renderFeature.getSimplifiedGeometry()).to.equal(renderFeature);
|
||||
const feature = new RenderFeature(type, flatCoordinates, ends, properties, 'foo');
|
||||
expect(feature.getSimplifiedGeometry()).to.equal(feature);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getStride()', function() {
|
||||
it('returns 2', function() {
|
||||
expect(renderFeature.getStride()).to.be(2);
|
||||
const feature = new RenderFeature(type, flatCoordinates, ends, properties, 'foo');
|
||||
expect(feature.getStride()).to.be(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getStyleFunction()', function() {
|
||||
it('returns undefined', function() {
|
||||
expect(renderFeature.getStyleFunction()).to.be(undefined);
|
||||
const feature = new RenderFeature(type, flatCoordinates, ends, properties, 'foo');
|
||||
expect(feature.getStyleFunction()).to.be(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getType()', function() {
|
||||
it('returns the type it was created with', function() {
|
||||
expect(renderFeature.getType()).to.equal(type);
|
||||
const feature = new RenderFeature(type, flatCoordinates, ends, properties, 'foo');
|
||||
expect(feature.getType()).to.equal(type);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import CanvasLineStringReplay from '../../../../../src/ol/render/canvas/LineStri
|
||||
import CanvasPolygonReplay from '../../../../../src/ol/render/canvas/PolygonReplay.js';
|
||||
import CanvasReplay from '../../../../../src/ol/render/canvas/Replay.js';
|
||||
import CanvasReplayGroup from '../../../../../src/ol/render/canvas/ReplayGroup.js';
|
||||
import _ol_renderer_vector_ from '../../../../../src/ol/renderer/vector.js';
|
||||
import {renderFeature} from '../../../../../src/ol/renderer/vector.js';
|
||||
import Fill from '../../../../../src/ol/style/Fill.js';
|
||||
import Stroke from '../../../../../src/ol/style/Stroke.js';
|
||||
import Style from '../../../../../src/ol/style/Style.js';
|
||||
@@ -88,7 +88,7 @@ describe('ol.render.canvas.ReplayGroup', function() {
|
||||
});
|
||||
|
||||
it('omits lineTo for repeated coordinates', function() {
|
||||
_ol_renderer_vector_.renderFeature(replay, feature0, fill0, 1);
|
||||
renderFeature(replay, feature0, fill0, 1);
|
||||
replay.replay(context, transform, 0, {});
|
||||
expect(lineToCount).to.be(4);
|
||||
lineToCount = 0;
|
||||
@@ -98,16 +98,16 @@ describe('ol.render.canvas.ReplayGroup', function() {
|
||||
});
|
||||
|
||||
it('does not omit moveTo for repeated coordinates', function() {
|
||||
_ol_renderer_vector_.renderFeature(replay, feature0, fill0, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, feature1, fill1, 1);
|
||||
renderFeature(replay, feature0, fill0, 1);
|
||||
renderFeature(replay, feature1, fill1, 1);
|
||||
replay.replay(context, transform, 0, {});
|
||||
expect(moveToCount).to.be(2);
|
||||
});
|
||||
|
||||
it('batches fill and stroke instructions for same style', function() {
|
||||
_ol_renderer_vector_.renderFeature(replay, feature1, style1, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, feature2, style1, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, feature3, style1, 1);
|
||||
renderFeature(replay, feature1, style1, 1);
|
||||
renderFeature(replay, feature2, style1, 1);
|
||||
renderFeature(replay, feature3, style1, 1);
|
||||
replay.replay(context, transform, 0, {});
|
||||
expect(fillCount).to.be(1);
|
||||
expect(strokeCount).to.be(1);
|
||||
@@ -115,9 +115,9 @@ describe('ol.render.canvas.ReplayGroup', function() {
|
||||
});
|
||||
|
||||
it('batches fill and stroke instructions for different styles', function() {
|
||||
_ol_renderer_vector_.renderFeature(replay, feature1, style1, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, feature2, style1, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, feature3, style2, 1);
|
||||
renderFeature(replay, feature1, style1, 1);
|
||||
renderFeature(replay, feature2, style1, 1);
|
||||
renderFeature(replay, feature3, style2, 1);
|
||||
replay.replay(context, transform, 0, {});
|
||||
expect(fillCount).to.be(2);
|
||||
expect(strokeCount).to.be(2);
|
||||
@@ -125,9 +125,9 @@ describe('ol.render.canvas.ReplayGroup', function() {
|
||||
});
|
||||
|
||||
it('batches fill and stroke instructions for changing styles', function() {
|
||||
_ol_renderer_vector_.renderFeature(replay, feature1, style1, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, feature2, style2, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, feature3, style1, 1);
|
||||
renderFeature(replay, feature1, style1, 1);
|
||||
renderFeature(replay, feature2, style2, 1);
|
||||
renderFeature(replay, feature3, style1, 1);
|
||||
replay.replay(context, transform, 0, {});
|
||||
expect(fillCount).to.be(3);
|
||||
expect(strokeCount).to.be(3);
|
||||
@@ -135,9 +135,9 @@ describe('ol.render.canvas.ReplayGroup', function() {
|
||||
});
|
||||
|
||||
it('batches fill and stroke instructions for skipped feature at the beginning', function() {
|
||||
_ol_renderer_vector_.renderFeature(replay, feature1, style1, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, feature2, style2, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, feature3, style2, 1);
|
||||
renderFeature(replay, feature1, style1, 1);
|
||||
renderFeature(replay, feature2, style2, 1);
|
||||
renderFeature(replay, feature3, style2, 1);
|
||||
const skippedUids = {};
|
||||
skippedUids[getUid(feature1)] = true;
|
||||
replay.replay(context, transform, 0, skippedUids);
|
||||
@@ -147,9 +147,9 @@ describe('ol.render.canvas.ReplayGroup', function() {
|
||||
});
|
||||
|
||||
it('batches fill and stroke instructions for skipped feature at the end', function() {
|
||||
_ol_renderer_vector_.renderFeature(replay, feature1, style1, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, feature2, style1, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, feature3, style2, 1);
|
||||
renderFeature(replay, feature1, style1, 1);
|
||||
renderFeature(replay, feature2, style1, 1);
|
||||
renderFeature(replay, feature3, style2, 1);
|
||||
const skippedUids = {};
|
||||
skippedUids[getUid(feature3)] = true;
|
||||
replay.replay(context, transform, 0, skippedUids);
|
||||
@@ -159,9 +159,9 @@ describe('ol.render.canvas.ReplayGroup', function() {
|
||||
});
|
||||
|
||||
it('batches fill and stroke instructions for skipped features', function() {
|
||||
_ol_renderer_vector_.renderFeature(replay, feature1, style1, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, feature2, style1, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, feature3, style2, 1);
|
||||
renderFeature(replay, feature1, style1, 1);
|
||||
renderFeature(replay, feature2, style1, 1);
|
||||
renderFeature(replay, feature3, style2, 1);
|
||||
const skippedUids = {};
|
||||
skippedUids[getUid(feature1)] = true;
|
||||
skippedUids[getUid(feature2)] = true;
|
||||
@@ -173,9 +173,9 @@ describe('ol.render.canvas.ReplayGroup', function() {
|
||||
|
||||
it('does not batch when overlaps is set to true', function() {
|
||||
replay = new CanvasReplayGroup(1, [-180, -90, 180, 90], 1, 1, true);
|
||||
_ol_renderer_vector_.renderFeature(replay, feature1, style1, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, feature2, style1, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, feature3, style1, 1);
|
||||
renderFeature(replay, feature1, style1, 1);
|
||||
renderFeature(replay, feature2, style1, 1);
|
||||
renderFeature(replay, feature3, style1, 1);
|
||||
replay.replay(context, transform, 0, {});
|
||||
expect(fillCount).to.be(3);
|
||||
expect(strokeCount).to.be(3);
|
||||
@@ -201,8 +201,8 @@ describe('ol.render.canvas.ReplayGroup', function() {
|
||||
}
|
||||
});
|
||||
|
||||
_ol_renderer_vector_.renderFeature(replay, feature1, style2, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, feature2, style2, 1);
|
||||
renderFeature(replay, feature1, style2, 1);
|
||||
renderFeature(replay, feature2, style2, 1);
|
||||
replay.replay(context, transform, 0, {});
|
||||
|
||||
expect(lineDashCount).to.be(1);
|
||||
@@ -242,13 +242,13 @@ describe('ol.render.canvas.ReplayGroup', function() {
|
||||
const geometrycollection = new Feature(new GeometryCollection(
|
||||
[point.getGeometry(), linestring.getGeometry(), polygon.getGeometry()]));
|
||||
replay = new CanvasReplayGroup(1, [-180, -90, 180, 90], 1, 1, true);
|
||||
_ol_renderer_vector_.renderFeature(replay, point, style, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, multipoint, style, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, linestring, style, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, multilinestring, style, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, polygon, style, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, multipolygon, style, 1);
|
||||
_ol_renderer_vector_.renderFeature(replay, geometrycollection, style, 1);
|
||||
renderFeature(replay, point, style, 1);
|
||||
renderFeature(replay, multipoint, style, 1);
|
||||
renderFeature(replay, linestring, style, 1);
|
||||
renderFeature(replay, multilinestring, style, 1);
|
||||
renderFeature(replay, polygon, style, 1);
|
||||
renderFeature(replay, multipolygon, style, 1);
|
||||
renderFeature(replay, geometrycollection, style, 1);
|
||||
_ol_transform_.scale(transform, 0.1, 0.1);
|
||||
replay.replay(context, transform, 0, {});
|
||||
expect(calls.length).to.be(9);
|
||||
|
||||
@@ -7,7 +7,7 @@ import MultiLineString from '../../../../src/ol/geom/MultiLineString.js';
|
||||
import MultiPoint from '../../../../src/ol/geom/MultiPoint.js';
|
||||
import MultiPolygon from '../../../../src/ol/geom/MultiPolygon.js';
|
||||
import CanvasReplayGroup from '../../../../src/ol/render/canvas/ReplayGroup.js';
|
||||
import _ol_renderer_vector_ from '../../../../src/ol/renderer/vector.js';
|
||||
import {renderFeature} from '../../../../src/ol/renderer/vector.js';
|
||||
import Fill from '../../../../src/ol/style/Fill.js';
|
||||
import Icon from '../../../../src/ol/style/Icon.js';
|
||||
import Stroke from '../../../../src/ol/style/Stroke.js';
|
||||
@@ -50,7 +50,7 @@ describe('ol.renderer.vector', function() {
|
||||
let listeners;
|
||||
|
||||
// call #1
|
||||
_ol_renderer_vector_.renderFeature(replayGroup, feature,
|
||||
renderFeature(replayGroup, feature,
|
||||
style, squaredTolerance, listener, listenerThis);
|
||||
|
||||
expect(iconStyleLoadSpy.calledOnce).to.be.ok();
|
||||
@@ -59,7 +59,7 @@ describe('ol.renderer.vector', function() {
|
||||
expect(listeners.length).to.eql(1);
|
||||
|
||||
// call #2
|
||||
_ol_renderer_vector_.renderFeature(replayGroup, feature,
|
||||
renderFeature(replayGroup, feature,
|
||||
style, squaredTolerance, listener, listenerThis);
|
||||
|
||||
expect(iconStyleLoadSpy.calledOnce).to.be.ok();
|
||||
@@ -78,7 +78,7 @@ describe('ol.renderer.vector', function() {
|
||||
style.getZIndex(), 'Image');
|
||||
const setImageStyleSpy = sinon.spy(imageReplay, 'setImageStyle');
|
||||
const drawPointSpy = sinon.stub(imageReplay, 'drawPoint').callsFake(nullFunction);
|
||||
_ol_renderer_vector_.renderFeature(replayGroup, feature,
|
||||
renderFeature(replayGroup, feature,
|
||||
style, squaredTolerance, listener, listenerThis);
|
||||
expect(setImageStyleSpy.called).to.be(false);
|
||||
setImageStyleSpy.restore();
|
||||
@@ -91,7 +91,7 @@ describe('ol.renderer.vector', function() {
|
||||
style.getZIndex(), 'Image');
|
||||
const setImageStyleSpy = sinon.spy(imageReplay, 'setImageStyle');
|
||||
const drawMultiPointSpy = sinon.stub(imageReplay, 'drawMultiPoint').callsFake(nullFunction);
|
||||
_ol_renderer_vector_.renderFeature(replayGroup, feature,
|
||||
renderFeature(replayGroup, feature,
|
||||
style, squaredTolerance, listener, listenerThis);
|
||||
expect(setImageStyleSpy.called).to.be(false);
|
||||
setImageStyleSpy.restore();
|
||||
@@ -105,7 +105,7 @@ describe('ol.renderer.vector', function() {
|
||||
const setFillStrokeStyleSpy = sinon.spy(lineStringReplay,
|
||||
'setFillStrokeStyle');
|
||||
const drawLineStringSpy = sinon.stub(lineStringReplay, 'drawLineString').callsFake(nullFunction);
|
||||
_ol_renderer_vector_.renderFeature(replayGroup, feature,
|
||||
renderFeature(replayGroup, feature,
|
||||
style, squaredTolerance, listener, listenerThis);
|
||||
expect(setFillStrokeStyleSpy.called).to.be(true);
|
||||
expect(drawLineStringSpy.called).to.be(true);
|
||||
@@ -120,7 +120,7 @@ describe('ol.renderer.vector', function() {
|
||||
const setFillStrokeStyleSpy = sinon.spy(lineStringReplay,
|
||||
'setFillStrokeStyle');
|
||||
const drawMultiLineStringSpy = sinon.stub(lineStringReplay, 'drawMultiLineString').callsFake(nullFunction);
|
||||
_ol_renderer_vector_.renderFeature(replayGroup, feature,
|
||||
renderFeature(replayGroup, feature,
|
||||
style, squaredTolerance, listener, listenerThis);
|
||||
expect(setFillStrokeStyleSpy.called).to.be(true);
|
||||
expect(drawMultiLineStringSpy.called).to.be(true);
|
||||
@@ -136,7 +136,7 @@ describe('ol.renderer.vector', function() {
|
||||
const setFillStrokeStyleSpy = sinon.spy(polygonReplay,
|
||||
'setFillStrokeStyle');
|
||||
const drawPolygonSpy = sinon.stub(polygonReplay, 'drawPolygon').callsFake(nullFunction);
|
||||
_ol_renderer_vector_.renderFeature(replayGroup, feature,
|
||||
renderFeature(replayGroup, feature,
|
||||
style, squaredTolerance, listener, listenerThis);
|
||||
expect(setFillStrokeStyleSpy.called).to.be(true);
|
||||
expect(drawPolygonSpy.called).to.be(true);
|
||||
@@ -152,7 +152,7 @@ describe('ol.renderer.vector', function() {
|
||||
const setFillStrokeStyleSpy = sinon.spy(polygonReplay,
|
||||
'setFillStrokeStyle');
|
||||
const drawMultiPolygonSpy = sinon.stub(polygonReplay, 'drawMultiPolygon').callsFake(nullFunction);
|
||||
_ol_renderer_vector_.renderFeature(replayGroup, feature,
|
||||
renderFeature(replayGroup, feature,
|
||||
style, squaredTolerance, listener, listenerThis);
|
||||
expect(setFillStrokeStyleSpy.called).to.be(true);
|
||||
expect(drawMultiPolygonSpy.called).to.be(true);
|
||||
|
||||
Reference in New Issue
Block a user