The SE_MPointFromBSON() function

The SE_MPointFromBSON() function takes a bson value with spatial data following the GeoJSON specification and a JSON path in a VARCHAR string, and returns an ST_MultiPoint object.

Syntax

create function SE_MPointFromBSON(bson,varchar(255))
returns ST_MultiPoint

Return type

ST_MultiPoint

Example

The city engineer wants to know the “MultiPoint” of a city, an array of one or more positions.

The following code inserts one row for GeoJSON geometry type MultiPoint.
-- create a table of bson value containing GeoJson spatial values under the city tag
create table bson_tab (pid serial, geometry bson, type varchar(16));
Table created.

insert into bson_tab values(0, ('{
		"city":{
			"type":"MultiPoint",
			"coordinates" : [[1, 0], [3, 2], [3, 2], [4, 5]]
		}
	 }'::json)::bson,
	'MultiPoint');
1 row(s) inserted.
The query selects a multipoint value from the table by using SE_MPointFromBSON.
select pid,se_mpointfrombson(geometry,'city') from bson_tab where type = 'MultiPoint' ;

This is the result.

pid           4
(expression)  4326 MULTIPOINT (1 0, 3 2, 3 2, 4 5) 

1 row(s) retrieved.

Copyright© 2019 HCL Technologies Limited