Skip to content
This repository has been archived by the owner on Jan 9, 2020. It is now read-only.

Add color legend support to ktile raster layer #451

Merged
merged 3 commits into from
Nov 17, 2017

Conversation

matthewma7
Copy link

And some code refactoring

2017-10-17_13-37-18

@manthey
Copy link
Member

manthey commented Oct 30, 2017

Should there be a legend even when the colors aren't custom? Also, it seems like there should be a way to modify the default -- for instance, if I want a black-to-white continuous scale with different min and max values.

@aashish24
Copy link
Contributor

@matthewma7 do you have an answer for @manthey's question above?

@matthewma7
Copy link
Author

@aashish24 I meant to ask @dorukozturk when I got a chance.
I guess I can ask him now.
Hi @dorukozturk, I don't you may not know the answer fully, but since you have more experience with Mapnik than I do, I am wondering that is the default Mapnik render behavior without style predictable? I mean, when there are three bands, it will be rendered to color. When there is, in this case, one band, does it always use the same greyscale? Is the greyscale ordinal or continuous?

@dorukozturk
Copy link
Contributor

dorukozturk commented Nov 10, 2017

@matthewma7 Here they list bunch of options. I think your options are

  • mapnik2.COLORIZER_LINEAR
  • mapnik2.COLORIZER_DISCRETE
  • mapnik2.COLORIZER_EXACT
  • mapnik2.COLORIZER_INHERIT

"The colorizer also has default color, which input values will be converted to if they don't match any stops.
The colorizer also has a default mode, which can be inherited by the stops." From the docs.

@aashish24
Copy link
Contributor

When there is, in this case, one band, does it always use the same greyscale? Is the greyscale ordinal or continuous

greyscale is assumed when there is only one band. You can look into QGIS which is the industry standard tool.

greyscale would be continuous (think of height map)

@matthewma7
Copy link
Author

After a discussion with @aashish24, we decided to implement legend for default raster styling in the separate PR, because it might involve something with some complexity outside the current changes.
An issue has been created for that request, #459

layer.url((x, y, z) => `${url}/${z}/${x}/${y}`);
} else {
layer.url((x, y, z) => `${url}/${z}/${x}/${y}?palette=${visProperties.palettable}&band=${visProperties.band}&minimum=${visProperties.min}&maximum=${visProperties.max}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

possible to wrap this long line?

@aashish24
Copy link
Contributor

LGTM if @manthey also approves it.

} else {
layer.url((x, y, z) => `${url}/${z}/${x}/${y}?
palette=${visProperties.palettable}&band=${visProperties.band}&
minimum=${visProperties.min}&maximum=${visProperties.max}`);
Copy link
Member

Choose a reason for hiding this comment

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

Unbreak this line or change how it is generated. The extra spaces and newlines mess up the query parameters. This should work instead:

            layer.url((x, y, z) => `${url}/${z}/${x}/${y}?` +
            `palette=${visProperties.palettable}&band=${visProperties.band}&` +
            `minimum=${visProperties.min}&maximum=${visProperties.max}`);

Copy link
Author

Choose a reason for hiding this comment

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

Oh, yes. I was carried away with the multiline support of template literals.

@matthewma7 matthewma7 merged commit e490c03 into master Nov 17, 2017
@matthewma7 matthewma7 deleted the raster_color_legend_support branch November 17, 2017 15:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants