-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adjust polygon position heights before removing duplicates if not perPositionHeight #6731
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,6 +217,13 @@ define([ | |
var outerRing = outerNode.positions; | ||
var holes = outerNode.holes; | ||
|
||
var i; | ||
if (!perPositionHeight) { | ||
for (i = 0; i < outerRing.length; i++) { | ||
ellipsoid.scaleToGeodeticSurface(outerRing[i], outerRing[i]); | ||
} | ||
} | ||
|
||
outerRing = arrayRemoveDuplicates(outerRing, Cartesian3.equalsEpsilon, true); | ||
if (outerRing.length < 3) { | ||
continue; | ||
|
@@ -234,12 +241,18 @@ define([ | |
var positions = outerRing.slice(); | ||
var numChildren = defined(holes) ? holes.length : 0; | ||
var polygonHoles = []; | ||
var i; | ||
var j; | ||
|
||
for (i = 0; i < numChildren; i++) { | ||
var hole = holes[i]; | ||
var holePositions = arrayRemoveDuplicates(hole.positions, Cartesian3.equalsEpsilon, true); | ||
var holePositions = hole.positions; | ||
if (!perPositionHeight) { | ||
for (j = 0; j < holePositions.length; ++j) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
ellipsoid.scaleToGeodeticSurface(holePositions[j], holePositions[j]); | ||
} | ||
} | ||
|
||
holePositions = arrayRemoveDuplicates(holePositions, Cartesian3.equalsEpsilon, true); | ||
if (holePositions.length < 3) { | ||
continue; | ||
} | ||
|
@@ -267,18 +280,6 @@ define([ | |
} | ||
} | ||
|
||
if (!perPositionHeight) { | ||
for (i = 0; i < outerRing.length; i++) { | ||
ellipsoid.scaleToGeodeticSurface(outerRing[i], outerRing[i]); | ||
} | ||
for (i = 0; i < polygonHoles.length; i++) { | ||
var polygonHole = polygonHoles[i]; | ||
for (j = 0; j < polygonHole.length; ++j) { | ||
ellipsoid.scaleToGeodeticSurface(polygonHole[j], polygonHole[j]); | ||
} | ||
} | ||
} | ||
|
||
hierarchy.push({ | ||
outerRing : outerRing, | ||
holes : polygonHoles | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -483,9 +483,15 @@ define([ | |
var queue = new Queue(); | ||
queue.enqueue(polygonHierarchy); | ||
var i; | ||
var j; | ||
while (queue.length !== 0) { | ||
var outerNode = queue.dequeue(); | ||
var outerRing = outerNode.positions; | ||
if (!perPositionHeight) { | ||
for (i = 0; i < outerRing.length; i++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
ellipsoid.scaleToGeodeticSurface(outerRing[i], outerRing[i]); | ||
} | ||
} | ||
outerRing = arrayRemoveDuplicates(outerRing, Cartesian3.equalsEpsilon, true); | ||
if (outerRing.length < 3) { | ||
continue; | ||
|
@@ -495,18 +501,24 @@ define([ | |
// The outer polygon contains inner polygons | ||
for (i = 0; i < numChildren; i++) { | ||
var hole = outerNode.holes[i]; | ||
hole.positions = arrayRemoveDuplicates(hole.positions, Cartesian3.equalsEpsilon, true); | ||
if (hole.positions.length < 3) { | ||
var holePositions = hole.positions; | ||
if (!perPositionHeight) { | ||
for (j = 0; j < holePositions.length; ++j) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
ellipsoid.scaleToGeodeticSurface(holePositions[j], holePositions[j]); | ||
} | ||
} | ||
holePositions = arrayRemoveDuplicates(holePositions, Cartesian3.equalsEpsilon, true); | ||
if (holePositions.length < 3) { | ||
continue; | ||
} | ||
polygons.push(hole.positions); | ||
polygons.push(holePositions); | ||
|
||
var numGrandchildren = 0; | ||
if (defined(hole.holes)) { | ||
numGrandchildren = hole.holes.length; | ||
} | ||
|
||
for ( var j = 0; j < numGrandchildren; j++) { | ||
for (j = 0; j < numGrandchildren; j++) { | ||
queue.enqueue(hole.holes[j]); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,24 +84,64 @@ defineSuite([ | |
|
||
it('createGeometry returns undefined due to duplicate hierarchy positions', function() { | ||
var hierarchy = { | ||
positions : Cartesian3.fromDegreesArray([ | ||
1.0, 1.0, | ||
1.0, 1.0, | ||
1.0, 1.0 | ||
]), | ||
holes : [{ | ||
positions : Cartesian3.fromDegreesArray([ | ||
1.0, 1.0, | ||
1.0, 1.0, | ||
1.0, 1.0 | ||
]), | ||
holes : [{ | ||
positions : Cartesian3.fromDegreesArray([ | ||
0.0, 0.0, | ||
0.0, 0.0, | ||
0.0, 0.0 | ||
]) | ||
}] | ||
0.0, 0.0, | ||
0.0, 0.0, | ||
0.0, 0.0 | ||
]) | ||
}] | ||
}; | ||
|
||
var geometry = PolygonGeometry.createGeometry(new PolygonGeometry({ polygonHierarchy : hierarchy })); | ||
expect(geometry).toBeUndefined(); | ||
}); | ||
|
||
it('createGeometry returns undefined due to duplicate hierarchy positions with different heights', function() { | ||
var hierarchy = { | ||
positions : Cartesian3.fromDegreesArrayHeights([ | ||
1.0, 1.0, 10.0, | ||
1.0, 1.0, 20.0, | ||
1.0, 1.0, 30.0 | ||
]), | ||
holes : [{ | ||
positions : Cartesian3.fromDegreesArrayHeights([ | ||
0.0, 0.0, 10.0, | ||
0.0, 0.0, 20.0, | ||
0.0, 0.0, 30.0 | ||
]) | ||
}] | ||
}; | ||
|
||
var geometry = PolygonGeometry.createGeometry(new PolygonGeometry({ polygonHierarchy : hierarchy })); | ||
expect(geometry).toBeUndefined(); | ||
}); | ||
|
||
it('createGeometry returns geometry if duplicate hierarchy positions with different heights and perPositionHeight is true', function() { | ||
var hierarchy = { | ||
positions : Cartesian3.fromDegreesArrayHeights([ | ||
1.0, 1.0, 10.0, | ||
1.0, 1.0, 20.0, | ||
1.0, 1.0, 30.0 | ||
]), | ||
holes : [{ | ||
positions : Cartesian3.fromDegreesArrayHeights([ | ||
0.0, 0.0, 10.0, | ||
0.0, 0.0, 20.0, | ||
0.0, 0.0, 30.0 | ||
]) | ||
}] | ||
}; | ||
|
||
var geometry = PolygonGeometry.createGeometry(new PolygonGeometry({ polygonHierarchy : hierarchy, perPositionHeight: true })); | ||
expect(geometry).not.toBeUndefined(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}); | ||
|
||
it('computes positions', function() { | ||
var p = PolygonGeometry.createGeometry(PolygonGeometry.fromPositions({ | ||
vertexFormat : VertexFormat.POSITION_ONLY, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,46 @@ defineSuite([ | |
expect(geometry).toBeUndefined(); | ||
}); | ||
|
||
it('createGeometry returns undefined due to duplicate hierarchy positions with different heights', function() { | ||
var hierarchy = { | ||
positions : Cartesian3.fromDegreesArrayHeights([ | ||
1.0, 1.0, 10.0, | ||
1.0, 1.0, 20.0, | ||
1.0, 1.0, 30.0 | ||
]), | ||
holes : [{ | ||
positions : Cartesian3.fromDegreesArrayHeights([ | ||
0.0, 0.0, 10.0, | ||
0.0, 0.0, 20.0, | ||
0.0, 0.0, 30.0 | ||
]) | ||
}] | ||
}; | ||
|
||
var geometry = PolygonOutlineGeometry.createGeometry(new PolygonOutlineGeometry({ polygonHierarchy : hierarchy })); | ||
expect(geometry).toBeUndefined(); | ||
}); | ||
|
||
it('createGeometry returns geometry if duplicate hierarchy positions with different heights and perPositionHeight is true', function() { | ||
var hierarchy = { | ||
positions : Cartesian3.fromDegreesArrayHeights([ | ||
1.0, 1.0, 10.0, | ||
1.0, 1.0, 20.0, | ||
1.0, 1.0, 30.0 | ||
]), | ||
holes : [{ | ||
positions : Cartesian3.fromDegreesArrayHeights([ | ||
0.0, 0.0, 10.0, | ||
0.0, 0.0, 20.0, | ||
0.0, 0.0, 30.0 | ||
]) | ||
}] | ||
}; | ||
|
||
var geometry = PolygonOutlineGeometry.createGeometry(new PolygonOutlineGeometry({ polygonHierarchy : hierarchy, perPositionHeight: true })); | ||
expect(geometry).not.toBeUndefined(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}); | ||
|
||
it('computes positions', function() { | ||
var p = PolygonOutlineGeometry.createGeometry(PolygonOutlineGeometry.fromPositions({ | ||
positions : Cartesian3.fromDegreesArray([ | ||
|
@@ -254,24 +294,24 @@ defineSuite([ | |
granularity : CesiumMath.PI_OVER_THREE | ||
})); | ||
|
||
expect(p).toEqual(Cartesian3.fromDegreesArray([ | ||
expect(p).toEqualEpsilon(Cartesian3.fromDegreesArray([ | ||
-124.0, 35.0, | ||
-124.0, 40.0, | ||
-110.0, 40.0, | ||
-110.0, 35.0 | ||
])); | ||
expect(h1).toEqual(Cartesian3.fromDegreesArray([ | ||
]), CesiumMath.EPSILON9); | ||
expect(h1).toEqualEpsilon(Cartesian3.fromDegreesArray([ | ||
-122.0, 36.0, | ||
-112.0, 36.0, | ||
-112.0, 39.0, | ||
-122.0, 39.0 | ||
])); | ||
expect(h2).toEqual(Cartesian3.fromDegreesArray([ | ||
]), CesiumMath.EPSILON9); | ||
expect(h2).toEqualEpsilon(Cartesian3.fromDegreesArray([ | ||
-120.0, 36.5, | ||
-120.0, 38.5, | ||
-114.0, 38.5, | ||
-114.0, 36.5 | ||
])); | ||
]), CesiumMath.EPSILON9); | ||
}); | ||
|
||
it('computes correct bounding sphere at height 0', function() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this get set on a temp var before the loop?