GeoJSONFromGeom

Teradata Vantageā„¢ JSON Data Type

brand
Software
Teradata Vantage
prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1150-162K

Purpose

The GeoJSONFromGeom function converts an ST_Geometry object into a JSON document that conforms to the GeoJSON standards.

Syntax



If you specify a RETURNS clause, you must enclose the function call in parenthesis.





TD_SYSFNLIB
The name of the database where the function is located.
geom_expr
An expression which evaluates to an ST_Geometry object that represents a Point, MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon, or GeometryCollection.
precision
An integer specifying the maximum number of decimal places in the coordinate values.
If this argument is NULL or not specified, the default precision is 15.
RETURNS data_type
Specifies that data_type is the return type of the function.
data_type can be VARCHAR, CLOB, or JSON.
integer
Specifies the maximum length of the return type.
If you do not specify a maximum length, the default is the maximum length supported by the return data type.
CHARACTER SET
The character set for the return value of the function, which can be LATIN or UNICODE.
If you do not specify a character set, the default character set for the user is used.
RETURNS STYLE column_expr
Specifies that the return type of the function is the same as the data type of the specified column. The data type of the column must be VARCHAR, CLOB, or JSON.
column_expr can be any valid table or view column reference.

Return Value

The result of this function is a JSON document which has a format that conforms to the GeoJSON standards as specified in https://tools.ietf.org/html/rfc7946 .

If you do not specify a RETURNS clause, the default return type is JSON with UNICODE as the character set. The length of the return value is 64000 bytes, which supports up to 32000 UNICODE characters. This can result in a failure if the underlying ST_Geometry object exceeds 64000 bytes when converted to a GeoJSON value.

The length of the converted GeoJSON value is greater than the underlying length of the ST_Geometry object.

The usual rules apply for the maximum length of each data type.

Data Type Character Set Maximum Length (characters)
VARCHAR LATIN 64000
UNICODE 32000
CLOB LATIN 2097088000
UNICODE 1048544000
JSON LATIN 16776192
UNICODE 8388096

Usage Notes

The GeoJSONFromGeom and GeomFromGeoJSON functions operate on or produce data in the JSON text format. They cannot be used on JSON data that is stored in one of the binary formats. However, JSON data stored in a binary format can be cast to/from its text representation to interact with these functions. The casting can be done implicitly, so little effort is needed to perform this operation.

ANSI Compliance

This function is not compliant with the ANSI SQL:2011 standard.