Writer Overview
The OSM writer will write out features as nodes, ways, and relations into an OSM file. Lines and areas that have more than 2000 points will be split into multiple ways, each having at most 2000 nodes. Duplicated nodes are also handled to make sure no duplicate OSM nodes are written out. Conversion of coordinates into WGS84/LL84 is done automatically into the writer.
OSM Tags Handling
Feature types in OSM writer do not have any predefined schema. User attributes that are specified on the feature type will be used as tags in the OSM elements of the output file, if such attributes exist on the features or geometry traits of the geometry.
Example: A feature type named “amenity” has 3 tags that OSM writer will create if the features have such attributes:
OSM_2_DEF amenity \
amenity xml_char(17) \
building xml_char(4) \
source xml_char(19)
OSM Elements Writing
There are common attributes on each OSM element that the writer will write out if feature attributes or geometry traits exist: id, uid, timestamp, visible, changeset
, and version
.
If an OSM node, point or relation does not have an id
attribute found on geometry or feature, then a negative value will be assigned to each element.
OSM node
All geometries that contain points (including line, polygon, donut or any multi geometry) will have their coordinates written out as OSM nodes.
Tags on the OSM node will only be written out if there are user attributes defined on feature types and such attributes exist on the feature as attributes or point-level geometry as traits.
In the case where there are multiple sources of the same node (for example, from a point and a line), only the first node with positive ID is written out. If there are no nodes with positive ID, then the first node the writer encounters will be written out.
OSM way
All linear geometries will have corresponding OSM way elements written out. The writer does not check for duplicated lines.
OSM relation
A feature is written out as an OSM relation if osm_relation_type
attribute exist, and the value of such attribute determines the type of relation.
Tags that are associated with the relation must be specified as attributes on the features. Tags for the members (OSM ways and nodes) must be specified as traits on each geometry part of feature.
Multipolygon relation
OSM writer also writes out multipolygon relation from donut or multipolygon geometry, even if osm_relation_type
attribute does not exist on the feature.
The multipolygon relation that is written out follows the rules and examples described in http://wiki.openstreetmap.org/wiki/Relation:multipolygon
Other relation
A feature with null or no geometry can be used to describe an OSM relation by specifying the following attributes:
osm_relation_type
|
The type of OSM relation to be written out |
member{}.ref, member{}.role and member{}.type list |
Each attribute describes the reference id, role and type of members in relation. The length of list attributes must be equal; otherwise, no relation will be written out. |
A feature with collection geometry can be written out as any relation provided that osm_relation_type
is specified. All non-null geometry parts will be written out as ways and/or nodes and included as members in the relation. The attributes of <member>
element (role
and type
) must be specified as traits to the geometry parts. The ref attribute of <member>
is populated from the ID of the ways or nodes that have been written out.