# Modeling Guide for 3D Objects - Part 1: Basics (Rules for Validating GML Geometries in CityGML)

## Document History

Version

Date

Author/s

Status

Remarks

0.1.0

01.10.2010

Coors

nicht öffentlich

Erstfassung

0.2.0

14.10.2010

Coors

nicht öffentlich

Solid ergänzt

0.3.0

23.10.2010

Gröger

nicht öffentlich

Verschmelzung mit Paper Gröger

0.4.0

23.11.2010

Coors

nicht öffentlich

Redaktionelle Änderungen und Ergänzungen zu Planarität von Polygonen

0.5.0

24.11.2010

Gröger

nicht öffentlich

Einarbeitung der Änderungen, die im CityGML-Forum von K.-H. Häfele vorgeschlagen wurden

0.6.0

15.12.2010

Gröger

öffentlich

Einarbeitung der Anregungen von G. Juen

0.7.0

20.01.2012

Karl-Heinz Häfele

nicht öffentlich

Konvertierung in Html, Verschiebung des Kapitel Planarität von Polygonen, Neues Kapitel CompositeSolid

0.7.0 EN

November 2013

Egbert Casper, Karl-Heinz Häfele

public

English Version

0.7.1 EN

November 2014

Egbert Casper

public

0.7.2 EN

November 2017

Egbert Casper

public

Minor editorial changes and completions, License change to Creative Commons BY-NC-SA-4.0

## References

• Cox, S., Daisey, P., Lake, R., Portele, C., Whiteside, A. (2004): OpenGIS Geography Markup Language (GML) Implementation Specification. Version: 3.1.1, OGC 03-105r1,
• Herring J. (2001): The OpenGIS Abstract Specification, Topic 1: Feature Geometry (ISO 19107 Spatial Schema), Open Geospatial Consortium, OGC Document Number 01-101. OGC.
• Gröger, G., Kolbe, T., Czerwinski, A., and Nagel, C. (2008) (Eds.): OpenGIS City Geography Markup Language (CityGML) Encoding Standard, OGC reference number OGC 08-007r1 version 1.0.0, 2008
• Gröger, G., Plümer, L. (2011): How to Achieve Consistency for 3D City Models. Geoinformatica, 15(1):137-165, DOI: 10.1007/s10707-009-0091-6.

## Preliminaries

• The rules refer to GML Version 3.1.
• The rules are based on the validity of the data with regard to the XML-Schema of GML 3.1.
• The rules are restricted to the elements of GML that are used in CityGML (Profile of GML, c.f. Figure 1 and Figure 2).
• If a condition applies to CityGML only (not to GML in general), it is stated explicitly.
 Figure 1: Profile of GML that is used in CityGML (Primitives and Composites)
 Figure 2: Profile of GML that is used in CityGML (Complexes and Aggregates)

## Spatial Reference Systems (SRS)

• Each geometry element (including pos, posList and coordinates) must
• either have a srsName attribute with proper value, or
• inherit the value of the srsName attribute from
• its parent geometries (even it its obtained recursively from the parents of the parents, etc.), or
• the gml:Envelope (or gml:Box) which is the value of the gml:boundedBy property of the parent feature or the parent feature collection (even if it is obtained recursively).
• A local value of a srsName attribute precedes the inherited value of a srsName attribute.
• If in geometries (pos, posList) the dimension of a SRS can not be derived from the SRS without a doubt, the attribute srsDimension must contain the dimension of the SRS.

## Definitions

### Planarity of Polygons

„Surfaces in CityGML are represented by polygons, which define a planar geometry, i.e. the boundary and all interior points are required to be located in one single plane.” (Gröger et al., 2008). The boundary of a Polygon is defined by one or more planar Linear Rings (see gml:Polygon). From practical point of view, Linear Rings that are not exactly planar should be accepted as a valid as well. Intuitively, a Linear Ring R would be defined as planar if there is a plane E with distance less than a given threshold  for all points Pi of R. However, this is true for Linear Rings with small bends and folds as shown in Figure 3 as well.

 Figure 3: : Bends and folds should not appear in planar Linear Rings

In order to avoid such situations, a slightly different definition of planarity of Linear Rings is introduced:

Definition 1: A Linear Ring ${\displaystyle R}$ is planar, if it is a valid Linear Ring and the distance of all points to any plane ${\displaystyle E_{ijk}}$, that is defined by three co-linear points ${\displaystyle P_{i}}$, ${\displaystyle P_{j}}$ and ${\displaystyle P_{k}}$, is less than a given threshold ${\displaystyle \epsilon }$ :

