# TatukGIS Developer Kernel 11

doc:de9im

## DE-9IM Intersection Model

TatukGIS supports a powerful, yet easy to manage, mechanism for querying against spatial relationships between two shapes known as the Dimensionally Extended 9 Intersection Model (DE-9IM). See also at Wikipedia.

The idea is to manage a nine-element mechanism in which each item defines relationship possibilities between the interiors, exteriors, and boundaries of two shapes. A relationship is defined in terms of intersection types, or lack of an intersection.

The meanings of the interior, exterior, and boundary, as they relate to shape types, are defined as follows:

Interior Boundary Exterior
TGIS_Point Point itself Nothing All except Interior
TGIS_Multipoint Points themselves Nothing All except Interior
TGIS_Arc (lines) Line itself except starting/ending points Starting & ending points of line All except Interior & Boundary
TGIS_Polygon (areas) Area of polygon Outline of polygon All except Interior & Boundary

The nature of the shape intersections is defined by a set of the interior, boundary, and exterior relationship possibilities, forming a 3×3 table.

A\B Interior Boundary Exterior
Interior * * *
Boundary * * *
Exterior * * *

The table can be represented by a string (row-by-row) like: `T*F**FFF*`

Each element of the table represents an intersection possibility:

Type Description
TIntersection exists
FIntersection does not exist
*Does not matter
0Intersection is a point (dimension = 0)
1Intersection is a line(dimension = 1)
2Intersection is a polygon (dimension = 2)

## Common cases

### Contains

#### Case description

A contains B if the interiors intersect and the exterior of A is not intersected by the Interior or boundary of B.

A\B Interior Boundary Exterior
Interior T * *
Boundary * * *
Exterior F F *

String representation is: `T*****FF*`
Predefined constant: `RELATE_CONTAINS`

#### Completely Contains

There is also a possible additional requirement that A completely contains B. In this case, the boundary of A must not intersect the interior or boundary of B.

String representation for this case is: `T**FF*FF*`
Predefined constant: `RELATE_CONTAINS_COMPLETELY`

### Cross

For relating shapes of different types. So, polygon can be crossed by line, but not with another polygon. (See Overlap).

#### Case description

A crosses B if the interiors intersect and the exterior of B intersects with the interior of A. General formula (except line-to-line situations).

A\B Interior Boundary Exterior
Interior T * T
Boundary * * *
Exterior * * *

String representation is: `"T*T******`
Predefined constant: `RELATE_CROSS`

#### Case description

A crosses B (and B crosses A) if the dimension of the intersection equals 0 (i.e., is a point). Only for line-to-line relationships.

A\B Interior Boundary Exterior
Interior 0 * *
Boundary * * *
Exterior * * *

String representation is: `0********`
Predefined constant: `RELATE_CROSS_LINE `

### Disjoint

#### Case description

There is no intersection of any kind.

A\B Interior Boundary Exterior
Interior F F *
Boundary F F *
Exterior * * *

String representation is: `FF*FF****`
Predefined constant: `RELATE_DISJOINT`

### Equality

#### Case description

A & B interiors intersect, and no interior or boundary of one shape intersects with the exterior or boundary of the other shape.

A\B Interior Boundary Exterior
Interior T * F
Boundary * * F
Exterior F F *

String representation is: `T*F**FFF*`
Predefined constant: `RELATE_EQUALITY`

### Intersect

#### Case description

By interiors.

A\B Interior Boundary Exterior
Interior T * *
Boundary * * *
Exterior * * *

String representation is: `T********`
Predefined constant: `RELATE_INTERSECT`

#### Case description

The interior of A intersects the boundary of B.

A\B Interior Boundary Exterior
Interior * T *
Boundary * * *
Exterior * * *

String representation is: “*T*******”
Predefined constant: RELATE_INTERSECT1

#### Case description

The boundary of A intersects the interior of B.

A\B Interior Boundary Exterior
Interior * * *
Boundary T * *
Exterior * * *

String representation is: `***T*****`
Predefined constant: `RELATE_INTERSECT2`

#### Case description

The boundary of A intersects the boundary of B.

A\B Interior Boundary Exterior
Interior * * *
Boundary * T *
Exterior * * *

String representation is: `****T****`
Predefine constant: `RELATE_INTERSECT3 `

### Overlap

For relating shapes of the same type. So, a polygon can overlap with another polygon, but not with a line. (See Cross).

#### Case description

A overlaps B (and B overlaps A) if both the interiors and exteriors intersect. General formula (except line-to-line situations).

A\B Interior Boundary Exterior
Interior T * T
Boundary * * *
Exterior T * *

String representation is: `T*T***T**`
Predefined constant: `RELATE_OVERLAP`

#### Case description

A overlaps B (and B overlap A) if the interior intersection has a dimension equal to 1 (is a line) and the exteriors intersect. Only for line-to-line relationships.

A\B Interior Boundary Exterior
Interior 1 * T
Boundary * * *
Exterior T * *

String representation is: `1*T***T**`
Predefined constant: `RELATE_OVERLAP_LINE`

### Touch

#### Case description

The boundary of A intersects with the interior of B.

A\B Interior Boundary Exterior
Interior F * *
Boundary T * *
Exterior * * *

String representation is: `F**T*****`
Predefined constant: RELATE_TOUCH_INTERIOR

#### Case description

The boundary of A intersects the boundary of B (but not the interior of B).

A\B Interior Boundary Exterior
Interior F * *
Boundary * T *
Exterior * * *

String representation is: `F***T****`
Predefined constant: `RELATE_TOUCH`

### Within

#### Case description

A is within B if the interiors intersect and the exterior of B is not intersected by the Interior or boundary of A.

A\B Interior Boundary Exterior
Interior T * F
Boundary * * F
Exterior * * *

String representation is: `T*F**F***`
Predefined constant: `RELATE_WITHIN`

#### Completely Within

There is also a possible additional requirement that A is completely within B.

String representation for this case is: `'TFF*FF***`
Predefined constant: `RELATE_WITHIN_COMPLETELY`

2019/10/03 09:32