誰かがこれを実装したことがありますか、またはこれを実装するのが難しいかどうか/ポインタを持っているかどうかを知っていますか?
public static SpatialRelationCriterion IsWithinDistance(string propertyName, object anotherGeometry, double distance)
{
// TODO: Implement
throw new NotImplementedException();
}
NHibernate.Spatial.Criterion.SpatialRestrictionsから
hqlで「whereNHSP.Distance(PROPERTY、:point)」を使用できます。しかし、このクエリを既存のCriteriaクエリと組み合わせたいと思います。
今のところ、ラフポリゴンを作成して使用しています
criteria.Add(SpatialRestrictions.Intersects("PROPERTY", myPolygon));
編集 SpatialRelationCriterionでコンストラクターをオーバーロードし、新しいSpatialRelation.Distanceを追加することで、プロトタイプが機能するようになりました
public static SpatialRelationCriterion IsWithinDistance(string propertyName, object anotherGeometry, double distance)
{
return new SpatialRelationCriterion(propertyName, SpatialRelation.Distance, anotherGeometry, distance);
}
SpatialRelationCriterionに新しいフィールドを追加しました
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));
}
オーバーロードされたISpatialDialect.GetSpatialRelationString
MsSql2008SpatialDialectにオーバーロードを実装
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が使用されていない理由がわかりませんか?