All Products
Search
Document Center

PolarDB:WKT

Last Updated:Mar 28, 2026

GanosBase represents surface mesh geometry as Well-Known Text (WKT) strings — a human-readable format that you can use directly in SQL statements and application code.

Geometric structures

In addition to the basic types defined in the Open Geospatial Consortium (OGC) Simple Feature model, GanosBase supports the following geometric structures in WKT format. For a description of the underlying data models, see Data models in surface mesh models.

Supported GanosBase geometric structures:

StructureWKT keywordDimensional support
IndexSurfaceINDEXSURFACEZ, M
TriangleStripTRIANGLESTRIPZ, M, ZM
TriangleFanTRIANGLEFANZ, M, ZM
MeshGeomMESHGEOMZ, M (all patches must use the same dimension)
SFmeshJSON format

Z and M dimensions

All GanosBase geometric structures support optional dimensional qualifiers:

  • Z — the elevation (height) ordinate of a coordinate

  • M — a measure value associated with each vertex, such as distance or time

Add the qualifier after the keyword: TRIANGLESTRIP Z(...), TRIANGLESTRIP M(...), or TRIANGLESTRIP ZM(...).

IndexSurface

An IndexSurface defines a surface by listing vertex coordinates and face indexes separately. Multiple faces can share the same vertex without repeating its coordinates.

Construct an IndexSurface using three keywords:

  • INDEXSURFACE — the outer wrapper

  • VERTEX — a comma-separated list of vertex coordinates; within each vertex, dimensions are separated by spaces

  • INDEX — a list of faces; each face is a parenthesized, comma-separated list of vertex indexes (zero-based)

Format:

INDEXSURFACE(
    VERTEX(x1 y1 z1,
        x2 y2 z2,
        ...
    ),
    INDEX(
        (i1,i2,i3,...),
        (j1,j2,j3,...),
        ...
    )
)

Example:

INDEXSURFACE(
    VERTEX(201755.424609375 241700.688720703 7025.00027160645,201755.424609375 241700.688720703 6774.9998336792,202255.431298828 241700.688720703 6774.9998336792,202255.431298828 241700.688720703 7025.00027160645,202255.431298828 243149.418896484 6774.9998336792,201755.424609375 243149.418896484 6774.9998336792,201755.424609375 243149.418896484 7025.00027160645,202255.431298828 243149.418896484 7025.00027160645),
    INDEX((0,1,2),(2,3,0),(4,5,6),(6,7,4),(2,1,5),(5,4,2),(3,2,7),(4,7,2),(0,3,7),(7,6,0),(1,0,5),(6,5,0))
)

With dimensional qualifiers:

INDEXSURFACE Z(
    VERTEX(201755.424609375 241700.688720703 7025.00027160645,201755.424609375 241700.688720703 6774.9998336792,202255.431298828 241700.688720703 6774.9998336792,202255.431298828 241700.688720703 7025.00027160645,202255.431298828 243149.418896484 6774.9998336792,201755.424609375 243149.418896484 6774.9998336792,201755.424609375 243149.418896484 7025.00027160645,202255.431298828 243149.418896484 7025.00027160645),
    INDEX((0,1,2),(2,3,0),(4,5,6),(6,7,4),(2,1,5),(5,4,2),(3,2,7),(4,7,2),(0,3,7),(7,6,0),(1,0,5),(6,5,0)))

INDEXSURFACE M(
    VERTEX(201755.424609375 241700.688720703 7025.00027160645,201755.424609375 241700.688720703 6774.9998336792,202255.431298828 241700.688720703 6774.9998336792,202255.431298828 241700.688720703 7025.00027160645,202255.431298828 243149.418896484 6774.9998336792,201755.424609375 243149.418896484 6774.9998336792,201755.424609375 243149.418896484 7025.00027160645,202255.431298828 243149.418896484 7025.00027160645),
    INDEX((0,1,2),(2,3,0),(4,5,6),(6,7,4),(2,1,5),(5,4,2),(3,2,7),(4,7,2),(0,3,7),(7,6,0),(1,0,5),(6,5,0)))