${\displaystyle \forall E_{ijk}\forall P_{a}=dist(P_{a},E_{ijk})\leq \epsilon }$

## gml:posList

• The number of items in the list should correlate with the product of the SRS dimension (usually in CityGML 3) and the number of positions.

## gml:_Curve, gml:LineString

• Only gml:LineStrings are allowed as subtypes of _Curves (rule applies to CityGML only)
• A gml:LineString has linear interpolation.
• For the child elements of a gml:LineString (control points) the following statements must hold true:
• They form a sequence of "pos" (DirectPositionType) or "pointProperty" (PointPropertyType) elements. "pos" elements are control points that belong to this curve only. "pointProperty" elements contain points that may be referenced from other geometries or that reference other points (via XLinks) which are defined in other geometries.
• Alternatively, a gml:LineString can be composed of a "posList" element, providing a compact way of representing coordinates. In that case all control points must belong to the same Curve and must be given in the same SRS. The number of points (Direct Position) must be at least two.
• Each control point in a gml:LineString occurs only once, beside the first and the last one which may both be identical.
• Line segments of a gml:LineString are defined by pairs of two subsequent control points. Those line segments must not intersect mutually and must not have any identical points. Exceptions of that rule are the pairs which consist of an endpoint of one line segment and the start point of the next line segment in the sequence.

## gml:LinearRing

The Linear Ring is the fundamental element to describe 3D geometry in CityGML. Every single polygon of a building geometry is defined by its boundary – the Linear Ring.

A sequence is an ordered list of elements. Unlike a set, order matters, and the exact same elements can appear multiple times at different positions in the sequence. A finite sequence ${\displaystyle a}$ with ${\displaystyle n+1}$ elements is denoted as ${\displaystyle a=(a_{0},a_{1},...,a_{n})}$. The empty sequence ${\displaystyle a=()}$ has no elements..

A finite sequence of points ${\displaystyle R=(P_{0},P_{1},...,P_{n}),n\geq 3,P_{i}=(x_{i},y_{i},z_{i})}$ is a Linear Ring if:

(i) the first and last point ${\displaystyle P_{0}}$ and ${\displaystyle P_{n}}$ represent the same point: ${\displaystyle P_{0}=P_{n}}$ (closeness)

(ii) All points of the sequence besides start and end point are different:

${\displaystyle {\underset {\underset {i\neq k}{\underset {k=0...n-1}{i=0...n-1}}}{\forall }}P_{i}\neq P_{k}}$


(iii) Two edges ${\displaystyle (P_{i},P_{i+1})}$ and ${\displaystyle (P_{k},P_{k+1})}$ ${\displaystyle i=0...(n-1),k=0...(n-1),i\not =k}$ do only intersect in one start-/ endpoint. No other intersection is allowed (no self intersection).

If all points of the sequence are co-planar, the Linear Ring is planar.

Examples:

 ${\displaystyle R=(P_{0},P_{1},P_{2},P_{3},P_{0})}$ with ${\displaystyle P_{0}=(1,1,1)}$ ${\displaystyle P_{1}=(3,1,1)}$ ${\displaystyle P_{2}=(3,3,1)}$ ${\displaystyle P_{3}=(1,3,1)}$ 1 1 1 3 1 1 3 3 1 1 3 1 1 1 1 Figure 4: Planar Linear Ring: definition, GML and graphic representation

Please note: The two Linear Rings ${\displaystyle R_{1}=(P_{0},P_{1},P_{2},P_{3},P_{0})}$ and ${\displaystyle R_{2}=(P_{0},P_{3},P_{2},P_{1},P_{0})}$ are not identical.

 ${\displaystyle R=(P_{0},P_{1},P_{2},P_{3})}$ ${\displaystyle R=(P_{0},P_{1},P_{3},P_{2},P_{0})}$ ${\displaystyle R=(P_{0},P_{1},P_{4},P_{3},P_{2},P_{4},P_{0})}$ No Linear Ring: not closed (see (i) closeness) No Linear Ring:self intersection (see (iii) self-intersection) No Linear Ring: ${\displaystyle P_{4}}$ appears twice in the sequence (see (ii), ${\displaystyle P_{4}=(2,2,1)}$) Figure 5: Examples of non-valid Linear Rings

 ${\displaystyle R=(P_{0},P_{1},P_{2},P_{4},P_{3},P_{0})}$ ${\displaystyle R=(P_{0},P_{1},P_{2},P_{0})}$ Linear Ring, but not planar ${\displaystyle P_{4}=(2,4,0)}$ No Linear Ring: all 3 points are co-linear; self-intersection (see (iii)) Figure 6: Special cases: non-planar and co-linear Linear Ring Elements.

