Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Question about class and nested selectors #304

Closed
yohanboniface opened this issue Sep 21, 2013 · 2 comments
Closed

Question about class and nested selectors #304

yohanboniface opened this issue Sep 21, 2013 · 2 comments
Milestone

Comments

@yohanboniface
Copy link
Contributor

I ran yesterday in a very very slow rendering of the HOT style in Tilemill, which, after some investigation, turns to be related to the syntax of the poi.mss file. This syntax was an attempt to factorize the cartocss code, but it appears to have a very bad impact on performances.

So, if we narrow the code to a sample, it looks like this:

.poi {
    [zoom>=18] {
        [shop!=null] {
            marker-fill: #222;
        }
    }
    [zoom>=10][zoom<15] {
        [aeroway='airport'] {
            marker-fill: #444;
         }
    }
}

What I think I'm doing here is targeting

  • shops not null from the layers of class .poi, starting at zoom 18
    • AND
  • aeroway=airport from zoom 10 to zoom 15 from the layers of class .poi

When I look at the Mapnik output generated by Carto, I see that I'm clearly missing some behaviour. It appears that both selectors are finally, partly, joined:

<Style name="style" filter-mode="first">
  <Rule>
    <MaxScaleDenominator>750000</MaxScaleDenominator>
    <MinScaleDenominator>2500</MinScaleDenominator>
    <Filter>([aeroway] = 'airport') and ([shop] != null)</Filter>
    <MarkersSymbolizer fill="#444444" />
  </Rule>
  <Rule>
    <MaxScaleDenominator>2500</MaxScaleDenominator>
    <Filter>([aeroway] = 'airport') and ([shop] != null)</Filter>
    <MarkersSymbolizer fill="#222222" />
  </Rule>
  <Rule>
    <MaxScaleDenominator>750000</MaxScaleDenominator>
    <MinScaleDenominator>2500</MinScaleDenominator>
    <Filter>([aeroway] = 'airport')</Filter>
    <MarkersSymbolizer fill="#444444" />
  </Rule>
  <Rule>
    <MaxScaleDenominator>2500</MaxScaleDenominator>
    <Filter>([shop] != null)</Filter>
    <MarkersSymbolizer fill="#222222" />
  </Rule>
</Style>

And I must say that I don't understand why.

I'm expecting this syntax to be just a DRYer version of the following:

.poi[shop!=null][zoom>=18] {
    marker-fill: #222;
}
.poi[aeroway='airport'][zoom>=10][zoom<18] {
    marker-fill: #444;
}

And thus, according to what I think I'm doing, I would expect a Mapnik XML more like this:

<Style name="style" filter-mode="first">
  <Rule>
    <MinScaleDenominator>2500</MinScaleDenominator>
    <Filter>([shop] != null)</Filter>
    <MarkersSymbolizer fill="#222222" />
  </Rule>
  <Rule>
    <MaxScaleDenominator>750000</MaxScaleDenominator>
    <MinScaleDenominator>2500</MinScaleDenominator>
    <Filter>([aeroway] = 'airport')</Filter>
    <MarkersSymbolizer fill="#444444" />
  </Rule>
</Style>

But it's not :)

So I guess I'm doing something wrong, but what? :)

Thanks in advance!

(Oh, and so the actual poi.mss turn to 292753 lines of XML, which is the reason of the slow rendering of zoom 10 ;) )

yohanboniface added a commit to hotosm/HDM-CartoCSS that referenced this issue Sep 24, 2013

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Workaround for mapbox/carto#304
@yohanboniface
Copy link
Contributor Author

Closing here, I think I've just hit #20 actually.

@yohanboniface
Copy link
Contributor Author

For the record (interesting lines are poi-point and poi-poly):

ybon@edoardo:~/Code/js/tilemill$ carto -bl ~/Code/maps/hdm/project.mml > mapnik.xml
Parsing time: 9ms
Parsing time: 10ms
Parsing time: 13ms
Parsing time: 2ms
Parsing time: 1ms
Parsing time: 11ms
processing layer: land-low
Inheritance time: 0ms
processing layer: land-high
Inheritance time: 0ms
processing layer: land-mid
Inheritance time: 0ms
processing layer: landuse_gen0
Inheritance time: 6ms
processing layer: landuse_gen1
Inheritance time: 3ms
processing layer: landuse
Inheritance time: 4ms
processing layer: hillshade
Inheritance time: 1ms
processing layer: contour_line
Inheritance time: 9ms
processing layer: waterway_low
Inheritance time: 0ms
processing layer: waterway_med
Inheritance time: 0ms
processing layer: waterway_high
Inheritance time: 3ms
processing layer: water_gen0
Inheritance time: 0ms
processing layer: water_gen1
Inheritance time: 0ms
processing layer: water
Inheritance time: 0ms
processing layer: landuse_overlays
Inheritance time: 1ms
processing layer: admin-1-4
Inheritance time: 0ms
processing layer: admin-5-10
Inheritance time: 0ms
processing layer: buildings
Inheritance time: 0ms
processing layer: aeroway-poly
Inheritance time: 0ms
processing layer: aeroway
Inheritance time: 3ms
processing layer: turning_circle_case
Inheritance time: 1ms
processing layer: roads_high
Inheritance time: 183ms
processing layer: railway
Inheritance time: 1ms
processing layer: roads_med
Inheritance time: 1ms
processing layer: roads_low
Inheritance time: 1ms
processing layer: turning_circle_fill
Inheritance time: 0ms
processing layer: barrier_lines
Inheritance time: 0ms
processing layer: barrier_areas
Inheritance time: 0ms
processing layer: power-poly
Inheritance time: 0ms
processing layer: power-line
Inheritance time: 0ms
processing layer: power-point
Inheritance time: 0ms
processing layer: poi-point
Inheritance time: 7823ms
processing layer: poi-poly
Inheritance time: 7556ms
processing layer: low_place
Inheritance time: 6ms
processing layer: place
Inheritance time: 7ms
processing layer: area_label
Inheritance time: 62ms
processing layer: motorway_label
Inheritance time: 2ms
processing layer: mainroad_label
Inheritance time: 1ms
processing layer: minorroad_label
Inheritance time: 0ms
processing layer: admin-label-1-4
Inheritance time: 0ms
processing layer: admin-label-5-10
Inheritance time: 0ms
processing layer: waterway_label
Inheritance time: 0ms
processing layer: natural_point_label
Inheritance time: 0ms
processing layer: housenumber
Inheritance time: 0ms

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

No branches or pull requests

1 participant