Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Show the contour-label symbol in meters or feet #5018

Closed
4 tasks
roblabs opened this issue May 12, 2016 · 23 comments
Closed
4 tasks

Show the contour-label symbol in meters or feet #5018

roblabs opened this issue May 12, 2016 · 23 comments
Labels
archived Archived because of inactivity Core The cross-platform C++ core, aka mbgl expressions feature localization Human language support and internationalization rendering

Comments

@roblabs
Copy link
Contributor

roblabs commented May 12, 2016

Summary — Give the Mapbox mobile or web customer an option to show the contour-label symbol in meters or feet. We also include discussion and our thoughts on the side effects of this [feature] request.

Platform: core, but working demo shown in iOS
Mapbox SDK version: ios-v3.2.2

Steps to trigger behavior

  1. Using the Mapbox Outdoor style, zoom to Lake Tahoe in the Sierra Nevada mountains on the border between California and Nevada
  2. This will show you features from terrain-v2 (contour-line and contour-label).
  3. Zoom to greater than 12 or 13, (even though the minzoom for contour-label is 11)
  4. contour-label will display as '12345 m', as the data is in meters
  5. USGS topo maps are in feet, and our customers will not want to do the arithmetic conversion from meters to feet. Especially, in the back country where our customers will likely use our Mapbox maps.

Proposed [feature]

  • This working iOS demo shows contours intervals in both meters and feet
  • This is an example only. We don't propose this as the final implementation, as it needs more architecture discussion with Mapbox.
  • See this commit on our fork, which also has a discussion on implementation, precision and affect on customers expecting 'feet', but instead getting 'converted meters'.
  • The mountain is Black Mountain Open Space Preserve in San Diego county

black-mountain-meters-feet

Actual behavior

black-mountain-meters-only

Background

  • Typical US Geological Service topo maps are in 40 foot intervals
  • Mapbox elevations from the Outdoors style (terrain-V2) are in 50 meters intervals
  • Ideally, our team would like to draw the topo lines as 40 feet intervals
  • But we don't know if the contour data comes in feet, or only as meters.
  • We are aware that Mapbox Streets v7 offers Peak elevations in feet and meters, and we want to drive the discussion on contours.

Mapbox Architecture

This has many implications that need input and architecture from the Mapbox core team —

  • How would the mobile customer set meters or feet? Should Mapbox provide a switch control somewhere accessible in the SDK?
  • What changes are needed for Outdoor styles when used in Android and the web?
  • What implications are on the Mapbox styles which already define "contour-label" as "{ele} m"?
  • What implications are on the Mapbox styles which already define "mountain-peak-label-with-elevation" as "{name_en}, {elevation_m}m"?
@1ec5
Copy link
Contributor

1ec5 commented May 12, 2016

Thank you for taking the time to come up with this proof of concept. As you’re probably aware, we’d either want the choice of units to be explicit either at design time in the style or at runtime based on the user locale, but this area of the codebase probably isn’t well suited to unit conversion logic. The surrounding code handles various properties defined in the style according to the Mapbox GL Style Specification. We’ve started to discuss the possibility of extending the specification to handle number formatting in mapbox/mapbox-gl-style-spec#452; perhaps unit options make sense in this context.

As for placing the contour lines at different intervals, that’s largely something the source would have to implement. Different sources can provide polylines at different elevations. @lucaswoj can probably explain better. 😃

@1ec5 1ec5 added the feature label May 12, 2016
@roblabs
Copy link
Contributor Author

roblabs commented May 12, 2016

Thanks for the feedback on the unit conversion. Yes, are right "sniffing for meters on every symbol and converting" isn't well suited. Empirically, we checked several large mountain peaks to see if the contour levels in feet still made sense. We wanted to make something real, rather than slide ware. We will not create a pull request, as it's the wrong architecture.

@lucaswoj, if you have any pointers on source data that may have contour levels in feet, rather than meters, then it would solve all. Then the style JSON could just deal with the units as a label, instead of the conversion.

