94

誰かがこれを実装したことがありますか、またはこれを実装するのが難しいかどうか/ポインタを持っているかどうかを知っていますか?

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が使用されていない理由がわかりませんか?

4

2 に答える 2

1

GitHub でこの問題を調査しています。素晴らしい洞察と可能な解決策を提供していただきありがとうございます。問題へのリンクは次のとおりです: https://github.com/nhibernate/NHibernate.Spatial/issues/61

これが修正され次第、新しい NuGet パッケージを公開します。

于 2016-05-24T10:23:28.570 に答える
0

はい、今のところ、DLL を再コンパイルすることが最善の解決策だと思います。

于 2012-12-04T23:43:09.293 に答える