Có ai thực hiện điều này, hoặc biết nếu nó sẽ khó khăn để thực hiện điều này/có bất kỳ con trỏ?Tiêu chí SpatialRestrictions.IsWithinDistance NHibernate.Spatial
public static SpatialRelationCriterion IsWithinDistance(string propertyName, object anotherGeometry, double distance)
{
// TODO: Implement
throw new NotImplementedException();
}
từ NHibernate.Spatial.Criterion.SpatialRestrictions
tôi có thể sử dụng "nơi NHSP.Distance (HỮU,: Điểm)" trong HQL. Nhưng muốn kết hợp truy vấn này với truy vấn Tiêu chí hiện tại của tôi.
cho thời điểm tôi đang tạo ra một đa giác thô, và sử dụng
criteria.Add(SpatialRestrictions.Intersects("PROPERTY", myPolygon));
EDIT Got một nguyên mẫu làm việc do quá tải nhà xây dựng trên SpatialRelationCriterion, thêm SpatialRelation.Distance mới
public static SpatialRelationCriterion IsWithinDistance(string propertyName, object anotherGeometry, double distance)
{
return new SpatialRelationCriterion(propertyName, SpatialRelation.Distance, anotherGeometry, distance);
}
đã thêm trường mới vào SpatialRelationCriterion
private readonly double? distance;
public SpatialRelationCriterion(string propertyName, SpatialRelation relation, object anotherGeometry, double distance)
: this(propertyName, relation, anotherGeometry)
{
this.distance = distance;
}
Edited 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));
}
quá tải ISpatialDialect.GetSpatialRelationString
thực hiện quá tải trong 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();
}
Không chắc chắn tại sao AddParameter không được sử dụng?
Tôi gặp vấn đề tương tự và chưa tìm thấy bất kỳ bản vá/sửa chữa hoàn chỉnh nào cho đến thời điểm này. Bạn đã giải quyết nó, hoặc bạn đã đi với các biến thể HQL? – Liedman
Hãy suy nghĩ đã đi với cách tiếp cận trên, và dll biên dịch lại để làm việc, nhưng vẫn còn mã thử nghiệm. – Ian
@Amesh là bạn không hài lòng với giải pháp đề xuất mà OP đưa ra? – Eranga