Skip to content

Commit 572a943

Browse files
committed
add unit test specifically for rectangles around polygons crossing IDL
1 parent 51698b3 commit 572a943

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

Specs/Core/PolygonGeometrySpec.js

+26-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ defineSuite([
44
'Core/arrayFill',
55
'Core/BoundingSphere',
66
'Core/Cartesian3',
7+
'Core/Cartographic',
78
'Core/Ellipsoid',
89
'Core/GeometryOffsetAttribute',
910
'Core/GeometryPipeline',
@@ -17,6 +18,7 @@ defineSuite([
1718
arrayFill,
1819
BoundingSphere,
1920
Cartesian3,
21+
Cartographic,
2022
Ellipsoid,
2123
GeometryOffsetAttribute,
2224
GeometryPipeline,
@@ -1095,7 +1097,7 @@ defineSuite([
10951097
expect(CesiumMath.toDegrees(boundingRhumb.west)).toEqualEpsilon(-90.0, CesiumMath.EPSILON10);
10961098
});
10971099

1098-
it('computes rectangles that cross the IDL', function() {
1100+
it('computes rectangles for rhumbline polygons that cross the IDL', function() {
10991101
var pRhumb = new PolygonGeometry({
11001102
vertexFormat : VertexFormat.POSITION_AND_ST,
11011103
polygonHierarchy: {
@@ -1116,6 +1118,29 @@ defineSuite([
11161118
expect(CesiumMath.toDegrees(boundingRhumb.west)).toEqualEpsilon(175.0, CesiumMath.EPSILON10);
11171119
});
11181120

1121+
it('computes rectangles for geodesic polygons that cross the IDL', function() {
1122+
var minLon = Cartographic.fromDegrees(-178, 3);
1123+
var minLat = Cartographic.fromDegrees(-179, -4);
1124+
var maxLon = Cartographic.fromDegrees(178, 3);
1125+
var maxLat = Cartographic.fromDegrees(179, 4);
1126+
var cartesianArray = Ellipsoid.WGS84.cartographicArrayToCartesianArray([minLat, minLon, maxLat, maxLon]);
1127+
1128+
var pGeodesic = new PolygonGeometry({
1129+
vertexFormat : VertexFormat.POSITION_AND_ST,
1130+
polygonHierarchy: {
1131+
positions : cartesianArray
1132+
},
1133+
granularity: CesiumMath.RADIANS_PER_DEGREE,
1134+
arcType : ArcType.GEODESIC
1135+
});
1136+
1137+
var boundingGeodesic = pGeodesic.rectangle;
1138+
expect(boundingGeodesic.east).toEqualEpsilon(minLon.longitude, CesiumMath.EPSILON10);
1139+
expect(boundingGeodesic.south).toEqualEpsilon(minLat.latitude, CesiumMath.EPSILON10);
1140+
expect(boundingGeodesic.west).toEqualEpsilon(maxLon.longitude, CesiumMath.EPSILON10);
1141+
expect(boundingGeodesic.north).toEqualEpsilon(maxLat.latitude, CesiumMath.EPSILON10);
1142+
});
1143+
11191144
it('computeRectangle', function() {
11201145
var options = {
11211146
vertexFormat : VertexFormat.POSITION_AND_ST,

0 commit comments

Comments
 (0)