Skip to content
This repository has been archived by the owner on Aug 14, 2018. It is now read-only.

sibartlett/RavenDB.Client.Spatial

Repository files navigation

Spatial JsonConverters for RavenDB

NuGet Packages!

Enabling you to use third-party spatial libraries with RavenDB 3.0+!

GeoJSON and WKT JsonConverters for:

Example

Here's an example of using a WKT JsonConverter with DotSpatial/Geo/NetTopologySuite.

public class MyClass
{
	public string Id { get; set; }
	public IGeometry Shape { get; set; }
}

public class MyIndex : AbstractIndexCreationTask<MyClass>
{
	public MyIndex()
	{
		Map = shapes => from doc in docs
						select new
						{
							doc.Shape
						};

		Spatial(x => x.Shape, x => x.Geography.Default())
	}
}

public class Program
{
	public void Main()
	{
		using (var store = new EmbeddableDocumentStore())
		{
			store.Conventions.CustomizeJsonSerializer = x => x.Converters.Add(new WktConverter());
			store.Initialize();

			using (var session = store.OpenSession())
			{
				session.Store(new MyClass { Shape = new Point(30.533, -34.543) });
				session.SaveChanges();
			}

			using (var session = store.OpenSession())
			{
				var results = session.Query<MyClass>()
								.Spatial(x => x.WithinRadiusOf(100, new Point(0, 0)))
								.ToList();
			}
		}
	}
}

License

RavenDB.Client.Spatial is licensed under the terms of the GNU Lesser General Public License as published by the Free Software Foundation.

About

RavenDB JsonConverters for third-party spatial libraries

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages