Relatude Help

Sorting by distance

Sort by DistanceTo in the query. Nodes with no location come last:

var closest = db.Query<IVenue>()
                .Where(v => v.Location.IsWithin(oslo, 10_000))
                .OrderBy(v => v.Location.DistanceTo(oslo))
                .Take(10)
                .Execute();

The distance is worked out node by node, so filter by radius first to keep the set small. OrderBy(v => v.Location) throws: coordinates are stored along a space-filling curve, and that order means nothing to a reader.