Open pnorman opened 6 years ago
I prefer putting all the ordering logic into the ORDER BY.
I agree, that's by far the cleanest. We should rewrite the queries that do not follow that format.
I'm working on this, but I'm a bit baffled by the SQL query in turning-circle-casing.
There is a weak convention that when you have two types, the more important is > the other, e.g. primary roads > secondary roads. This is what z_order uses, where primary road z_order > a secondary road z_order.
So do we want:
CASE power
WHEN 'tower' THEN 2
WHEN 'pole' THEN 1
ELSE NULL
END DESC
rather than the current:
CASE power
WHEN 'tower' THEN 1
WHEN 'pole' THEN 2
ELSE NULL
END
(With implied "ASC" ascending order)?
Yes.
If it should be ascending or descending depends on the layer. Generally text layers need most important first and drawing layers need most important last.
It's common to use some kind of custom ordering, because alphanumeric sorting is not useful for most OSM data. Some examples are
turning-circle-fill
stations
various
aeroways
We manage to use
ORDER BY
,These all work, but it'd be nice to standardize so I know which way to write.
I am not a particular fan of value statements. Where we have case statements in column lists we don't use that column anywhere, so I'd rather not use those either. Instead, I prefer putting all the ordering logic into the
ORDER BY
.There is a weak convention that when you have two types, the more important is > the other, e.g. primary roads > secondary roads. This is what z_order uses, where primary road z_order > a secondary road z_order.
I haven't touched on
ASC
vsDESC
and the reason is which you want depends on if the layer is being used for something that paints over itself or collides. For the former, you want the most important last, for the latter, you want it first