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
centerline function causes GEOS errors #7058
Comments
I can understand doing that. It would be nice to identify the features that
cause the issues to understand what's going on and maybe avoid the error in
the first place.
…--Steve
On Thu, Mar 28, 2024 at 5:28 PM Seth G ***@***.***> wrote:
When using the centerline function for labels GEOS can return an error,
which then stops all rendering. For example:
LAYER
NAME "lake-labels"
STATUS OFF
TYPE LINE
CONNECTIONTYPE OGR
CONNECTION "/vsicurl/https://github.com/MapServer/MapServer-demo/raw/main/data/lakespy2.shp"
GEOMTRANSFORM (centerline([shape]))
# GEOMTRANSFORM (centerline(densify([shape], 0.1)))
CLASS
LABEL
COLOR 255 255 255
TEXT (initcap("[LAKE_NAME]"))
TYPE truetype
SIZE 12
PARTIALS false
POSITION cc
FORCE TRUE
ANGLE FOLLOW
END #label
END
Without using densify when zoomed out MapServer returns the following:
<ServiceExceptionReport xmlns="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.3.0" xsi:schemaLocation="http://www.opengis.net/ogc http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd">
<ServiceException> msDrawMap(): Image handling error. Failed to draw layer named 'lake-labels'. msGeomTransformShape(): Expression parser error. Failed to process shape expression: centerline([shape]) yyparse(): Expression parser error. Executing centerline failed. msGEOSCenterline(): GEOS library error. Centerline generation failed, try densifying the shapes. </ServiceException>
</ServiceExceptionReport>
Probably best to log this as an error, but to proceed with rendering the
rest of the image as best as possible?
Note - adding densify causes rendering to timeout when using a dataset
with vsicurl.
—
Reply to this email directly, view it on GitHub
<#7058>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMGN65MZIJLUZNN5LIM4B3Y2SDQLAVCNFSM6AAAAABFNSOAZWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGIYTIMRWHE4TINQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
@sdlime I found the features causing the issue. I see you already have a check for error-ing on features like this at MapServer/msautotest/misc/centerline.map Line 155 in 5a943d5
Below is a Mapfile to recreate the issue - just comment out This is the Itasca lakes demo dataset. The issue with using Possible options?
Without the above MapServer can happily return images until one of these features is in the extent and then errors start appearing.
The images below show the two features that cause the crash. 1 line - 5 points. 1 line - 6 points.
|
How do those features labels look after applying your auto densify patch? I'll try track down where the infinite loop exists. Seems to me that at least part of the fix is to avoid that regardless. |
Hmmm... I'm starting to think we might not want to do anything with this - yet. I'm trying understand where things break down to see if there is something automatic that can be done with these simple, elongated shapes. That said, I think maybe we should just live with the error and try and provide guidance on how to avoid it - so it's not a blocker for 8.2. For example, in this particular case the layer definition is really inefficient in that we're not restricting labeling to features with non-null lake names. Given that the centerline function is computationally intensive, we should emphasize the need to isolate relevant features - and likely avoid the error as result. Yes, one could still run into issues so there is work to be done here. |
@sdlime - that sounds good to me - I just wanted to log the issue as I ran into it with the Itasca demo datasets. Agree it shouldn't be a blocker for 8.2, it has been an issue since the 8.0 release. |
I don't think we're going to want to pursue the related pull request. My guess is that an alternative approach for simple, but weird features like these might be needed. I had a bunch of simple shape test cases (triangles, squares, etc...) on my old dev box that I need to retrieve. Ideally I'd love to identify a way to isolate polygons that are candidates for curved labels and then use the horizontal labels for others - so basically two layers. Some sort of quick assessment of complexity or sinuosity. The ratio of polygon area to bounding box area might be one option. I think it's fine to keep this ticket around though... |
A simple square generates the error too:
Densifying fixes things. I think if one has a layer with a mix of simple and complex geometries is where things will get wonky. I may be that simply getting to a minimal number of vertices is enough - I need to figure out where that limit is. |
Looks like simple, convex shapes present the issue. A simple concave shape - e.g. start with a square and bump one side in - works great. There's probably a separate algorithm to consider under some conditions - convex + limited number of points. |
When using the
centerline
function for labels GEOS can return an error, which then stops all rendering. For example:Without using
densify
when zoomed out MapServer returns the following:Probably best to log this as an error, but to proceed with rendering the rest of the image as best as possible?
Note - adding
densify
causes rendering to timeout when using a dataset withvsicurl
.The text was updated successfully, but these errors were encountered: