Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

RavenDB integration now supports multiple spatial fields for each index

  • Loading branch information...
commit eccfb05452f437e3b7e13d32f5f3750c4f2f54f7 1 parent a49f73c
@sibartlett authored
View
6 .gitignore
@@ -1,6 +1,3 @@
-
-<!-- saved from url=(0063)https://raw.github.com/github/gitignore/master/CSharp.gitignore -->
-<html><script type="text/javascript">window["_gaUserPrefs"] = { ioo : function() { return true; } }</script><script id="tinyhippos-injected">if (window.top.require) { window.top.require("ripple/bootstrap").inject(window, document); }</script><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><script>window["_GOOG_TRANS_EXT_VER"] = "1";</script><script>window["_GOOG_TRANS_EXT_VER"] = "1";</script></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
[Bb]in/
[Oo]bj/
@@ -104,5 +101,4 @@ Generated_Code #added for RIA/Silverlight projects
# Visual Studio version. Backup files are not needed, because we have git ;-)
_UpgradeReport_Files/
Backup*/
-UpgradeLog*.XML
-</pre></body><link rel="stylesheet" type="text/css" href="data:text/css,"></html>
+UpgradeLog*.XML
View
30 Geo.Raven.Silverlight4/Geo.Raven.Silverlight4.csproj
@@ -63,18 +63,36 @@
</Reference>
</ItemGroup>
<ItemGroup>
- <Compile Include="..\Geo.Raven\GeoContractResolver.cs">
- <Link>GeoContractResolver.cs</Link>
+ <Compile Include="..\Geo.Raven\GeoRavenExtensions.cs">
+ <Link>GeoRavenExtensions.cs</Link>
</Compile>
- <Compile Include="..\Geo.Raven\GeoIndexCreationTask.cs">
+ <Compile Include="..\Geo.Raven\Indexes\GeoIndexCreationTask.cs">
<Link>GeoIndexCreationTask.cs</Link>
</Compile>
- <Compile Include="..\Geo.Raven\GeoRavenExtensions.cs">
- <Link>GeoRavenExtensions.cs</Link>
+ <Compile Include="..\Geo.Raven\Indexes\GeoIndexTranformer.cs">
+ <Link>GeoIndexTranformer.cs</Link>
+ </Compile>
+ <Compile Include="..\Geo.Raven\Indexes\GeoMultiMapIndexCreationTask.cs">
+ <Link>GeoMultiMapIndexCreationTask.cs</Link>
</Compile>
- <Compile Include="..\Geo.Raven\GeoValueProvider.cs">
+ <Compile Include="..\Geo.Raven\Json\GeoContractResolver.cs">
+ <Link>GeoContractResolver.cs</Link>
+ </Compile>
+ <Compile Include="..\Geo.Raven\Json\GeoValueProvider.cs">
<Link>GeoValueProvider.cs</Link>
</Compile>
+ <Compile Include="..\Geo.Raven\Query\AbstractWhereClause.cs">
+ <Link>AbstractWhereClause.cs</Link>
+ </Compile>
+ <Compile Include="..\Geo.Raven\Query\LinqWhereClause.cs">
+ <Link>LinqWhereClause.cs</Link>
+ </Compile>
+ <Compile Include="..\Geo.Raven\Query\LuceneWhereClause.cs">
+ <Link>LuceneWhereClause.cs</Link>
+ </Compile>
+ <Compile Include="..\Geo.Raven\SpatialField.cs">
+ <Link>SpatialField.cs</Link>
+ </Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
View
30 Geo.Raven.Silverlight5/Geo.Raven.Silverlight5.csproj
@@ -63,18 +63,36 @@
</Reference>
</ItemGroup>
<ItemGroup>
- <Compile Include="..\Geo.Raven\GeoContractResolver.cs">
- <Link>GeoContractResolver.cs</Link>
+ <Compile Include="..\Geo.Raven\GeoRavenExtensions.cs">
+ <Link>GeoRavenExtensions.cs</Link>
</Compile>
- <Compile Include="..\Geo.Raven\GeoIndexCreationTask.cs">
+ <Compile Include="..\Geo.Raven\Indexes\GeoIndexCreationTask.cs">
<Link>GeoIndexCreationTask.cs</Link>
</Compile>
- <Compile Include="..\Geo.Raven\GeoRavenExtensions.cs">
- <Link>GeoRavenExtensions.cs</Link>
+ <Compile Include="..\Geo.Raven\Indexes\GeoIndexTranformer.cs">
+ <Link>GeoIndexTranformer.cs</Link>
+ </Compile>
+ <Compile Include="..\Geo.Raven\Indexes\GeoMultiMapIndexCreationTask.cs">
+ <Link>GeoMultiMapIndexCreationTask.cs</Link>
</Compile>
- <Compile Include="..\Geo.Raven\GeoValueProvider.cs">
+ <Compile Include="..\Geo.Raven\Json\GeoContractResolver.cs">
+ <Link>GeoContractResolver.cs</Link>
+ </Compile>
+ <Compile Include="..\Geo.Raven\Json\GeoValueProvider.cs">
<Link>GeoValueProvider.cs</Link>
</Compile>
+ <Compile Include="..\Geo.Raven\Query\AbstractWhereClause.cs">
+ <Link>AbstractWhereClause.cs</Link>
+ </Compile>
+ <Compile Include="..\Geo.Raven\Query\LinqWhereClause.cs">
+ <Link>LinqWhereClause.cs</Link>
+ </Compile>
+ <Compile Include="..\Geo.Raven\Query\LuceneWhereClause.cs">
+ <Link>LuceneWhereClause.cs</Link>
+ </Compile>
+ <Compile Include="..\Geo.Raven\SpatialField.cs">
+ <Link>SpatialField.cs</Link>
+ </Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
View
14 Geo.Raven/Geo.Raven.csproj
@@ -42,15 +42,19 @@
<HintPath>..\packages\RavenDB.Client.1.2.2138-Unstable\lib\net40\Raven.Client.Lightweight.dll</HintPath>
</Reference>
<Reference Include="System" />
- <Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
- <Compile Include="GeoMultiMapIndexCreationTask.cs" />
- <Compile Include="GeoContractResolver.cs" />
- <Compile Include="GeoIndexCreationTask.cs" />
+ <Compile Include="Indexes\GeoIndexTranformer.cs" />
+ <Compile Include="Json\GeoValueProvider.cs" />
+ <Compile Include="SpatialField.cs" />
+ <Compile Include="Indexes\GeoMultiMapIndexCreationTask.cs" />
+ <Compile Include="Json\GeoContractResolver.cs" />
+ <Compile Include="Indexes\GeoIndexCreationTask.cs" />
<Compile Include="GeoRavenExtensions.cs" />
- <Compile Include="GeoValueProvider.cs" />
+ <Compile Include="Query\AbstractWhereClause.cs" />
+ <Compile Include="Query\LinqWhereClause.cs" />
+ <Compile Include="Query\LuceneWhereClause.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
View
68 Geo.Raven/GeoRavenExtensions.cs
@@ -1,14 +1,12 @@
-using System.Collections.Generic;
-using System.Linq;
-using System.Text.RegularExpressions;
-using Geo.Geometries;
+using System;
+using System.Linq.Expressions;
using Geo.Interfaces;
-using Geo.Measure;
-using Geo.Raven;
-using Raven.Abstractions.Data;
-using Raven.Abstractions.Indexing;
+using Geo.Raven.Json;
+using Geo.Raven.Query;
+using Raven.Client;
+using Raven.Client.Linq;
-namespace Raven.Client
+namespace Geo.Raven
{
public static class GeoRavenExtensions
{
@@ -18,58 +16,14 @@ public static IDocumentStore ApplyGeoConventions(this IDocumentStore store)
return store;
}
- public static IDocumentQueryBase<T, TSelf> WithinRadiusOf<T, TSelf>(this IDocumentQueryBase<T, TSelf> self, double radiusKm, IPosition position) where TSelf : IDocumentQueryBase<T, TSelf>
+ public static IRavenQueryable<T> Geo<T>(this IRavenQueryable<T> source, Expression<Func<T, IRavenIndexable>> property, Func<LinqWhereClause<T>, IRavenQueryable<T>> clause)
{
- var coordinate = position.GetCoordinate();
- return self.WithinRadiusOf(radiusKm, coordinate.Latitude, coordinate.Longitude);
+ return clause(new LinqWhereClause<T>(source, property));
}
- public static IDocumentQueryBase<T, TSelf> WithinRadiusOf<T, TSelf>(this IDocumentQueryBase<T, TSelf> self, Distance radius, IPosition position) where TSelf : IDocumentQueryBase<T, TSelf>
+ public static IDocumentQuery<T> Geo<T>(this IDocumentQuery<T> query, Expression<Func<T, IRavenIndexable>> propertySelector, Func<LuceneWhereClause<T>, IDocumentQuery<T>> clause)
{
- var coordinate = position.GetCoordinate();
- return self.WithinRadiusOf(radius.ConvertTo(DistanceUnit.Km).Value, coordinate.Latitude, coordinate.Longitude);
- }
-
- public static IDocumentQueryBase<T, TSelf> RelatesToShape<T, TSelf>(this IDocumentQueryBase<T, TSelf> self, IRavenIndexable shape, SpatialRelation relation, double distanceErrorPct = Constants.DefaultSpatialDistanceErrorPct) where TSelf : IDocumentQueryBase<T, TSelf>
- {
- return self.RelatesToShape(Constants.DefaultSpatialFieldName, new GeoValueProvider().GetValue(shape), relation, distanceErrorPct);
- }
-
- public static IDocumentQueryCustomization WithinRadiusOf(this IDocumentQueryCustomization self, double radiusKm, IPosition position)
- {
- var coordinate = position.GetCoordinate();
- return self.WithinRadiusOf(radiusKm, coordinate.Latitude, coordinate.Longitude);
- }
-
- public static IDocumentQueryCustomization WithinRadiusOf(this IDocumentQueryCustomization self, Distance radius, IPosition position)
- {
- var coordinate = position.GetCoordinate();
- return self.WithinRadiusOf(radius.ConvertTo(DistanceUnit.Km).Value, coordinate.Latitude, coordinate.Longitude);
- }
-
- public static IDocumentQueryCustomization RelatesToShape(this IDocumentQueryCustomization self, IRavenIndexable shape, SpatialRelation relation)
- {
- return self.RelatesToShape(Constants.DefaultSpatialFieldName, new GeoValueProvider().GetValue(shape), relation);
- }
-
- public static IndexDefinition TransformGeoMaps(this IndexDefinition definition)
- {
- definition.Maps = new HashSet<string>(definition.Maps.Select(TransformGeoIndexes));
- definition.Reduce = TransformGeoIndexes(definition.Reduce);
- return definition;
- }
-
- private static string TransformGeoIndexes(string value)
- {
- if (value == null)
- return null;
-
- return Regex.Replace(value, @"GeoIndex\((?<prop>[\w\d\s\.]+)(?<sep>[,)])", match =>
- string.Format("SpatialGenerate(\"{0}\", {1}.{2}{3}",
- Constants.DefaultSpatialFieldName,
- match.Groups["prop"].Value,
- GeoContractResolver.IndexProperty,
- match.Groups["sep"].Value));
+ return clause(new LuceneWhereClause<T>(query, propertySelector));
}
}
}
View
24 Geo.Raven/GeoValueProvider.cs
@@ -1,24 +0,0 @@
-using System;
-using Geo.Interfaces;
-using Raven.Imports.Newtonsoft.Json.Serialization;
-
-namespace Geo.Raven
-{
- public class GeoValueProvider : IValueProvider
- {
- public void SetValue(object target, object value)
- {
- throw new NotSupportedException();
- }
-
- public object GetValue(object target)
- {
- return GetValue(target as IRavenIndexable);
- }
-
- public string GetValue(IRavenIndexable target)
- {
- return target == null ? null : target.GetIndexString();
- }
- }
-}
View
5 Geo.Raven/GeoIndexCreationTask.cs → Geo.Raven/Indexes/GeoIndexCreationTask.cs
@@ -1,10 +1,9 @@
using System;
using Geo.Interfaces;
using Raven.Abstractions.Indexing;
-using Raven.Client;
using Raven.Client.Indexes;
-namespace Geo.Raven
+namespace Geo.Raven.Indexes
{
public class GeoIndexCreationTask<TDocument> : GeoIndexCreationTask<TDocument, TDocument>
{
@@ -29,7 +28,7 @@ public object GeoIndex(IRavenIndexable shape, SpatialSearchStrategy strategy, in
public override IndexDefinition CreateIndexDefinition()
{
- return base.CreateIndexDefinition().TransformGeoMaps();
+ return GeoIndexTranformer.Transform(base.CreateIndexDefinition(), Conventions);
}
}
}
View
36 Geo.Raven/Indexes/GeoIndexTranformer.cs
@@ -0,0 +1,36 @@
+using System.Collections.Generic;
+using System.Linq;
+using System.Text.RegularExpressions;
+using Raven.Abstractions.Indexing;
+using Raven.Client.Document;
+
+namespace Geo.Raven.Indexes
+{
+ internal class GeoIndexTranformer
+ {
+ public static IndexDefinition Transform(IndexDefinition definition, DocumentConvention conventions)
+ {
+ definition.Maps = new HashSet<string>(definition.Maps.Select(x => TransformGeoIndexes(x, definition, conventions)));
+ definition.Reduce = TransformGeoIndexes(definition.Reduce, definition, conventions);
+ return definition;
+ }
+
+ private static string TransformGeoIndexes(string value, IndexDefinition definition, DocumentConvention conventions)
+ {
+ if (value == null)
+ return null;
+
+ return Regex.Replace(value, @"GeoIndex\((?<pre>[^.]+)[.](?<prop>[^),]+)(?<remainder>[^)]*)[)]", match =>
+ {
+ var fieldPrefix = match.Groups["prop"].Value.Replace(".", "_");
+ return string.Format("SpatialGenerate(\"{0}_{1}\", {2}.{3}.{1}{4})",
+ match.Groups["prop"].Value.Replace(".", "_"),
+ SpatialField.Name,
+ match.Groups["pre"].Value,
+ match.Groups["prop"].Value,
+ match.Groups["remainder"].Value
+ );
+ });
+ }
+ }
+}
View
5 Geo.Raven/GeoMultiMapIndexCreationTask.cs → ...n/Indexes/GeoMultiMapIndexCreationTask.cs
@@ -1,10 +1,9 @@
using System;
using Geo.Interfaces;
using Raven.Abstractions.Indexing;
-using Raven.Client;
using Raven.Client.Indexes;
-namespace Geo.Raven
+namespace Geo.Raven.Indexes
{
public abstract class GeoMultiMapIndexCreationTask : GeoMultiMapIndexCreationTask<object>
{
@@ -29,7 +28,7 @@ public object GeoIndex(IRavenIndexable shape, SpatialSearchStrategy strategy, in
public override IndexDefinition CreateIndexDefinition()
{
- return base.CreateIndexDefinition().TransformGeoMaps();
+ return GeoIndexTranformer.Transform(base.CreateIndexDefinition(), Conventions);
}
}
}
View
9 Geo.Raven/GeoContractResolver.cs → Geo.Raven/Json/GeoContractResolver.cs
@@ -4,18 +4,17 @@
using Geo.Interfaces;
using Raven.Imports.Newtonsoft.Json.Serialization;
-namespace Geo.Raven
+namespace Geo.Raven.Json
{
public class GeoContractResolver : DefaultContractResolver
{
private readonly Assembly _assembly = typeof(Coordinate).Assembly;
- public const string IndexProperty = "__geo";
protected override JsonProperty CreateProperty(MemberInfo member, global::Raven.Imports.Newtonsoft.Json.MemberSerialization memberSerialization)
{
var prop = base.CreateProperty(member, memberSerialization);
- if(member.DeclaringType !=null)
+ if(member.DeclaringType != null)
{
if (member.DeclaringType.Assembly == _assembly)
{
@@ -43,10 +42,10 @@ protected override JsonObjectContract CreateObjectContract(Type objectType)
{
Readable = true,
ShouldSerialize = value => true,
- PropertyName = IndexProperty,
+ PropertyName = SpatialField.Name,
PropertyType = typeof(string),
Converter = ResolveContractConverter(typeof(string)),
- ValueProvider = new GeoValueProvider()
+ ValueProvider = new GeoValueProvider<IRavenIndexable, string>(x => x.GetIndexString())
});
}
View
26 Geo.Raven/Json/GeoValueProvider.cs
@@ -0,0 +1,26 @@
+using System;
+using Raven.Imports.Newtonsoft.Json.Serialization;
+
+namespace Geo.Raven.Json
+{
+ public class GeoValueProvider<T, TResult> : IValueProvider where T : class
+ {
+ private readonly Func<T, object> _func;
+
+ public GeoValueProvider(Func<T, object> func)
+ {
+ _func = func;
+ }
+
+ public void SetValue(object target, object value)
+ {
+ throw new NotSupportedException();
+ }
+
+ public object GetValue(object target)
+ {
+ var obj = target as T;
+ return obj == null ? default(TResult) : _func(obj);
+ }
+ }
+}
View
32 Geo.Raven/Query/AbstractWhereClause.cs
@@ -0,0 +1,32 @@
+using Geo.Interfaces;
+using Geo.Measure;
+using Raven.Abstractions.Indexing;
+
+namespace Geo.Raven.Query
+{
+ public abstract class AbstractWhereClause<T>
+ {
+ public abstract T RelatesToShape(IRavenIndexable geometry, SpatialRelation relation);
+ public abstract T WithinRadiusOf(IPosition position, Distance distance);
+
+ public T Within(IRavenIndexable geometry)
+ {
+ return RelatesToShape(geometry, SpatialRelation.Within);
+ }
+
+ public T Intersects(IRavenIndexable geometry)
+ {
+ return RelatesToShape(geometry, SpatialRelation.Intersects);
+ }
+
+ public T Contains(IRavenIndexable geometry)
+ {
+ return RelatesToShape(geometry, SpatialRelation.Contains);
+ }
+
+ public T WithinRadiusOf(IPosition position, double value, DistanceUnit unit = DistanceUnit.M)
+ {
+ return WithinRadiusOf(position, new Distance(value, unit));
+ }
+ }
+}
View
31 Geo.Raven/Query/LinqWhereClause.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Linq.Expressions;
+using Geo.Interfaces;
+using Geo.Measure;
+using Raven.Abstractions.Indexing;
+using Raven.Client.Linq;
+
+namespace Geo.Raven.Query
+{
+ public class LinqWhereClause<T> : AbstractWhereClause<IRavenQueryable<T>>
+ {
+ private readonly IRavenQueryable<T> _source;
+ private readonly Expression<Func<T, IRavenIndexable>> _property;
+
+ public LinqWhereClause(IRavenQueryable<T> source, Expression<Func<T, IRavenIndexable>> property)
+ {
+ _source = source;
+ _property = property;
+ }
+
+ public override IRavenQueryable<T> RelatesToShape(IRavenIndexable geometry, SpatialRelation relation)
+ {
+ return _source.Customize(x => x.RelatesToShape(SpatialField.NameFor(_property), geometry.GetIndexString(), relation));
+ }
+
+ public override IRavenQueryable<T> WithinRadiusOf(IPosition position, Distance distance)
+ {
+ return _source.Customize(x => x.WithinRadiusOf(SpatialField.NameFor(_property), distance.ConvertTo(DistanceUnit.Km).Value, position.GetCoordinate().Latitude, position.GetCoordinate().Longitude));
+ }
+ }
+}
View
31 Geo.Raven/Query/LuceneWhereClause.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Linq.Expressions;
+using Geo.Interfaces;
+using Geo.Measure;
+using Raven.Abstractions.Indexing;
+using Raven.Client;
+
+namespace Geo.Raven.Query
+{
+ public class LuceneWhereClause<T> : AbstractWhereClause<IDocumentQuery<T>>
+ {
+ private readonly IDocumentQuery<T> _query;
+ private readonly Expression<Func<T, IRavenIndexable>> _propertySelector;
+
+ public LuceneWhereClause(IDocumentQuery<T> query, Expression<Func<T, IRavenIndexable>> propertySelector)
+ {
+ _query = query;
+ _propertySelector = propertySelector;
+ }
+
+ public override IDocumentQuery<T> RelatesToShape(IRavenIndexable geometry, SpatialRelation relation)
+ {
+ return _query.RelatesToShape(SpatialField.NameFor(_propertySelector), geometry.GetIndexString(), relation);
+ }
+
+ public override IDocumentQuery<T> WithinRadiusOf(IPosition position, Distance distance)
+ {
+ return _query.WithinRadiusOf(SpatialField.NameFor(_propertySelector), distance.ConvertTo(DistanceUnit.Km).Value, position.GetCoordinate().Latitude, position.GetCoordinate().Longitude);
+ }
+ }
+}
View
36 Geo.Raven/SpatialField.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq.Expressions;
+using Geo.Interfaces;
+
+namespace Geo.Raven
+{
+ internal static class SpatialField
+ {
+ public const string Name = "__spatial";
+
+ public static string NameFor<T>(Expression<Func<T, IRavenIndexable>> propertySelector)
+ {
+ var members = new List<string>();
+ var expression = propertySelector.Body;
+ while (expression != null)
+ {
+ if (expression.NodeType == ExpressionType.MemberAccess)
+ {
+ var memberExpression = (MemberExpression)expression;
+ members.Add(memberExpression.Member.Name);
+ expression = memberExpression.Expression;
+ }
+ else
+ break;
+ }
+
+ if (members.Count <= 0)
+ return null;
+
+ members.Add(Name);
+
+ return string.Join("_", members);
+ }
+ }
+}
View
27 Geo.Tests/Raven/RavenTestFixtureBase.cs
@@ -1,8 +1,8 @@
using System;
using System.Linq;
-using Geo.Geometries;
using Geo.Interfaces;
using Geo.Raven;
+using Geo.Raven.Indexes;
using NUnit.Framework;
using Raven.Abstractions.Indexing;
using Raven.Client;
@@ -20,6 +20,7 @@ public void InitRaven(params AbstractIndexCreationTask[] indexes)
{
if (Store != null)
Store.Dispose();
+
Store = new EmbeddableDocumentStore { RunInMemory = true }.ApplyGeoConventions().Initialize();
foreach (var index in indexes)
Store.ExecuteIndex(index);
@@ -37,6 +38,9 @@ public class GeoDoc
{
public string Id { get; set; }
public IGeometry Geometry { get; set; }
+ public string Data1 { get; set; }
+ public string Data2 { get; set; }
+ public string Data3 { get; set; }
}
public class TestIndex : GeoIndexCreationTask<GeoDoc>
@@ -46,6 +50,9 @@ public TestIndex()
Map = docs => from doc in docs
select new
{
+ doc.Data1,
+ doc.Data2,
+ doc.Data3,
_ = GeoIndex(doc.Geometry)
};
}
@@ -66,7 +73,7 @@ public void AssertThatIndexPropertyIsGenerated(IGeometry geometry)
using (var session = Store.OpenSession())
{
var json = session.Load<RavenJObject>(doc.Id);
- var result = json.Value<RavenJObject>("Geometry").ContainsKey(GeoContractResolver.IndexProperty);
+ var result = json.Value<RavenJObject>("Geometry").ContainsKey("__spatial");
Assert.That(result, Is.True);
}
}
@@ -81,7 +88,7 @@ public void AssertFalse(IGeometry geometry, SpatialRelation relation, IGeometry
AssertThat(geometry, relation, geometry2, false);
}
- private void AssertThat(IGeometry geometry, SpatialRelation relation, IGeometry geometry2, bool expected)
+ private void AssertThat(IGeometry geometry, SpatialRelation relation, IRavenIndexable geometry2, bool expected)
{
InitRaven(new TestIndex());
var doc = new GeoDoc
@@ -95,12 +102,9 @@ private void AssertThat(IGeometry geometry, SpatialRelation relation, IGeometry
}
using (var session = Store.OpenSession())
{
- var result = session.Query<RavenJObject, TestIndex>()
- .Customize(x =>
- {
- x.RelatesToShape(geometry2, relation);
- x.WaitForNonStaleResults();
- })
+ var result = session.Query<GeoDoc, TestIndex>()
+ .Geo(x => x.Geometry, x => x.RelatesToShape(geometry2, relation))
+ .Customize(x => x.WaitForNonStaleResults())
.Any();
var relationString = relation.ToString().ToLowerInvariant();
@@ -111,10 +115,7 @@ private void AssertThat(IGeometry geometry, SpatialRelation relation, IGeometry
relationString = relationString.Substring(0, relationString.Length - 1);
}
- var msg = string.Format("Geometry {0}{1} {2} {3}", s? "does" : "is", result? "" : " not", relationString, new GeoValueProvider().GetValue(geometry2));
-
- Console.WriteLine(msg);
-
+ var msg = string.Format("Geometry {0}{1} {2} {3}", s ? "does" : "is", result ? "" : " not", relationString, geometry2.GetIndexString());
Assert.That(result, Is.EqualTo(expected), msg);
}
View
2  Geo.Tests/Raven/RavenTests.cs
@@ -33,7 +33,7 @@ public void CircleTests()
[Test]
public void LineStringTests()
{
- var lineString = new LineString(new[] { new Coordinate(0, 0), new Coordinate(1, 1), new Coordinate(1, 2), new Coordinate(0, 0) });
+ var lineString = new LineString(new[] { new Coordinate(0, 0), new Coordinate(1, 1), new Coordinate(1, 2) });
AssertThatIndexPropertyIsGenerated(lineString);
AssertTrue(lineString, SpatialRelation.Within, new Circle(0, 0, 600000));
AssertFalse(lineString, SpatialRelation.Within, new Circle(0, 160, 600000));
Please sign in to comment.
Something went wrong with that request. Please try again.