-
Notifications
You must be signed in to change notification settings - Fork 823
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
Convert springs to use ST_PointOnSurface and reformat SQL #3233
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,14 +285,22 @@ Layer: | |
<<: *osm2pgsql | ||
table: |- | ||
(SELECT | ||
way, "natural" | ||
FROM planet_osm_polygon | ||
WHERE "natural" IN ('spring') | ||
UNION ALL | ||
SELECT | ||
way, "natural" | ||
FROM planet_osm_point | ||
WHERE "natural" IN ('spring') | ||
way, | ||
"natural" | ||
FROM | ||
(SELECT | ||
ST_PointOnSurface(way) AS way, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: is psql smart enough to only do the ST_PointOnSurface calculation for objects satisfying There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I see now it avoids the duplication of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case the conditions on the tag columns are simple enough a subselect isn't necessary, but on longer queries, these can be over a dozen lines. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, clear. And what about the question above? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Postgres can do the query either way, the results are the same. It will pick whichever is cheapest, which will normally be using the index, filtering by geometry, then calculating st_pointonsurface. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So if I understand you correctly, in this query it will also calculate ST_PointOnSurface for polygons that are not natural=spring, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no guarantee one way or the other. It's unlikely to, but with a small database and the right indexes it might. |
||
"natural" | ||
FROM planet_osm_polygon | ||
WHERE way && !bbox! | ||
UNION ALL | ||
SELECT | ||
way, | ||
"natural" | ||
FROM planet_osm_point | ||
WHERE way && !bbox! | ||
) _ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like unwanted space + underscore. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would you suggest as an alternative for what to call the inner subselect? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know, however I don't like such shortcuts in the big SQL section of a public project. Typical BTW: there are more undocumented conventions and sections that I don't understand, it might make sense to add more comments one day. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
WHERE "natural" IN ('spring') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we not add another There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could, but the PR is no different than current behavior. I suppose the difference is that filtering on contains is now cheap to do in-db |
||
) AS springs | ||
properties: | ||
minzoom: 14 | ||
|
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.
Does wrapping this in a superquery accomplish anything at all? It seems to me that leaving lines 287-290 and 302 out would yield exactly the same result?
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.
No, since then the query would return all polygons regardless of their
natural
column.