このページには、Microsoft SQL Server データベース プロバイダーでの空間データの使用に関する追加情報が含まれています。 EF Core での空間データの使用に関する一般的な情報については、主な 空間データ のドキュメントを参照してください。
地理学 または 幾何学
既定では、空間プロパティは SQL Server の geography 列にマップされます。
geometryを使用するには、モデルで列の種類を構成します。
地理ポリゴンの環
geography列の種類を使用する場合、SQL Server は外部リング (またはシェル) と内部リング (または穴) に追加の要件を課します。 外部リングは反時計回りに、内部リングは時計回りに向いている必要があります。
NetTopologySuite (NTS) は、データベースに値を送信する前にこれを検証します。
FullGlobe
SQL Server には、 geography 列型を使用する場合に地球全体を表す標準以外のジオメトリ型があります。 また、(外部リングを使用せずに) 地球全体に基づいて多角形を表現する方法もあります。 これらはどちらも NTS ではサポートされていません。
Warnung
FullGlobe とそれに基づく多角形は NTS ではサポートされていません。
曲線
メインの 空間データ のドキュメントで説明したように、NTS は現在曲線を表すことができません。 つまり、EF Core で使用する前に、 STCurveToLine メソッドを使用して CircularString、CompoundCurve、および CurePolygon の値を変換する必要があります。
Warnung
CircularString、CompoundCurve、および CurePolygon は NTS ではサポートされていません。
空間関数マッピング
次の表は、どの NTS メンバーがどの SQL 関数に変換されているかを示しています。 翻訳は、列の種類が geography か geometry かによって異なることに注意してください。
| .NET | SQL (地理情報) | SQL (ジオメトリ) | 追加されたバージョン: |
|---|---|---|---|
| EF.Functions.CurveToLine(geometry) | @geometry.STCurveToLine() | @geometry.STCurveToLine() | EF Core 7.0 |
| ジオメトリ。領域 | @geometry.STArea() | @geometry.STArea() | |
| ジオメトリ.AsBinary() | @geometry.STAsBinary() | @geometry.STAsBinary() | |
| ジオメトリ.AsText() | @geometry.AsTextZM() | @geometry.AsTextZM() | |
| ジオメトリ。境界 | @geometry.STBoundary() | ||
| ジオメトリ::Buffer(distance) | @geometry.STBuffer(@distance) | @geometry.STBuffer(@distance) | |
| ジオメトリ。重心 | @geometry.STCentroid() | ||
| ジオメトリ。Contains(g) | @geometry.STContains(@g) | @geometry.STContains(@g) | |
| ジオメトリ。ConvexHull() | @geometry.STConvexHull() | @geometry.STConvexHull() | |
| ジオメトリ.Crosses(g) | @geometry.STCrosses(@g) | ||
| ジオメトリ。Difference(other) | @geometry.STDifference(@other) | @geometry.STDifference(@other) | |
| ジオメトリ。ディメンション | @geometry.STDimension() | @geometry.STDimension() | |
| ジオメトリ.Disjoint(g) | @geometry.STDisjoint(@g) | @geometry.STDisjoint(@g) | |
| ジオメトリ.距離(g) | @geometry.STDistance(@g) | @geometry.STDistance(@g) | |
| ジオメトリ。エンベロープ | @geometry.STEnvelope() | ||
| ジオメトリ.EqualsTopologically(g) | @geometry.STEquals(@g) | @geometry.STEquals(@g) | |
| ジオメトリ。GeometryType | @geometry.STGeometryType() | @geometry.STGeometryType() | |
| ジオメトリ。GetGeometryN(n) | @geometry.STGeometryN(@n + 1) | @geometry.STGeometryN(@n + 1) | |
| ジオメトリ.InteriorPoint | @geometry.STPointOnSurface() | ||
| ジオメトリ。Intersection(other) | @geometry.STIntersection(@other) | @geometry.STIntersection(@other) | |
| ジオメトリ。Intersects(g) | @geometry.STIntersects(@g) | @geometry.STIntersects(@g) | |
| geometry.IsEmpty | @geometry.STIsEmpty() | @geometry.STIsEmpty() | |
| ジオメトリ.IsSimple | @geometry.STIsSimple() | ||
| ジオメトリ.IsValid | @geometry.STIsValid() | @geometry.STIsValid() | |
| ジオメトリ.IsWithinDistance(geom, distance) | @geometry.STDistance(@geom) <= @distance | @geometry.STDistance(@geom) <= @distance | |
| ジオメトリ。長さ | @geometry.STLength() | @geometry.STLength() | |
| ジオメトリ。NumGeometries | @geometry.STNumGeometries() | @geometry.STNumGeometries() | |
| ジオメトリ.NumPoints | @geometry.STNumPoints() | @geometry.STNumPoints() | |
| ジオメトリ。OgcGeometryType | CASE @geometry.STGeometryType() when N'Point' then 1 ...終わり | CASE @geometry.STGeometryType() when N'Point' then 1 ...終わり | |
| ジオメトリ.Overlaps(g) | @geometry.STOverlaps(@g) | @geometry.STOverlaps(@g) | |
| ジオメトリ。PointOnSurface | @geometry.STPointOnSurface() | ||
| ジオメトリ。Relate(g, intersectionPattern) | @geometry.STRelate(@g、@intersectionPattern) | ||
| ジオメトリ.SRID | @geometry.STSrid | @geometry.STSrid | |
| ジオメトリ。SymmetricDifference(other) | @geometry.STSymDifference(@other) | @geometry.STSymDifference(@other) | |
| ジオメトリ。ToBinary() | @geometry.STAsBinary() | @geometry.STAsBinary() | |
| geometry.ToText() | @geometry.AsTextZM() | @geometry.AsTextZM() | |
| ジオメトリ。Touches(g) | @geometry.STTouches(@g) | ||
| ジオメトリ.Union(other) | @geometry.STUnion(@other) | @geometry.STUnion(@other) | |
| ジオメトリ。Within(g) | @geometry.STWithin(@g) | @geometry.STWithin(@g) | |
| geometryCollection[i] | @geometryCollection.STGeometryN(@i + 1) | @geometryCollection.STGeometryN(@i + 1) | |
| geometryCollection.Count(ジオメトリコレクションの数) | @geometryCollection.STNumGeometries() | @geometryCollection.STNumGeometries() | |
| lineString.Count | @lineString.STNumPoints() | @lineString.STNumPoints() | |
| lineString.EndPoint | @lineString.STEndPoint() | @lineString.STEndPoint() | |
| lineString.GetPointN(n) | @lineString.STPointN(@n + 1) | @lineString.STPointN(@n + 1) | |
| lineString.IsClosed | @lineString.STIsClosed() | @lineString.STIsClosed() | |
| lineString.IsRing | @lineString.IsRing() | ||
| lineString.StartPoint | @lineString.STStartPoint() | @lineString.STStartPoint() | |
| multiLineString.IsClosed | @multiLineString.STIsClosed() | @multiLineString.STIsClosed() | |
| ポイントM | @point.M | @point.M | |
| ポイントX | @point.Long | @point.STX | |
| ポイントY | @point.Lat | @point.STY | |
| ポイント・Z | @point.Z | @point.Z | |
| ポリゴン。ExteriorRing | @polygon.RingN(1) | @polygon.STExteriorRing() | |
| ポリゴン。GetInteriorRingN(n) | @polygon.RingN(@n + 2) | @polygon.STInteriorRingN(@n + 1) | |
| polygon.NumInteriorRings | @polygon.NumRings() - 1 | @polygon.STNumInteriorRing() |
集計関数
| .NET | SQL | 追加されたバージョン: |
|---|---|---|
| GeometryCombiner.Combine(group.Select(x => x.Property)) | CollectionAggregate(プロパティ) | EF Core 7.0 |
| ConvexHull.Create(group.Select(x => x.Property)) | ConvexHullAggregate(プロパティ) | EF Core 7.0 |
| UnaryUnionOp.Union(group.Select(x => x.Property)) | UnionAggregate(プロパティ) | EF Core 7.0 |
| EnvelopeCombiner.CombineAsGeometry(group.Select(x => x.Property)) | EnvelopeAggregate(プロパティ) | EF Core 7.0 |
その他のリソース
.NET