All Products
Search
Document Center

PolarDB:WKT

Last Updated:Oct 17, 2024

GanosBase surface models can be represented in Well-Known Text (WKT) format, which is a textual format that is easy to read and understand.

Geometric structures

In addition to the basic types defined in the Open Geospatial Consortium (OGC) Simple Feature model, GanosBase surface models support also the following geometric structures. These geometric structures can also be represented in WKT format. For information about the geometric structures, see Data models in surface mesh models.

IndexSurface

The IndexSurface geometric structure is constructed in WKT by using the INDEXSURFACE keyword, VERTEX keyword, and INDEX keyword. Vertex coordinates are separated by commas (,), dimensions are separated by spaces ( ). The indexes of each face are enclosed in parentheses () with each index separated by a comma (,). 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))
)

The IndexSurface geometric structure also supports Z and M dimensional information.

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

The TriangleStrip geometric structure is constructed in WKT by using the INDEXSURFACE keyword followed by all coordinate strings. Example:

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

The TriangleStrip geometric structure also supports Z and M dimensional information.

    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

The TriangleFan geometric structure is constructed in WKT by using the TRIANGLEFAN keyword followed by all coordinate strings. Example:

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

The TriangleFan geometric structure also supports Z and M dimensional information.

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

The MeshGeom geometric structure is constructed in WKT by using the main keyword MESHGEOM and keywords PATCH, NORMAL, and TEXCOORD.

  • PATCH

    Defines geometric types and the coordinate information. The keyword can contain one or more sub-objects, separated by commas (,). The supported geometric types are:

    Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, IndexSurface, TriangleStrip, and TriangleFan.

    Example:

    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 represented as three-dimensional point coordinates. The coordinate strings are separated by commas (,). 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.

    Example:

    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 represented as two-dimensional point coordinates. The coordinate strings are separated by commas (,). 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.

    Example:

    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

The following examples describe how the MeshGeom geometric structure is represented in WKT:

  • Two PATCH keywords

    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)))
        )
    )
  • NORMAL and TEXCOORD keywords

    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)
        )
    )

    The MeshGeom geometric structure also supports the Z and M dimensional information. The dimensions of all patches in the MeshGeom geometric structure must be the same.

    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

The MeshGeom geometric structure can reference other MeshGeom objects in WKT format by using the following keywords: schema, table, column, and key. The last three keywords (table, column, and key) are mandatory. The referencing details are enclosed in @ symbols. 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

The SFmesh geometric structure uses JSON as its WKT representation method and contains the following node information:

  • version: the SFmesh version. Valid value: 1.

  • srid: the spatial reference system identifier (SRID).

  • lod: the Level of Detail (LOD).

  • root: the root node ID. Default value: 0.

  • meshgeoms: an array of referenced MeshGeom objects. Each entry in the array can represent an external reference that uses the MeshGeom WKT format.

  • meshes: an array of referenced SFmesh objects. These can be external references and comply with SFmesh WKT format.

  • textures: an array of texture objects used in the mesh.

  • materials: an array of material objects used to define surface properties of the mesh.

  • primitives: an array of tuples that represent the primitive elements. The element type can be meshgeom or mesh. The meshgeom type can include material information, which is defined by using the material keyword.

  • nodes: defines the hierarchical structure of the mesh components. Nodes can have the following attributes:

    • primitive: the primitive information.

    • children: an array of child objects.

    • id: the ID for the node within this structure.

    • matrix: the transformation matrix, which is described in the following format:

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

Examples

The following sample code provides an example of a common JSON representation of an SFmesh object:

{
  "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

The SFmesh geometric structure can reference other SFmesh objects by using the following keywords: schema, table, column, and key. The last three keywords (table, column, and key) are mandatory. The referencing details are enclosed in @ symbols. 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) is an extended version of WKT that includes additional information such as the Spatial Reference System Identifier (SRID) and the SOLID paramter. Each section of information is separated by a semicolon (;).

  • For information about SRIDs, see Spatial reference systems.

  • The SOLID parameter specifies whether the geometry is filled Valid values:

    • true

    • false (default)

Example:

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)))))