## gml:Polygon

• A Polygon ${\displaystyle S}$ is defined by a planar Linear Ring ${\displaystyle R_{s}}$ (exterior ring).
• A polygon has exactly one exterior ring. In addition, a polygon can have ${\displaystyle n\geq 0}$ interior rings. These interior rings a planar Linear Rings as well. All interior rings and the exterior ring must be on the same plane (within the given tolerance).
• As interior rings define holes in the polygon, they have to be completely included in the area defined by the exterior ring.
 Figure 7: Polygon with correct interior ring (left) and incorrect inner ring (right)
• Interior rings must not overlap other Linear Rings or be included in another Linear Ring (except the exterior Linear Ring).
 Figure 8: Polygon with two correct interior Rings (left) and two interlaced, not correct interior Rings (right)
• Interior rings and the exterior ring may touch each other in a finite number of points. The inner area of the polygon has to be connected.
 Figure 9: Polygon with correct, interior ring touching the outer ring at exactly one point (left) and incorrect interior Ring touching the outer ring at two points and splitting the polygon (right)
• • The order of points of the exterior ring defines the orientation of the polygon. The non co-linear points ${\displaystyle P_{i}}$, ${\displaystyle P_{j}}$ und ${\displaystyle P_{k}}$define the plane ${\displaystyle E(P_{i},P_{j},P_{k})}$. The normal vector ${\displaystyle {\vec {n}}}$ is given by the cross product of the two vectors ${\displaystyle {\vec {P_{i}P_{j}}}}$ and ${\displaystyle {\vec {P_{j}P_{k}}}}$:

${\displaystyle {\vec {n}}={\frac {{\vec {P_{i}P_{j}}}\times {\vec {P_{j}P_{k}}}}{\|{{\vec {P_{i}P_{j}}}\times {\vec {P_{j}P_{k}}}}\|}}}$

Please note: that due to the tolerance of planar Linear Rings, the normal vector can be ambiguous.

Remark: The two Linear Rings ${\displaystyle R_{1}=(P_{0},P_{1},P_{2},P_{3},P_{0})}$ and ${\displaystyle R_{2}=(P_{0},P_{3},P_{2},P_{1},P_{0})}$ define polygons with the same geometric extend but different orientation.

 Figure 10: Polygon with normal vector n

## gml:OrientableSurface

• If the value of the attribute “orientation” of an OrientableSurface is "+", the orientation of the OrientableSurface is identical to the one of the baseSurface. If the value of “orientation is " ", the normal of the OrientableSurface has a direction which is opposite to the normal of the baseSurface. The default value of “orientation” is "+".
• Either the element “baseSurface” references the base surface via a XLink attribute or the element “baseSurface” contains the base surface as child element. The base surface has positive orientation.

## gml:MultiSurface

A MultiSurface is an unstructured set ${\displaystyle M=\lbrace S_{1},S_{2},...S_{n}\rbrace }$ of polygons. No further constraints are defined for a MultiSurface element. It is not necessary that ${\displaystyle M}$ is a connected surface. Orientation of the polygons is arbitrary. By a MultiSurface any existing polygonal boundary representation of a rigid body can be described. Unfortunately, also objects that do not exist in real space can be modeled.

Due to the missing constraints it is recommended that MultiSurface elements should only be used to model non-volumetric parts of the building model as shown in Figure 11. Volumetric parts should be modeled as solids (see gml:Solid)

 Figure 11: Modeling overlapping roof parts (above: complete models, polygons outlined; below: roof polygons exploded) Please note: the left model in Figure 11 is created with a MultiSurface element containing 7 polygons. However, the polygons do not represent a valid boundary of a rigid body. Calculating a volume is not possible. The right model is the same building geometry but modeled with 1 Solid element (7 polygons) and 1 MultiSurface element (2 polygons F6 and F8) as recommended (see CityGML Standard v1.0,p.61)

## gml:CompositeSurface

A set ${\displaystyle C=\lbrace S_{1},S_{2},...,S_{n}\rbrace }$ of polygons is a CompositeSurface for which

1. The intersection of two polygons ${\displaystyle S_{k}}$ and ${\displaystyle S_{l}}$ of ${\displaystyle C}$ is either empty or contains only points ${\displaystyle P}$ and/or edges ${\displaystyle e}$that are part of both Linear Rings.

