RU:Osmosis

From OpenStreetMap Wiki
Jump to: navigation, search
В процессе перевода +/-
Эта страница находится в процессе перевода или помечена для этой цели, поэтому может содержать пропуски, ошибки и непереведённые фрагменты. Исходная статья – Osmosis.
Если вы знаете английский, то можете помочь нам, переведя часть оригинальной статьи. Общие сведения о переводе статей на русский язык можно найти здесь.

Вы можете закончить перевод

Help
Available languages
Deutsch English Français Italiano 日本語 Русский ‪中文(简体)‬
Подразделы
Установка
Руководство пользователя
Примеры
Разработка
Создание модулей

Osmosis приложение java для командной строки, предназначенное для обработки данных OSM. Этот инструмент содержит набор модулей, которые могут работать в цепочке, чтобы выполнять сложные операции. Например он имеет компоненты для чтения из базы данных и из файла, компоненты для записи в базу данных и в файл, компоненты для доставки и применения пакетов правок к источникам данных, имеет компоненты для сортировки данных, и т.д. Он был написан таким образом, чтобы было легко добавлять новые функции без переделки общих задач, таких как обработка базы данных или файла.

Некоторые примеры того, что может делать это средство:

Contents

Текущее состояние

Osmosis is in a state where the majority of the codebase is unlikely to change drastically. New functionality will be introduced over time in the form of new tasks and plugins but existing functionality is unlikely to be removed. All bug reports welcome. Осмос находится в состоянии, когда большинство кодов базы вряд ли радикально изменится. Новые функциональные возможности будут введены с течением времени в виде новых задач и модулей, но существующие функции вряд ли будут удалены. Все сообщения об ошибках - приветствуются.

Текущая выпущенная версия поддерживает обе модели данных OSM - и 0.5, и 0,6. API v0.6 полностью поддерживается в кодах базы в svn. Новый стабильный релиз будут выпущен, как только будет принято решение о его развертывании.

В настоящее время мы занимаемся проблемами проверки данных. И высока вероятность того, что обработка xml будет сбоить из-за несоответствия правилам. Чтобы избежать появления неверных символов в xml файле, в новой версии (0.31.2) исправлено решение задач, связанных с записью xml. Теперь файлы, произведенные в Osmosis, поддерживают xml-utf8.

Скачивание

Последние версии

Внимание! Здесь находится версия 0.31. Есть более свежая версия - смотри раздел "Исправление неработающего UTF8".

Последние версии в двоичных кодах:

Последние полные версии:

Исправление неработающего UTF8

Файл с решённым вопросом поддержки набора символов UTF8 находится здесь:

Ночная сборка

Ночную сборку можно скачать здесь: http://dev.openstreetmap.org/~bretth/osmosis-build/

Java 1.5

Версии, совместимые с java5:

Схема DB (база данных)

Если вы желаете создать локальную схему, используйте сценарий (скрипт) для создания схемы (mysql и postgresql) соответствующего продукта (потребуется ночная сборка osmosis), то ищите здесь:

Subversion

Хранилище Subversion находится здесь: http://svn.openstreetmap.org/applications/utils/osmosis/

(Подробности читайте в инструкции Osmosis/Installation.)

Использование

Подробности использования

Полное руководство с подробным описанием, как использовать Osmosis, вы найдёте в Osmosis/Detailed Usage.

Примеры использования

(Подробности смотрите на подстраницах Osmosis/Examples.)

Импортировать файл планеты в локальную базу данных MySQL.

osmosis --read-xml file="planet.osm" --write-mysql host="x" database="x" user="x" password="x"

Экспортировать файл планеты из локальной базы данных MySQL.

osmosis --read-mysql host="x" database="x" user="x" password="x" --write-xml file="planet.osm"

Извлечь пакет правок, проанализировав два файла планеты.

osmosis --read-xml file="planet1.osm" --read-xml file="planet2.osm" --derive-change --write-xml-change file="planetdiff-1-2.osc"

Извлечь пакет правок, проанализировав файл планеты и базу данных.

osmosis --read-xml file="planet1.osm" --read-mysql host="x" database="x" user="x" password="x" --derive-change --write-xml-change file="planetdiff-1-2.osc"

Применить пакет правок на файл планеты.

osmosis  --read-xml-change file="planetdiff-1-2.osc" --read-xml file="planet1.osm" --apply-change --write-xml file="planet2.osm" or
osmosis  --read-xml file="planet1.osm" --read-xml-change file="planetdiff-1-2.osc" --apply-change --write-xml file="planet2.osm" for the older version

Отсортировать содержимое файла планеты.

osmosis --read-xml file="data.osm" --sort type="TypeThenId" --write-xml file="data-sorted.osm"

