LIVE DEMO

Spatial neighbourhoods: graph meets map

Neighbourhood polygons, places as points and a graph of people above them: test containment, search by distance with the grid index, overlay shapes, and combine friends with distance in one query.

Spatial neighbourhoods: graph meets map: Neighbourhood polygons, places as points and a graph of people above them: test containment, search by distance with the grid index, overlay shapes, and combine friends with distance in one query.

This interactive demo needs WebGL. Read about it.

Spatial neighbourhoods: graph meets mapOpen the full demo →

What you are looking at

A small city, two kilometres across, laid out in metres. Five neighbourhoods are stored as polygons and every café, gym and cinema as a point. They are ordinary property values on nodes, validated when they are written, so a shape can sit in the same record as a name or a rating.

Above the map, the same six people from the embeddings demo float as a graph: who knows whom, which places they like, and where they live. That is the point of the demo. In Galactus DB the graph and the map are one database, so a single query can follow relationships and filter by distance at once.

The containment tests, distances, grid index, overlaps and centre points are computed in your browser with the same planar maths. Each step shows the Galactus DB Cypher that answers the same question. Nothing connects to a database.

Things to try

How the point index helps

The point index divides the map into a grid. A distance search reads only the squares its circle touches, then measures the places in them exactly. However large the city grows, a 500 m search still reads only the squares around it, where a scan would read everything.

In Galactus DB

CREATE POINT INDEX placeLoc FOR (p:Place) ON (p.loc);

CALL db.index.geo.withinDistance('placeLoc', point({x: 960, y: 860}), 500)
YIELD node, distance
RETURN node.name, round(distance) AS metres ORDER BY metres;

MATCH (me:Person {name: 'Ada'})-[:KNOWS]-(f:Person)-[:LIKES]->(c:Place {kind: 'Café'})
WHERE point.distance(c.loc, me.home) <= 800
RETURN c.name, collect(DISTINCT f.name) AS likedBy;

Galactus DB returns overlap shapes from spatial.intersection; the shares of the delivery zone shown in the demo are worked out in the browser from their areas.

Learn more