tangrams / tangram

WebGL map rendering engine for creative cartography
https://tangram.city
MIT License
2.22k stars 290 forks source link

3D extrude with not-hardcoded property name #620

Closed jaakla closed 7 years ago

jaakla commented 7 years ago

Openmaptiles.org vector tile schema uses render_height and render_min_height as tag names for building heights. It seems that Tangram renderer expects specific hardcoded names for same properties (height and min_height). Is there way to read the values from these different property names? Maybe accept field name as value for 'extrude' style parameter?

Is it good pattern to hardcode mapzen schema properties to the rendering?

Also it would be even better to use function here, as depending on specific styling and zoom level one may want to amplify (or reduce) building heights in 3D rendering.

cc @cellum

meetar commented 7 years ago

extrude takes a function! Here are the docs: https://mapzen.com/documentation/tangram/draw/#extrude

Here's an example:

extrude: |
    function() {
        return feature.area / 100.;
    }

(example added to the docs with https://github.com/tangrams/tangram-docs/commit/2282dbeea1ea2ebf140ecc193ad5d94e1c4e04b0)

And here's a sample scene with that example: https://mapzen.com/tangram/play/?api=5%2F1221#15.1500/40.7550/-74.0011

jaakla commented 7 years ago

No luck with min_height via function :( ?

bcamper commented 7 years ago

Can you provide an example of what it is you are trying to accomplish?

On Wed, Nov 15, 2017 at 3:50 AM, Jaak Laineste notifications@github.com wrote:

No luck with min_height via function :( ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tangrams/tangram/issues/620#issuecomment-344525714, or mute the thread https://github.com/notifications/unsubscribe-auth/AABBXdnqKSvH-4f9eo4zMh11vXUKL246ks5s2qXtgaJpZM4QdOcn .

jaakla commented 7 years ago

I dont really know whether and how Tangram shows extruded buildings if min_heigth > 0, but I would expect it shows a bit more complex buildings like this example from f4map. screenshot 2017-11-15 13 01 20

Update: now I see Tangram does not use min_height ? Same building:

screenshot 2017-11-15 13 04 34

meetar commented 7 years ago

@jaakla Yes, extrude takes a function which can return [min_height, max_height]! Here's the relevant line from the docs:

Optional boolean, number, [min, max], or function returning any of the previous values.

By default, if extrude is set to true, the feature's min_height and max_height properties will be used. Here's the relevant line from the docs:

boolean: if true, features will be extruded using the values in the feature’s height and min_height properties (if those properties exist).

Here's an example scene: https://mapzen.com/tangram/play/?api=5/1224#15.0625/40.7560/-74.0005

However, for now, Tangram only extrudes vertically, which means we don't support the roof types in the OSM "Simple 3D Buildings" schema, the way f4map does: http://wiki.openstreetmap.org/wiki/Simple_3D_buildings

The central spire of the Tallina Teletorn has a roof:shape of pyramidal: https://www.openstreetmap.org/way/228672266

So it may not look quite like the image you included above (and you may need to move the camera around to see it), but here's the Tallina Teletorn in the main Tangram demo (http://tangrams.github.io/tangram/#17.54333107500086/59.471267674342386/24.886954963300443):

screen shot 2017-11-15 at 9 33 04 am