
GQLINSERT (paris:City {name: "Paris", location: point(2.4, 48.9), landmark: point3d(100, 25.3, 652.1)}), (newYork:City {name: "New York", location: point(-74.0, 40.7), landmark: point3d(95, 23, 54)}), (london:City {name: "London", location: point(-0.13, 51.5), landmark: point3d(5.2, 66, 3.2)}), (newYork)-[:Connects]->(paris), (newYork)-[:Connects]->(london), (paris)-[:Connects]->(london)
Creates a two-dimensional geographical coordinate.
| Syntax | point(<longitude>, <latitude>) | ||
| Arguments | Name | Type | Description |
<longitude> | Numeric | The longitude value, ranging from -180 to 180 | |
<latitude> | Numeric | The latitude value, ranging from -90 to 90 | |
| Return Type | POINT | ||
GQLRETURN point(116.3, 39.9) AS point
Result:
JSON{ "longitude": 116.3, "latitude": 39.9 }
Creates a three-dimensional Cartesian coordinate.
| Syntax | point3d(<x>, <y>, <z>) | ||
| Arguments | Name | Type | Description |
<x> | Numeric | The x coordinate | |
<y> | Numeric | The y coordinate | |
<z> | Numeric | The z coordinate | |
| Return Type | POINT3D | ||
GQLRETURN point3d(10, 15, 5) AS point3d
Result:
JSON{ "x": 10, "y": 15, "z": 5 }
Computes the distance between two points. For POINT values, it uses the Haversine formula to calculate the great-circle distance on Earth in kilometers. For POINT3D values, it computes the Euclidean distance.
| Syntax | distance(<point1>, <point2>) | ||
| Arguments | Name | Type | Description |
<point1> | POINT or POINT3D | The first point | |
<point2> | POINT or POINT3D | The second point; must be the same type as <point1> | |
| Return Type | DOUBLE | ||
GQLMATCH (n1:City {name: 'New York'}) MATCH (n2:City {name: 'London'}) RETURN distance(n1.location, n2.location)
Result: 5570.833653336143
Extracts a coordinate value from a POINT or POINT3D value by index.
| Syntax | pointget(<point>, <index>) | ||
| Arguments | Name | Type | Description |
<point> | POINT or POINT3D | A point value | |
<index> | INT | Coordinate index. For POINT: 0 = longitude, 1 = latitude. For POINT3D: 0 = x, 1 = y, 2 = z. | |
| Return Type | DOUBLE | ||
GQLMATCH (n {name: "New York"}) RETURN pointget(n.location, 0) AS longitude, pointget(n.location, 1) AS latitude
Result:
| longitude | latitude |
|---|---|
| -74.0 | 40.7 |