Skip to content

Commit df17965

Browse files
authored
Merge pull request #6693 from likangning93/polylinesOnTerrainCheckDuplicates
check for adjacent duplicate positions in GroundPolylineGeometry
2 parents 6d55550 + 14440a9 commit df17965

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

Source/Core/GroundPolylineGeometry.js

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
define([
22
'./ApproximateTerrainHeights',
3+
'./arrayRemoveDuplicates',
34
'./BoundingSphere',
45
'./Cartesian3',
56
'./Cartographic',
@@ -24,6 +25,7 @@ define([
2425
'./WebMercatorProjection'
2526
], function(
2627
ApproximateTerrainHeights,
28+
arrayRemoveDuplicates,
2729
BoundingSphere,
2830
Cartesian3,
2931
Cartographic,
@@ -451,6 +453,10 @@ define([
451453
cartographics[i] = cartographic;
452454
}
453455

456+
// Remove duplicates
457+
cartographics = arrayRemoveDuplicates(cartographics, Cartographic.equalsEpsilon);
458+
cartographicsLength = cartographics.length;
459+
454460
/**** Build heap-side arrays for positions, interpolated cartographics, and normals from which to compute vertices ****/
455461
// We build a "wall" and then decompose it into separately connected component "volumes" because we need a lot
456462
// of information about the wall. Also, this simplifies interpolation.

Specs/Core/GroundPolylineGeometrySpec.js

+19
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,25 @@ defineSuite([
216216
expect(geometry.attributes.texcoordNormalization2D).not.toBeDefined();
217217
});
218218

219+
it('removes adjacent positions with the same latitude/longitude', function() {
220+
var startCartographic = Cartographic.fromDegrees(0.01, 0.0);
221+
var endCartographic = Cartographic.fromDegrees(0.02, 0.0);
222+
var groundPolylineGeometry = new GroundPolylineGeometry({
223+
positions : Cartesian3.fromRadiansArrayHeights([
224+
startCartographic.longitude, startCartographic.latitude, 0.0,
225+
endCartographic.longitude, endCartographic.latitude, 0.0,
226+
endCartographic.longitude, endCartographic.latitude, 0.0,
227+
endCartographic.longitude, endCartographic.latitude, 10.0
228+
]),
229+
granularity : 0.0
230+
});
231+
232+
var geometry = GroundPolylineGeometry.createGeometry(groundPolylineGeometry);
233+
234+
expect(geometry.indices.length).toEqual(36);
235+
expect(geometry.attributes.position.values.length).toEqual(24);
236+
});
237+
219238
it('miters turns', function() {
220239
var groundPolylineGeometry = new GroundPolylineGeometry({
221240
positions : Cartesian3.fromDegreesArray([

0 commit comments

Comments
 (0)