Skip to content

Commit

Permalink
add unit test specifically for rectangles around polygons crossing IDL
Browse files Browse the repository at this point in the history
  • Loading branch information
likangning93 committed Feb 1, 2019
1 parent 51698b3 commit ad2f587
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion Specs/Core/PolygonGeometrySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ defineSuite([
'Core/arrayFill',
'Core/BoundingSphere',
'Core/Cartesian3',
'Core/Cartographic',
'Core/Ellipsoid',
'Core/GeometryOffsetAttribute',
'Core/GeometryPipeline',
Expand All @@ -17,6 +18,7 @@ defineSuite([
arrayFill,
BoundingSphere,
Cartesian3,
Cartographic,
Ellipsoid,
GeometryOffsetAttribute,
GeometryPipeline,
Expand Down Expand Up @@ -1095,7 +1097,7 @@ defineSuite([
expect(CesiumMath.toDegrees(boundingRhumb.west)).toEqualEpsilon(-90.0, CesiumMath.EPSILON10);
});

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

it('computes rectangles for geodetic polygons that cross the IDL', function() {
var minLon = Cartographic.fromDegrees(-178, 3);
var minLat = Cartographic.fromDegrees(-179, -4);
var maxLon = Cartographic.fromDegrees(178, 3);
var maxLat = Cartographic.fromDegrees(179, 4);
var cartesianArray = Ellipsoid.WGS84.cartographicArrayToCartesianArray([minLat, minLon, maxLat, maxLon]);

var pGeodesic = new PolygonGeometry({
vertexFormat : VertexFormat.POSITION_AND_ST,
polygonHierarchy: {
positions : cartesianArray
},
granularity: CesiumMath.RADIANS_PER_DEGREE,
arcType : ArcType.GEODESIC
});

var boundingGeodesic = pGeodesic.rectangle;
expect(boundingGeodesic.east).toEqualEpsilon(minLon.longitude, CesiumMath.EPSILON10);
expect(boundingGeodesic.south).toEqualEpsilon(minLat.latitude, CesiumMath.EPSILON10);
expect(boundingGeodesic.west).toEqualEpsilon(maxLon.longitude, CesiumMath.EPSILON10);
expect(boundingGeodesic.north).toEqualEpsilon(maxLat.latitude, CesiumMath.EPSILON10);
});

it('computeRectangle', function() {
var options = {
vertexFormat : VertexFormat.POSITION_AND_ST,
Expand Down

0 comments on commit ad2f587

Please sign in to comment.