Skip to content

Commit

Permalink
Merge pull request #8176 from shehzan10/fix-8042
Browse files Browse the repository at this point in the history
Fix GeoJSON Polygon Overlapping problem
  • Loading branch information
Hannah authored Sep 18, 2019
2 parents 501a83b + ef61266 commit b97488a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Change Log
* Fixed relative-to-center check, `depthFailAppearance` resource freeing for `Primitive` [#8044](https://github.com/AnalyticalGraphicsInc/cesium/pull/8044)
* Reduces size of approximateTerrainHeights.json by rounding the numbers [#7959](https://github.com/AnalyticalGraphicsInc/cesium/pull/7959)
* Fixed undefined `quadDetails` error from zooming into the map really close. [#8011](https://github.com/AnalyticalGraphicsInc/cesium/pull/8011)
* Fixed triangulation bug in polygons using `ArcType.RHUMB`. [#8042](https://github.com/AnalyticalGraphicsInc/cesium/issues/8042)

### 1.61 - 2019-09-03

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
* [Brandon Barker](https://github.com/ProjectBarks)
* [Peter Gagliardi](https://github.com/ptrgags)
* [Ian Lilley](https://github.com/IanLilleyT)
* [Shehzan Mohammed](https://github.com/shehzan10)
* [Northrop Grumman](http://www.northropgrumman.com)
* [Joseph Stein](https://github.com/nahgrin)

Expand Down
32 changes: 31 additions & 1 deletion Source/Core/PolygonGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,29 @@ define([
return computeRectangle(polygonHierarchy.positions, ellipsoid, arcType, granularity, result);
};

var cartographicScratchArray = [];
function cartesian3ToCartographicAsCartesian2(ellipsoid) {
return function (positions) {
var numberOfPoints = positions.length;

var i;
if (cartographicScratchArray.length < numberOfPoints) {
for (i = cartographicScratchArray.length; i < numberOfPoints; i++) {
cartographicScratchArray.push(new Cartographic());
}
}

var cartographicPositions = ellipsoid.cartesianArrayToCartographicArray(positions, cartographicScratchArray);
var result = [];
for (i = 0; i < numberOfPoints; i++) {
var cartographicPosition = cartographicPositions[i];
result.push(new Cartesian2(cartographicPosition.longitude, cartographicPosition.latitude));
}

return result;
};
}

/**
* Computes the geometric representation of a polygon, including its vertices, indices, and a bounding sphere.
*
Expand All @@ -934,7 +957,14 @@ define([

var tangentPlane = EllipsoidTangentPlane.fromPoints(outerPositions, ellipsoid);

var results = PolygonGeometryLibrary.polygonsFromHierarchy(polygonHierarchy, tangentPlane.projectPointsOntoPlane.bind(tangentPlane), !perPositionHeight, ellipsoid);
var results;
if (arcType === ArcType.RHUMB) {
var projectionFunction = cartesian3ToCartographicAsCartesian2(ellipsoid);
results = PolygonGeometryLibrary.polygonsFromHierarchy(polygonHierarchy, projectionFunction, !perPositionHeight, ellipsoid);
} else {
results = PolygonGeometryLibrary.polygonsFromHierarchy(polygonHierarchy, tangentPlane.projectPointsOntoPlane.bind(tangentPlane), !perPositionHeight, ellipsoid);
}

var hierarchy = results.hierarchy;
var polygons = results.polygons;

Expand Down

0 comments on commit b97488a

Please sign in to comment.