Skip to content
This repository has been archived by the owner on Dec 26, 2017. It is now read-only.

Add support for 3D buildings in MapboxGL #454

Open
5 of 8 tasks
ghost opened this issue Oct 18, 2016 · 18 comments
Open
5 of 8 tasks

Add support for 3D buildings in MapboxGL #454

ghost opened this issue Oct 18, 2016 · 18 comments
Labels

Comments

@ghost
Copy link

ghost commented Oct 18, 2016

In light of added support for fill-extrude-height and fill-extrude-base, I'd like to add the height attributes to OSM2Vectortiles backend so at a later date, a tm2source and style (probably Liberty) can pick it up.

I'll take this on. Steps I can see:

  • adjust imposm mapping to add it in
  • adjust import-sql to add it as a function and calculate if no heights given
  • confirm that a demo tm2source can pick it up (will only render buildings into the mbtiles)
  • test display in a viewer

More todos:

  • Add additional fields
  • Do I handle defaults in import-sql? What about catching clearly bad values and nulling them?
  • Handle both building and building part with the same geometry, leads to rendering artifacts
  • Advanced rendering for rooftops??
@ghost ghost added the feature label Oct 18, 2016
@ghost ghost self-assigned this Oct 18, 2016
@lukasmartinelli
Copy link
Member

Cool. In the v3 we use the following approach of Paul Norman (OSM Clear to calculate render_height:

-- 3.66 is obtained by correlating the heights and level data in OSM
-- raising to a power < 1 reduces the height range displayed which looks better
least(greatest(3, COALESCE(height,levels*3.66,5)),400)^.7 AS render_height

@kekscom
Copy link

kekscom commented Oct 19, 2016

Hi,
I'm considering to join your efforts and go for Vector Tile support in OSM Buildings.
Is there a chance to include a lot more attributes, i.e. building levels, roof shapes etc.?
Packing as JSON string would be fine.
With that, I could also imagine an extended version of MapboxGL in terms of 3D buildings.

@ghost
Copy link
Author

ghost commented Oct 19, 2016

@kekscom
Yep, I could definitely include more attributes like roofshapes, though they won't be rendered as complex rooftops! I could also add in materials so that color choices can be made by the style.

With regards to 3D and MapboxGL, I'm not sure it's 100% at the point where it replaces something like Cesium in capability. I have a working offline demo that uses OSM2World and 3DCityDB to fill a database with buildings and dump them to tiles to view in Cesium. It's a powerful solution for handling lots of buildings with the full capabilities of drawing complex rooftops as opposed to basic extrusions. Only hurdle is hardware needs to view lots of buildings in a downtown area when in KML formats.

@ghost
Copy link
Author

ghost commented Oct 20, 2016

Okay, I did the first demos last night. I got it to draw in 3D, but I don't have any proper height dependent 3D drawing yet. Might be an issue that I did Switzerland, mostly centered over Zurich so not much in the way of complex buildings. I will try New York next. Unfortunately the fill-extrude-height and fill-extrude-base requires "stops", adding a layer of complexity to my demo style.

Second issue that I may face, what "order" do I do in the tm2source for buildings? Right now, it's ORDER BY ST_YMin(ST_Envelope(geometry)) DESC. But thinking about it now, I may need to change this to be height dependent, drawing the lowest layers first, potentially sorting on min_level/min_height. Hmmm.

@kekscom
Copy link

kekscom commented Oct 20, 2016

@stirringhalo First I needed to know whether you would be interested in adding more information. As coverage with extended buildings tags varies a lot, it might not make sense to predefine e fixed attribute set.

Once there is an agreement about that, I'm fine to work on the renderer.

@ghost
Copy link
Author

ghost commented Oct 20, 2016

@kekscom I have no problem adding more tag information.

@ghost
Copy link
Author

ghost commented Oct 21, 2016

Oop, better image:
image

Have to figure out why building:part is missing, I'm not as familiar with imposm3 mapping as I am imposm2. Any thoughts @lukasmartinelli ?

I'd like to put forward a tm2source eventually with all the tags, but it will explicitly not be compatible with Streets as much as reasonably possible.

@ghost
Copy link
Author

ghost commented Oct 21, 2016

I figured out the bug, it was a missing set of keys in mapping.yml!

Looking great so far, I'm adding the additional features and I'm testing data-driven colouring using the colour functionality. I would love for Mapbox to add support for fallback values in the "identity" function when a value does not exist. For now, I'm just fill with default values in DB but it's definitely ugly.

@ghost
Copy link
Author

ghost commented Oct 21, 2016

More progress,

screenshot

Decided against rendering the materials as that would get extremely complicated and may not look very good with the limited pattern fill capabilities

@lukasmartinelli
Copy link
Member

Have to figure out why building:part is missing, I'm not as familiar with imposm3 mapping as I am imposm2. Any thoughts @lukasmartinelli ?

Just note here which OSM source data you require for the 3D buildings.

Decided against rendering the materials as that would get extremely complicated and may not look very good with the limited pattern fill capabilities

Wow looks very nice ❤️

@ghost
Copy link
Author

ghost commented Oct 25, 2016

@lukasmartinelli
For all, see the enhancement/add_height branch. It's got all the current progress for this.

I'm waiting on mapbox/mapbox-gl-style-spec#480 to see how default fall-back styles will be handled for the identity function.

Feel free to rip these out and put them into the open tm2source and associated import workflow.

@ghost
Copy link
Author

ghost commented Jan 9, 2017

Integrated with OpenMapTiles....

https://openmaptiles.github.io/klokantech-3d-gl-style/#14.47/40.7086/-74.0049/16/56

@nicooprat
Copy link

Amazing! Any idea what's happening with the Eiffel Tower though? https://openmaptiles.github.io/klokantech-3d-gl-style/#15.85/48.8593/2.2959/0/57

@ghost
Copy link
Author

ghost commented Jan 9, 2017

@nicooprat The 3D is formed by straight extrusion in the z-direction with no complex roof shapes or diagonals in the z-direction possible. So all building/building:parts are rectangular!

Without any further awesomeness in Mapbox-gl-js, this is as far as we can go.

@nicooprat
Copy link

Oh too bad! Thanks for the explanation. And your work, of course :)

@klokan
Copy link
Member

klokan commented Jan 10, 2017

@stirringhalo did a great job here... Big "thank you" belongs to him!

BTW It seems there is a space for a small improvement on the Eiffel tower shape:

screen shot 2017-01-10 at 06 59 14

https://www.mapbox.com/bites/00295/streets.html

vs

screen shot 2017-01-10 at 07 05 07

@klokan
Copy link
Member

klokan commented Jan 10, 2017

@ghost
Copy link
Author

ghost commented Jan 10, 2017

@klokan Hmmm, I wonder if it's an issue with units/stories/feet in the base feature of OSM that caused that as I've seen nothing elsewhere (especially over NY) to suggest there's a widespread issue. I have seen some super impossibly tall towers in Mumbai, suggesting it's an issue with how imposm3 imports/converts it.

I will dig into this! openmaptiles/openmaptiles#128

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants