Rename _ol_geom_Polygon_ to Polygon

This commit is contained in:
Tim Schaub
2017-12-14 08:56:12 -07:00
parent 3c78cb7872
commit c502f016f7
52 changed files with 255 additions and 255 deletions

View File

@@ -2,7 +2,7 @@ import _ol_geom_Geometry_ from '../../../../src/ol/geom/Geometry.js';
import _ol_geom_GeometryCollection_ from '../../../../src/ol/geom/GeometryCollection.js';
import LineString from '../../../../src/ol/geom/LineString.js';
import Point from '../../../../src/ol/geom/Point.js';
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
import Polygon from '../../../../src/ol/geom/Polygon.js';
describe('ol.geom.GeometryCollection', function() {
@@ -16,7 +16,7 @@ describe('ol.geom.GeometryCollection', function() {
beforeEach(function() {
point = new Point([10, 20]);
line = new LineString([[10, 20], [30, 40]]);
poly = new _ol_geom_Polygon_([outer, inner1, inner2]);
poly = new Polygon([outer, inner1, inner2]);
multi = new _ol_geom_GeometryCollection_([point, line, poly]);
});
@@ -58,7 +58,7 @@ describe('ol.geom.GeometryCollection', function() {
it('returns a collection of geometries', function() {
var point = new Point([10, 20]);
var line = new LineString([[10, 20], [30, 40]]);
var poly = new _ol_geom_Polygon_([outer, inner1, inner2]);
var poly = new Polygon([outer, inner1, inner2]);
var multi = new _ol_geom_GeometryCollection_([point, line, poly]);
var geometries = multi.getGeometries();
@@ -66,7 +66,7 @@ describe('ol.geom.GeometryCollection', function() {
expect(geometries).to.have.length(3);
expect(geometries[0]).to.be.a(Point);
expect(geometries[1]).to.be.a(LineString);
expect(geometries[2]).to.be.a(_ol_geom_Polygon_);
expect(geometries[2]).to.be.a(Polygon);
});
});
@@ -76,7 +76,7 @@ describe('ol.geom.GeometryCollection', function() {
it('has a working clone method', function() {
var point = new Point([10, 20]);
var line = new LineString([[10, 20], [30, 40]]);
var poly = new _ol_geom_Polygon_([outer, inner1, inner2]);
var poly = new Polygon([outer, inner1, inner2]);
var multi = new _ol_geom_GeometryCollection_([point, line, poly]);
var clone = multi.clone();
expect(clone).to.not.be(multi);
@@ -124,7 +124,7 @@ describe('ol.geom.GeometryCollection', function() {
beforeEach(function() {
point = new Point([5, 20]);
line = new LineString([[10, 20], [30, 40]]);
poly = new _ol_geom_Polygon_([outer, inner1, inner2]);
poly = new Polygon([outer, inner1, inner2]);
multi = new _ol_geom_GeometryCollection_([point, line, poly]);
});
@@ -153,7 +153,7 @@ describe('ol.geom.GeometryCollection', function() {
beforeEach(function() {
point = new Point([10, 20]);
line = new LineString([[10, 20], [30, 40]]);
poly = new _ol_geom_Polygon_([outer, inner1, inner2]);
poly = new Polygon([outer, inner1, inner2]);
multi = new _ol_geom_GeometryCollection_([point, line, poly]);
});

View File

@@ -1,5 +1,5 @@
import _ol_geom_MultiPolygon_ from '../../../../src/ol/geom/MultiPolygon.js';
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
import Polygon from '../../../../src/ol/geom/Polygon.js';
describe('ol.geom.MultiPolygon', function() {
@@ -19,11 +19,11 @@ describe('ol.geom.MultiPolygon', function() {
it('can append polygons', function() {
multiPolygon.appendPolygon(
new _ol_geom_Polygon_([[[0, 0], [0, 2], [1, 1], [2, 0]]]));
new Polygon([[[0, 0], [0, 2], [1, 1], [2, 0]]]));
expect(multiPolygon.getCoordinates()).to.eql(
[[[[0, 0], [0, 2], [1, 1], [2, 0]]]]);
multiPolygon.appendPolygon(
new _ol_geom_Polygon_([[[3, 0], [4, 1], [5, 2], [5, 0]]]));
new Polygon([[[3, 0], [4, 1], [5, 2], [5, 0]]]));
expect(multiPolygon.getCoordinates()).to.eql([
[[[0, 0], [0, 2], [1, 1], [2, 0]]],
[[[3, 0], [4, 1], [5, 2], [5, 0]]]
@@ -42,11 +42,11 @@ describe('ol.geom.MultiPolygon', function() {
it('can append polygons', function() {
multiPolygon.appendPolygon(
new _ol_geom_Polygon_([[[0, 0], [0, 2], [1, 1], [2, 0]]]));
new Polygon([[[0, 0], [0, 2], [1, 1], [2, 0]]]));
expect(multiPolygon.getCoordinates()).to.eql(
[[[[0, 0], [0, 2], [1, 1], [2, 0]]]]);
multiPolygon.appendPolygon(
new _ol_geom_Polygon_([[[3, 0], [4, 1], [5, 2], [5, 0]]]));
new Polygon([[[3, 0], [4, 1], [5, 2], [5, 0]]]));
expect(multiPolygon.getCoordinates()).to.eql([
[[[0, 0], [0, 2], [1, 1], [2, 0]]],
[[[3, 0], [4, 1], [5, 2], [5, 0]]]
@@ -99,11 +99,11 @@ describe('ol.geom.MultiPolygon', function() {
it('can return individual polygons', function() {
var polygon0 = multiPolygon.getPolygon(0);
expect(polygon0).to.be.an(_ol_geom_Polygon_);
expect(polygon0).to.be.an(Polygon);
expect(polygon0.getCoordinates()).to.eql(
[[[0, 0], [0, 2], [1, 1], [2, 0]]]);
var polygon1 = multiPolygon.getPolygon(1);
expect(polygon1).to.be.an(_ol_geom_Polygon_);
expect(polygon1).to.be.an(Polygon);
expect(polygon1.getCoordinates()).to.eql(
[[[3, 0], [4, 1], [5, 2], [5, 0]]]);
});
@@ -112,10 +112,10 @@ describe('ol.geom.MultiPolygon', function() {
var polygons = multiPolygon.getPolygons();
expect(polygons).to.be.an(Array);
expect(polygons).to.have.length(2);
expect(polygons[0]).to.be.an(_ol_geom_Polygon_);
expect(polygons[0]).to.be.an(Polygon);
expect(polygons[0].getCoordinates()).to.eql(
[[[0, 0], [0, 2], [1, 1], [2, 0]]]);
expect(polygons[1]).to.be.an(_ol_geom_Polygon_);
expect(polygons[1]).to.be.an(Polygon);
expect(polygons[1].getCoordinates()).to.eql(
[[[3, 0], [4, 1], [5, 2], [5, 0]]]);
});

View File

@@ -1,14 +1,14 @@
import * as _ol_extent_ from '../../../../src/ol/extent.js';
import _ol_geom_Circle_ from '../../../../src/ol/geom/Circle.js';
import _ol_geom_LinearRing_ from '../../../../src/ol/geom/LinearRing.js';
import _ol_geom_Polygon_ from '../../../../src/ol/geom/Polygon.js';
import Polygon from '../../../../src/ol/geom/Polygon.js';
describe('ol.geom.Polygon', function() {
it('can be constructed with a null geometry', function() {
expect(function() {
return new _ol_geom_Polygon_(null);
return new Polygon(null);
}).not.to.throwException();
});
@@ -16,7 +16,7 @@ describe('ol.geom.Polygon', function() {
var polygon;
beforeEach(function() {
polygon = new _ol_geom_Polygon_([]);
polygon = new Polygon([]);
});
it('defaults to layout XY', function() {
@@ -59,7 +59,7 @@ describe('ol.geom.Polygon', function() {
beforeEach(function() {
outerRing = [[0, 1], [1, 4], [4, 3], [3, 0]];
innerRing = [[2, 2], [3, 2], [3, 3], [2, 3]];
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
polygon = new Polygon([outerRing, innerRing]);
flatCoordinates = [0, 1, 1, 4, 4, 3, 3, 0, 2, 2, 3, 2, 3, 3, 2, 3];
outsideOuter = [0, 4];
inside = [1.5, 1.5];
@@ -104,7 +104,7 @@ describe('ol.geom.Polygon', function() {
it('does not reverse any rings', function() {
outerRing.reverse();
innerRing.reverse();
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
polygon = new Polygon([outerRing, innerRing]);
var coordinates = polygon.getCoordinates();
expect(coordinates[0]).to.eql(outerRing);
expect(coordinates[1]).to.eql(innerRing);
@@ -126,8 +126,8 @@ describe('ol.geom.Polygon', function() {
var cw = [[-180, -90], [-180, 90], [180, 90], [180, -90], [-180, -90]];
var ccw = [[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]];
var right = new _ol_geom_Polygon_([ccw, cw]);
var left = new _ol_geom_Polygon_([cw, ccw]);
var right = new Polygon([ccw, cw]);
var left = new Polygon([cw, ccw]);
it('returns coordinates as they were constructed', function() {
expect(right.getCoordinates()).to.eql([ccw, cw]);
@@ -150,20 +150,20 @@ describe('ol.geom.Polygon', function() {
it('reverses the outer ring if necessary', function() {
outerRing.reverse();
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
polygon = new 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]);
polygon = new 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]);
polygon = new Polygon([outerRing, innerRing]);
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
});
@@ -178,7 +178,7 @@ describe('ol.geom.Polygon', function() {
beforeEach(function() {
outerRing = [[0, 0, 1], [4, 4, 2], [4, 0, 3]];
innerRing = [[2, 1, 4], [3, 1, 5], [3, 2, 6]];
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
polygon = new Polygon([outerRing, innerRing]);
flatCoordinates = [0, 0, 1, 4, 4, 2, 4, 0, 3, 2, 1, 4, 3, 1, 5, 3, 2, 6];
outsideOuter = [1, 3];
inside = [3.5, 0.5];
@@ -248,20 +248,20 @@ describe('ol.geom.Polygon', function() {
it('reverses the outer ring if necessary', function() {
outerRing.reverse();
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
polygon = new 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]);
polygon = new 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]);
polygon = new Polygon([outerRing, innerRing]);
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
});
@@ -276,7 +276,7 @@ describe('ol.geom.Polygon', function() {
beforeEach(function() {
outerRing = [[0, 0, 1], [4, 4, 2], [4, 0, 3]];
innerRing = [[2, 1, 4], [3, 1, 5], [3, 2, 6]];
polygon = new _ol_geom_Polygon_(
polygon = new Polygon(
[outerRing, innerRing], 'XYM');
flatCoordinates = [0, 0, 1, 4, 4, 2, 4, 0, 3, 2, 1, 4, 3, 1, 5, 3, 2, 6];
outsideOuter = [1, 3];
@@ -347,20 +347,20 @@ describe('ol.geom.Polygon', function() {
it('reverses the outer ring if necessary', function() {
outerRing.reverse();
polygon = new _ol_geom_Polygon_([outerRing, innerRing]);
polygon = new 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]);
polygon = new 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]);
polygon = new Polygon([outerRing, innerRing]);
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
});
@@ -377,7 +377,7 @@ describe('ol.geom.Polygon', function() {
innerRing1 =
[[2, 4, 7, 8], [4, 4, 9, 10], [4, 5, 11, 12], [2, 5, 13, 14]];
innerRing2 = [[3, 2, 15, 16], [4, 3, 17, 18], [2, 3, 19, 20]];
polygon = new _ol_geom_Polygon_([outerRing, innerRing1, innerRing2]);
polygon = new Polygon([outerRing, innerRing1, innerRing2]);
flatCoordinates = [
0, 6, 1, 2, 6, 6, 3, 4, 3, 0, 5, 6,
2, 4, 7, 8, 4, 4, 9, 10, 4, 5, 11, 12, 2, 5, 13, 14,
@@ -456,14 +456,14 @@ describe('ol.geom.Polygon', function() {
it('reverses the outer ring if necessary', function() {
outerRing.reverse();
polygon = new _ol_geom_Polygon_([outerRing, innerRing1, innerRing2]);
polygon = new 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]);
polygon = new Polygon([outerRing, innerRing1, innerRing2]);
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
});
@@ -471,7 +471,7 @@ describe('ol.geom.Polygon', function() {
outerRing.reverse();
innerRing1.reverse();
innerRing2.reverse();
polygon = new _ol_geom_Polygon_([outerRing, innerRing1, innerRing2]);
polygon = new Polygon([outerRing, innerRing1, innerRing2]);
expect(polygon.getOrientedFlatCoordinates()).to.eql(flatCoordinates);
});
@@ -483,7 +483,7 @@ describe('ol.geom.Polygon', function() {
var polygon;
beforeEach(function() {
polygon = new _ol_geom_Polygon_(
polygon = new Polygon(
[[[3, 0], [1, 3], [0, 6], [2, 6], [3, 7], [4, 6], [6, 6], [4, 3]]]);
});
@@ -491,7 +491,7 @@ describe('ol.geom.Polygon', function() {
it('returns the expected result', function() {
var simplifiedGeometry = polygon.getSimplifiedGeometry(9);
expect(simplifiedGeometry).to.be.an(_ol_geom_Polygon_);
expect(simplifiedGeometry).to.be.an(Polygon);
expect(simplifiedGeometry.getCoordinates()).to.eql(
[[[3, 0], [0, 3], [0, 6], [6, 6], [3, 3]]]);
});
@@ -511,7 +511,7 @@ describe('ol.geom.Polygon', function() {
describe('#scale()', function() {
it('scales a polygon', function() {
var geom = new _ol_geom_Polygon_([
var geom = new Polygon([
[[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]]
]);
geom.scale(10);
@@ -520,7 +520,7 @@ describe('ol.geom.Polygon', function() {
});
it('accepts sx and sy', function() {
var geom = new _ol_geom_Polygon_([
var geom = new Polygon([
[[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]]
]);
geom.scale(2, 3);
@@ -529,7 +529,7 @@ describe('ol.geom.Polygon', function() {
});
it('accepts an anchor', function() {
var geom = new _ol_geom_Polygon_([
var geom = new Polygon([
[[-1, -2], [1, -2], [1, 2], [-1, 2], [-1, -2]]
]);
geom.scale(3, 2, [-1, -2]);
@@ -542,7 +542,7 @@ describe('ol.geom.Polygon', function() {
describe('#getInteriorPoint', function() {
it('returns XYM point with intersection width as M', function() {
var geom = new _ol_geom_Polygon_([[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]);
var geom = new Polygon([[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]);
var interiorPoint = geom.getInteriorPoint();
expect(interiorPoint.getType()).to.be('Point');
expect(interiorPoint.layout).to.be('XYM');
@@ -550,7 +550,7 @@ describe('ol.geom.Polygon', function() {
});
it('returns XYM point for donut polygons', function() {
var geom = new _ol_geom_Polygon_([
var geom = new Polygon([
[[0.5, 0.5], [0.5, 2.5], [2.5, 2.5], [2.5, 0.5], [0.5, 0.5]],
[[1, 1], [2, 1], [2, 2], [1, 2], [1, 1]]
]);
@@ -564,7 +564,7 @@ describe('ol.geom.Polygon', function() {
describe('ol.geom.Polygon.fromExtent', function() {
it('creates the correct polygon', function() {
var extent = [1, 2, 3, 5];
var polygon = _ol_geom_Polygon_.fromExtent(extent);
var polygon = Polygon.fromExtent(extent);
var flatCoordinates = polygon.getFlatCoordinates();
expect(flatCoordinates).to.eql(
[1, 2, 1, 5, 3, 5, 3, 2, 1, 2]);
@@ -578,7 +578,7 @@ describe('ol.geom.Polygon', function() {
it('creates a regular polygon', function() {
var circle = new _ol_geom_Circle_([0, 0, 0], 1, 'XYZ');
var polygon = _ol_geom_Polygon_.fromCircle(circle);
var polygon = Polygon.fromCircle(circle);
var coordinates = polygon.getLinearRing(0).getCoordinates();
expect(coordinates[0].length).to.eql(3);
expect(coordinates[0][2]).to.eql(0);
@@ -599,7 +599,7 @@ describe('ol.geom.Polygon', function() {
it('creates a regular polygon with custom sides and angle', function() {
var circle = new _ol_geom_Circle_([0, 0], 1);
var polygon = _ol_geom_Polygon_.fromCircle(circle, 4, Math.PI / 2);
var polygon = Polygon.fromCircle(circle, 4, Math.PI / 2);
var coordinates = polygon.getLinearRing(0).getCoordinates();
expect(coordinates[4]).to.eql(coordinates[0]);
expect(coordinates[0][0]).to.roughlyEqual(0, 1e-9);