Skip to content

Commit 5813aee

Browse files
committed
revert tessellate changes
1 parent a331a9e commit 5813aee

File tree

3 files changed

+3
-55
lines changed

3 files changed

+3
-55
lines changed

packages/turf-tesselate/index.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,15 @@ function tesselate(
5050

5151
function processPolygon(coordinates: Position[][]) {
5252
const data = flattenCoords(coordinates);
53-
const dim: number = coordinates[0][0].length;
53+
const dim = 2;
5454
const result = earcut(data.vertices, data.holes, dim);
5555

5656
const features: Feature<Polygon>[] = [];
5757
const vertices: Position[] = [];
5858

5959
result.forEach(function (vert: any, i: number) {
6060
const index = result[i];
61-
// if elevation component is included in the original coordinates, include it in the output coordinates
62-
if (dim > 2) {
63-
vertices.push([
64-
data.vertices[index * dim],
65-
data.vertices[index * dim + 1],
66-
data.vertices[index * dim + 2],
67-
]);
68-
} else {
69-
vertices.push([
70-
data.vertices[index * dim],
71-
data.vertices[index * dim + 1],
72-
]);
73-
}
61+
vertices.push([data.vertices[index * dim], data.vertices[index * dim + 1]]);
7462
});
7563

7664
for (var i = 0; i < vertices.length; i += 3) {

packages/turf-tesselate/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
"Abel Vázquez <@AbelVM>",
88
"Morgan Herlocker <@morganherlocker>",
99
"Tom MacWright <@tmcw>",
10-
"Vladimir Agafonkin <@mourner>",
11-
"Pavel Rozvora <@prozvora>"
10+
"Vladimir Agafonkin <@mourner>"
1211
],
1312
"license": "MIT",
1413
"bugs": {

packages/turf-tesselate/test.ts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3499,44 +3499,5 @@ test("tesselate", function (t) {
34993499
tesselate(featurecollection([]));
35003500
}, /input must be a Polygon or MultiPolygon/);
35013501

3502-
var simplePolygonWithElevation = {
3503-
type: "Feature",
3504-
id: "CoordsWithElevation",
3505-
properties: { name: "CoordsWithElevation" },
3506-
geometry: {
3507-
type: "Polygon",
3508-
coordinates: [
3509-
[
3510-
[-123.233256, 42.006186, 130],
3511-
[-114.634459, 35.00118, 130],
3512-
[-118.183517, 33.763391, 130],
3513-
[-124.213628, 42.000709, 130],
3514-
[-123.233256, 42.006186, 130],
3515-
],
3516-
],
3517-
},
3518-
};
3519-
3520-
var simpleTrianglesWithElevation = tesselate(simplePolygonWithElevation);
3521-
t.equal(
3522-
simpleTrianglesWithElevation.type,
3523-
"FeatureCollection",
3524-
"Polygon returns a FeatureCollection"
3525-
);
3526-
t.equal(
3527-
simpleTrianglesWithElevation.features[0].geometry.type,
3528-
"Polygon",
3529-
"contains at least 1 triangle"
3530-
);
3531-
t.equal(
3532-
simpleTrianglesWithElevation.features[0].geometry.coordinates[0].length,
3533-
4,
3534-
"triangle is valid"
3535-
);
3536-
t.equal(
3537-
simpleTrianglesWithElevation.features[0].geometry.coordinates[0][0][2],
3538-
130,
3539-
"triangle coordinates contain elevation"
3540-
);
35413502
t.end();
35423503
});

0 commit comments

Comments
 (0)