The polygon ${\displaystyle S}$ is defined by the planar Linear Ring ${\displaystyle R_{k}=(P_{0}^{k},P_{1}^{k},...,P_{n}^{k})}$. The intersection of ${\displaystyle S_{i}}$ and ${\displaystyle S_{k}}$ equals
${\displaystyle S_{i}\cap S_{k}={\begin{cases}\emptyset \\\lbrace Q_{0},Q_{1},...,Q_{m}\rbrace ,Q_{j}=P_{k}^{i}\\\lbrace e_{0},e_{1},...,e_{m}\rbrace ,e_{j}={\overline {P_{i}^{k}P_{i+1}^{k}}}\end{cases}}}$

1. Every edge ${\displaystyle e_{k}={\overline {P_{i}^{k}P_{i+1}^{k}}}}$ of a Linear Ring ${\displaystyle R_{k}=(P_{0}^{k},P_{1}^{k},...,P_{n}^{k})}$ , defining a polygon ${\displaystyle S_{k}\in C}$ is used exactly once as an edge ${\displaystyle e_{l}={\overline {P_{j}^{l}P_{j+1}^{l}}}}$ in a Linear Ring ${\displaystyle R_{l}=(P_{0}^{l},P_{1}^{l},...,P_{m}^{l})}$ defining another polygon ${\displaystyle S_{l}\in C}$ with ${\displaystyle P_{i}^{k}=P_{j+1}^{l}}$ and ${\displaystyle P_{i+1}=P_{j}^{l}}$.
2. All polygons in ${\displaystyle C}$ are oriented such that the normal vectors of neighbouring polygons point to the same direction.
3. The union of all polygons in ${\displaystyle C}$ without the edges or points where the polygons touch, is isomorphic to a polygon.

It follows from (i) and (ii) that the surface defined by ${\displaystyle C}$ , must not contain any overlapping or penetrating polygons, that is, polygons touch at most at points or edges.

## gml:Solid

A solid geometry represents a rigid body. The surface of the solid is defined by a set of polygons with the following properties. The set ${\displaystyle C=\lbrace S_{1},S_{2},...,S_{n}\rbrace }$ of polygons bounds a solid if:

1. The intersection of two polygons ${\displaystyle S_{k}}$ and ${\displaystyle S_{l}}$ of ${\displaystyle C}$ is either empty or contains only points ${\displaystyle P}$ and edges ${\displaystyle e}$ that are part of both Linear Rings. The polygon ${\displaystyle S}$ is defined by the Linear Ring ${\displaystyle R_{k}=(P_{0}^{k},P_{1}^{k},...,P_{n}^{k})}$. The intersection of ${\displaystyle S_{k}}$ and ${\displaystyle S_{l}}$ equals:
${\displaystyle S_{i}\cap S_{k}={\begin{cases}\emptyset \\\lbrace Q_{0},Q_{1},...,Q_{m}\rbrace ,Q_{j}=P_{k}^{i}\\\lbrace e_{0},e_{1},...,e_{m}\rbrace ,e_{j}={\overline {P_{i}^{k}P_{i+1}^{k}}}\end{cases}}}$
2. Every Edge ${\displaystyle e_{k}={\overline {P_{i}^{k}P_{i+1}^{k}}}}$ of a Linear Ring ${\displaystyle R_{k}=(P_{0}^{k},P_{1}^{k},...,P_{n}^{k})}$ , defining a polygon ${\displaystyle S_{k}\in C}$, is used exactly once as an edge ${\displaystyle e_{l}={\overline {P_{j}^{l}P_{j+1}^{l}}}}$ in a Linear Ring ${\displaystyle R_{l}=(P_{0}^{l},P_{1}^{l},...,P_{m}^{l})}$, defining another polygon ${\displaystyle S_{l}\in C}$ with ${\displaystyle P_{i}^{k}=P_{j+1}^{l}}$ and ${\displaystyle P_{i+1}=P_{j}^{l}}$.
3. All polygons in ${\displaystyle C}$ are oriented such that the normal vector of each polygon points to the outside of the solid.
4. All polygons in ${\displaystyle C}$ are connected, that is the dual graph of ${\displaystyle C}$ has a path containing all nodes. The dual graph GC =(VC, EC) of ${\displaystyle C}$ consists of a set VC of nodes and a set EC of edges. Every node v of VC represents exactly one polygon of ${\displaystyle C}$. An edge shared by two polygons ${\displaystyle S_{k}}$ and ${\displaystyle S_{l}}$ of ${\displaystyle C}$ is represented by an edge ${\displaystyle e=(v_{s_{k}},v_{s_{l}})}$ in EC.
5. For every point ${\displaystyle P}$ of a Linear Ring of a polygon of ${\displaystyle C}$ applies: The graph ${\displaystyle G_{P}=(V_{P},E_{P})}$, that is only build by polygons and edges that touch${\displaystyle P}$ is connected. Each node ${\displaystyle v}$ of ${\displaystyle V_{P}}$ represents a polygon which Linear Ring contains ${\displaystyle P}$. Two nodes are connected by an edge ${\displaystyle e}$ of ${\displaystyle E_{P}}$ if the two polygons represented by the nodes have a common edge that touches ${\displaystyle P}$.

