Store rings so exerior is clockwise and interior is counter-clockwise

KML and WKT don't specify a winding order, so we write those out in CW/CCW order (for exterior/interior).  GML references ISO 19107 that specifies CCW/CW, so we serialize in that winding order.

Having hand generated all this GML data the first time around, I reserve the right to modify it for the tests.
This commit is contained in:
Tim Schaub
2013-06-24 17:46:36 -06:00
parent e292d8fa12
commit 99ba5a0da8
20 changed files with 150 additions and 121 deletions

View File

@@ -44,6 +44,28 @@ describe('ol.geom.Polygon', function() {
expect(poly.rings[2]).to.be.a(ol.geom.LinearRing);
});
var isClockwise = ol.geom.LinearRing.isClockwise;
it('forces exterior ring to be clockwise', function() {
var outer = [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]];
expect(isClockwise(outer)).to.be(false);
var poly = new ol.geom.Polygon([outer]);
var ring = poly.rings[0];
expect(isClockwise(ring.getCoordinates())).to.be(true);
});
it('forces interior ring to be counter-clockwise', function() {
var outer = [[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]];
var inner = [[2, 2], [2, 8], [8, 8], [8, 2], [2, 2]];
expect(isClockwise(inner)).to.be(true);
var poly = new ol.geom.Polygon([outer, inner]);
var ring = poly.rings[1];
expect(isClockwise(ring.getCoordinates())).to.be(false);
});
});
describe('#dimension', function() {