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 program cannot continue to call turf.union after using turf.buffer on geojson #2701

Open
4 tasks
showarp opened this issue Aug 15, 2024 · 2 comments
Open
4 tasks

Comments

@showarp
Copy link

showarp commented Aug 15, 2024

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

@smallsaucepan
Copy link
Member

Thanks for reporting @showarp. Can you try zipping the geojson files first to see if you can attach them? They usually compress quite well. Alternatively are you able to upload to dropbox (or similar) and provide a link?

The issue is possibly with a third party library, so having the data causing the problem will be a big help.

@showarp
Copy link
Author

showarp commented Aug 16, 2024

result.zip Here's the cleanest reproduction of the bug, go run leaflet.html to see it, and I found that if I change the code on line 58 to let result = turf.buffer(x, 0.000621*1.5, { units: “miles” }); the program is working fine, but I don't want this temporary solution. Thank you for your reply!

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

No branches or pull requests

2 participants