Skip to content
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

Explain concepts behind ordering #138

Open
pnorman opened this issue Aug 21, 2016 · 4 comments
Open

Explain concepts behind ordering #138

pnorman opened this issue Aug 21, 2016 · 4 comments

Comments

@pnorman
Copy link
Contributor

pnorman commented Aug 21, 2016

Most people with a web background will be used to the ordering model of layers then an order within the layers. Tangram's is substantially different. There is relatively little documentation on Tangram's ordering or how it differs.

The order mapping is documented as

Applies to all draw styles. Sets the drawing order of the draw style, to be used in case of depth collisions. Higher-ordered layers will be drawn over lower-ordered layers. Child layers override parent layers.

Depth collisions are undefined, as is depth.

Higher-ordered layers will be drawn over lower-ordered layers.

order is a property of draw groups which then belong to a layer or sublayer. Layers are part of the layers element which is a YAML mapping, so layers have no YAML order.

When rendering from MVT there are two additional orders: layer order within the tile and feature order within a layer. How do these come into play?

I would expect the overall order to be draw order, layer order, then feature order but I can find nothing documenting this.

@meetar
Copy link
Member

meetar commented Aug 22, 2016

Thanks for this feedback – I'll use this thread to track the changes I make to address the issue, starting with: a371101

@pnorman
Copy link
Contributor Author

pnorman commented Aug 23, 2016

With some testing with lines coming from the same MVT layer and the same tangram order I found out that the top-most object is the is one which comes first in the MVT ordering, the reverse of expectations.

E.g. normally in a roads layer you'd want "high value" roads to to the end in an ascending sort. This is reflected in the osm2pgsql z_order which puts motorways high so they will be at the end of a layer if that layer sorts by z_order. This is because conventional algorithms draw the first object in the layer first and later ones on top of it.

Tangram requires the reverse of this.

@pnorman
Copy link
Contributor Author

pnorman commented Aug 23, 2016

Another factor that comes into ordering is the name of the styles.

If I have

styles:
    z:
        base: lines
        dash: [2, 2]
        dash_background_color: blue
layers:
    roads:
        data: { source: mapzen }
        draw:
            lines:
                order: 2
                color: green
                width: 14
            z:
                order: 2
                color: black
                width: 6

I get a different result if I change the name of the style object to "a"
image with z and
image with a.

@nvkelso
Copy link
Member

nvkelso commented Aug 23, 2016

That’s correct, names sort A to Z within the same order (or default order
if not defined). I think this was a modification a couple versions ago in
Tangram to add some amount of determinism (and consistent determinism
between JS and ES).

On Tue, Aug 23, 2016 at 2:48 PM, Paul Norman notifications@github.com
wrote:

Another factor that comes into ordering is the name of the styles.

If I have

styles:
z:
base: lines
dash: [2, 2]
dash_background_color: bluelayers:
roads:
data: { source: mapzen }
draw:
lines:
order: 2
color: green
width: 14
z:
order: 2
color: black
width: 6

I get a different result if I change the name of the style object to "a"
[image: image]
https://cloud.githubusercontent.com/assets/1190866/17910982/4d2fc662-6940-11e6-95bf-ca5858dbd7a7.png
with z and
[image: image]
https://cloud.githubusercontent.com/assets/1190866/17910992/5f42a8f6-6940-11e6-899b-5f2d74d2bb34.png
with a.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#138 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA0EO9V2PFYL40rJy5rpGBvARvMrX85Uks5qi2qjgaJpZM4JpQhQ
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants