using System;using System.Collections.Generic;using System.Diagnostics;using System.Linq;using System.Text;using System.Threading.Tasks;using Raven.Client.Indexes;using Raven.Tests.Helpers;
namespace ConsoleApplication{ public class Car { public string Id { get; set; }
public double? Latitude { get; set; }
public double? Longitude { get; set; } }
public class Cars_Spatial : AbstractIndexCreationTask<Car, Cars_Spatial.Query> { public class Query { public object Position { get; set; } }
public Cars_Spatial() { Map = cars => from car in cars select new { Position = SpatialGenerate(nameof(Query.Position), car.Latitude, car.Longitude), };
Spatial(q => q.Position, options => options.Geography.Default()); } }
public class SpatialTest : RavenTestBase { public void Run() { using (var store = NewDocumentStore(requestedStorage: "Esent")) using (var session = store.OpenSession()) { session.Store(new Car { Latitude = 44.3190634, Longitude = 23.8071472, });
session.SaveChanges();
store.ExecuteIndex(new Cars_Spatial()); WaitForIndexing(store);
var inRange = session.Query<Cars_Spatial.Query, Cars_Spatial>() .Spatial(q => q.Position, criteria => criteria.WithinRadius(1, latitude: 44.3185266, longitude: 23.81044)) .OfType<Car>() .ToList();
Debugger.Break(); } } }
public static class Program { public static void Main(string[] args) { var test = new SpatialTest();
test.Run(); } }}
--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hibernating Rhinos Ltd
Michael Yarichuk l RavenDB Core Team
Office: +972-4-622-7811 l Fax: +972-153-4-622-7811
RavenDB paving the way to "Data Made Simple" http://ravendb.net/
Map = cars => from car in cars select new {
SomeRandomFieldName = SpatialGenerate(nameof(Query.Position), car.Latitude, car.Longitude), };