标准空间限制

是否有人实现了这一点,或者知道是否难以实现这一点/有任何指示吗?

public static SpatialRelationCriterion IsWithinDistance(string propertyName, object anotherGeometry, double distance)
{
// TODO: Implement
throw new NotImplementedException();
}

从 NHibernate。空间。标准。空间限制

我可以在 hql 中使用“ where NHSP.Range (PROPERTY,: point)”,但是希望将这个查询与我现有的 Criteria 查询结合起来。

目前我正在创建一个粗略的多边形,并使用

criteria.Add(SpatialRestrictions.Intersects("PROPERTY", myPolygon));

通过重载构造函数在空间关系标准上得到一个工作原型,添加新的空间关系。距离

public static SpatialRelationCriterion IsWithinDistance(string propertyName, object anotherGeometry, double distance)
{
return new SpatialRelationCriterion(propertyName, SpatialRelation.Distance, anotherGeometry, distance);
}

在“空间关系标准”中添加了一个新字段

private readonly double? distance;


public SpatialRelationCriterion(string propertyName, SpatialRelation relation, object anotherGeometry, double distance)
: this(propertyName, relation, anotherGeometry)
{
this.distance = distance;
}

编辑 ToSqlString

object secondGeometry = Parameter.Placeholder;
if (!(this.anotherGeometry is IGeometry))
{
secondGeometry = columns2[i];
}


if (distance.HasValue)
{
builder.Add(spatialDialect.GetSpatialRelationString(columns1[i], this.relation, secondGeometry, distance.Value, true));
}
else
{
builder.Add(spatialDialect.GetSpatialRelationString(columns1[i], this.relation, secondGeometry, true));
}

重载的空间方言

在 MsSql2008空间方言中实现了过载

public SqlString GetSpatialRelationString(object geometry, SpatialRelation relation, object anotherGeometry, double distance, bool criterion)
{
var x = new SqlStringBuilder(8)
.AddObject(geometry)
.Add(".ST")
.Add(relation.ToString())
.Add("(")
.AddObject(anotherGeometry)
.Add(")");


if (criterion)
{
x.Add(" < ");
x.AddObject(distance.ToString());
}


return x.ToSqlString();
}

不确定为什么没有使用 AddParameter?

3060 次浏览

Yes I think that Recompile the DLL is the best solution for now.

we are looking into this issue over at GitHub. Thanks for providing great insight and a possible solution. Here's a link to the issue: https://github.com/nhibernate/NHibernate.Spatial/issues/61

I will publish new NuGet packages as soon as this is fixed.