-
Notifications
You must be signed in to change notification settings - Fork 372
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
LargestEmptyCircle: is the boundary considered as obstacle as well? #855
Comments
Yes, it will indeed by dependent on your actual use case whether that's something desired or not, and so you can quite easily add the envelope or convex hull to the obstacles manually, if desired, with the current interface.
Yes, I was exploring LEC today (to expose it in shapely, which also triggered me to open this issue), and encountered similar questions, see shapely/shapely#1307 (comment). The first issue was not actually that the LEC might be "outside" of the polygon, but actually that it is within the interior of it, since LEC only considers the polygon's linework. I was trying to achieve the possible desired result ("inside" the polygon but not in its interior) by creating a custom And in a similar way, it was somewhat possible to create the custom It would be nice to make this a bit easier to achieve as a user. Potential ideas (without knowing the details about how / constraints of the algorithm being used here):
|
Right, that's an issue as well. Polygonal obstacles are not currently supported. It would be nice to have that capability. The algorithm is quite general, so it should be fairly easy to add this by testing distance to polygonal obstacles as well as linear and point ones. The computed LEC will be disjoint from all obstacle geometries, and the LEC centre will lie inside the boundary. I suppose a further option would be to require the entire LEC to lie within the boundary. Have to think about this to see if that's feasible. (I suspect it is, since this is similar to the logic for the Maximum Inscribed Circle). EDIT: this can be done by including the linework of the boundary geometry as an obstacle. I don't think there's a need to put any requirements on how the boundary relates to the obstacles. Although obviously if the obstacles cover the boundary no LEC exists. (I'm not sure why the constraint that the boundary cover the obstacles in in place). |
I wonder if it's still feasible to have a single function for this (as in PostGIS)? If only the polygonal boundary is provided, the result is the MIC. If obstacles are provided then this determines the LEC within the boundary (if any). |
I think so- but will have to test / analyze to confirm that this will work. |
In particular, there may be a failure mode if no LEC can be determined (e.g. when the obstacles cover the boundary completely). |
I'm working on adding the ability to specify an LEC boundary polygon to JTS. It turns out that the GEOS restriction to have the boundary cover the obstacles is easily removed by a simple fix in the code. I'll port this to GEOS soon. |
The final enhancement to fully handle polygonal obstacles has been added to JTS: locationtech/jts#988 This will be ported to GEOS soon. |
It's ported now. |
@jorisvandenbossche Here's the enhanced (Note that
![]() |
I am running into a case where LargestEmptyCircle doesn't return the radius line of a circle that would be fully inside the envelope or convex hull of the input linestring.
Using geosop:
(the tolerance doesn't matter that much. Using a value of 1 gives a not super accurate radius in the second case, but what matters is the location of the center which is too much towards the bottom which causes the circle to be outside of the convex hull of the input, and this also happens for smaller tolerance values)
Visualizing the above:
vs
My expectation was that the second result would not be correct, although re-reading the documentation of LargestEmptyCircle now, I have to admit isn't explicit about this:
geos/capi/geos_c.h.in
Lines 3897 to 3902 in 386461d
Also in the second output above, the center is within the boundary (check). And the interior of the formed circle does not intersect with any of the obstacles (check). But I would have expected that the boundary is also treated as an additional "obstacle" (which, to be honest, is not said as such in the documentation). But so I suppose that is not the case?
I can manually add the envelope of the linestring to the input obstacles (creating a MultiLineString of the original input with the boundary of its envelope), and then I get the result I expected:
The text was updated successfully, but these errors were encountered: