Qualcuno lo ha implementato o sa se sarebbe difficile implementarlo / avere suggerimenti?
public static SpatialRelationCriterion IsWithinDistance(string propertyName, object anotherGeometry, double distance)
{
// TODO: Implement
throw new NotImplementedException();
}
da NHibernate.Spatial.Criterion.SpatialRestrictions
Posso usare "where NHSP.Distance (PROPERTY,: point)" in hql. Ma desidero combinare questa query con la mia query Criteria esistente.
per il momento sto creando un poligono approssimativo e utilizzo
criteria.Add(SpatialRestrictions.Intersects("PROPERTY", myPolygon));
EDIT Ottenuto un prototipo che funziona sovraccaricando il costruttore su SpatialRelationCriterion, aggiungendo nuovo SpatialRelation.Distance
public static SpatialRelationCriterion IsWithinDistance(string propertyName, object anotherGeometry, double distance)
{
return new SpatialRelationCriterion(propertyName, SpatialRelation.Distance, anotherGeometry, distance);
}
aggiunto un nuovo campo a SpatialRelationCriterion
private readonly double? distance;
public SpatialRelationCriterion(string propertyName, SpatialRelation relation, object anotherGeometry, double distance)
: this(propertyName, relation, anotherGeometry)
{
this.distance = distance;
}
ToSqlString modificato
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 sovraccarico
sovraccarico implementato 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();
}
Non sei sicuro del motivo per cui AddParameter non viene utilizzato?