TriangleStrip

A TriangleStrip defines a connected series of triangles where each new vertex, combined with the previous two, forms the next triangle. Construct it using the TRIANGLESTRIP keyword followed by a comma-separated list of coordinate strings.

Examples:

TRIANGLESTRIP(0 0 1 1,0 10 2 2,10 10 3 3,10 0 4 4)

TRIANGLESTRIP Z(0 0 1,0 10 2,10 10 3,10 0 4)
TRIANGLESTRIP M(0 0 1,0 10 2,10 10 3,10 0 4)
TRIANGLESTRIP ZM(0 0 1 1,0 10 2 2,10 10 3 3,10 0 4 4)

TriangleFan

A TriangleFan defines a set of triangles that all share a common center vertex. Each new vertex connects to the center and the previous vertex to form the next triangle. Construct it using the TRIANGLEFAN keyword followed by a comma-separated list of coordinate strings.

Examples:

TRIANGLEFAN(0 0 1 1,0 10 2 2,10 10 3 3,10 0 4 4)

TRIANGLEFAN Z(0 0 1,0 10 2,10 10 3,10 0 4)
TRIANGLEFAN M(0 0 1,0 10 2,10 10 3,10 0 4)
TRIANGLEFAN ZM(0 0 1 1,0 10 2 2,10 10 3 3,10 0 4 4)

MeshGeom

A MeshGeom combines geometry, normal vectors, and texture coordinates into a single object. Construct it using the MESHGEOM keyword with the following sub-keywords:

PATCH

Defines the geometry of the object. A PATCH can contain one or more sub-objects separated by commas. Supported geometry types: Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, IndexSurface, TriangleStrip, and TriangleFan.

PATCH(POINT(0 0 1))

PATCH(
    POINT(0 0 1),
    TRIANGLESTRIP(0 0 1,0 10 2,10 10 3,10 0 4)
    )

NORMAL

Defines normal vectors as 3D point coordinates. Coordinate strings within each sub-object are separated by commas, and each sub-object is enclosed in parentheses. The number of normal vector points must match the number of vertices in the corresponding PATCH sub-object.

NORMAL(
    (0 0 0, 1 1 1,2 2 2, 3 3 3)
    )

NORMAL(
    (0 0 0, 1 1 1,2 2 2, 3 3 3),
    (1 2 1, 3 3 4)
    )

TEXCOORD

Defines texture coordinates as 2D point coordinates. Coordinate strings within each sub-object are separated by commas, and each sub-object is enclosed in parentheses. The number of texture coordinate points must match the number of vertices in the corresponding PATCH sub-object.

TEXCOORD(
    (0 0, 1 1, 2 2, 3 3)
)

TEXCOORD(
    (0 0, 1 1, 2 2, 3 3),
    (1 1, 0 0, 2 2, 3 3)
)

Examples

With two PATCH sub-objects:

MESHGEOM(
    PATCH(
        POINT(0 0 1),
        INDEXSURFACE(VERTEX(0 0 1,0 10 2,10 10 3,10 0 4), INDEX((0,1,2),(1,2,3)))
    )
)

With NORMAL and TEXCOORD:

MESHGEOM(
    PATCH(
        TRIANGLESTRIP(0 0 1,0 10 2,10 10 3,10 0 4)
    ),
    NORMAL(
        (0 0 0, 1 1 1,2 2 2, 3 3 3)
    ),
    TEXCOORD(
        (0 0, 1 1, 2 2, 3 3)
    )
)

With dimensional qualifier — all patches in a MeshGeom must use the same dimension:

MESHGEOM(
    PATCH(
        POINT M(0 0 1),
        INDEXSURFACE M(
            VERTEX(0 0 1,0 10 2,10 10 3,10 0 4),
            INDEX((0,1,2),(1,2,3))
        )
    )
)

Reference an object

