Skip to content

Commit

Permalink
Fix building flat roofs with user provided data when terrain is enabl…
Browse files Browse the repository at this point in the history
…ed (#10347)

* Do not depend on underlaying height property to assess flat roofs

* Add regression render test

* Remove extraneous tiles

* Add test sample page for fill-extrusion querying on terrain

* Add fill extrusion querying as part of release testing

* Fix getLoadedBucket when not overzoomed when using client data sources

* Remove dependency on 'type' feature property

Co-authored-by: Vladimir Agafonkin <[email protected]>

* Address review comments

* Address review feedback: Trim down example size

* Address @arindam1993's comment

Co-authored-by: Vladimir Agafonkin <[email protected]>
  • Loading branch information
karimnaaji and mourner authored Feb 5, 2021
1 parent 4892bd0 commit f0b5d95
Show file tree
Hide file tree
Showing 9 changed files with 1,357 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/data/bucket/fill_extrusion_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ class FillExtrusionBucket implements Bucket {
}

addFeature(feature: BucketFeature, geometry: Array<Array<Point>>, index: number, canonical: CanonicalTileID, imagePositions: {[_: string]: ImagePosition}) {
const flatRoof = this.enableTerrain && feature.properties && feature.properties.hasOwnProperty('type') &&
feature.properties.hasOwnProperty('height') && vectorTileFeatureTypes[feature.type] === 'Polygon';
const flatRoof = this.enableTerrain && feature.properties &&
vectorTileFeatureTypes[feature.type] === 'Polygon';

const metadata = flatRoof ? new PartMetadata() : null;

Expand Down
23 changes: 14 additions & 9 deletions src/render/draw_fill_extrusion.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,22 @@ function flatRoofsUpdate(context, source, coord, bucket, layer, terrain) {

const getLoadedBucket = (nid) => {
const maxzoom = source.getSource().maxzoom;
// In overscale range, look one tile zoom above and under. We do this to
// avoid flickering and use the content in Z-1 and Z+1 buckets until Z bucket is loaded.
for (const j of [0, -1, 1]) {
if (nid.overscaledZ + j < maxzoom) continue;
if (j > 0 && nid.overscaledZ < maxzoom) continue;
const n = source.getTileByID(nid.calculateScaledKey(nid.overscaledZ + j));
const getBucket = (key) => {
const n = source.getTileByID(key);
if (n && n.hasData()) {
const nBucket: ?FillExtrusionBucket = (n.getBucket(layer): any);
if (nBucket) return nBucket;
return n.getBucket(layer);
}
}
};
// In overscale range, we look one tile zoom above and under. We do this to avoid
// flickering and use the content in Z-1 and Z+1 buckets until Z bucket is loaded.
let b0, b1, b2;
if (nid.overscaledZ === nid.canonical.z || nid.overscaledZ >= maxzoom)
b0 = getBucket(nid.key);
if (nid.overscaledZ >= maxzoom)
b1 = getBucket(nid.calculateScaledKey(nid.overscaledZ + 1));
if (nid.overscaledZ > maxzoom)
b2 = getBucket(nid.calculateScaledKey(nid.overscaledZ - 1));
return b0 || b1 || b2;
};

const projectedToBorder = [0, 0, 0]; // [min, max, maxOffsetFromBorder]
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f0b5d95

Please sign in to comment.