It follows from (i) and (ii) that the surface defined by ${\displaystyle C}$ has no holes. Together with conditions (4) and (5) it follows that the inner of the solid defined by ${\displaystyle C}$ is connected ${\displaystyle S}$ is denoted as closed CompositeSurface.

Examples:

 correct: 6 surfaces, closed, correct surface orientation correct: 11 surfaces, closed, correct surface orientation correct: 10 surfaces, closed, correct surface orientation correct: 30 surfaces, closed, correct surface orientation

 incorrect: 5 surfaces, not closed, correct surface orientation incorrect: 6 surfaces, closed, incorrect surface orientation incorrect: 12 surfaces, no closed (two outer hulls), correct surface orientation incorrect: 12 surfaces, not closed (inner and outer hull), correct surface orientation

## gml:CompositeSolid

A CompositeSolid is represented by a nonempty set ${\displaystyle C=\{S_{1},...,S_{n}\}}$ of Solids (see 10.) with the following properties:

1. The intersection of the inner of two solids ${\displaystyle S_{i}}$, ${\displaystyle S_{j}}$, 1 ≤ i ≤ n, 1 ≤ j ≤ n, i ≠ j of ${\displaystyle C}$ is empty, that is either both solids ${\displaystyle S_{i}}$, ${\displaystyle S_{j}}$ are disjoint or both solids are connected only by surfaces, lines or points.
2. Let ${\displaystyle C'}$ be the union of all solids from ${\displaystyle C}$. Then the boundary of ${\displaystyle C'}$ (the surface of ${\displaystyle C'}$ without the surfaces or points where the solids touch each other) is the boundary of a solid.

In CityGML inner inclusions ( hollow spaces ) are not considered in CompositeSolids, as in solids.

Examples:

 correct; surface contact correct; surface contact correct; surface contact correct; surface contact

 not correct; line contact not correct; point contact not correct; no contact at all not correct; intersection

 not correct; 26 boxes with surface contact but with internal hollow space not correct; interior boundaries

## gml:Triangle

• A Triangle is a special case of a polygon that is bounded by one outer Linear Ring with four points.
• There are no interior rings (no element "interior").

## gml:TriangulatedSurface

A triangulated surface is a CompositeSurface that consists of triangles only, but is not closed (it may have boundaries). There is no restriction on how the triangulation is derived.

## gml:Tin

In contrast to a gml:TriangulatedSurface, the triangles of a gml:TIN are not represented explicitly, but by its three vertices (called control points). In addition, breaklines, stop lines and the maximal length of a side of a triangle can be represented in a gml:TIN.

1. A TIN is a triangulated surface that is the result of the application of a Delaunay Algorithm or of a similar algorithm (extended by breaklines, stop lines and the maximal length of a side of a triangle). The surface satisfies the Delaunay criterion:
1. For each triangle in the network, the circle passing through its vertices does not contain, in its interior, the vertex of any other triangle.
2. Stoplines are lines where the local continuity or regularity of the surface is questionable. In the area of these pathologies, triangles intersecting a stopline shall be removed from the TIN surface, leaving holes in the surface. If triangles incident to the boundary of the surfaces are removed, the boundary of the surfaces changes.
3. Breaklines are lines that are critical for the shape of the surface, representing local ridges, or depressions (such as drainage lines) in the surface. As such their constituent segments must be included in the TIN even if doing so violates the Delaunay criterion.
4. Areas of the surface where the data is not sufficiently dense to assure reasonable calculations shall be removed by adding a retention criterion for triangles based on the length of their sides. For any triangle sides exceeding maximum length, the adjacent triangles to that triangle side shall be removed from the surface. # The number of control points is at least three.
5. The surface is not affected by the order in which the control points are given. Application schemas may add information based on the ordering of the control points to facilitate the reconstruction of the TIN from the control points.