概述
函数point()
将一个包含两个坐标值的对象组装为一个坐标。
参数:point({latitude: <value_1>, longitude: <value_2>})
<value_1>
和<value_2>
:经纬度数值
返回值:
- 坐标值(point类型)
一般用法
本例将经纬度(39.9° N 116.3° E)转换为坐标:
return point({latitude:39.9, longitude:116.3})
POINT(39.900000 116.300000)
本例将一列对象转换为坐标:
uncollect [{latitude:39.9, longitude:116.3},{latitude:31.2, longitude:121.5}] as a
return point(a)
POINT(39.900000 116.300000)
POINT(31.200000 121.500000)
设置point类型属性值
示例图集:
在一个空图集中,依次运行以下各行语句创建示例图集:
create().node_property(@default, "name").node_property(@default, "lat_long", point)
insert().into(@default).nodes([{_id:"L001", _uuid:1, name:"New York", lat_long:point({latitude:40.7, longitude:-74.0})}, {_id:"L002", _uuid:2, name:"Paris", lat_long:point({latitude:48.5, longitude:2.2})}, {_id:"L003", _uuid:3, name:"Sydney", lat_long:point({latitude:-33.9, longitude:150.9})}, {_id:"L004", _uuid:4, name:"Beijing", lat_long:point({latitude:39.9, longitude:116.3})}])
本例插入一个@location点:
insert().into(@default).nodes({name: "Shanghai", lat_long: point({latitude: 31.2, longitude: 121.5}), _id: "L005", _uuid: 5}) as n
return n{*}
| _id | _uuid | name | lat_long |
|-------|-------|------------|-----------------------------|
| L005 | 5 | Shanghai | POINT(31.200000 121.500000) |