Hat jemand dies implementiert oder weiß, ob es schwierig wäre, dies zu implementieren/irgendwelche Zeiger zu haben?Kriterien SpatialRestrictions.IsWithinDistance NHibernate.Spatial
public static SpatialRelationCriterion IsWithinDistance(string propertyName, object anotherGeometry, double distance)
{
// TODO: Implement
throw new NotImplementedException();
}
von NHibernate.Spatial.Criterion.SpatialRestrictions
kann ich "wo NHSP.Distance (SACH: Punkt)" in hql. Ich möchte diese Abfrage jedoch mit meiner vorhandenen Criteria-Abfrage kombinieren.
für den Moment eine grobe Polygon Ich erstelle und
mitcriteria.Add(SpatialRestrictions.Intersects("PROPERTY", myPolygon));
EDIT einen Prototyp arbeitet Got Konstruktor auf SpatialRelationCriterion durch Überlastung, neue SpatialRelation.Distance Zugabe
public static SpatialRelationCriterion IsWithinDistance(string propertyName, object anotherGeometry, double distance)
{
return new SpatialRelationCriterion(propertyName, SpatialRelation.Distance, anotherGeometry, distance);
}
ein neues Feld zu SpatialRelationCriterion hinzugefügt
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));
}
überlastet ISpatialDialect.GetSpatialRelationString
implementiert Überlastung in 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();
}
nicht sicher, warum AddParameter nicht verwendet?
Ich habe das gleiche Problem, und habe bis jetzt keinen vollständigen Patch/Reparatur/was auch immer gefunden. Hast du es gelöst, oder hast du die HQL Variante gewählt? – Liedman
Think ging mit dem obigen Ansatz, und rekompilierte DLL, um zu arbeiten, war aber immer noch experimentellen Code. – Ian
@ Amresh sind Sie nicht zufrieden mit der vorgeschlagenen Lösung OP gab? – Eranga