Elements (also data primitives) are the basic components in OpenStreetMap from which everything else is defined. These consist of Nodes (which define a point in space), Ways (which define a linear features and areas), and Relations - with an optional role - which are sometimes used to define the relation between other elements. All of the above can have one of more associated tags.
Main article: node
A node defines a single geospatial point using a latitude and longitude. A third optional dimension, altitude, can be recorded; key:ele and a node can also be defined at a particular layer=* or level=*. Nodes can be used to define standalone point features and also be used to define the path of a way.
A town or village can be represented by a node with place=* and name=*. A node may also be used without tags as part of a way and where used in this way does not need to have any tags. In some cases nodes along a way do have tags (such as power=tower to represent a tower or pylon along a power line or building=entrance to identify the way into a building.
Main article: Way
The second primitive element is the way which is an ordered list of between 2 and 2000 nodes. Ways can be used to represent linear features (vectors) or polygons (areas).
A way can be included as member of relation and may have an associated Role. Ways of more that 2000 nodes will need to be split into two or more shorter ways. Where ways meet, for example at a road junction, they should share a node. Ways may be 'open' (where they do not share a first and last node) or 'closed' where they do. In some cases a closed way will be interpreted as a 'closed polyline' and in other instances as an Area and in some cases as both a closed polyline and an area. It is necessary to interpret the tags to review the tags associated with the way and in some cases the tags associated with any relations associated with the way.
An open Polyline is an ordered interconnection of between 2 and 2000 nodes describing a linear feature which does not share a first and last node. Many roads, streams and railway lines are described as open polylines.
Main article: Area
An Area (also polygon) is an enclosed filled area of territory defined as a closed Way. Closed ways with some tags such as landuse=* are assumed to be areas, others, such as highway=footway are assumed to be closed Polylines unless they also have a area=yes tag.
Areas can also be described using the Multipolygon relation.
Main article: Relation
A Relation consists of an ordered list of nodes, ways and sometimes also other relations as member of the new relation. The relation can have tags and each element can also optionally also have a defined role within the relation. A single element may appear multiple times in a relation and a relation can be included as member of another relation.
Main article: Tag
A Tag should perhaps not be regarded as an "Element" in it's own right, but rather it is a small unit of data attached to one of the above elements. A tag consists of two free format textual fields, a 'key' and a 'value', each of which are Unicode strings of up to 255 characters. There are however many conventions on how individual features are best described. By way of example, a residential road is defined using a key of 'highway' and a value of 'residential' to form the tag highway=residential. Keys may in addition use a namespace to further refine their purpose, so that maxspeed:winter=* indicates that there is a separate speed limit during the winter.
Nodes, Ways and Relations have the following attributes in common i.e. we store these fields for every element.
|id||integer||Used for identifying the element. Element types have their own ID space, so there could be a node with id=100 and a way with id=100, which are unlikely to be related or geographically near to each other.|
|user||string||The display name of the user who last modified the object. A user can change their display name|
|uid||integer||The numeric user id. of the user who last modified the object. The user id. number will remain constant.|
|timestamp||W3C Date and Time Formats||time of the last modification|
|whether the object is deleted or not in the database, if visible="false" then the object should only be returned by history calls.|
|version||integer||The edit version of the object. Newly created objects start at version 1 and the value is incremented by the server when a client uploads a new version of the object. The server will reject a new version of an object if the version sent by the client does not match the current version of the object in the database.|
|changeset||integer||The changeset in which the object was created or updated.|
Of course in addition we store the tags, and also a full editing history of every element.