示例图集
以下示例根据该图集运行:

distance()
计算两个坐标点之间的直线距离。
语法 | distance(<point1>, <point2>) |
||
参数 | 名称 | 类型 | 描述 |
<point1> |
POINT 或POINT3D |
第一个点 | |
<point2> |
POINT 或POINT3D |
第二个点 | |
返回类型 | DOUBLE |
find().nodes({name == "New York"}) as p1
find().nodes({name == "London"}) as p2
return distance(p1.location, p2.location)
结果:
distance(p1.location, p2.location) |
---|
5571177.78487926 |
point()
构建一个二维地理坐标。可使用point()
函数指定point
类型属性值。
语法 | point({latitude: <lati>, longitude: <longti>}) |
||
参数 | 名称 | 类型 | 描述 |
<lati> |
数值 | 纬度值 | |
<longti> |
数值 | 经度值 | |
返回类型 | POINT |
return point({latitude:39.9, longitude:116.3}) as point
结果:
point |
---|
POINT(39.9 116.3) |
insert().into(@City).nodes([{name: "Tokyo", location: point({latitude: 35.7, longitude: 139.7})}]) as n
return n.location
结果:
n.location |
---|
POINT(35.7 139.7) |
point3d()
构建一个三维笛卡尔坐标。可使用point3d()
函数指定point3d
类型属性值。
语法 | point3d({x: <value_x>, y: <value_y>, z: <value_z>}) |
||
参数 | 名称 | 类型 | 描述 |
<value_x> |
数值 | x值 | |
<value_y> |
数值 | y值 | |
<value_z> |
数值 | z值 | |
返回类型 | POINT3D |
return point3d({x:10, y:15, z:5}) as point3d
结果:
point3d |
---|
POINT3D(10 15 5) |
insert().into(@City).nodes([{name: "Tokyo", landmark: point3d({x:10, y:15, z:5})}]) as n
return n.landmark
结果:
n.landmark |
---|
POINT3D(10 15 5) |