Add ol.geom.Polygon#getOrientedFlatCoordinates
This commit is contained in:
@@ -94,6 +94,29 @@ describe('ol.geom.Polygon', function() {
|
||||
expect(polygon.containsCoordinate(insideInner)).to.be(false);
|
||||
});
|
||||
|
||||
describe('#getOrientedFlatCoordinates', function() {
|
||||
|
||||
it('reverses the outer ring if necessary', function() {
|
||||
outerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses inner rings if necessary', function() {
|
||||
innerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses all rings if necessary', function() {
|
||||
outerRing.reverse();
|
||||
innerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('construct with 3D coordinates', function() {
|
||||
@@ -142,6 +165,29 @@ describe('ol.geom.Polygon', function() {
|
||||
expect(polygon.containsCoordinate(insideInner)).to.be(false);
|
||||
});
|
||||
|
||||
describe('#getOrientedFlatCoordinates', function() {
|
||||
|
||||
it('reverses the outer ring if necessary', function() {
|
||||
outerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses inner rings if necessary', function() {
|
||||
innerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses all rings if necessary', function() {
|
||||
outerRing.reverse();
|
||||
innerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('construct with 3D coordinates and layout XYM', function() {
|
||||
@@ -191,6 +237,29 @@ describe('ol.geom.Polygon', function() {
|
||||
expect(polygon.containsCoordinate(insideInner)).to.be(false);
|
||||
});
|
||||
|
||||
describe('#getOrientedFlatCoordinates', function() {
|
||||
|
||||
it('reverses the outer ring if necessary', function() {
|
||||
outerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses inner rings if necessary', function() {
|
||||
innerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses all rings if necessary', function() {
|
||||
outerRing.reverse();
|
||||
innerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('construct with 4D coordinates', function() {
|
||||
@@ -248,6 +317,31 @@ describe('ol.geom.Polygon', function() {
|
||||
expect(polygon.containsCoordinate(insideInner2)).to.be(false);
|
||||
});
|
||||
|
||||
describe('#getOrientedFlatCoordinates', function() {
|
||||
|
||||
it('reverses the outer ring if necessary', function() {
|
||||
outerRing.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing1, innerRing2]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses inner rings if necessary', function() {
|
||||
innerRing1.reverse();
|
||||
innerRing2.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing1, innerRing2]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
it('reverses all rings if necessary', function() {
|
||||
outerRing.reverse();
|
||||
innerRing1.reverse();
|
||||
innerRing2.reverse();
|
||||
polygon = new ol.geom.Polygon([outerRing, innerRing1, innerRing2]);
|
||||
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('with a simple polygon', function() {
|
||||
|
||||
Reference in New Issue
Block a user