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

Add voronoi.topology. #1819

Closed
wants to merge 6 commits into from
Closed

Add voronoi.topology. #1819

wants to merge 6 commits into from

Conversation

mbostock
Copy link
Member

@mbostock mbostock commented Apr 2, 2014

No description provided.

Also, fix the case where the polygon surrounds the viewport.
@jasondavies
Copy link
Contributor

I’m guessing it’s unrelated to the topology, but I noticed a clipping bug the first time I viewed your example. Here’s a reproducible example:

voronoi clip bug

@mbostock
Copy link
Member Author

mbostock commented Apr 2, 2014

The bug appears to be in voronoi.topology. It looks like I’m not stitching together the clipped edges correctly. Here’s a version just using non-topological polygons:

screen shot 2014-04-02 at 8 23 14 am

@mbostock
Copy link
Member Author

mbostock commented Apr 2, 2014

Actually, it might even be in topojson.merge. Because this still appears to work correctly:

svg.append("path")
    .datum(topojson.feature(topology, {type: "GeometryCollection", geometries: topology.objects.voronoi.geometries.filter(function(d, i) { return i & 1; })}))
    .attr("class", "voronoi-cell")
    .attr("d", d3.geo.path().projection(null));

The closing coordinate of the polygon wasn’t exactly the starting coordinate,
and so topojson.merge was having problems stitching things back together.
@jasondavies
Copy link
Contributor

You beat me to it! :)

@mbostock
Copy link
Member Author

mbostock commented Apr 2, 2014

Fixed in b1284d4.

screen shot 2014-04-02 at 8 46 51 am

The topojson.merge algorithm requires exact matches between the starting and closing coordinate of each polygon ring (in order to stitch them together). Normally this happens with quantized integer coordinates so small precision problems don’t occur. Here we’re doing the merging in non-quantized coordinates so I made sure that the first & last coordinate are exactly the same.

@mbostock
Copy link
Member Author

mbostock commented Apr 2, 2014

You beat me to it! :)

5 points to Gryffindor!

@mbostock mbostock added this to the 3.5 milestone Apr 8, 2014
@mbostock
Copy link
Member Author

mbostock commented Apr 8, 2014

I’m unsure whether to add this as a new method, though it does seem nice to piggy-back off of TopoJSON’s representation of topologies. My main concern is whether the d3.geom.voronoi API is sufficient doing things with Voronoi diagrams, or if we need to expose the lower-level concepts of edges & half-edges.

@mbostock mbostock mentioned this pull request Apr 8, 2014
jasondavies and others added 2 commits April 10, 2014 14:55
This makes voronoi.topology more consistent with the non-topological version,
and has the nice side-effect that you ignore coincident points by default.

Fixes #1861.
@isaomatsunami
Copy link

I wish you expose half-edges so that we can write Marching Squares algorithm (my current concern) upon it.

@mbostock
Copy link
Member Author

I’d still love to ship this feature for 3.5, but I think the API needs further thought.

@mbostock mbostock mentioned this pull request Nov 14, 2014
@mbostock mbostock modified the milestones: 3.5, 3.6 Dec 6, 2014
@sbryfcz
Copy link

sbryfcz commented Jun 3, 2015

Is there any update on this? I'd love to be able to run this awesome functionality on a node backend. It seems that the old build that contained this functionality is not node compatible. I get lots of errors. Document not being defined and such. Any suggestions for how I could proceed? I love how D3 and topojson has become very rich with functionality for manipulating topology. Keep up the great work!

@mbostock
Copy link
Member Author

I’m thinking about the new API over in the d3-voronoi module; see d3/d3-voronoi#1 and d3/d3-voronoi#2.

@IftachSadeh
Copy link

Hey Mike,

Thanks for the awesome work on this project!
The voronoi.topology() functionality is great. Is there any way for one to use it with the current master version of d3? (I see it's not yet part of d3-voronoi either)

Thanks!

@mbostock mbostock modified the milestones: 3.6, 4.0 Oct 22, 2015
@mbostock
Copy link
Member Author

Although I opted not to build this functionality into d3-voronoi directly, the latest release 0.3 of d3-voronoi makes the underlying Voronoi diagram available, so it’s now possible to do this in “user land” without touching the d3-voronoi implementation. For example:

cd52a201d7694eb9d890

If there’s demand, I’ll consider adding this to d3-voronoi, but I think it makes sense as an optional extension to d3-voronoi at the moment.

@mbostock mbostock closed this Jan 16, 2016
@jasondavies jasondavies deleted the voronoi-topology branch September 13, 2017 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants