where spatial.within(spatial.point(Latitude, Longitude), spatial.wkt('Circle(30 30 d=500.0000)'))
Where the shape is in WKT format and the relation is one of Within, Contains, Disjoint, Intersects. The above example will yield the same results as the example from the Radius Search section.
When using spatial.wkt() to define a polygon, the vertices (points that form the corners of the polygon) must be listed
in a counter-clockwise order:
All of the above examples are using the dynamic querying capabilities of RavenDB and will create automatic indexes to retrieve their results. However, spatial queries can also be performed against static indexes, and this is done in a very similar way.
public class Events_ByCoordinates : AbstractIndexCreationTask<Event>
Map = events => from e in events
Coordinates = CreateSpatialField(e.Latitude, e.Longitude)
from index 'Events/ByCoordinates'
where spatial.within(Coordinates, spatial.circle(500, 30, 30))
If you want to know how to setup and customize a spatial field in static index please refer to this article.
In order to sort the results by distance, please use the OrderByDistance or OrderByDistanceDescending methods. You can read more about them here.
Distance in RavenDB by default is measured in kilometers.