A MeshGeom can reference another MeshGeom stored in a database table. Enclose all reference values in @ symbols. The table, column, and key keywords are mandatory; schema is optional.

Format:

MESHGEOM(
    schema(@schema_name@),
    table(@table_name@),
    column(@column_name@),
    key(@where_clause@)
)

Example:

MESHGEOM(
    schema(@public@),
    table(@mytable@),
    column(@mycolumn@),
    key(@id=1@)
)

SFmesh

An SFmesh represents a hierarchical mesh scene graph. Unlike the other geometric structures, its WKT representation is a JSON object.

Fields:

FieldDescription
versionThe SFmesh version. Valid value: 1.
sridThe Spatial Reference System Identifier (SRID).
lodThe Level of Detail (LOD).
rootThe root node ID. Default: 0.
meshgeomsAn array of MeshGeom objects, expressed as MeshGeom WKT strings.
meshesAn array of SFmesh references, expressed as SFmesh WKT strings.
texturesAn array of texture objects used in the mesh.
materialsAn array of material objects that define surface properties.
primitivesAn array of primitive elements. Each element is either a meshgeom type or a mesh type. The meshgeom type can include a material property.
nodesThe hierarchical structure of the mesh. Each node can have a primitive, a list of children, an id, and a matrix (transformation matrix).

The matrix field uses a 4x4 transformation matrix in the following layout:

/ a  b  c  xoff \
| d  e  f  yoff |
| g  h  i  zoff |
\ 0  0  0     1 /

Example

{
  "version": 1,
  "root": 0,
  "meshgeoms": ["MESHGEOM(PATCH(TRIANGLESTRIP(0 0,0 10,10 10,10 0)))"],
  "meshes": [
    "MESH(schema(@public@), table(@t_mesh@), column(@the_mesh@), key(@num=1@))"
  ],
  "primitives": [
    {
      "mesh": 0
    },
    {
      "meshgeom": 0
    }
  ],
  "nodes": [
    {
      "children": [1, 2],
      "id": 100
    },
    {
      "primitive": 0
    },
    {
      "primitive": 1,
      "matrix": [2, 0, 0, 1, 0, 2, 0, 3, 0, 0, 2, 4, 0, 0, 0, 1],
      "id": 10
    }
  ],
  "materials": [
    {
      "type": "db",
      "attributes": {
        "schema": "public",
        "table": "t_material",
        "column": "the_material",
        "key": "num=1"
      }
    }
  ],
  "textures": [
    {
      "compressionType": "None",
      "format": "JPEG",
      "wrap": "Wrap",
      "type": "Url",
      "depth": 3,
      "width": 256,
      "height": 256,
      "size": 15,
      "data": "http://aaa.png"
    }
  ]
}

Reference an object

An SFmesh can reference another SFmesh stored in a database table using the MESH() keyword. Enclose all reference values in @ symbols. The table, column, and key keywords are mandatory; schema is optional.

Format:

MESH(
    schema(@schema_name@),
    table(@table_name@),
    column(@column_name@),
    key(@where_clause@)
)

Example:

MESH(
    schema(@public@),
    table(@mytable@),
    column(@mycolumn@),
    key(@id=1@)
)

EWKT

Extended Well-Known Text (EWKT) extends the WKT format with additional metadata. Each piece of metadata is separated by a semicolon (;).

EWKT supports two extensions:

  • SRID — embeds a Spatial Reference System Identifier (SRID) into the geometry string. For details about SRIDs, see Spatial reference systems.

  • SOLID — specifies whether the geometry is filled. Valid values: true, false (default: false).

Examples:

SRID=4326;MESHGEOM(PATCH(INDEXSURFACE M(VERTEX(0 0 1,0 10 2,10 10 3,10 04), INDEX((0,1,2),(1,2,3)))))

SRID=4326;SOLID=true;MESHGEOM(PATCH(INDEXSURFACE M(VERTEX(0 0 1,0 10 2,1010 3,10 0 4), INDEX((0,1,2),(1,2,3)))))