@lucaswoj
Copy link
Contributor

The raw elevation data and prebuilt contour geometries are available from USGS. They can be hard to work with due to their size. We have some internal projects underway to make this easier to work with but nothing to announce yet.

I wish you luck and regret that I can't provide more help! This is a Hard Problem.

@1ec5 1ec5 added the localization Human language support and internationalization label Dec 7, 2016
@jfirebaugh jfirebaugh changed the title [core] [feature] [ios][android] Show the contour-label symbol in meters or feet Show the contour-label symbol in meters or feet May 12, 2017
@kkaefer kkaefer added Core The cross-platform C++ core, aka mbgl rendering labels May 30, 2017
@1ec5
Copy link
Contributor

1ec5 commented Sep 11, 2017

Now that the iOS and macOS SDKs support runtime styling, it’s possible for MGLMapView to automatically swap meters for feet, at least in mountain peak elevation labels, without requiring any changes to mbgl. mapbox/mapbox-gl-language#9 discusses the same approach but geared toward GL JS.

@HikingDev
Copy link

Hi,

whats the point in changing the mountain peak to ft whereas the contour labels stay with meter?
Are there any plans to offer {elevation_ft} for contour-label as its available for mountain-peak-label?

@roblabs
Copy link
Contributor Author

roblabs commented Dec 20, 2017

@roesneb — you bring up a good point, and this indeed is a hard problem to solve. My original proposal from a year ago had its own problems. My contour lines were drawn in metric, as it is how the Mapbox contours were made, but the units were converted to Imperial. Still not the right solution.

In order to offer both imperial and metric units for contours would mean the map tile service would have to serve up two distinct layers of contours.

I've studied this quite extensively, and the best solution I could come up with is to make my own contours in Imperial units using USGS data. The contour data set could be large. For the region of San Diego County, California the vector tiles was 100 MB.

Comparison between 𝘦 π Maps, Klokantech Terrain, and Mapbox Outdoors.

Map Contour Lines Contour Labels
Original Proposal Metric Imperial converted from Metric. Lines are still Metric!!
𝘦 π Maps Imperial using raw data from USGS Imperial
Klokantech Terrain Metric Metric
Mapbox Outdoors Metric Metric

(left to right) 𝘦 π Maps, Klokantech Terrain, Mapbox Outdoors, 𝘦 π (USGS) + Mapbox (Metric)
hot-springs-epihot-springs-klokantechhot-springs-mapboxhot-springs-epi-mapbox

Hot Springs Mountain, highest point in San Diego County

@1ec5
Copy link
Contributor

1ec5 commented Dec 20, 2017

We’ve started to discuss the possibility of extending the specification to handle number formatting in mapbox/mapbox-gl-style-spec#452; perhaps unit options make sense in this context.

As of #9439, the style JSON can now contain freeform mathematical expressions, which makes it much easier to implement unit conversions for labels. Runtime styling support for expressions has landed on Android as of #10654, and iOS/macOS support will land in #10726. In Swift, demetricating the label would look like this:

// Convert to feet, round down, cast to a string, and append “ft”.
contourLabels.text = NSExpression(format: "mgl_join({CAST(mgl_round(ele / 0.3048), 'NSString'), ' ft'})")

(I’m working on a more concise way to append strings, but the unit conversion itself is pretty concise.)

But to @roesneb’s point, a more complete solution would require moving the contours to more appropriate intervals. One approach would be for the source to provide contours at closer intervals, relying on the layer to filter out minor contours. Mapbox Terrain does support variable density, keyed on the index field. However, I’m unsure whether the density is sufficient.

#10642 is adding new source types for rawer vector terrain data. While that PR is focused on hillshading effects, I wonder if it would unblock generating these terrain contour geometries on the client side as well.

/cc @mollymerp @kkaefer

@mollymerp
Copy link
Contributor

@1ec5 for reference: client side contour generation ticketed here mapbox/mapbox-gl-js#5844

@GitStu
Copy link

GitStu commented Apr 27, 2018

