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

Not enough building merging & simplification #1686

Closed
4 tasks
zerebubuth opened this issue Oct 11, 2018 · 4 comments
Closed
4 tasks

Not enough building merging & simplification #1686

zerebubuth opened this issue Oct 11, 2018 · 4 comments

Comments

@zerebubuth
Copy link
Member

Building heights and extra properties (e.g: roof_shape or roof_colour) are preventing merging between buildings. For example, tile 14/6066/9294 in the north-west of Sao Paulo:

North-west Sao Paulo, coloured by unique feature

(Coloured uniquely by feature.) There is some merging going, but still leaving us with over 9,000 unique multipolygons. Partly, this is because we're not quantising height enough:

North-west Sao Paulo, coloured by height

(There are 5,406 unique height values.) Even when we zoom out, and are quantising values (although not all?), there's still a lot of merging inhibited by neighbouring building heights differing by more than 5m.

North-west Sao Paulo, zoom 13, coloured by unique height

It also looks like we're not quantising heights for buildings (should they be building:parts?) with min_height or layer != 0.

Also, we have quite a lot of small courtyards within buildings which probably aren't visible at this zoom level.

Finally, in this zoomed-in block from the 13/3033/4647 tile, you can see there's not a lot of merging going on between building geometries (even if they might be merged into the same multipolygon feature), so we're wasting a lot of bytes to describe each individual polygon.

Overzoomed section of zoom 13 tile, coloured by unique feature

In summary:

  • Drop superfluous properties, e.g: roof_material, and quantize height more aggressively at lower zooms for smaller buildings.
  • Make sure we're quantising heights for buildings with layer or min_height.
  • Drop small courtyards within buildings.
  • Dilate or buffer building geometry slightly while merging to try and merge adjacent buildings with very small gaps between them.
@zerebubuth zerebubuth added this to the v1.6.0 milestone Oct 11, 2018
@nvkelso
Copy link
Member

nvkelso commented Oct 15, 2018

Looks like the Mapzen house styles hide many buildings at zooms 13 and 14, indicating to me we can drop scale_rank 3,4,5 at zoom 13 and scale_rank 4,5 at zoom 14.

        # building footprints, pre-extrusion
        footprints:
            filter:
                # show footprints for buildings at least one zoom level before they will be extruded
                - { $zoom: 13, scale_rank: [1,2] }
                - { $zoom: 14, scale_rank: [1,2,3] }
                - { $zoom: 15, height: { min: 100 } }
                - { $zoom: 15, area: { min: 500 } }
                - { $zoom: 15, volume: { min: 100000 } }
                - { $zoom: 16, area: { min: 100 } }
                - { $zoom: 16, volume: { min: 50000 } }
                - { $zoom: { min: 17 }, area: true }

@nvkelso
Copy link
Member

nvkelso commented Dec 14, 2018

Connects to #1689.

@nvkelso
Copy link
Member

nvkelso commented Dec 14, 2018

zoom 13

Smattering of building removed (okay), much more merging (great!)

SF: 13/37.7607/-122.4357

buildings_zoom_13

zoom 14

Tons of tiny building removed (sad but okay), much more merging (great!), tiny file size (great!)

SF: 14/37.7822/-122.4300

buildings_zoom_14

zoom 15

All the tiny building kept (good), much more merging (great!), smaller file size (great!)

SF: 15/37.7835/-122.4275

buildings_zoom_15

zoom 16

All the buildings, with their IDs (no merging, good), similar file size (okay, improve another day possibly thru geometry generalization)

SF: 16/37.7796/-122.4229

buildings_zoom_16

Future self:

All using this color lookup function:

                        color: |
                            function() {
                              if( feature.id ) {
                                  var letters = '0123456789ABCDEF';
                                  var color = '#';
                                  for (var i = 0; i < 6; i++ ) {
                                      color += letters[Math.floor(Math.random() * 16)];
                                  }
                                  return color;
                              } else {
                                  if( feature.scale_rank == 6 ) {
                                      return [1.,0.,0.,1];
                                  } else if( feature.scale_rank == 5 ) {
                                      return [0.,1.,0.,1];
                                  } else if( feature.scale_rank == 4 ) {
                                      return [0.,0.,1.,1];
                                  } else if( feature.scale_rank == 3 ) {
                                      return [0.,0.,0.5,1];
                                  } else if( feature.scale_rank == 2 ) {
                                      return [0.,0.5,0.,1];
                                  } else if( feature.scale_rank == 1 ) {
                                      return [0.,0.5,0.,1];
                                  } else if( feature.scale_rank == 0 ) {
                                      return [0.5,0.,0.,1];
                                  } else {
                                      return [0.5,0.5,0.5,1];
                                  }
                              }
                            }

@nvkelso
Copy link
Member

nvkelso commented Dec 14, 2018

A few comments:

First: this change looks visually great for Bubble Wrap and hugely reduces file size. Huzzah!

But there seem to be 2 issues:

  • scale_rank is always 1 now instead of range of 1 to 5. -- regression we should fix
  • zoom 14 missing some buildings -- not a ship block issue, but we'd likely fix it fixing the regression, and it's important for a style like Refill which we've compromised a bit.

To clarify, I think zoom 13 looks better in this new setup (dropping more buildings), but zoom 14 looks worse (drops slightly too many buildings).

I've filed #1732 to dig into that, and we can close this original issue which is huge step forward :)

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

2 participants