From 615520b51ff270fb2e8723c8ad2ac310a8f20274 Mon Sep 17 00:00:00 2001 From: Oliver Tonnhofer Date: Thu, 7 May 2015 16:40:50 +0200 Subject: [PATCH] update docs --- docs/conf.py | 4 +- docs/index.rst | 7 +-- docs/install.rst | 14 ++++++ docs/mapping.rst | 106 ++++++++++++++++++++++++++++++++++++++++------ docs/tutorial.rst | 67 +++++++++++++++++++++-------- 5 files changed, 162 insertions(+), 36 deletions(-) create mode 100644 docs/install.rst diff --git a/docs/conf.py b/docs/conf.py index 6fe6042..bf47ce2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -44,7 +44,7 @@ master_doc = 'index' # General information about the project. project = u'Imposm3' -copyright = u'2014, Oliver Tonnhofer' +copyright = u'2015, Oliver Tonnhofer' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -127,7 +127,7 @@ html_theme = 'sphinxdoc' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +# html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied diff --git a/docs/index.rst b/docs/index.rst index 428fcfa..9859b48 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,7 +1,7 @@ Imposm3 ======= -Imposm3 is an importer for OpenStreetMap data. It reads PBF files and can import the data into PostgreSQL/PostGIS databases. +Imposm3 is an importer for OpenStreetMap data. It reads PBF files and imports the data into PostgreSQL/PostGIS databases. It is designed to create databases that are optimized for rendering/tile/map-services. It is developed and supported by `Omniscale `_ and is released as open source under the `Apache Software License 2.0 `_. Imposm3 is a rewrite of Imposm 2 with even better performance and support for (minutely) diff updates. @@ -11,7 +11,7 @@ Features -------- Custom database schemas - It creates tables for different data types. This allows easier styling and better performance for rendering in WMS or tile services. + It creates separate tables for different feature types. This allows easier styling and better performance for rendering in tile or WMS services. Multiple CPU/core support Imposm is parallel from the ground up. It distributes parsing and processing to multiple CPUs/cores. @@ -29,7 +29,7 @@ Generalized tables It can automatically create tables with lower spatial resolutions, perfect for rendering large road networks in low resolutions for example. Limit to polygons - It can limit imported geometries to polygons from Shapefiles or GeoJSON. + It can limit imported geometries to polygons from GeoJSON. HStore support Don't know which tags you will be needing? Store all tags in an `HStore column `_. @@ -55,6 +55,7 @@ Contents .. toctree:: :maxdepth: 2 + install tutorial mapping diff --git a/docs/install.rst b/docs/install.rst new file mode 100644 index 0000000..e85806b --- /dev/null +++ b/docs/install.rst @@ -0,0 +1,14 @@ +Installation +============ + +Binary +------ + +There are no official releases, but you find development builds at . +These builds are for x86 64bit Linux and require *no* further dependencies. Download, untar and start `imposm3`. +(Note: These binaries require glibc >= 2.15 at the moment. Ubuntu 12.04 is recent enough, Debian 7 not.) + +Source +------ + +Please see `the README for build instructions `_. \ No newline at end of file diff --git a/docs/mapping.rst b/docs/mapping.rst index 2c4bbe9..96d6135 100644 --- a/docs/mapping.rst +++ b/docs/mapping.rst @@ -1,7 +1,7 @@ Data Mapping ============ -The data mapping defines which `OSM feature types `_ should be imported in which table. The mapping is described with a JSON file. +The data mapping defines which `OSM feature types `_ should be imported in which table. The mapping is a JSON file. See `example-mapping.json `_ for an example. @@ -9,7 +9,7 @@ See `example-mapping.json `_. + +The optional ``sql_filter`` can be used to limit the rows that will be generalized. You can use it to drop geometries that are to small for the target map scale. + +:: + + "generalized_tables": { + "waterareas_gen_50": { + "source": "waterareas", + "sql_filter": "ST_Area(geometry)>50000.000000", + "tolerance": 50.0 + }, + + + +.. _tags: + +Tags +---- + +Imposm caches only tags that are required for a ``mapping`` or for any ``columns``. This keeps the cache small as it does not store any tags that are not required for the import. You can change this if you want to import all tags, e.g with the ``hstore_tags`` column type. + +Add ``load_all`` to the ``tags`` object inside your mapping JSON file. You still manually can exclude single tags with the ``exclude`` option. + +To load all tags exepct ``created_by`` and ``source``:: + + "tags": { + "load_all": true, + "exclude": [ + "created_by", + "source" + ] + }, + diff --git a/docs/tutorial.rst b/docs/tutorial.rst index e73a367..3a9cbf9 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -1,7 +1,16 @@ Tutorial ======== -The import process is separated into multiple steps. You can combine most steps in one command, but we will explain each one in detail here. +The ``imposm3`` command has multiple sub-commands. This tutorial will explain the most important sub-commands: ``import`` and ``diff``. + +Use the name of the sub-command as the second argument to start it. For example, to print the installed version number call the ``version`` sub-command:: + + $ imposm3 version + 0.1dev-20150507-7ddba33 + + +Preparation +^^^^^^^^^^^ Create database --------------- @@ -23,7 +32,7 @@ You also need to make sure that the user is allowed to access the database from host all all 127.0.0.1/32 md5 -(Don't forget to reload PostgreSQL after changes.) +(Don't forget to reload PostgreSQL after these changes.) The following command should print the PostGIS version, if everything was successful:: @@ -32,36 +41,40 @@ The following command should print the PostGIS version, if everything was succes Please `refer to the PostGIS `_ and `PostgreSQL documentation `_ for more information. +Importing +^^^^^^^^^ + +The import process is separated into multiple steps. +You can combine most steps in one command, but we will explain each one in detail here. + Reading ------- -The first step is the reading of the OpenStreetMap data. Building the way and relation geometries requires random access to all nodes and ways, but this is not supported by the OSM PBF data format. Imposm needs to store all nodes, ways and relations in an intermediary data store that allows random access to these elements. It does this on-disk to keep the memory usage of Imposm low. Having lot's of memory will still speed the import up, because your OS will use all free memory for caching of these files. +The first step is the reading of the OpenStreetMap data. Building the way and relation geometries requires random access to all nodes and ways, but this is not supported by the OSM PBF data format. Imposm needs to store all nodes, ways and relations in an intermediary data store that allows random access to these elements. It does this on-disk to keep the memory usage of Imposm low. Having lots of memory will still speed the import up, because your OS will use all free memory for caching of these files. Imposm uses LevelDB key-value databases for this, which are fast and compact. - Imposm needs to know which OSM elements you want to have in your database. You can use the provided ``mapping.json`` file for this tutorial, but you should read :doc:`mapping` for more information on how to define your own mapping. To read an extract:: - imposm3 import -mapping mapping.json -read germany.osm.pbf Cache files ~~~~~~~~~~~ -Imposm stores the cache files in `/tmp/imposm3`. You can change that path with ``-cachedir``. Imposm can merge multiple OSM files into the same cache (e.g. when combining multiple extracts) with the ``-appendcache`` option or it can overwrite existing caches with ``-overwritecache``. Imposm will fail to ``-read`` if it finds existing cache files and you don't specify ``-appendcache`` or ``-overwritecache``. +Imposm stores the cache files in `/tmp/imposm3`. You can change that path with ``-cachedir``. Imposm can merge multiple OSM files into the same cache (e.g. when combining multiple extracts) with the ``-appendcache`` option or it can overwrite existing caches with ``-overwritecache``. Imposm will fail to ``-read`` if it finds existing cache files and if you don't specify either ``-appendcache`` or ``-overwritecache``. Writing ------- -The second step is the writing of OpenStreetMap features into the database. It reads the features from the cache from step one, builds all geometries and imports them into the according tables. It overwrites existing tables, :ref:`see below ` how to work with existing datasets. +The second step is the writing of OpenStreetMap features into the database. It reads the features from the cache from step one, builds all geometries and imports them into the according tables. It overwrites existing tables, :ref:`see below ` for more information on how to update your database in production. After the import, it creates the generalized tables and indicies. -You need to tell Imposm the connection parameters of your database. The ``-connection`` option takes a URL in the format ``postigs://username:password@host:port/databasename``. +You need to tell Imposm the connection parameters of your database. The ``-connection`` option takes a URL in the format ``postgis://username:password@host:port/databasename``. In our example: :: @@ -70,20 +83,20 @@ In our example: You can combine reading and writing:: - imposm3 import -mapping mapping.json -read -write -connection postgis://osm:osm@localhost/osm hamburg.osm.pbf + imposm3 import -mapping mapping.json -read hamburg.osm.pbf -write -connection postgis://osm:osm@localhost/osm Limit to ~~~~~~~~ -You can limit the imported geometries to polygon boundaries. You can load the limit-to polygons from GeoJSON files. Linestrings and polygons will be clipped exactly at the limit to geometry. The geometries need to be in EPSG:4326. +You can limit the imported geometries to polygon boundaries. You can load the limit-to polygons from GeoJSON files. Line strings and polygons will be clipped exactly at the limit to geometry. The GeoJSON needs to be in EPSG:4326. :: imposm3 import -mapping mapping.json -connection postgis://osm:osm@localhost/osm -read europe.osm.pbf -write -limitto germany.geojson -``-limitto`` also controls which elements are stored in the internal cache. You can configure a buffer around the ``-limitto`` geometry with the ``-limittocachebuffer`` to add more elements to your cache. This is necessary for getting complete polygons and linestrings at the boundaries of your ``-limitto`` geometry. +``-limitto`` also controls which elements are stored in the internal cache. You can configure a buffer around the ``-limitto`` geometry with the ``-limittocachebuffer`` to add more elements to your cache. This is necessary for getting complete polygons and line strings at the boundaries of your ``-limitto`` geometry. Config file ~~~~~~~~~~~ @@ -133,17 +146,17 @@ You can combine reading, writing and optimizing:: Deploy production tables ------------------------ -Since Imposm overwrites existing tables on import, it is recommended to use different schemas for import and for production. +Since Imposm overwrites existing tables on import (``-write``), it is recommended to use different schemas for import and for production. Imposm imports all tables into the ``import`` schema by default. For example, after the import the table ``osm_roads`` is accessible as ``import.osm_roads`` and not as ``osm_roads`` or ``public.osm_roads``. .. note:: Database schemas are a feature of a few databases including PostgreSQL to define multiple namespaces for tables. Don't mistake this for database schemas (as in data model) which are discussed in doc:`mapping`. -Imposm can `deploy` all imported tabels by updating the schema of the tables. -To move all tables form ``import`` the default schema ``public``:: +Imposm can `deploy` all imported tables by updating the schema of the tables. +To move all tables form ``import`` to the default schema ``public``:: imposm3 import -mapping mapping.json -connection postgis://osm:osm@localhost/osm -deployproduction -This will also move all existing Imposm tables from the ``public`` to the ``backup``. +This will also remove all existing Imposm tables from ``backup`` and it will moves tables from the ``public`` to the ``backup`` schema. You can revert a deploy (moving ``public`` tables to ``import`` and ``backup`` tables to ``public``):: @@ -161,7 +174,7 @@ Other options Projection ~~~~~~~~~~ -Imposm uses the the web mercator projection (``EPSG:385``) for the imports. You can change this with the ``--srid`` option. At the moment only EPSG:3857 and EPSG:4326 are supported. +Imposm uses the the web mercator projection (``EPSG:3857``) for the imports. You can change this with the ``-srid`` option. At the moment only EPSG:3857 and EPSG:4326 are supported. Diff @@ -173,6 +186,24 @@ Imposm needs to cache a few more information to be able to update the database f imposm3 import -config config.json -read hamburg.osm.pbf -write -diff -Read :doc:`diff` for more information. +Read :ref:`diff` for more information. -.. note:: Each diff import requires access to the cache files from this initial import. So it is a good idea to set ``-cachedir`` to a more premanent location then `/tmp/`. \ No newline at end of file +.. note:: Each diff import requires access to the cache files from this initial import. So it is a good idea to set ``-cachedir`` to a premanent location instead of `/tmp/`. + + +.. _diff: + +Updating +^^^^^^^^ + +Imposm allows you to update an existing database by importing changes from an `OSM changes file `_. Changes files contain all edits made to the OSM dataset in a defined time-range. These files are `available at planet.openstreetmap.org `_. + +The ``diff`` sub-command requires similar options as the ``import`` sub-command. You can pass one or more XML changes files to ``diff``, instead of a PBF file for the ``-read`` option. + +To update an existing database with three change files:: + + imposm3 diff -config config.json changes-1.osc.gz changes-2.osc.gz changes-3.osc.gz + +Remember that you have to make the initial import with the ``-diff`` option. See above. + +.. note:: You should not make changes to the mapping file after the initial import. Changes are not detected and this can result aborted updates or incomplete data.