Source code editor What Is Ajax

↑

The set of geometry types proposed by OGC's **SQL with Geometry Types** environment is based on the **OpenGIS Geometry Model**. In this model, each geometric object has the following general properties:

It is associated with a Spatial Reference System, which describes the coordinate space in which the object is defined.

It belongs to some geometry class.

The geometry classes define a hierarchy as follows:

`Geometry`

(non-instantiable)`Point`

(instantiable)`Curve`

(non-instantiable)`LineString`

(instantiable)`Line`

`LinearRing`

`Surface`

(non-instantiable)`Polygon`

(instantiable)

`GeometryCollection`

(instantiable)`MultiPoint`

(instantiable)`MultiCurve`

(non-instantiable)`MultiLineString`

(instantiable)

`MultiSurface`

(non-instantiable)`MultiPolygon`

(instantiable)

It is not possible to create objects in non-instantiable classes. It is possible to create objects in instantiable classes. All classes have properties, and instantiable classes may also have assertions (rules that define valid class instances).

`Geometry`

is the base class. It is an abstract class. The instantiable subclasses of `Geometry`

are restricted to zero-, one-, and two-dimensional geometric objects that exist in two-dimensional coordinate space. All instantiable geometry classes are defined so that valid instances of a geometry class are topologically closed (that is, all defined geometries include their boundary).

The base `Geometry`

class has subclasses for `Point`

, `Curve`

, `Surface`

, and `GeometryCollection`

:

`Point`

represents zero-dimensional objects.`Curve`

represents one-dimensional objects, and has subclass`LineString`

, with sub-subclasses`Line`

and`LinearRing`

.`Surface`

is designed for two-dimensional objects and has subclass`Polygon`

.`GeometryCollection`

has specialized zero-, one-, and two-dimensional collection classes named`MultiPoint`

,`MultiLineString`

, and`MultiPolygon`

for modeling geometries corresponding to collections of`Points`

,`LineStrings`

, and`Polygons`

, respectively.`MultiCurve`

and`MultiSurface`

are introduced as abstract superclasses that generalize the collection interfaces to handle`Curves`

and`Surfaces`

.

`Geometry`

, `Curve`

, `Surface`

, `MultiCurve`

, and `MultiSurface`

are defined as non-instantiable classes. They define a common set of methods for their subclasses and are included for extensibility.

`Point`

, `LineString`

, `Polygon`

, `GeometryCollection`

, `MultiPoint`

, `MultiLineString`

, and `MultiPolygon`

are instantiable classes.

`Geometry`

is the root class of the hierarchy. It is a non-instantiable class but has a number of properties that are common to all geometry values created from any of the `Geometry`

subclasses. These properties are described in the following list. Particular subclasses have their own specific properties, described later.

**Geometry Properties**

A geometry value has the following properties:

Its

**type**. Each geometry belongs to one of the instantiable classes in the hierarchy.Its

**SRID**, or Spatial Reference Identifier. This value identifies the geometry's associated Spatial Reference System that describes the coordinate space in which the geometry object is defined.In MySQL, the SRID value is just an integer associated with the geometry value. All calculations are done assuming Euclidean (planar) geometry.

Its

**coordinates**in its Spatial Reference System, represented as double-precision (eight-byte) numbers. All non-empty geometries include at least one pair of (X,Y) coordinates. Empty geometries contain no coordinates.Coordinates are related to the SRID. For example, in different coordinate systems, the distance between two objects may differ even when objects have the same coordinates, because the distance on the

