-
Notifications
You must be signed in to change notification settings - Fork 819
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
[WIP] Switch to ST_PointOnSurface #3228
[WIP] Switch to ST_PointOnSurface #3228
Conversation
Big general questions from me:
|
Personally I have no idea unfortunately. |
If there's a big performance penalty that gets worse as database size goes up, it's probably from a missing
We'd have to write the function. |
I'm inclined towards doing this layer by layer to start, starting with layers like bridges where there isn't a point equivalent. |
I did some more testing.
No, interestingly enough it's the exact opposite: the I used a set of tiles which takes 11s to render in master, and 17s in this PR, both on z17.
@pnorman Is there anything we can do with the condition to speed this up? Does Postgres guarantee that conjuncts are evaluated left to right, i.e. is Edit: it seems replacing |
Then you're missing the addition of a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flagging as request changes as it's got performance issues, some missed SQL, and the SQL will need reformatting.
@@ -167,7 +161,6 @@ | |||
#springs { | |||
[natural = 'spring'][zoom >= 14] { | |||
marker-file: url('symbols/spring.svg'); | |||
marker-placement: interior; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There don't seem to be the required changes to the springs SQL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Resolves gravitystorm#1644. This is a necessary step towards vector rendering (see gravitystorm#1644). As this changes the label placement algorithm for polygons, this causes differences in label placement. (SQL deliberately not indented to increase readability of the diff.)
02e79b3
to
03ce8bb
Compare
60de793
to
439a125
Compare
In fact the subqueries I created were not necessary, so I removed them. This should also fix the formatting issue. |
The performance issues remain in my latest version. The code should now be simpler and easier to review, @pnorman could you check if this is the right approach?
I'm fine with either approach, however I'm afraid we might miss performance issues if we do this layer by layer. The performance issues created by each of the layer changes might be insignificant, but significant when considered together. Also, some layers might have a worse performance hit then others, so when converting layer by layer we can't be sure we won't run into performance problems when converting the last layer. |
As I remember - calling ST_Centroid for simple polygons ( see more:
|
We can't say which ones are "simple", so we have to treat them all the same. ST_Centroid is not suitable for this job anyway, because it does not guarantee to return the point on the surface (maybe that's why it's faster): |
As I understand - checking convexity of polygons gives better result . CASE WHEN ST_NPoints(ST_ConvexHull(geometry))=ST_NPoints(geometry)
THEN ST_Centroid(geometry)
ELSE ST_PointOnSurface(geometry) |
I'm not a programmer and I don't know just by looking at the code, but I was involved in investigating #1465 and testing improved |
Too much SQL, and if there are ST_PointOnSurface performance improvements we should get them in PostGIS. |
I still find it difficult to review the changes to all the unrelated layout, and we need to establish conventions for how we're going to do the SQL. This is why I did #3233. In this pr, the springs code is incorrect since it only applies the !bbox! condition to the rows coming from the polygons table, not the points table. |
Whoops. How does Mapnik decide then whether to wrap the code in a superquery with Now I think of it, this might well be the reason for the performance issues I encountered (it would certainly explain why adding |
There was one case of unrelated layout, and that's fixed now. Some brackets needed to be added in unrelated code due to OR/AND precedence order.
Yes, I agree we need that.
Fixed that now. Unfortunately, after the fix performance is still as bad as it used to be. |
Mapnik always wraps the query fragment we supply, but it only adds the |
Resolves gravitystorm#1644. This is a necessary step towards vector rendering (see gravitystorm#1644). This is a second trial of gravitystorm#3228, based on the word by @pnorman in gravitystorm#3233. This is a first step, once we have this than we can probably merge the point and poly layers (for example amenity-points and amenity-points-poly).
Superseded by #3636 |
Resolves #1644.
This is a necessary step towards vector rendering (see #1644).
As this changes the label placement algorithm for polygons, this causes differences in label placement.
It seems this comes with a performance penalty. This should be investigated further.
Before:
After:
(SQL deliberately not indented to increase readability of the diff.)