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
SplitPolygonExample.cs does split, but only returns one part of the result #114
Comments
can be related to #87? other changes are at least one year old... |
I haven't tried the sample before, so I cannot tell when (or if?) it actually worked. |
This example does not work with current JTS either. I'm sure it did work at the time I added it. |
So we can close this issue. thanks @chau-intl for this report. |
I think it broke with cd319e6 or one of the subsequent. Maybe @dr-jts has a clue on how to handle that. |
Any Idea how to fix this problem?I tried to use difference but it returns an empty polygon |
@jholt456 Could you post a unit test for the sample pictures? |
Sure thing @FObermaier. The images were captured from an application I am working on, but this test replicates the issue. It returns 64 polys on v1.13.3.2, and 32 on v1.14. Please let me know if I can send anything else over. [TestMethod]
public void Should_Find_Correct_Number_Of_Polygons_From_Lines()
{
var paths = new List<IGeometry>();
for (int x = 1; x < 10; x++)
{
var startPoint = new Coordinate(x * 40, 30);
var endPoint = new Coordinate(x * 40, 440);
paths.Add(new LineString(new[] { startPoint, endPoint }));
}
for (int y = 1; y < 10; y++)
{
var startPoint = new Coordinate(30, y * 40);
var endPoint = new Coordinate(450, y * 40);
paths.Add(new LineString(new[] { startPoint, endPoint }));
}
var noder = new NetTopologySuite.Noding.Snapround.GeometryNoder(new PrecisionModel(1.0d));
var geomFactory = GeometryFactory.Default;
var nodedLines = noder.Node(paths);
var nodedDedupedLinework = geomFactory.BuildGeometry(nodedLines.ToArray()).Union();
Polygonizer polygonizer = new Polygonizer();
polygonizer.Add(nodedDedupedLinework);
var polygons = polygonizer.GetPolygons();
Assert.AreEqual(64, polygons.Count);
} |
Your issue can be resolved using the |
In fact it turned out that the split polygon example will continue to work when using the constructor mentioned above. Sorry! |
Changing default Polygonizer constructor to initialize ExtractOnlyPolygonal with false.
@jholt456 a not related question, Can you say what library are you using to draw shapes?thanks |
@am2222 Not using a library in the images I posted due to interactivity requirements for this project. I use NTS for the heavy lifting behind the scenes, but the view just binds an ItemsControl to a Shapes collection on the view model. Each shape type has a DataTemplate to specify how it will be rendered. In the case of a Polygon, the data template renders a standard WPF polygon, all points from the shape (used as drag handles), and a label. In the past I have used the WpfPathGeometryWriter provided by NTS, and it worked great for quickly displaying shapes. Hope that helps, let me know if I can give you anymore info. |
Looking a the samples I have found the
SplitPolygonExample.cs
which simple splits a polygon using a line.At the moment it seems like something has changed in
NetTopologySuite.Operation.Polygonize
, since the split using the line cuts the polygon but only return the left hand part. I would expect both parts to be returned.@FObermaier do you know something about this?
The text was updated successfully, but these errors were encountered: