Skip to content
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

The @turf/tesselate function fails to properly process GeoJSON Polygon data that includes elevation. #2672

Open
Seungup opened this issue Aug 6, 2024 · 0 comments

Comments

@Seungup
Copy link

Seungup commented Aug 6, 2024

Description

The @turf/tesselate function fails to properly process GeoJSON Polygon data that includes elevation.

Reproduction

The issue can be reproduced with the following GeoJSON file:

{
  "type": "Feature",
  "geometry": {
    "type": "Polygon",
    "coordinates": [
      [
        [130.2138542686084, 36.85831846193179, 0],
        [121.54982788145819, 34.421266048716696, 0],
        [131.58908870149648, 33.113275358661966, 0],
        [130.2138542686084, 36.85831846193179, 0]
      ]
    ]
  },
  "properties": {}
}

Code Location

The problem occurs in the following code location:

const data = flattenCoords(coordinates);
const dim = 2;
const result = earcut(data.vertices, data.holes, dim);
const features: Feature<Polygon>[] = [];
const vertices: Position[] = [];
result.forEach(function (vert: any, i: number) {
const index = result[i];
vertices.push([data.vertices[index * dim], data.vertices[index * dim + 1]]);
});

Expected Behavior

The tesselate function should handle GeoJSON Polygons with elevation data correctly, as specified in RFC 7946 Section 3.1.1. According to the RFC, a position is an array of numbers with the first two elements being longitude and latitude, and an optional third element for altitude or elevation.

Actual Behavior

The tesselate function fails to process the provided GeoJSON Polygon, resulting in an error.

Additional Information

Please provide any additional information here that may be useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant