Skip to content

Commit

Permalink
fixes #8842
Browse files Browse the repository at this point in the history
  • Loading branch information
hpinkos committed Jun 12, 2020
1 parent a23f6e1 commit 94aac1e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 4 deletions.
8 changes: 6 additions & 2 deletions Source/Core/WallGeometryLibrary.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import arrayRemoveDuplicates from "./arrayRemoveDuplicates.js";
import Cartesian3 from "./Cartesian3.js";
import Cartographic from "./Cartographic.js";
import defined from "./defined.js";
import EllipsoidTangentPlane from "./EllipsoidTangentPlane.js";
Expand All @@ -13,14 +15,16 @@ var WallGeometryLibrary = {};

function latLonEquals(c0, c1) {
return (
CesiumMath.equalsEpsilon(c0.latitude, c1.latitude, CesiumMath.EPSILON14) &&
CesiumMath.equalsEpsilon(c0.longitude, c1.longitude, CesiumMath.EPSILON14)
CesiumMath.equalsEpsilon(c0.latitude, c1.latitude, CesiumMath.EPSILON10) &&
CesiumMath.equalsEpsilon(c0.longitude, c1.longitude, CesiumMath.EPSILON10)
);
}

var scratchCartographic1 = new Cartographic();
var scratchCartographic2 = new Cartographic();
function removeDuplicates(ellipsoid, positions, topHeights, bottomHeights) {
positions = arrayRemoveDuplicates(positions, Cartesian3.equalsEpsilon, true);

var length = positions.length;
if (length < 2) {
return;
Expand Down
49 changes: 47 additions & 2 deletions Specs/Core/WallGeometrySpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,53 @@ describe("Core/WallGeometry", function () {
expect(cartographic.height).toEqualEpsilon(2000.0, CesiumMath.EPSILON8);
});

it("does not clean positions that add up past EPSILON14", function () {
var eightyPercentOfEpsilon14 = 0.8 * CesiumMath.EPSILON14;
it("removes duplicates with very small difference", function () {
var w = WallGeometry.createGeometry(
new WallGeometry({
vertexFormat: VertexFormat.POSITION_ONLY,
positions: [
new Cartesian3(
4347090.215457887,
1061403.4237998386,
4538066.036525028
),
new Cartesian3(
4348147.589624987,
1043897.8776143644,
4541092.234751661
),
new Cartesian3(
4348147.589882754,
1043897.8776762491,
4541092.234492364
),
new Cartesian3(
4335659.882947743,
1047571.602084736,
4552098.654605664
),
],
})
);

var numPositions = 8;
var numTriangles = 4;
var positions = w.attributes.position.values;
expect(positions.length).toEqual(numPositions * 3);
expect(w.indices.length).toEqual(numTriangles * 3);

var cartographic = ellipsoid.cartesianToCartographic(
Cartesian3.fromArray(positions, 0)
);
expect(cartographic.height).toEqualEpsilon(0.0, CesiumMath.EPSILON8);

cartographic = ellipsoid.cartesianToCartographic(
Cartesian3.fromArray(positions, 3)
);
});

it("does not clean positions that add up past EPSILON10", function () {
var eightyPercentOfEpsilon14 = 0.8 * CesiumMath.EPSILON10;
var inputPositions = Cartesian3.fromRadiansArrayHeights([
1.0,
1.0,
Expand Down

0 comments on commit 94aac1e

Please sign in to comment.