Hello,
I work for Recreation.gov and we are rebuilding the entire website and system as we speak. Going live with this new effort this October. We will be including an interactive MapBox map on the new site showing campgrounds, campsites, and other federal recreation-related features/places. We are interested in using a MapBox base layer with contours labeled in feet rather than meters (or at least would like the option to toggle between them). Is there an update on the problem with being able to show contours in feet in MapBox?

@roblabs
Copy link
Contributor Author

roblabs commented Apr 27, 2018

@GitStu — Our team has solved this problem of "contours in feet" by processing USGS contour lines as Mapbox vector tiles.

The solution for Rec.gov could be similar:

  • use USGS contours line with Mapbox base layer
  • Swap out the Mapbox contour layer used in Mapbox Terrain V2 with the USGS contours in feet
  • Contact me if you need assistance; we make custom maps using authoritative Federal trail & campsites

See a live map of the San Bernardino National Forest, http://RobLabs.com/sbnf that has contours in feet and USFS campsites.

san-jacinto

@GitStu
Copy link

GitStu commented Apr 27, 2018 via email

@roblabs
Copy link
Contributor Author

roblabs commented Apr 28, 2018

Yes, we use authoritative federal roads data, so campground loop roads do show up. Some forests have "Yellow Posts" campgrounds and those are fairly well documented on the FS web sites, but the loop roads with campsites doesn't seem to be published.

@bcbeta
Copy link

bcbeta commented Aug 6, 2018

@roblabs it would seem the tilesets are huge? I haven't been able to get them under the upload limit.

@GitStu
Copy link

GitStu commented Aug 6, 2018 via email

@friedbunny
Copy link
Contributor

@GitStu If the site/app is following Mapbox ToS, there will be an “Improve this map” link in the attribution — that site will guide you through reporting issues.

@GitStu
Copy link

GitStu commented Aug 6, 2018 via email

@GitStu
Copy link

GitStu commented Aug 6, 2018 via email

@friedbunny
Copy link
Contributor

@GitStu let’s keep this issue on topic — please feel free to report issues via our website.

@GitStu
Copy link

GitStu commented Aug 6, 2018 via email

@roblabs
Copy link
Contributor Author

roblabs commented Aug 6, 2018

Hello @davem2020,

Regarding your question on the size of the tiles:

@roblabs it would seem the tilesets are huge? I haven't been able to get them under the upload limit.

Here are some solutions that We have used to work with large tile sets

  • Mapbox limitations are that tiles should be < 500KB/tile when uploading to Mapbox.com/studio
  • We make offline maps for mobile, so we don't have that limitation.
  • Use data reduction techniques in Tippecanoe to reduce tile size, https://github.com/mapbox/tippecanoe
  • Reduce the zoom level range. For example, in my research zoom levels of 11-13 or 11-14 are sufficient for dense, high frequency lines such as contours.
  • Tippecanoe will give a warning and error when any tile is > 500 KB. Use that information to determine your next step. For example, if your tile set of contours throws errors at zoom=5, then ask yourself why you need contours at zoom=5.

@bcbeta
Copy link

bcbeta commented Aug 6, 2018

Thanks for the explanation. I will have to explore tippecanoe. I had been uploading the shp file directly to mapbox which quickly exceeded the 260 mg limit.

@stale stale bot added the archived Archived because of inactivity label Mar 24, 2019
@stale
Copy link

stale bot commented Mar 25, 2019

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

@stale stale bot closed this as completed Mar 25, 2019
@friedbunny friedbunny reopened this Mar 25, 2019
@stale stale bot removed the archived Archived because of inactivity label Mar 25, 2019
@stale stale bot added the archived Archived because of inactivity label Sep 21, 2019
@stale
Copy link

stale bot commented Sep 21, 2019

This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

@stale stale bot closed this as completed Sep 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived Archived because of inactivity Core The cross-platform C++ core, aka mbgl expressions feature localization Human language support and internationalization rendering
Projects
None yet
Development

No branches or pull requests

9 participants