Closed evanl5 closed 7 years ago
This is the expected behavior but there is an unstated assumption that the topology used to derive the mesh is valid, part of which is a requirement that the geometry used to derive the mesh is not self-overlapping. So in your example, you’ll need to decide whether to derive the mesh from Kenya or Kenya’s states, but you can’t include both in the source geometry; I recommend grouping your geometry by administrative level, as is done for example in us-atlas, which provides separate layers for the nation, states and counties.
My geometry actually is grouped by administrative level. I have four administrative levels and three desired mesh layers (one for disputed borders, one for non-disputed borders, and one for selected borders), creating them as separate layers would require 12 layers. In an effort to simplify the process of creating the mesh layers I decided to pass all visible administrative levels to the mesh function at once as nested GeometryCollections. This is how I discovered the problem.
Is there any chance you would consider a feature request to add this functionality?
If there are more than two geometries in a collection that share the same arcs, the mesh filter function will ignore some neighboring geometries.
For instance, given the following topology, the filter function will never be passed geometry with id 2.
For a more practical use case, in the screenshot below the bold line is created with a mesh filter intend to outline Uganda. However, since Uganda shares borders with both Kenya and Kenya’s states, the filter fails and the border is partially missing.
The issue appears to be in the extractArcs function (https://github.com/topojson/topojson-client/blob/master/src/mesh.js#L50) where only the first and last neighbors are sent to the filter function.
Here are some possible solutions that I could think of:
pass all geometries as a third argument to the filter function.
only pass all geometries to the filter function.
pass each geometry as an individual argument to the filter function
allow the way the filter function is applied to be changed as an optional argument to the mesh function