The above examples make use of the default pipe connection feature, however a simple read and write planet file command line could be written in two ways. The first example uses default pipe connection, the second explicitly connects the two components using a pipe named "mypipe". The default pipe connection will always work so long as each task is specified in the correct order. Each task pushes its output stream(s) onto a stack, and each task that requires input stream(s) takes them from the stack. This stack-based approach is the reason why the above "--apply-change" example first reads the change file, then the data file - the --apply-change task will then first retrieve the data file from the stack and then the change file.

osmosis --read-xml file="planetin.osm" --write-xml file="planetout.osm"
osmosis --read-xml file="planetin.osm" outPipe.0="mypipe" --write-xml file="planetout.osm" inPipe.0="mypipe"

Извлечь область, основываясь на файле, описывающем многоугольник Osmosis/Polygon Filter File Format:

osmosis --read-xml file="planet-latest.osm" --bounding-polygon file="country2pts.txt" --write-xml file="germany.osm"

Extract only those ways that have certain tags. Specifying --used-node only extracts those nodes that are used in the filtered ways. Relations stay untouched.

osmosis --read-xml city.osm --way-key-value keyValueList="railway.tram,railway.tram_stop" --used-node --write-xml city_tram.osm

On larger files (e.g. a planet file), this may result in a segfault due to memory limitations. In this case, passing idTrackerType=BitSet as a parameter to --used-node may help:

osmosis --read-xml city.osm --way-key-value keyValueList="railway.tram,railway.tram_stop" --used-node idTrackerType=BitSet --write-xml city_tram.osm

Note that --way-key-value and --node-key-value cannot be used in one run. Instead, create two (or more) files in several runs and merge them together afterwards (yes, for n files you need n-1 merge commands):

osmosis --rx 1.osm --rx 2.osm --rx 3.osm --merge --merge --wx merged.osm

Only 0.5 tasks are available from version 0.22 onwards.

Извлечение прямоугольных областей

One of the basic use cases is extracting a smaller subset of OSM XML. You might have downloaded the world OSM (planet.osm) and want to extract some region, or maybe you have a country extract downloaded, but only want one city. The simplest way to do that is by extracting a rectangle.

An example that extracts Nuremberg and some area around it from Germany - or maybe world - OSM:

 bzcat downloaded.osm.bz2 | osmosis\
  --read-xml enableDateParsing=no file=/dev/stdin\
  --bounding-box top=49.5138 left=10.9351 bottom=49.3866 right=11.201 --write-xml file=-\
  | bzip2 > extracted.osm.bz2

This approach uses bzip2 directly for extracting and compressing, as it is claimed to be more effective than the built-in archiver.

The easiest way to get coordinates is to doubleclick the spot you want coordinates for, then click "Permalink" and grab data from URL field.

Getting Help and Reporting Bugs

The best place to get answers to questions on osmosis usage is the osm dev mailing list.

http://lists.openstreetmap.org/listinfo/dev

Please discuss potential bugs on the dev mailing list before creating new tickets. If you're confident you have discovered a bug, it can be logged in the OSM trac system against the "osmosis" component:

http://trac.openstreetmap.org/query?component=osmosis

Смотрите также

Разработка

Details on osmosis development are available at Osmosis/Development. Visit there for documentation on the internal structure of osmosis, design decisions, steps to configuring development environments, etc.

Notes

The minimum supported Java version is 1.6. Osmosis makes use of some java.awt.geom classes that only appeared in 1.6, if these are re-written to use 1.5 functionality it may be possible to return to the previous minimum of 1.5. Osmosis utilises generics and java.util.concurrent features requiring Java 1.5 as a minimum.

A number of tasks produce temporary files that contain serialised java classes to avoid using too much RAM. These files are gzipped to reduce disk space and in many cases improve performance through reduced IO. This will fail on some Java installations where the uncompressed data exceeds 2GB. This is caused by [Bug 5092263]. Upgrading to a later JDK will fix this problem. The only other option is to modify the source code to use uncompressed temporary files, contact me if this is required. This affects the IBM JDK1.5.0 included with IBM Rational tools such as Rational Software Architect. This was fixed in Sun JDK 5.0u8(b01) and Sun JDK 6.0.

The built-in bzip (.bz2) performance is much slower than the gzip (.gz) built in Java one (Java gzip utilizes native code to improve performance). Also recent planet downloads use features of bzip which are not supported by the built-in bzip library (streams). For working with these, and for faster processing of any larger files, it is suggested to use platform's native bzip implementations and read and write files from /dev/stdin and /dev/stdout respectively. ( pbzip2 -d -c planet.osm.bz2 | bin/osmosis --rx /dev/stdin --wx /dev/stdout | gzip -c > planet-same.osm.gz ) See also Osmosis/Examples#Benchmark tests

Personal tools
Namespaces
Variants
Actions
site
Toolbox