**planar**coordinate system and the distance on the**geocentric**system (coordinates on the Earth's surface) are different things.Its

**interior**,**boundary**, and**exterior**.Every geometry occupies some position in space. The exterior of a geometry is all space not occupied by the geometry. The interior is the space occupied by the geometry. The boundary is the interface between the geometry's interior and exterior.

Its

**MBR**(Minimum Bounding Rectangle), or Envelope. This is the bounding geometry, formed by the minimum and maximum (X,Y) coordinates:((MINX MINY, MAXX MINY, MAXX MAXY, MINX MAXY, MINX MINY))

Whether the value is

**simple**or**non-simple**. Geometry values of types (`LineString`

,`MultiPoint`

,`MultiLineString`

) are either simple or non-simple. Each type determines its own assertions for being simple or non-simple.Whether the value is

**closed**or**not closed**. Geometry values of types (`LineString`

,`MultiString`

) are either closed or not closed. Each type determines its own assertions for being closed or not closed.Whether the value is

**empty**or**non-empty**A geometry is empty if it does not have any points. Exterior, interior, and boundary of an empty geometry are not defined (that is, they are represented by a`NULL`

value). An empty geometry is defined to be always simple and has an area of 0.Its

**dimension**. A geometry can have a dimension of –1, 0, 1, or 2:–1 for an empty geometry.

0 for a geometry with no length and no area.

1 for a geometry with non-zero length and zero area.

2 for a geometry with non-zero area.

`Point`

objects have a dimension of zero.`LineString`

objects have a dimension of 1.`Polygon`

objects have a dimension of 2. The dimensions of`MultiPoint`

,`MultiLineString`

, and`MultiPolygon`

objects are the same as the dimensions of the elements they consist of.

A `Point`

is a geometry that represents a single location in coordinate space.

`Point`

Examples

Imagine a large-scale map of the world with many cities. A

`Point`

object could represent each city.On a city map, a

`Point`

object could represent a bus stop.

`Point`

Properties

X-coordinate value.

Y-coordinate value.

`Point`

is defined as a zero-dimensional geometry.The boundary of a

`Point`

is the empty set.

A `Curve`

is a one-dimensional geometry, usually represented by a sequence of points. Particular subclasses of `Curve`

define the type of interpolation between points. `Curve`

is a non-instantiable class.

`Curve`

Properties

A

`Curve`

has the coordinates of its points.A

`Curve`

is defined as a one-dimensional geometry.A

`Curve`

is simple if it does not pass through the same point twice.A

`Curve`

is closed if its start point is equal to its endpoint.The boundary of a closed

`Curve`

is empty.The boundary of a non-closed

`Curve`

consists of its two endpoints.A

`Curve`

that is simple and closed is a`LinearRing`

.

A `LineString`

is a `Curve`

with linear interpolation between points.

`LineString`

Examples

On a world map,

`LineString`

objects could represent rivers.In a city map,

`LineString`

objects could represent streets.

`LineString`

Properties

A

`LineString`

has coordinates of segments, defined by each consecutive pair of points.A

`LineString`

is a`Line`

if it consists of exactly two points.A

`LineString`

is a`LinearRing`

if it is both closed and simple.

A `Surface`

is a two-dimensional geometry. It is a non-instantiable class. Its only instantiable subclass is `Polygon`

.

`Surface`

Properties

A

`Surface`

is defined as a two-dimensional geometry.The OpenGIS specification defines a simple

`Surface`

as a geometry that consists of a single “patch” that is associated with a single exterior boundary and zero or more interior boundaries.The boundary of a simple

`Surface`

is the set of closed curves corresponding to its exterior and interior boundaries.

A `Polygon`

is a planar `Surface`

representing a multisided geometry. It is defined by a single exterior boundary and zero or more interior boundaries, where each interior boundary defines a hole in the `Polygon`

.

`Polygon`

Examples

On a region map,

`Polygon`

objects could represent forests, districts, and so on.

`Polygon`

Assertions

The boundary of a

`Polygon`

consists of a set of`LinearRing`

objects (that is,`LineString`

objects that are both simple and closed) that make up its exterior and interior boundaries.A

`Polygon`

has no rings that cross. The rings in the boundary of a`Polygon`

may intersect at a`Point`

, but only as a tangent.A

`Polygon`

has no lines, spikes, or punctures.A

`Polygon`

has an interior that is a connected point set.A

`Polygon`

may have holes. The exterior of a`Polygon`

with holes is not connected. Each hole defines a connected component of the exterior.

The preceding assertions make a `Polygon`

a simple geometry.

A `GeometryCollection`

is a geometry that is a collection of one or more geometries of any class.

All the elements in a `GeometryCollection`

must be in the same Spatial Reference System (that is, in the same coordinate system). There are no other constraints on the elements of a `GeometryCollection`

, although the subclasses of `GeometryCollection`

described in the following sections may restrict membership. Restrictions may be based on:

Element type (for example, a

`MultiPoint`

may contain only`Point`

elements)Dimension

Constraints on the degree of spatial overlap between elements

A `MultiPoint`

is a geometry collection composed of `Point`

elements. The points are not connected or ordered in any way.

`MultiPoint`

Examples

On a world map, a

`MultiPoint`

could represent a chain of small islands.On a city map, a

`MultiPoint`

could represent the outlets for a ticket office.

`MultiPoint`

Properties

A

`MultiPoint`

is a zero-dimensional geometry.A

`MultiPoint`

is simple if no two of its`Point`

values are equal (have identical coordinate values).The boundary of a

`MultiPoint`

is the empty set.

A `MultiCurve`

is a geometry collection composed of `Curve`

elements. `MultiCurve`

is a non-instantiable class.

`MultiCurve`

Properties

A

`MultiCurve`

is a one-dimensional geometry.A

`MultiCurve`

is simple if and only if all of its elements are simple; the only intersections between any two elements occur at points that are on the boundaries of both elements.A

`MultiCurve`

boundary is obtained by applying the “mod 2 union rule” (also known as the “odd-even rule”): A point is in the boundary of a`MultiCurve`

if it is in the boundaries of an odd number of`MultiCurve`

elements.A

`MultiCurve`

is closed if all of its elements are closed.The boundary of a closed

`MultiCurve`

is always empty.

A `MultiLineString`

is a `MultiCurve`

geometry collection composed of `LineString`

elements.

`MultiLineString`

Examples

On a region map, a

`MultiLineString`

could represent a river system or a highway system.

A `MultiSurface`

is a geometry collection composed of surface elements. `MultiSurface`

is a non-instantiable class. Its only instantiable subclass is `MultiPolygon`

.

`MultiSurface`

Assertions

Two

`MultiSurface`

surfaces have no interiors that intersect.Two

`MultiSurface`

elements have boundaries that intersect at most at a finite number of points.

A `MultiPolygon`

is a `MultiSurface`

object composed of `Polygon`

elements.

`MultiPolygon`

Examples

On a region map, a

`MultiPolygon`

could represent a system of lakes.

`MultiPolygon`

Assertions

A

`MultiPolygon`

has no two`Polygon`

elements with interiors that intersect.A

`MultiPolygon`

has no two`Polygon`

elements that cross (crossing is also forbidden by the previous assertion), or that touch at an infinite number of points.A

`MultiPolygon`

may not have cut lines, spikes, or punctures. A`MultiPolygon`

is a regular, closed point set.A

`MultiPolygon`

that has more than one`Polygon`

has an interior that is not connected. The number of connected components of the interior of a`MultiPolygon`

is equal to the number of`Polygon`

values in the`MultiPolygon`

.

`MultiPolygon`

Properties

A

`MultiPolygon`

is a two-dimensional geometry.A

`MultiPolygon`

boundary is a set of closed curves (`LineString`

values) corresponding to the boundaries of its`Polygon`

elements.Each

`Curve`

in the boundary of the`MultiPolygon`

is in the boundary of exactly one`Polygon`

element.Every

`Curve`

in the boundary of an`Polygon`

element is in the boundary of the`MultiPolygon`

.