mapbox / mapbox/mapbox-gl-language
Demetricate elevations
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 204
- Forks
- 51
- PR merge metrics
- No merged PRs in 30d
Description
Now that expression support has landed in GL JS master, this plugin can demetricate any length measurements that occur in labels if the user agent specifies a U.S. locale, based on the following properties in the Mapbox Streets source:
* `building` layer: `height` and `min_height`
* `state_label` and `water_label` layers: `area`
* `road_label` layer: `len`
* `mountain_peak_label` layer: `elevation_m` (use `elevation_ft`)
Of these properties, `height`, `min_height`, and `elevation_m`/`elevation_ft` are the most likely to appear in labels. `area` and `len` are projected areas and lengths, respectively, which aren’t particularly practical for labeling.
For most of these properties, we’ll need to introduce expressions that convert between meters and feet or between square kilometers and square miles or acres. This will require the library to use the new expression syntax instead of the legacy property function syntax, although perhaps we could detect the absence of expression support and still adjust property functions if needed.
For `elevation_m`, we’ll simply switch to `elevation_ft`. One challenge will be localizing units that are written out alongside the property: for example, [the `mountain_peak_label` documentation](https://www.mapbox.com/vector-tiles/mapbox-streets-v7/#mountain_peak_label) recommends specifying a text field of `{elevation_m}m`, but `{elevation_m} meters` could occur instead.
Demetrication should be an option, not mandatory, since meters are used in technical contexts in the U.S.
/cc @lukasmartinelli @anandthakker
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how the plugin currently rewrites label properties and whether it supports GL JS expressions; review the listed Mapbox Streets layers and fields, especially height, min_height, and elevation_m. Done means an optional U.S.-locale demetrication path is defined for the relevant fields, including unit text handling and behavior when expression support is absent, with coverage for supported cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- localization
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100