Giter VIP home page Giter VIP logo

Comments (5)

veltman avatar veltman commented on June 1, 2024 1

Thanks for the detailed post! This is actually on my todo list - basically if you have a multishape with n shapes, your single shape currently needs at least n+2 vertices in order to get triangulated into enough pieces. So in your case, using the default maxSegmentLength for those circles looks like it gives you a nonagon, so any feature with 8 or more parts would fail.

This fix has been delayed a little because rather than add colinear points on the original shape, which can result in weird slivers, I think the right approach is to still triangulate normally first, but then to split those triangles in half if needed, and that's a bit more involved to implement. But hopefully I should have it in there in the next few days.

In the meantime, as you mention you could decrease maxSegmentLength, or you could limit the shapes to the eight largest polygons, or simplify the geometry until none of the features have that many.

from flubber.

kforeman avatar kforeman commented on June 1, 2024

My fallback for now is to return d3.interpolateString() instead if flubber.combine() fails.

If you'd like me to integrate that directly into flubber and submit a PR let me know. I just figured it's probably best to avoid silent errors and instead have users handle them explicitly.

from flubber.

kforeman avatar kforeman commented on June 1, 2024

Nice, I was thinking something along the same lines (recursively splitting up the triangles until there are enough pieces) but don't know my way around the code quite well enough yet to know the best place to implement.

from flubber.

veltman avatar veltman commented on June 1, 2024

I pushed v0.2.5 which should fix this error - I'll look into other splitting strategies later this week to see whether the results are any better.

from flubber.

veltman avatar veltman commented on June 1, 2024

Thought about this a bit more and I think the way to go is probably to split any triangle that's more than x% of the total area from the midpoint of its longest side to the opposite vertex before the merge step. That ought to result in fewer sliver triangles that span the whole width/height of the shape, and it would never result in more than a handful of extra ops.

from flubber.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.