Skip to content

Commit

Permalink
delete duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
hpinkos committed Dec 9, 2015
1 parent 5128fac commit 8762420
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 30 deletions.
4 changes: 3 additions & 1 deletion Source/Core/PolylineVolumeGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ define([
'./IndexDatatype',
'./Math',
'./PolygonPipeline',
'./PolylinePipeline',
'./PolylineVolumeGeometryLibrary',
'./PrimitiveType',
'./VertexFormat',
Expand All @@ -39,6 +40,7 @@ define([
IndexDatatype,
CesiumMath,
PolygonPipeline,
PolylinePipeline,
PolylineVolumeGeometryLibrary,
PrimitiveType,
VertexFormat,
Expand Down Expand Up @@ -374,7 +376,7 @@ define([
*/
PolylineVolumeGeometry.createGeometry = function(polylineVolumeGeometry) {
var positions = polylineVolumeGeometry._positions;
var cleanPositions = PolylineVolumeGeometryLibrary.removeDuplicatesFromPositions(positions, polylineVolumeGeometry._ellipsoid);
var cleanPositions = PolylinePipeline.removeDuplicates(positions);
var shape2D = polylineVolumeGeometry._shape;
shape2D = PolylineVolumeGeometryLibrary.removeDuplicatesFromShape(shape2D);

Expand Down
28 changes: 0 additions & 28 deletions Source/Core/PolylineVolumeGeometryLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,34 +262,6 @@ define([
return ((prev.x * next.y) - (prev.y * next.x)) >= 0.0;
};

function latLonEquals(c0, c1) {
return ((CesiumMath.equalsEpsilon(c0.latitude, c1.latitude, CesiumMath.EPSILON10)) && (CesiumMath.equalsEpsilon(c0.longitude, c1.longitude, CesiumMath.EPSILON10)));
}
var carto0 = new Cartographic();
var carto1 = new Cartographic();
PolylineVolumeGeometryLibrary.removeDuplicatesFromPositions = function(positions, ellipsoid) {
var length = positions.length;
if (length < 2) {
return positions.slice(0);
}

var cleanedPositions = [];
cleanedPositions.push(positions[0]);

for (var i = 1; i < length; ++i) {
var v0 = positions[i - 1];
var v1 = positions[i];
var c0 = ellipsoid.cartesianToCartographic(v0, carto0);
var c1 = ellipsoid.cartesianToCartographic(v1, carto1);

if (!latLonEquals(c0, c1)) {
cleanedPositions.push(v1); // Shallow copy!
}
}

return cleanedPositions;
};

var scratchForwardProjection = new Cartesian3();
var scratchBackwardProjection = new Cartesian3();

Expand Down
4 changes: 3 additions & 1 deletion Source/Core/PolylineVolumeOutlineGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ define([
'./IndexDatatype',
'./Math',
'./PolygonPipeline',
'./PolylinePipeline',
'./PolylineVolumeGeometryLibrary',
'./PrimitiveType',
'./WindingOrder'
Expand All @@ -36,6 +37,7 @@ define([
IndexDatatype,
CesiumMath,
PolygonPipeline,
PolylinePipeline,
PolylineVolumeGeometryLibrary,
PrimitiveType,
WindingOrder) {
Expand Down Expand Up @@ -280,7 +282,7 @@ define([
*/
PolylineVolumeOutlineGeometry.createGeometry = function(polylineVolumeOutlineGeometry) {
var positions = polylineVolumeOutlineGeometry._positions;
var cleanPositions = PolylineVolumeGeometryLibrary.removeDuplicatesFromPositions(positions, polylineVolumeOutlineGeometry._ellipsoid);
var cleanPositions = PolylinePipeline.removeDuplicates(positions);
var shape2D = polylineVolumeOutlineGeometry._shape;
shape2D = PolylineVolumeGeometryLibrary.removeDuplicatesFromShape(shape2D);

Expand Down

0 comments on commit 8762420

Please sign in to comment.