By browsing on this website you are agreeing to our 'Terms & Conditions' and the 'Privacy Policy' in regards to your rights and personal data handling.
Spatial functionality has been merged into RQL. To reflect that change, the Client API has integrated this feature into the session.Query and session.Advanced.DocumentQuery. The following migration samples will focus on the session.Query - the most common and recommended way of interaction with querying capabilities on RavenDB.
Namespaces
3.x
using Raven.Abstractions.Indexing;
using Raven.Client.Document;
4.0
using Raven.Client.Documents;
using Raven.Client.Documents.Indexes.Spatial;
Example I - Index
The following changes have been applied:
All spatial fields must be created using the CreateSpatialField method
No support for GeoJSON and other non-standard formats
No support for spatial clustering
3.x
private class SpatialDoc_ByShapeAndPoint : AbstractIndexCreationTask<SpatialDoc>
{
public SpatialDoc_ByShapeAndPoint()
{
Map = docs => from spatial in docs
select new
{
Shape = spatial.Shape,
Point = spatial.Point,
_ = SpatialGenerate("Coordinates", spatial.Point.Latitude, spatial.Point.Longitude),
_ = SpatialClustering("Clustering", spatial.Point.Latitude, spatial.Point.Longitude)
};
Spatial(x => x.Shape, options => options.Geography.Default());
Spatial(x => x.Point, options => options.Cartesian.BoundingBoxIndex());
}
}
4.0
private class SpatialDoc_ByShapeAndPoint : AbstractIndexCreationTask<SpatialDoc>
{
public SpatialDoc_ByShapeAndPoint()
{
Map = docs => from spatial in docs
select new
{
Shape = CreateSpatialField(spatial.Shape.Wkt),
Point = CreateSpatialField(spatial.Point.Latitude, spatial.Point.Longitude),
Coordinates = CreateSpatialField(spatial.Point.Latitude, spatial.Point.Longitude)
};
Spatial(x => x.Shape, options => options.Geography.Default());
Spatial(x => x.Point, options => options.Cartesian.BoundingBoxIndex());
}
}