Osm2city.py

From FlightGear wiki
Revision as of 21:17, 11 April 2013 by Radi (talk | contribs) (Created page with "Take openstreetmap floorplans, create 3d buildings ready for use in FlightGear. Development [https://gitorious.org/fg-radi/osm2city repository] on gitorous. Written in python...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Take openstreetmap floorplans, create 3d buildings ready for use in FlightGear.

Development repository on gitorous. Written in python 2.7, developed on Linux

It's at a rather early stage of development, and currently not very user-friendly. You probably should know some python if you want to use it yourself. But it produces realistic city layouts (after all, it uses realistic data). The whole process -- from scratch to flying in FG -- for a city the size of LOWI takes perhaps one hour, including maybe a total of 15 mins manual work.

Has been tested with Dresden, Germany (EDDC) and Innsbruck, Austria (LOWI). Both areas are now populated with about 50,000 buildings. Rendering this in FG is quite demanding. The FG process eats ~2.8GB RAM when flying in those areas, the download is ~50 MB each.

Features

  • reads buildings from OSM. Honors height and level tags.
  • reads existing .stg, won't place OSM building if there's a static model nearby
  • reads pre-calculated terrain elevation: places buildings at correct elevation
  • LOD animation based on building height and area
  • cluster a number of buildings into a single .ac files. Clusters overlap to alleviate sharp LOD borders
  • basic sloped roof generation
  • texture manager: DB of facade/roof textures
  • ~10 different, hi-res facade textures, some roof textures
  • find matching texture for given building (number of levels, modern/old building, etc)
  • find matching roof texture for given facade texture
  • basic lightmap support
  • shows statistics on processed buildings
  • writes .ac, .xml, .stg

Planned

  • make command line interface. Currently, everything is hard-coded.
  • Rembrandt lighting
  • put shared models if/where OSM indicates so: gas stations...
  • use residential/industrial/commercial tags/areas. ATM, all is residential.
  • more complex roof shapes, put these into separate LOD
  • more complex facade generation. Currently, all sides get same texture
  • geometry cleanup, simplify too complex buildings (what is "too complex"?)
  • use more LOD levels, write them to different .ac so users can easily reduce building density, therefore improve performance
  • put large buildings into one ac, sort/rate buildings by stand-out-ness
  • then ship light/med/full .stg

Ideas

  • nearby hi-rise objects of similar shape get same texture? Probably too special a feature.
  • bump map/reflection effects?
  • a mode that generally uses shared models? If we find a shared models of matching floorplan, use this instead of creating a new, individual building? Will break clusters.

Workflow:

  • get osm data (wget line)
  • probe elevation for this area:
  • make elev.in
  • run FG: nasal console: elev.get() -> execute. Might take a long time, depending on the area scanned.
  • produces elev.xml (which is actually just plain 5 column data: lon,lat,x,y,elevation)
  • run osm2city.py
  • the first run parses OSM data. This again takes quite long, but the result is written to disk. Next startup is much faster.
  • run install.sh

Improve fps:

  • adjust LOD range in FG
  • use less buildings: increase min_area, LOD_percentage

(- use smaller tiles? Tradeoff between distance calculations/xml parsing and GPU)

How you could get involved: take pictures of buildings where you live! I'm especially interested in south-east asian style architecture, as I'm planning to populate Hong Kong Kai Tak (VHXX) in the future.