Commit e63d9cbb authored by Rick Gruber-Riemer's avatar Rick Gruber-Riemer

New method to copy textures to scenery directories. Plus updated description.

parent 9b31b458
# -*- coding: utf-8 -*-
""" Copies texture related data in directory 'tex' into the scenery folders.
"""
import argparse
import logging
import os
import shutil
import sys
import parameters
import tools
def main():
if parameters.PATH_TO_OUTPUT:
scenery_path = parameters.PATH_TO_OUTPUT
else:
scenery_path = parameters.PATH_TO_SCENERY
scenery_path += os.sep + "Objects"
if os.path.exists(scenery_path):
level_one_dirs = os.listdir(scenery_path)
level_two_dirs = list()
for level_one_dir in level_one_dirs:
sub_dir_path = scenery_path + os.sep + level_one_dir
if os.path.isdir(sub_dir_path):
level_two_dir_list = os.listdir(sub_dir_path)
for level_two_dir in level_two_dir_list:
if os.path.isdir(sub_dir_path + os.sep + level_two_dir):
level_two_dirs.append(sub_dir_path + os.sep + level_two_dir)
if len(level_two_dirs) == 0:
logging("The scenery path does not seem to have necessary sub-directories in %s", scenery_path)
sys.exit(1)
else:
orig_tex_dir = tools.get_osm2city_directory() + os.sep + "tex"
tex_content_list = os.listdir(orig_tex_dir)
if not os.path.exists(orig_tex_dir):
logging.error("The original tex dir seems to be missing: %s", orig_tex_dir)
sys.exit(1)
for level_two_dir in level_two_dirs:
tex_dir = level_two_dir + os.sep + "tex"
if not os.path.exists(tex_dir):
os.mkdir(tex_dir)
logging.info("Copying texture stuff to sub-directory %s", tex_dir)
for content in tex_content_list:
shutil.copy(orig_tex_dir + os.sep + content, tex_dir)
else:
logging.error("The scenery path must include a directory 'Objects' like %s", scenery_path)
sys.exit(1)
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
parser = argparse.ArgumentParser(description="Copies texture related data in directory 'tex' into the scenery folders.")
parser.add_argument("-f", "--file", dest="filename",
help="Mandatory: read parameters from FILE (e.g. params.ini)", metavar="FILE")
parser.add_argument("-o", dest="o", action="store_true", help="do not overwrite existing elevation data")
args = parser.parse_args()
if args.filename is not None:
parameters.read_from_file(args.filename)
else:
logging.error("The filename argument is mandatory")
sys.exit(1)
main()
......@@ -19,6 +19,44 @@ Therefore before running ``osm2city`` related programs please either:
::
$ cd /home/pingu/fg_customscenery/projects
====================
Overview of Programs
====================
``osm2city`` contains the following programs to generate scenery objects based on OSM data:
* ``osm2city.py``: generates buildings. See also the related `Wiki osm2city article <http://wiki.flightgear.org/Osm2city.py>`_.
* ``osm2pylon.py``: generates pylons and cables between them for power lines, aerial ways, railway overhead lines as well as streetlamps. See also the related `Wiki osm2pylon article <http://wiki.flightgear.org/Osm2pylons.py>`_.
* ``roads.py``: generates different types of roads. See also the related `Wiki roads article <http://wiki.flightgear.org/Osm2roads.py>`_.
* ``piers.py``: generates piers and boats. See also the related `Wiki piers article <http://wiki.flightgear.org/OsmPiers.py>`_.
* ``platforms.py``: generates (railway) platforms. See also the related `Wiki platforms article <http://wiki.flightgear.org/OsmPlatforms.py>`_.
Calling one of these programs only with command line option ``--help`` or ``-h`` will present all available parameters. E.g.
::
/usr/bin/python2.7 /home/pingu/develop_vcs/osm2city/platforms.py --help
usage: platforms.py [-h] [-f FILE] [-l LOGLEVEL]
platform.py reads OSM data and creates platform models for use with FlightGear
optional arguments:
-h, --help show this help message and exit
-f FILE, --file FILE read parameters from FILE (e.g. params.ini)
-l LOGLEVEL, --loglevel LOGLEVEL
set loglevel. Valid levels are VERBOSE, DEBUG, INFO,
WARNING, ERROR, CRITICAL
In most situations you may want to at least provide command line parameter ``-f`` and point to a ``params.ini`` file. E.g.
::
/usr/bin/python2.7 /home/pingu/develop_vcs/osm2city/osm2city.py -f LSZS/params.ini -l DEBUG -a
Remember that the paths are relative to the ``WORKING_DIRECTORY``. Alternatively provide the full path to your ``params.ini`` [#]_ file.
.. [#] ou can name this file whatever you want — "params.ini" is just a convenience / convention.
.. osm2city documentation master file, created by
sphinx-quickstart on Sat Jan 23 16:17:58 2016.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to osm2city's documentation!
====================================
While the article on Flightgear's Wiki_ presents in general terms what ``osm2city`` is and what features it has, this manual goes into depth with many aspects of generating scenery objects based on OpenStreetMap_ (OSM) data and deploying/using them in FlightGear_.
While the article on FlightGear's Wiki_ presents in general terms what ``osm2city`` is and what features it has, this manual goes into depth with many aspects of generating scenery objects based on OpenStreetMap_ (OSM) data and deploying/using them in FlightGear_.
.. _FlightGear: http://www.flightgear.org/
......@@ -13,7 +9,7 @@ While the article on Flightgear's Wiki_ presents in general terms what ``osm2cit
.. _OpenStreetMap: http://www.osm.org/
Before you generate your own sceneries, you might want to get familiar with the output of ``osm2city`` by first deploying some of the downloadable already generated sceneries and have a look at chapter :ref:`Deploy and Use Generated Scenery Objects <chapter-deploy-label>`. The following list is not exhaustive and more sceneries are typically announced in the Sceneries_ part of the FlightGear Forums:
Before you generate your own sceneries, you might want to get familiar with the output of ``osm2city`` by first deploying some of the downloadable osm2city sceneries and have a look at chapter :ref:`Using Generated Scenery <chapter-using-label>`. The following list is not exhaustive and more sceneries are typically announced in the Sceneries_ part of the FlightGear Forums:
* `Areas populated with osm2city scenery <http://wiki.flightgear.org/Areas_populated_with_osm2city_scenery>`_
* `LOWI city buildings <http://forum.flightgear.org/viewtopic.php?f=5&t=19625>`_
......
......@@ -50,7 +50,7 @@ Do the following:
#. Download the packages either using Git_ or as a zip-package.
#. Add the ``osm2city`` directory to your ``PYTHONPATH``. You can read more about this at https://docs.python.org/2/using/cmdline.html#envvar-PYTHONPATH.
#. Create soft links between as described in the following subchapter.
#. Create soft links between as described in the following sub-chapter.
.. _Git: http://www.git-scm.com/
......
......@@ -18,7 +18,7 @@ View a List of Parameters
The final truth about parameters is stored in ``parameters.py`` — unfortunately the content in this chapter might be out of date (including default values).
It might be easiest to read ``parameters.py`` directly. Phython code is easy to read also for non-programmers. Otherwise you can run the following to see a listing:
It might be easiest to read ``parameters.py`` directly. Python code is easy to read also for non-programmers. Otherwise you can run the following to see a listing:
::
......@@ -77,7 +77,7 @@ NO_ELEV Boolean False Set this to
developers to check generated scenery objects a bit faster not caring about
the vertical position in the scenery.
ELEV_MODE String n/a Choose one of "FgelevCaching", 2Fgelev", "Telnet", "Manual". See chapter
ELEV_MODE String n/a Choose one of "FgelevCaching", "Fgelev", "Telnet", "Manual". See chapter
:ref:`Available Elevation Probing Mode<chapter-elev-modes-label>` for more
details.
......
......@@ -20,7 +20,7 @@ It is recommended to start with generating scenery objects for a small area arou
Creating a Directory Structure
==============================
The following shows a directory structure, which one of the deverlopers is using — feel free to use any other structure.
The following shows a directory structure, which one of the developers is using — feel free to use any other structure.
::
......@@ -177,9 +177,9 @@ There are a few different possibilities to generate elevation data, each of whic
The two methods using ``Fgelev`` require a bit less manual setup and intervention, however you need to be able to compile a C++ class with dependencies. ``FgelevCaching`` might give the best accuracy, be fastest and most automated. However memory requirements, speed etc. might vary depending on your parameter settings (e.g. ``ELEV_RASTER_*``) and the ratio between scenery area and the number of OSM objects.
All methods apart from ``FgelevCaching`` will generate a file ``elev.out`` to be put into your input folder. ``FgelevCaching`` can also keep data cached (in a file called ``elev.pkl`` in the input directory) — so from a chaching perspective there is not much of a difference [#]_.
All methods apart from ``FgelevCaching`` will generate a file ``elev.out`` to be put into your input folder. ``FgelevCaching`` can also keep data cached (in a file called ``elev.pkl`` in the input directory) — so from a caching perspective there is not much of a difference [#]_.
The next chapters describe each elevation probing meode and link to a :ref:`detailed description of subtasks <chapter-subtasks-label>`.
The next chapters describe each elevation probing mode and link to a :ref:`detailed description of sub-tasks <chapter-subtasks-label>`.
.. FIXME: provide runtime data for each mode for comparison
......@@ -248,7 +248,7 @@ This mode can be used with older FlightGear versions and is save, but also needs
#. :ref:`Copy file elev.out <chapter-elev.out-copy-label>`
#. :ref:`Unhide scenery objects <chapter-unhide-label>`
While FlightGear is running, open menu ``Debug/Nasal Console`` in the FlighGear user interface. Write ``elev.get_elevation()`` and hit the "Execute" button. Be patient as it might seem as nothing is happening for many minutes. At the end you might get output like the following in the ``Nasal Console``:
While FlightGear is running, open menu ``Debug/Nasal Console`` in the FlightGear user interface. Write ``elev.get_elevation()`` and hit the "Execute" button. Be patient as it might seem as nothing is happening for many minutes. At the end you might get output like the following in the ``Nasal Console``:
::
......@@ -280,7 +280,7 @@ Compile Patched fgelev
``osm2city`` comes with a patched version of ``fgelev``, which by means of a parameter ``expire`` drastically can improve the speed and avoid hanging. The patched version can be found in
``osm2city`` subdirectory ``fgelev`` as source file ``fgelev.cxx``. Before using it, you need to compile it and then replace the version, which comes with your FlightGear installation in the same directory as ``fgfs``/``fgfs.exe``. In Windows it might be in "D:/Program Files/FlightGear/bin/Win64/fgelev.exe".
Compilation depends on your operating system and hardware. On a Linux Debian derivate you might use the following:
Compilation depends on your operating system and hardware. On a Linux Debian derivative you might use the following:
#. Download and compile according to `Scripted Compilation on Linux Debian/Ubuntu`_
......@@ -495,7 +495,7 @@ Copy File elev.out
Finally copy file ``elev.out`` from the path specified in the edited ``elev.nas`` file (see :ref:`Adapt File elev.nas <chapter-elev.nas-label>`) to the input directory (e.g. ``fg_customscenery/projects/LSZS``).
-----
.. [#] Failing to do so might result in an exception, where the stack trace might contain something like ``KeyError: 1227981870``.
......
......@@ -8,7 +8,7 @@ Using Generated Scenery
Adding to FG_SCENERY Path
=========================
You need to add the directory containing the ``Objects`` folder (i.e. not the ``Objects`` folder itself) to the paths, where FlightGear searches for scenery. You can to this eithr through the command line option ``--fg-scenery`` or setting the FG_SCENERY environment variable. This is extensively described in the ``README.scenery`` and the ``getstart.pdf`` [#]_ documents found in $FG_ROOT/Docs as part of your FlightGear installation.
You need to add the directory containing the ``Objects`` folder (i.e. not the ``Objects`` folder itself) to the paths, where FlightGear searches for scenery. You can to this either through the command line option ``--fg-scenery`` or setting the FG_SCENERY environment variable. This is extensively described in the ``README.scenery`` and the ``getstart.pdf`` [#]_ documents found in $FG_ROOT/Docs as part of your FlightGear installation.
If you followed the :ref:`directory structure <chapter-creating-directory-structure-label>` presented in chapter :ref:`Preparation <chapter-preparation-label>` and we take the example of ``LSZS`` then you would e.g. use the following command line option:
......@@ -22,7 +22,13 @@ If you followed the :ref:`directory structure <chapter-creating-directory-struct
Copy Textures
=============
FIXME
If you are using ``osm2city.py`` to generate buildings or ``roads.py`` to generate roads, then you need to have the content of the ``tex`` linked from ``osm2city-data`` copied or linked into all scenery sub-folders, where there are ``*.stg`` files. There are two possibilities:
#. Do it manually. In this case you can choose whether to create links or hard copies. If you want to distribute the generated scenery objects, then you must copy the whole directory. E.g. ``/home/pingu/fg_customscenery/LSZS/Objects/e000n40/e009n46/tex`` in the example used previously.
#. Use ``copy_texture_stuff.py`` to do it automatically. E.g.
::
/usr/bin/python2.7 /home/pingu/development/osm2city/copy_texture_stuff.py -f LSZS/params.ini
.. _chapter-lod-label:
......@@ -63,7 +69,7 @@ In FlightGear you can influence the actual distance (in meters) for the respecti
Disable Urban Shader and Random Buildings
=========================================
There is no point in having both OSM building scenery objects and dynamically generated buildings in FlightGear. Therefore it is recommended to turn off the ranom building and urban shader features in FlightGear. Please be aware that this will also affect those areas in FlightGear, where there are no generated scenery objects from OSM.
There is no point in having both OSM building scenery objects and dynamically generated buildings in FlightGear. Therefore it is recommended to turn off the random building and urban shader features in FlightGear. Please be aware that this will also affect those areas in FlightGear, where there are no generated scenery objects from OSM.
There are two possibilities to disable random buildings:
......@@ -83,9 +89,9 @@ In the same dialog press the ``Shader Options`` button and set the slider for ``
Change Materials to Hide Urban Textures
=======================================
FlightGear allows to change the texture used for a given landclass. More information is available in ``$FG_ROOT/Docs/README.materials`` as well as in the FlightGear Forum thread regarding `New Regional Textures`_. There is not yet a good base texture replacing the urban textures. However many users find it more visually appealing to use a uniform texture like grass under the generated buildings etc. instead of urban textures (because urban textures interfere visually with ways, houses etc.). A drawback of using diferent textures is the absence of trees — owever in many regions of the world there are lot of trees / vegetation in urban areas.
FlightGear allows to change the texture used for a given land-class. More information is available in ``$FG_ROOT/Docs/README.materials`` as well as in the FlightGear Forum thread regarding `New Regional Textures`_. There is not yet a good base texture replacing the urban textures. However many users find it more visually appealing to use a uniform texture like grass under the generated buildings etc. instead of urban textures (because urban textures interfere visually with ways, houses etc.). A drawback of using different textures is the absence of trees — however in many regions of the world there are lot of trees / vegetation in urban areas.
E.g. for the airport ``LSZS`` in Engadina in Switzerland you would have to go to ``$FG_ROOT/Materials/regions`` and edit file ``europe.xml`` in a text editor: add name-tags for e.g. ``BuiltUpCover``, ``Urban``, ``Town``, ``SubUrban`` to a material as shown below and comment out the existing name-tags using ``<!-- -->``. Basically all name-tags, which relate to a material using ``<effect>Effects/urban</effect>``. The outcome before and after edit (you need to restart FlightGear in between!) can be seen in the screenshots below (for illustration purposes the buildings and roads do not have textures).
E.g. for the airport ``LSZS`` in Engadin in Switzerland you would have to go to ``$FG_ROOT/Materials/regions`` and edit file ``europe.xml`` in a text editor: add name-tags for e.g. ``BuiltUpCover``, ``Urban``, ``Town``, ``SubUrban`` to a material as shown below and comment out the existing name-tags using ``<!-- -->``. Basically all name-tags, which relate to a material using ``<effect>Effects/urban</effect>``. The outcome before and after edit (you need to restart FlightGear in between!) can be seen in the screenshots below (for illustration purposes the buildings and roads do not have textures).
::
......@@ -116,7 +122,7 @@ E.g. for the airport ``LSZS`` in Engadina in Switzerland you would have to go to
.. image:: fgfs_materials_cropgrass.png
Depending on your region and your shader settings you might want to search for e.g. ``GrassCover`` in file ``global-summer.xml`` instead (shown in screenshot below with ALS_ and more random vegetation). However be aware that you still need to outcomment in e.g. ``europe.xml`` and within ``global-summer.xml``.
Depending on your region and your shader settings you might want to search for e.g. ``GrassCover`` in file ``global-summer.xml`` instead (shown in screenshot below with ALS_ and more random vegetation). However be aware that you still need to comment out in e.g. ``europe.xml`` and within ``global-summer.xml``.
.. image:: fgfs_materials_grass.png
......@@ -130,12 +136,10 @@ Depending on your region and your shader settings you might want to search for e
Consider Sharing Your Generated Scenery Objects
===============================================
Although this guide hopefully helps, not eerybody might be able to generate scenery objects wih ``osm2city`` related programs. Therefore please consider sharing your generated scenery objects. You can do so by announcing it in the Sceneries_ part of the FlightGear Forums and linking from the bottom of the osm2city related Wiki_ article.
Although this guide hopefully helps, not everybody might be able to generate scenery objects wih ``osm2city`` related programs. Therefore please consider sharing your generated scenery objects. You can do so by announcing it in the Sceneries_ part of the FlightGear Forums and linking from the bottom of the osm2city related Wiki_ article.
.. _Sceneries: http://forum.flightgear.org/viewforum.php?f=5
.. _Wiki: http://wiki.flightgear.org/Osm2city.py
-----
.. [#] As of beginning of 2016: chapters 3.1, 4.1, 4.5
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment