Skip to content

buckets should be allowed to specify more than one format #244

Closed

Description

@ansis

Currently, buckets specify one output format: a line, fill, point, text.

I think buckets should specify multiple formats, for example:

{
    "line": { "linecap": "round" },
    "fill": true
}

Buckets are instructions for selecting features and converting them to a renderable format. You may want multiple formats for the same group of features. These formats can impact each other. If both fills and lines will be drawn for a feature it would be good to avoid duplicating data in the vertex buffers. If text and points need to be placed together, they need to be processed together. Adding multiple formats to one bucket, instead of making separate buckets for each format lets us handle these things.

Since buckets would have more than one possible rendering, the style would need specify a type. Either

{
    "type": "line",
    "color": "#000"
}

To draw an outline, you'd have two layers, one for the outline and one for the fill.

Or you could prefix everything, which is a bit more ambiguous (what order are they drawn in?) and it adds two ways of doing things, but is less verbose.

{
    "line-color": "#000",
    "fill-color": "#f00",
}

This is somewhat related to #240 (comment)

Before I break everything, is this a good idea @kkaefer?

Activity

  1. kkaefer commented on Jan 27, 2014

    @kkaefer
    Member

    Since you're going to have two separate classes anyway, why not create two separate buckets with the same filters? Specifically, what does "If text and points need to be placed together, they need to be processed together." mean?

  2. ansis commented on Jan 27, 2014

    @ansis
    ContributorAuthor

    I'm seeing two reasons:

    To handle placement for text and points/shields together

    not yet implemented

    For example, you want to place a label together with an icon/shield, and only show either of them when both of them can be shown. This means placement and collision detection needs to happen together for both features. How would we process them together if they were in separate buckets?

    To avoid duplicating data

    Ideally:

    If we want just fills: a line vertex buffer (for gl.LINE_STRIP) and an element buffer for fills
    If we want just lines: a triangulated vertex buffer (for gl.TIRANGLE_STRIP)
    If we want lines and fills: a triangulated vertex buffer (for gl.TRIANGLE_STRIP) and an element buffer for fills

    If we have two separate buckets (one for lines, one for fills), how can we avoid adding the vertices to the buffer twice in two different formats? Or does it not matter that much if we do duplicate the data?

  3. kkaefer commented on Jan 28, 2014

    @kkaefer
    Member

    I can follow 1), but 2) seems a little weird to me: We have a clear distinction between fills and lines, and drawing either one as another type doesn't make much sense? If we're drawing fills, we're drawing a 1px outline too that feeds off the same buffer, so there is no vertex duplication here. The only duplication would occur if you wanted to draw fill outlines as something other than a 1px line.

  4. ansis commented on Jan 28, 2014

    @ansis
    ContributorAuthor

    The only duplication would occur if you wanted to draw fill outlines as something other than a 1px line.

    Yeah, this was what I was trying to say. I think this use might be fairly common.

    Any use of line patterns would require a second, duplicated bucket. I ran into that a lot when making this: https://hey.mapbox.com/board/tech/webgl-pencil.gif . If we expose the fade distance for lines (currently 1 pixel for antialiasing) we could use lines with soft edges instead of blurring in many cases (vector terrain, building shadows). Having fills + wide lines is probably fairly common, and the duplication could be significant for layers with many vertices (buildings).

    but, after sleeping on it:

    I'm going to forget about this for now. Its not that important. I'll see how things are when I start on 1). thanks

  5. added a commit that references this issue on Oct 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions