tilemill-project / tilemill

TileMill is a modern map design studio
https://tilemill-project.github.io/tilemill/
BSD 3-Clause "New" or "Revised" License
3.12k stars 528 forks source link

geography_class compile extremely slow? #539

Closed yhahn closed 13 years ago

yhahn commented 13 years ago

I'm finding the carto compile time of geography-class to be extremely slow, around 9000ms and I've narrowed it down to these lines

https://github.com/mapbox/tilemill/blob/master/examples/geography-class/labels.mss#L39-64

Replacing them with these lines drops compile time to ~200ms but I'm not really sure what the reason was for the way the rules were defined originally.

[zoom>=2][Z_POSTAL>=2] { text-name: "[POSTAL]"; }
[zoom>=2][Z_ABBREV>=2] { text-name: "[ABBREV]"; }
[zoom>=2][Z_NAME>=2] { text-name: "[NAME]"; }
[zoom>=2][Z_ADMIN>=2] { text-name: "[ADMIN]"; }

Would love to know the reason for the rules?

ajashton commented 13 years ago

I dont think this used to take that long, but it definitely is a complex section. I can try to find a way to rework it, but the code you posted is not equivalent. What this style is doing is deciding at which zoom level certain types of labels should appear based on manually assigned values in the data table. (For example, smaller countries might have the abbreviated version of the label set to show for more zoom levels than other countries.)

yhahn commented 13 years ago

Right, can you explain how these rules do what you described? It's opaque to me what the difference between the rules are.

ajashton commented 13 years ago

For example, in the shapefile a particular country might have the following values:

This means I want the abbreviation label to be used at Z4 and above, until Z7 when it should switch to the common name label. The postal code and full administrative name won't be used, and the country won't have any label below Z4.

With your version the country would be labelled with the full name from Z2 and up.

ajashton commented 13 years ago

With this logic, I'm basically defining a lot of unique styles with a basic set rules. This is necessary because there are a lot of zoom levels, a lot of different-sized countries, and a lot of different length labels that I'm trying to account for.

What I could do instead of handling this logic in Carto is preprocess the shapefile to flatten out the labelling logic there to a bunch of colums like label_z3, label_z4, label_z5, etc.

yhahn commented 13 years ago

Hmm, ok... can you explain how the current rules differ from

[zoom>=2][Z_POSTAL>=2][Z_POSTAL<=5] { text-name: "[POSTAL]"; }
[zoom>=2][Z_ABBREV>=2][Z_ABBREV<=6] { text-name: "[ABBREV]"; }
[zoom>=2][Z_NAME>=2][Z_NAME<=6] { text-name: "[NAME]"; }
[zoom>=2][Z_ADMIN>=2][Z_ADMIN<=6] { text-name: "[ADMIN]"; }
ajashton commented 13 years ago

The Z_* values don't match up to the proper zoom levels. [zoom>=2][Z_ADMIN>=2][Z_ADMIN<=6] is true at zoom level 2 for a Z_ADMIN value of 6, but the intention is that if Z_ADMIN is 6, it should't show up below Z6.

yhahn commented 13 years ago

o i see.

ajashton commented 13 years ago

Such complex logic is overkill for an example project, so I removed it. The project still compiles very slowly for me. I'll see what else I can do..

ajashton commented 13 years ago

This seems to have been resolved