Skip to content

The program cannot continue to call turf.union after using turf.buffer on geojson #2701

@showarp

Description

@showarp

Please provide the following when reporting an issue:

  • The version of Turf you are using, and any other relevant versions.

v7.0.0

Because the original data set is too large (40+MB), it can't be uploaded. Only some fragments can be intercepted here.

This is a json file that contains two jsons in geojson format{Groove:{some geojsondata},TreePit:{some geojsondata}}

  • Snippet of source code or for complex examples use jsfiddle.
        var geo_buffer_data = [...groove_data,...treepit_data]
        geo_buffer_data = geo_buffer_data.map((x)=>{
            let result = turf.buffer(x, 0.000621*2, { units: "miles" });
            result = turf.truncate(result,{precision:5,mutate:true})
            return result
        })
        geo_buffer_data = turf.featureCollection(geo_buffer_data)
        try {
            geo_buffer_data = turf.union(geo_buffer_data);
            geo_buffer_data.geometry.coordinates = geo_buffer_data.geometry.coordinates.map((x,i)=>{
                return [x[0]]
            })
            geo_buffer_data = turf.simplify(geo_buffer_data, { tolerance: 0.00001, highQuality: false });
            var BufferLayer = L.geoJSON(geo_buffer_data,{
                style: {color: "#ffff00"}
            })
        } catch (error) {
            console.log(error)
            var BufferLayer = undefined
        }
  • Verify this issue hasn't already been reported, or resolved in the latest alpha pre-release.

I used turf.truncate to truncate five decimal places based on the proposal given in #2258, but this error was still displayed. But if the decimal point is truncated to the last 4 digits, it can work smoothly, but for me, the precision of the decimal point cannot accurately express my geojson data. I want to know what caused this error.

image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions