Getting started

The well-known text representation for  geometry

Each geometry type has a well-known text representation from which new instances can be constructed or existing instances can be converted to textual form for alphanumeric display, or use in systems where binary representations of geometry are not supported.

The ISO/OGC specification of the well-known text representation for geometry is limited to 2D geometric objects.  ESRI has extended this specification to support elevations and measures.  If you are using this format to exchange data with other systems, they may not know how to interpret elevation and measure tags.

The text representation is an ASCII text-formatted string that allows geometry to be exchanged in ASCII text form.

The well-known text representation of geometry can be incorporated into a C program. The structure for such an implementation is defined below. The notation {}* denotes zero or more repetitions of the tokens within the braces. The braces do not appear in the output token list.

<Geometry Tagged Text> :=
 
| <Point Tagged Text>
| <LineString Tagged Text>

| <Polygon Tagged Text>

| <MultiPoint Tagged  Text>

| <MultiLineString Tagged Text>

| <MultiPolygon Tagged Text>

<Point Tagged Text> :=
POINT <Point Text>

<LineString Tagged Text> :=
LINESTRING <LineString Text>

<Polygon Tagged Text> :=
POLYGON <Polygon Text>

<MultiPoint Tagged Text> := 
MULTIPOINT <Multipoint Text>

<MultiLineString Tagged Text> :=
MULTILINESTRING <MultiLineString Text>

<MultiPolygon Tagged Text> :=
MULTIPOLYGON <MultiPolygon Text>

 

<Point Text> := EMPTY
|    <Point>
| Z  <PointZ>
| M  <PointM>
| ZM <PointZM>

 

<Point> :=  <x>  <y> 
<x> := double precision literal
<y> := double precision literal

<PointZ> :=  <x>  <y>  <z>
<x> := double precision literal

<y> := double precision literal

<z> := double precision literal

<PointM> :=  <x>  <y>  <m>
<x> := double precision literal

<y> := double precision literal

<m> := double precision literal

<PointZM> :=  <x>  <y>  <z>  <m>
<x> := double precision literal

<y> := double precision literal

<z> := double precision literal

<m> := double precision literal

 

<LineString Text> := EMPTY
|    ( <Point Text >   {,  <Point Text> }*  )
| Z  ( <PointZ Text >  {,  <PointZ Text> }*  )
| M  ( <PointM Text >  {,  <PointM Text> }*  )
| ZM ( <PointZM Text > {,  <PointZM Text> }*  )

 

 

<Polygon Text> := EMPTY
| ( <LineString Text > {,< LineString Text > }*)

 

 

<Multipoint Text> := EMPTY
| ( <Point Text >   {,  <Point Text > }*  )

 

 

<MultiLineString Text> := EMPTY
| ( <LineString Text > {,< LineString Text>}*  )

 

 

<MultiPolygon Text> := EMPTY
| ( < Polygon Text > {,  < Polygon Text > }*  )

The <text description> is made up of three basic components enclosed in single quotes:

'<geometry type> [coordinate type] [coordinate list]'

The geometrytype is defined as one of the following: point, linestring, polygon, multipoint, multilinestring, or multipolygon.

The coordinate type specifies whether or not the geometry has Z coordinates and/or measures. Leave this argument blank if the geometry has neither; otherwise, set the coordinate type to Z for geometries containing Z coordinates, M for geometries with measures, and ZM for geometries that have both.

The coordinate list defines the double-precision vertices of the geometry. Coordinate lists are comma-delimited and enclosed by parentheses. Geometries having multiple components require sets of parentheses to enclose each component part. If the geometry is empty, the EMPTY keyword replaces the coordinates.

 The following examples provide a complete list of all possible permutations of the
text description portion of the text representation:

Geometry type
Text Description
Comment
point
point empty
empty point
point
point z empty
empty point with z coordinate
point
point m empty
empty point with measure
point
point zm empty
empty point with z coordinate and measure
point
point ( 10.05  10.28 )
point
point
point z ( 10.05  10.28  2.51 )
point with z coordinate
point
point m ( 10.05  10.28  4.72 )
point with measure
point
point zm ( 10.05  10.28  2.51 4.72 )
point with z coordinate and measure
linestring
linestring empty
empty linestring
linestring
linestring z empty
empty linestring with z coordinates
linestring
linestring m empty
empty linestring with measures
linestring
linestring zm empty
empty linestring with z coordinates and measures
linestring
linestring ( 10.05  10.28 , 20.95  20.89 )
linestring
linestring
linestring z ( 10.05 10.28 3.09, 20.95 31.98 4.72, 21.98 29.80 3.51 )
linestring with z coordinates
linestring
linestring m ( 10.05 10.28 5.84, 20.95 31.98 9.01, 21.98 29.80 12.84 )
linestring with measures
linestring
linestring zm (10.05 10.28 3.09 5.84, 20.95 31.98 4.72 9.01, 21.98 29.80 3.51 12.84)
linestring with z coordinates and measures
polygon
polygon empty
empty polygon
polygon
polygon z empty
empty polygon with z coordinates
polygon
polygon m empty
empty polygon with measures
polygon
polygon zm empty
empty polygon with z coordinates and measures
polygon
polygon (( 10 10, 10 20, 20 20, 20 15, 10 10))
polygon
polygon
polygon z ((10 10 3, 10 20 3, 20 20 3, 20 15 4, 10 10 3))
polygon with z coordinates
polygon
polygon m (( 10 10 8, 10 20 9, 20 20 9, 20 15 9, 10 10 8 ))
polygon with measures
polygon
polygon zm (( 10 10 3 8, 10 20 3 9, 20 20 3 9, 20 15 4 9, 10 10 3 8 ))
polygon with z coordinates and measures
multipoint
multipoint empty
empty multipoint
multipoint
multipoint z empty
empty multipoint with z coordinates
multipoint
multipoint m empty
empty multipoint with measures
multipoint
multipoint zm empty
empty multipoint with z coordinates and measures
multipoint
multipoint (10 10, 20 20)
multipoint with two points
multipoint
multipoint z (10 10 2, 20 20 3)
multipoint with z coordinates
multipoint
multipoint m (10 10 4, 20 20 5)
multipoint with measures
multipoint
multipoint zm (10 10 2 4, 20 20 3 5)
multipoint with z coordinates and  measures
multilinestring
multilinestring empty
empty multilinestring
multilinestring
multilinestring z empty
empty multilinestring with z coordinates
multilinestring
multilinestring m empty
empty multilinestring with measures
multilinestring
multilinestring zm empty
empty multilinestring with z coordinates and measures
multilinestring
multilinestring (( 10.05  10.28 , 20.95  20.89 ),( 20.95  20.89, 31.92 21.45))
multilinestring
multilinestring
multilinestring z ((10.05  10.28  3.4, 20.95  20.89  4.5),( 20.95  20.89 4.5, 31.92  21.45  3.6))
multilinestring with z coordinates
multilinestring
multilinestring m ((10.05  10.28  8.4, 20.95  20.89  9.5),( 20.95  20.89 9.5, 31.92  21.45  8.6))
multilinestring with measures
multilinestring
multilinestring zm ((10.05  10.28  3.4  8.4, 20.95  20.89  4.5  9.5),
 
( 20.95  20.89  4.5  9.5, 31.92  21.45  3.6  8.6))
multilinestring with z coordinates and measures
multipolygon
multipolygon empty
empty multipolygon
multipolygon
multipolygon z empty
empty multipolygon with z coordinates
multipolygon
multipolygon m empty
empty multipolygon with measures
multipolygon
multipolygon zm empty
empty multipolygon with z coordinates and measures
multipolygon
multipolygon (((10 10, 10 20, 20 20, 20 15 , 10 10), (50 40, 50 50, 60 50, 60 40, 50 40)))
multipolygon
multipolygon
multipolygon z (((10 10 7, 10 20 8, 20 20 7, 20 15 5, 10 10 7), (50 40 6, 50 50 6, 60 50 5, 60 40 6, 50 40 7)))
multipolygon with z coordinates
multipolygon
multipolygon m (((10 10 2, 10 20 3, 20 20 4, 20 15 5, 10 10 2), (50 40 7, 50 50 3, 60 50 4, 60 40 5, 50 40 7))) <E>
multipolygon with measures
multipolygon
multipolygon zm (((10 10 7 2, 10 20 8 3, 20 20 7 4, 20 15 5 5, 10 10 7 2), (50 40 6 7, 50 50 6 3, 60 50 5 4, 60 40 6 5, 50 40 7 7)))
multipolygon with z coordinates and measures

Informix modified well-known text representation

The Informix software provides an additional modified well-known text representation for loading text strings directly into geometry columns without filtering the string through one of the Spatial DataBlade text functions. By placing the SRID in front of the text description the resulting text string can be inserted directly into a spatial column. The load statement reads text files generated with this format and inserts the modified well-known text representation into the geometry columns.

To create a modified well-known text representation, remove the quotes and precede the text description with the SRID separated by a space.

For example, the well-known text representation of a point in the pointfromtext function:

pointfromtext(point zm (10.98  29.91 10.2 9.1),1)

would convert to

1 point zm(10.98  29.91 10.2 9.1)

The modified text string could be written into a file separated from other column values by the standard delimiter. The file can be read by the Informix SQL load statement that inserts text-formatted values into a table.