Skip to content
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

Demetricate elevations #9

Open
1ec5 opened this issue Sep 10, 2017 · 2 comments
Open

Demetricate elevations #9

1ec5 opened this issue Sep 10, 2017 · 2 comments

Comments

@1ec5
Copy link
Contributor

1ec5 commented Sep 10, 2017

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 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

@1ec5
Copy link
Contributor Author

1ec5 commented Apr 26, 2018

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.

Tracking expression support in general in #20.

@1ec5
Copy link
Contributor Author

1ec5 commented Dec 20, 2018

Once the number-format expression operator introduced in mapbox/mapbox-gl-js#7626 is adopted by Mapbox Studio, this plugin should use it to format numbers in elevations at the same time that it converts the elevations to the appropriate unit.

/cc @ChrisLoer

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

No branches or pull requests

1 participant