Don't automatically orient rings in ol.geom.Polygon
This commit is contained in:
@@ -192,8 +192,6 @@ ol.geom.Polygon.prototype.setCoordinates = function(coordinates, opt_layout) {
|
||||
var ends = ol.geom.flat.deflateCoordinatess(
|
||||
this.flatCoordinates, 0, coordinates, this.stride, this.ends_);
|
||||
this.flatCoordinates.length = ends.length === 0 ? 0 : ends[ends.length - 1];
|
||||
ol.geom.flat.orientLinearRings(
|
||||
this.flatCoordinates, 0, this.ends_, this.stride);
|
||||
this.dispatchChangeEvent();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -73,19 +73,13 @@ describe('ol.geom.Polygon', function() {
|
||||
expect(polygon.getStride()).to.be(2);
|
||||
});
|
||||
|
||||
it('reverses the outer ring if necessary', function() {
|
||||
polygon = new ol.geom.Polygon([outerRing.reverse(), innerRing]);
|
||||
expect(polygon.getFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses inner rings if necessary', function() {
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing.reverse()]);
|
||||
expect(polygon.getFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses all rings if necessary', function() {
|
||||
polygon = new ol.geom.Polygon([outerRing.reverse(), innerRing.reverse()]);
|
||||
expect(polygon.getFlatCoordinates()).to.eql(flatCoordinates);
|
||||
it('does not reverse any rings', function() {
|
||||
outerRing.reverse();
|
||||
innerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
var coordinates = polygon.getCoordinates();
|
||||
expect(coordinates[0]).to.eql(outerRing);
|
||||
expect(coordinates[1]).to.eql(innerRing);
|
||||
});
|
||||
|
||||
it('does not contain outside coordinates', function() {
|
||||
@@ -136,21 +130,6 @@ describe('ol.geom.Polygon', function() {
|
||||
expect(polygon.getStride()).to.be(3);
|
||||
});
|
||||
|
||||
it('reverses the outer ring if necessary', function() {
|
||||
polygon = new ol.geom.Polygon([outerRing.reverse(), innerRing]);
|
||||
expect(polygon.getFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses inner rings if necessary', function() {
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing.reverse()]);
|
||||
expect(polygon.getFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses all rings if necessary', function() {
|
||||
polygon = new ol.geom.Polygon([outerRing.reverse(), innerRing.reverse()]);
|
||||
expect(polygon.getFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('does not contain outside coordinates', function() {
|
||||
expect(polygon.containsCoordinate(outsideOuter)).to.be(false);
|
||||
});
|
||||
@@ -200,21 +179,6 @@ describe('ol.geom.Polygon', function() {
|
||||
expect(polygon.getStride()).to.be(3);
|
||||
});
|
||||
|
||||
it('reverses the outer ring if necessary', function() {
|
||||
polygon = new ol.geom.Polygon([outerRing.reverse(), innerRing]);
|
||||
expect(polygon.getFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses inner rings if necessary', function() {
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing.reverse()]);
|
||||
expect(polygon.getFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses all rings if necessary', function() {
|
||||
polygon = new ol.geom.Polygon([outerRing.reverse(), innerRing.reverse()]);
|
||||
expect(polygon.getFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('does not contain outside coordinates', function() {
|
||||
expect(polygon.containsCoordinate(outsideOuter)).to.be(false);
|
||||
});
|
||||
@@ -271,24 +235,6 @@ describe('ol.geom.Polygon', function() {
|
||||
expect(polygon.getStride()).to.be(4);
|
||||
});
|
||||
|
||||
it('reverses the outer ring if necessary', function() {
|
||||
polygon = new ol.geom.Polygon(
|
||||
[outerRing.reverse(), innerRing1, innerRing2]);
|
||||
expect(polygon.getFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses inner rings if necessary', function() {
|
||||
polygon = new ol.geom.Polygon(
|
||||
[outerRing, innerRing1.reverse(), innerRing2.reverse()]);
|
||||
expect(polygon.getFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses all rings if necessary', function() {
|
||||
polygon = new ol.geom.Polygon(
|
||||
[outerRing.reverse(), innerRing1.reverse(), innerRing2.reverse()]);
|
||||
expect(polygon.getFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('does not contain outside coordinates', function() {
|
||||
expect(polygon.containsCoordinate(outsideOuter)).to.be(false);
|
||||
});
|
||||
|
||||
@@ -314,9 +314,8 @@ describe('ol.interaction.Draw', function() {
|
||||
var geometry = features[0].getGeometry();
|
||||
expect(geometry).to.be.a(ol.geom.Polygon);
|
||||
|
||||
// note that order is forced clockwise (despite drawing counter-clockwise)
|
||||
expect(geometry.getCoordinates()).to.eql([
|
||||
[[10, -20], [30, -10], [30, -20], [10, -20]]
|
||||
[[10, -20], [30, -20], [30, -10], [10, -20]]
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user