Allow geometries to use a shared vertex array

The ol.geom.SharedVertices structure represents a flattened array of vertex coordinates.  This is intended to support optimal WebGL rendering.
This commit is contained in:
Tim Schaub
2013-03-02 18:39:24 +01:00
parent bdfa2cc88c
commit b52d283641
23 changed files with 1086 additions and 217 deletions
+20 -1
View File
@@ -1,4 +1,4 @@
gooog.require('ol.test.geom.Polygon');
goog.provide('ol.test.geom.Polygon');
describe('ol.geom.Polygon', function() {
@@ -20,6 +20,16 @@ describe('ol.geom.Polygon', function() {
}).toThrow();
});
it('accepts shared vertices', function() {
var vertices = new ol.geom.SharedVertices();
var p1 = new ol.geom.Polygon([outer], vertices);
var p2 = new ol.geom.Polygon([outer, inner1], vertices);
var p3 = new ol.geom.Polygon([outer, inner2], vertices);
expect(p1.getCoordinates()).toEqual([outer]);
expect(p2.getCoordinates()).toEqual([outer, inner1]);
expect(p3.getCoordinates()).toEqual([outer, inner2]);
});
});
describe('#rings', function() {
@@ -62,8 +72,17 @@ describe('ol.geom.Polygon', function() {
});
describe('#getCoordinates()', function() {
it('returns an array', function() {
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
expect(poly.getCoordinates()).toEqual([outer, inner1, inner2]);
});
});
});
goog.require('ol.geom.Geometry');
goog.require('ol.geom.Polygon');
goog.require('ol.geom.SharedVertices');