-
Notifications
You must be signed in to change notification settings - Fork 61
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
Add script for extracting style statistics #747
Conversation
Co-authored-by: Clay Smalley <claysmalley@gmail.com>
Co-authored-by: Clay Smalley <claysmalley@gmail.com>
Stats output samples:
|
let layer = layers[i]; | ||
layerMap.set(layer.id, layers[i]); | ||
let layerSize = JSON.stringify(layer).length; | ||
let layerGroup = layer.id.split("_", 1)[0]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this PR introduces a new naming convention for layer IDs that the statistics code depends on. We should document this naming convention.
Better yet, we should avail ourselves of the metadata
property, which is an object that you can stuff arbitrary properties into. A style authored in Mapbox Studio inserts metadata
in abundance, including for grouping layers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh oh 😅 that sounds like several KB worth of style JSON. Maybe let's document it for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done - contributor's guide updated!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still seems fragile, but let’s ticket out something less fragile as tail work. At a glance, we could group the layers by source layer to get pretty similar statistics, modulo some layer organization weirdness in OpenMapTiles.
This PR adds a script that offers a set of utilities for analyzing layers. Additionally, I have renamed a number of layers in order to logically group them for the purpose of statistics generation (since the choice of layer id is essentially arbitrary).
Usage examples:
npm run stats -- -a -s
npm run stats -- -c
npm run stats -- -pp -pl background
npm run stats -- -pg park
npm run stats -- --help