Instances swap order with nested rules #235

Open
gravitystorm opened this Issue Jan 6, 2013 · 6 comments

Projects

None yet

4 participants

@gravitystorm
Collaborator

This is an isolation of the problem reported at gravitystorm/openstreetmap-carto#23

We want to define lines (instance 'a') and dashes (instance 'b'), and want the dashes to always be on top of the lines. To do this, we define 'a' first.

#roads[zoom >= 14] {
  a/line-width: 5;
  a/line-color: blue;
  b/line-width: 15;
  b/line-dasharray: 5,15;
  [zoom >= 15] {
    a/line-width: 8;
    b/line-width: 16;
  }
  [highway = 'primary'] {
    a/line-color: red;
  }
}

You get expected behaviour at zoom 14 (black dashes over all lines)

zoom14

and unexpectedly, at zoom 15 the red lines are over the top of the dashes.

zoom15

The order of the instances is based on the order that each instance is defined in the file, but it's hard to see why, for primary roads at z15, it thinks that b/ is declared higher up in the file than a/.

@springmeyer
Member

Subtle bug, thanks for the solid report. However you must mean 'instances' not attachments, right?

@gravitystorm
Collaborator

Gah! Yes, I meant instances :-) I've updated the report to save further confusion.

@tmcw
Member
tmcw commented Jan 7, 2013

Seems like the order is correct here: https://gist.github.com/4477412 since the nested rule with [type='highway'] makes a the last instance to appear in the style.

@gravitystorm
Collaborator

@tmcw - sorry, it's not clear whether you're saying there's a workaround (by rearranging things), or that carto is behaving as expected. Do you agree there's a bug?

@tmcw
Member
tmcw commented Jan 15, 2013

y, to be a little clearer about this potential workaround:

// zoom >= 15, and the last style is b
#roads[zoom >= 14] {
  a/line-width: 5;
  a/line-color: blue;
  b/line-width: 15;
  b/line-dasharray: 5,15;

  a/line-width: 8;
  b/line-width: 16;
}

// highway=primary, last style is a
#roads[zoom >= 14] {
  a/line-width: 5;
  a/line-color: blue;
  b/line-width: 15;
  b/line-dasharray: 5,15;

  a/line-color: red;
}
@springmeyer
Member

report of inverted styles also at http://support.mapbox.com/discussions/tilemill/6834-land-and-water-inverting-at-zoom-level-17, but not sure/doubtful it has to do with instances...

@nebulon42 nebulon42 added the bug label Mar 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment