The SE_AsBSON() function

The SE_AsBSON() function takes a geometry object and returns a BSON document in GeoJSON format.

The return type of SE_AsBSON() is defined as a BSON document. Typically, you use SE_AsBSON() to retrieve spatial data from the server and send it to a client that displays data in GeoJSON format: SELECT SE_AsBSON(geomcol) FROM mytable

This function takes an ST_Point, ST_LineString, ST_Polygon, ST_MultiPoint, ST_MultiLineString, or ST_MultiPolygon and returns a BSON document in GeoJSON format. If the geometry value is empty, this function returns NULL.

Syntax

SE_AsBSON(g1 ST_Geometry)

Return type

BSON

Example

The point with the definition of '4326 point(-123.434 43.872)' is converted into the following BSON document in GeoJSON format:
{ "type": "Point", "coordinates": [-123.434,43.872] }