Skip to content

Commit e4e3781

Browse files
committed
Implement EqualsExact spatial criteria
1 parent 675587f commit e4e3781

File tree

14 files changed

+237
-15
lines changed

14 files changed

+237
-15
lines changed

NHibernate.Spatial.MsSql/Dialect/MsSql2012FunctionRegistration.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,9 @@ public SqlString GetSpatialRelationString(object geometry, SpatialRelation relat
413413
case SpatialRelation.CoveredBy:
414414
return GetSpatialRelationString(anotherGeometry, SpatialRelation.Covers, geometry, criterion);
415415

416+
case SpatialRelation.EqualsExact:
417+
throw new NotSupportedException($"{relation} not supported by SQL Server");
418+
416419
default:
417420
// NOTE: Cast is only required if "geometry" is passed in as a parameter
418421
// directly, rather than as a column name. This is because parameter

NHibernate.Spatial.MySQL/Dialect/MySQL57SpatialDialect.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,9 @@ public SqlString GetSpatialRelationString(object geometry, SpatialRelation relat
331331
case SpatialRelation.CoveredBy:
332332
return GetSpatialRelationString(anotherGeometry, SpatialRelation.Covers, geometry, criterion);
333333

334+
case SpatialRelation.EqualsExact:
335+
throw new NotSupportedException($"{relation} not supported by SQL Server");
336+
334337
default:
335338
return new SqlStringBuilder(6)
336339
.Add(SpatialDialect.IsoPrefix)

NHibernate.Spatial.PostGis/Dialect/PostGis20Dialect.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,16 @@ public SqlString GetSpatialRelationString(object geometry, SpatialRelation relat
320320
case SpatialRelation.CoveredBy:
321321
return GetSpatialRelationString(anotherGeometry, SpatialRelation.Covers, geometry, criterion);
322322

323+
case SpatialRelation.EqualsExact:
324+
return new SqlStringBuilder()
325+
.Add(SpatialDialect.IsoPrefix)
326+
.Add("OrderingEquals(")
327+
.AddObject(geometry)
328+
.Add(", ")
329+
.AddObject(anotherGeometry)
330+
.Add(")")
331+
.ToSqlString();
332+
323333
default:
324334
return new SqlStringBuilder(6)
325335
.Add(SpatialDialect.IsoPrefix)

NHibernate.Spatial/Criterion/Lambda/LambdaSpatialRestrictionBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ public AbstractCriterion Eq(object value)
107107
/// <summary>
108108
/// Apply a "eq exact" constraint to the named property
109109
/// </summary>
110-
public AbstractCriterion EqExact(object value, double tolerance)
110+
public AbstractCriterion EqExact(object value)
111111
{
112-
return Process(SpatialRestrictions.EqExact(propertyName, value, tolerance));
112+
return Process(SpatialRestrictions.EqExact(propertyName, value));
113113
}
114114

115115
/// <summary>

NHibernate.Spatial/Criterion/Lambda/QueryOverSpatialRestrictionBuilderBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ public TReturn Eq(object value)
101101
/// <summary>
102102
/// Apply a "eq exact" constraint to the named property
103103
/// </summary>
104-
public TReturn EqExact(object value, double tolerance)
104+
public TReturn EqExact(object value)
105105
{
106-
return Add(SpatialRestrictions.EqExact(propertyName, value, tolerance));
106+
return Add(SpatialRestrictions.EqExact(propertyName, value));
107107
}
108108

109109
/// <summary>

NHibernate.Spatial/Criterion/SpatialProjections.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,17 @@ public static SpatialProjection Equals(string propertyName, string anotherProper
246246
return new SpatialRelationProjection(propertyName, SpatialRelation.Equals, anotherPropertyName);
247247
}
248248

249+
/// <summary>
250+
/// Determines whether the specified geometry property is exactly equal to another geometry property.
251+
/// </summary>
252+
/// <param name="propertyName">Name of the property.</param>
253+
/// <param name="anotherPropertyName">Name of another property.</param>
254+
/// <returns></returns>
255+
public static SpatialProjection EqualsExact(string propertyName, string anotherPropertyName)
256+
{
257+
return new SpatialRelationProjection(propertyName, SpatialRelation.EqualsExact, anotherPropertyName);
258+
}
259+
249260
/// <summary>
250261
/// Determines whether the specified geometry property intersects another geometry property.
251262
/// </summary>

NHibernate.Spatial/Criterion/SpatialProjectionsLambda.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,17 @@ public static SpatialProjection Equals<T>(Expression<Func<T, object>> expression
258258
return Equals(GetPropertyName(expression), GetPropertyName(anotherExpression));
259259
}
260260

261+
/// <summary>
262+
/// Determines whether the specified geometry property is exactly equal to another geometry property.
263+
/// </summary>
264+
/// <param name="expression">Name of the property.</param>
265+
/// <param name="anotherExpression">Name of another property.</param>
266+
/// <returns></returns>
267+
public static SpatialProjection EqualsExact<T>(Expression<Func<T, object>> expression, Expression<Func<T, object>> anotherExpression)
268+
{
269+
return EqualsExact(GetPropertyName(expression), GetPropertyName(anotherExpression));
270+
}
271+
261272
/// <summary>
262273
/// Determines whether the specified geometry property intersects another geometry property.
263274
/// </summary>

NHibernate.Spatial/Criterion/SpatialRestrictions.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,14 @@ public static SpatialRelationCriterion Eq(string propertyName, object anotherGeo
142142
}
143143

144144
/// <summary>
145-
/// Determines whether the specified geometry property is exactly equals (within a tolerance) to another geometry.
145+
/// Determines whether the specified geometry property is exactly equal to another geometry.
146146
/// </summary>
147147
/// <param name="propertyName">Name of the property.</param>
148148
/// <param name="anotherGeometry">Another geometry.</param>
149-
/// <param name="tolerance">The tolerance.</param>
150149
/// <returns></returns>
151-
public static SpatialRelationCriterion EqExact(string propertyName, object anotherGeometry, double tolerance)
150+
public static SpatialRelationCriterion EqExact(string propertyName, object anotherGeometry)
152151
{
153-
// TODO: Implement
154-
throw new NotImplementedException();
152+
return new SpatialRelationCriterion(propertyName, SpatialRelation.EqualsExact, anotherGeometry);
155153
}
156154

157155
/// <summary>

NHibernate.Spatial/SpatialRelation.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ public enum SpatialRelation
5252
/// </summary>
5353
Equals,
5454

55+
/// <summary>
56+
///
57+
/// </summary>
58+
EqualsExact,
59+
5560
/// <summary>
5661
///
5762
/// </summary>

Tests.NHibernate.Spatial.MsSql2012/MsSql2012NtsTestCasesFixture.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ public class MsSql2012NtsTestCasesFixture : NtsTestCasesFixture
2121
protected override string TestSimpleDataPath => Path.Combine(LocalDataPath, @"TestSimple.xml");
2222

2323
[Test]
24-
[Ignore("Not supported by MS SQL")]
24+
[Ignore("Not supported by SQL Server")]
25+
public override void EqualsExact()
26+
{ }
27+
28+
[Test]
29+
[Ignore("Not supported by SQL Server")]
2530
public override void StringRelate()
26-
{
27-
base.StringRelate();
28-
}
31+
{ }
2932

3033
[Test]
3134
public void WhenRelateWithoutPatternThenThrows()

0 commit comments

Comments
 (0)