Add ol.geom.LineString#getSimplifiedGeometryInternal

This commit is contained in:
Tom Payne
2013-12-06 15:01:24 +01:00
parent 9612182f70
commit 6275d8528e
2 changed files with 50 additions and 0 deletions

View File

@@ -156,6 +156,39 @@ describe('ol.geom.LineString', function() {
});
describe('with a simple line string', function() {
var lineString;
beforeEach(function() {
lineString = new ol.geom.LineString(
[[0, 0], [1, 1], [3, 3], [5, 1], [6, 3], [7, 5]]);
});
describe('#getSimplifiedGeometry', function() {
it('returns the expectedResult', function() {
var simplifiedGeometry = lineString.getSimplifiedGeometry(1);
expect(simplifiedGeometry).to.be.an(ol.geom.LineString);
expect(simplifiedGeometry.getCoordinates()).to.eql(
[[0, 0], [3, 3], [5, 1], [7, 5]]);
});
it('caches by resolution', function() {
var simplifiedGeometry1 = lineString.getSimplifiedGeometry(1);
var simplifiedGeometry2 = lineString.getSimplifiedGeometry(1);
expect(simplifiedGeometry1).to.be(simplifiedGeometry2);
});
it('invalidates the cache when the geometry changes', function() {
var simplifiedGeometry1 = lineString.getSimplifiedGeometry(1);
lineString.setCoordinates(lineString.getCoordinates());
var simplifiedGeometry2 = lineString.getSimplifiedGeometry(1);
expect(simplifiedGeometry1).not.to.be(simplifiedGeometry2);
});
});
});
});