Skip to content

docs for hillshade layer and raster-dem source#5805

Merged
mollymerp merged 4 commits intomasterfrom
andrewharvey-hillshade-docs
Dec 7, 2017
Merged

docs for hillshade layer and raster-dem source#5805
mollymerp merged 4 commits intomasterfrom
andrewharvey-hillshade-docs

Conversation

@andrewharvey
Copy link
Collaborator

@mollymerp This isn't ready for merging, but posting it here for feedback. This PR includes:

  1. added hillshade example
    I'm not sure if we should have a dedicated example for the hillshade layer, but I put one together.

  2. added raster-dem source and hillshade layer to docs.

  3. included raster-dem source in the style spec rather than it being a type of the raster source.

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page

@andrewharvey andrewharvey force-pushed the andrewharvey-hillshade-docs branch from 686f330 to eb74914 Compare December 4, 2017 21:58
@andrewharvey andrewharvey force-pushed the andrewharvey-hillshade-docs branch 4 times, most recently from fa57cc4 to 0121b03 Compare December 5, 2017 00:32
Copy link
Contributor

@mollymerp mollymerp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for tackling this @andrewharvey! This is looking great – just a few small comments.

map.removeLayer('hillshade_highlight_bright');

map.setLight({
position: [1.15, 335, 60]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to include this because we decided to use layer-specific lighting properties for the hillshade layer type (hillshade-illumination-direction and hillshade-illumination-anchor).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this since the debug map used a light position, but I see what you mean now.

"id": "hillshading",
"source": "dem",
"type": "hillshade"
}, 'waterway-river-canal-shadow');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add a comment explaining why we want the hillshade layer underneath this layer

@@ -40,7 +40,7 @@ module.exports = function validateSource(options) {
errors = errors.concat(validateObject({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can actually get rid of this case now and add raster-dem into the previous case with vector and raster sources. you will have to edit line 26 to something like

valueSpec: styleSpec[`source_${type.replace('-','_'}`],

to get it to work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, that reduces code duplication.

var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/outdoors-v9',
center: [-74.50, 40],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's change the map center to somewhere with ⛰ s. Z11, center: -119.5857, 37.7221 is yosemite valley for example

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed!

@andrewharvey andrewharvey force-pushed the andrewharvey-hillshade-docs branch from 0121b03 to f133fde Compare December 5, 2017 23:16
map.removeLayer('hillshade_shadow_med');
map.removeLayer('hillshade_shadow_faint');
map.removeLayer('hillshade_highlight_med');
map.removeLayer('hillshade_highlight_bright');
Copy link
Collaborator Author

@andrewharvey andrewharvey Dec 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mollymerp I'm not sure about this. In terms of an example for the hillshade layer, it might make better sense to just use the Mapbox Basic style and add hillshading to that. It would be a simpler example.

This example is more complex as it removes the existing hillshade layers from Outdoors client side. Especially given any real map wanting Outdoors with raster hillshading would first cut the Hillshade layers from Outdoors in Studio and save that as a new style rather than doing it client side... 💭

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah good point – I made a new public style in the Mapbox account that is Outdoors minus the hillshade layers,so you can use this style id and explain with a comment what it is ?

mapbox://styles/mapbox/cjaudgl840gn32rnrepcb9b9g

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. Assuming you're okay that people will copy the example and rely on that style not disappearing in the future?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep – and we can replace it with a permanent style whenever our core styles start using this layer type.

@andrewharvey andrewharvey force-pushed the andrewharvey-hillshade-docs branch from f133fde to 0f5be60 Compare December 5, 2017 23:48
@andrewharvey andrewharvey changed the title sketch of docs for hillshading docs for hillshade layer and raster-dem source Dec 7, 2017
@mollymerp mollymerp force-pushed the andrewharvey-hillshade-docs branch from dd3ebfe to 0d6da33 Compare December 7, 2017 04:20
@mollymerp
Copy link
Contributor

Thanks for the fixes @andrewharvey – I added a couple tweaks to the example, and added in the explicit properties the raster-dem source type currently supports for consistency with the other source types, as well as to remove the scheme property, which isn't currently supported because this source only works with the mapbox terrain-rgb tileset at the moment.

"value": "string",
"doc": "An array of one or more tile source URLs, as in the TileJSON spec."
},
"bounds": {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's interesting, I tested bounds and found it had no affect. I better re-test it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in order for it to work you have to use the tiles: [...] property to specify the url because otherwise the bounds returned by the source's TileJSON will override the ones you specify. which I suppose we should also document 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this worked as expected for me:

        "rasterTerrain": {
            "type": "raster-dem",
            "tiles": [`https://a.tiles.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.png?access_token=${mapboxgl.accessToken}`],
            "bounds" : [-40, -40, 40, 40]
        }

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh that makes sense now 😁

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, it should be documented but I don't think it's critical for this PR. The same applies to the rest of these properties and raster sources too.

@mollymerp mollymerp merged commit 93319ba into master Dec 7, 2017
@mollymerp mollymerp deleted the andrewharvey-hillshade-docs branch December 7, 2017 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants