Sdílet prostřednictvím


Prostorová data ve zprostředkovateli SQL Serveru EF Core

Tato stránka obsahuje další informace o používání prostorových dat se zprostředkovatelem databáze Microsoft SQL Serveru. Obecné informace o používání prostorových dat v EF Core najdete v hlavní dokumentaci k prostorovým datům .

Zeměpisná oblast nebo geometrie

Ve výchozím nastavení se prostorové vlastnosti mapují na geography sloupce v SQL Serveru. Pokud chcete použít geometry, nakonfigurujte typ sloupce v modelu.

Zeměpisné mnohoúhelníkové kruhy

Při použití geography typu sloupce SQL Server ukládá další požadavky na vnější kruh (nebo shell) a vnitřní kroužky (nebo díry). Vnější kroužek musí být orientovaný proti směru hodinových ručiček a vnitřní kroužky po směru hodinových ručiček. NetTopologySuite (NTS) to ověří před odesláním hodnot do databáze.

FullGlobe

SQL Server má nestandardní typ geometrie, který představuje celý glóbus při použití geography typu sloupce. Má také způsob, jak znázornit mnohoúhelníky založené na celém glóbusu (bez vnějšího kroužku). Protokol NTS nepodporuje žádnou z těchto možností.

Výstraha

NtS nepodporuje FullGlobe a mnohoúhelníky založené na něm.

Křivky

Jak je uvedeno v hlavní dokumentaci k prostorovým datům, NTS v současné době nedokáže reprezentovat křivky. To znamená, že před použitím v EF Core budete muset transformovat hodnoty CircularString, CompoundCurve a CurePolygon pomocí metody STCurveToLine .

Výstraha

NTS nepodporuje CircularString, CompoundCurve a CurvePolygon.

Mapování prostorových funkcí

Tato tabulka ukazuje, které členy NTS jsou přeloženy do kterých funkcí SQL. Všimněte si, že překlady se liší v závislosti na tom, zda je sloupec typu geografie nebo geometrie.

platforma .NET SQL (zeměpisná oblast) SQL (geometrie) Přidáno do
EF. Functions.CurveToLine(geometrie) @geometry.STCurveToLine() @geometry.STCurveToLine() EF Core 7.0
Geometrie.Plocha @geometry.STArea() @geometry.STArea()
Geometrie.AsBinary() @geometry.STAsBinary() @geometry.STAsBinary()
geometry.AsText() @geometry.AsTextZM() @geometry.AsTextZM()
Geometrie. Hranice @geometry.STBoundary()
Geometrie. Vyrovnávací paměť (vzdálenost) @geometry.STBuffer(@distance) @geometry.STBuffer(@distance)
Geometrie. Centroid @geometry.STCentroid()
Geometrie. Contains(g) @geometry.STContains(@g) @geometry.STContains(@g)
Geometrie. KonvexHull() @geometry.STConvexHull() @geometry.STConvexHull()
Geometrie. Křížky(g) @geometry.STCrosses(@g)
Geometrie. Rozdíl(jiné) @geometry.STDifference(@other) @geometry.STDifference(@other)
Geometrie. Dimenze @geometry.STDimension() @geometry.STDimension()
Geometrie.Neslučitelný(g) @geometry.STDisjoint(@g) @geometry.STDisjoint(@g)
Geometrie. Vzdálenost(g) @geometry.STDistance(@g) @geometry.STDistance(@g)
Geometrie. Obálky @geometry.STEnvelope()
Geometrie. EqualsTopologically(g) @geometry.STEquals(@g) @geometry.STEquals(@g)
Geometrie. GeometryType @geometry.STGeometryType() @geometry.STGeometryType()
Geometrie.GetGeometryN(n) @geometry.STGeometryN(@n + 1) @geometry.STGeometryN(@n + 1)
Geometrie.InteriorPoint @geometry.STPointOnSurface()
Geometrie. Průnik (jiné) @geometry.STIntersection(@other) @geometry.STIntersection(@other)
Geometrie. Intersects(g) @geometry.STIntersects(@g) @geometry.STIntersects(@g)
Geometrie. Isempty @geometry.STIsEmpty() @geometry.STIsEmpty()
Geometrie.IsSimple @geometry.STIsSimple()
Geometrie. Isvalid @geometry.STIsValid() @geometry.STIsValid()
Geometrie. IsWithinDistance(geom, vzdálenost) @geometry.STDistance(@geom) <= @distance @geometry.STDistance(@geom) <= @distance
Geometrie. Délka @geometry.STLength() @geometry.STLength()
Geometrie. NumGeometrie @geometry.STNumGeometries() @geometry.STNumGeometries()
Geometrie. NumPoints @geometry.STNumPoints() @geometry.STNumPoints()
Geometrie.OgcGeometryType CASE @geometry.STGeometryType() KDYŽ N'Point' PAK 1 ... KONEC CASE @geometry.STGeometryType() WHEN N'Point' THEN 1 ... END
Geometrie. Překrývání (g) @geometry.STOverlaps(@g) @geometry.STOverlaps(@g)
Geometrie. PointOnSurface @geometry.STPointOnSurface()
Geometrie.Relate(g, průnikovýVzor) @geometry.STRelate(@g, @intersectionPattern)
Geometrie. SRID @geometry.STSrid @geometry.STSrid
Geometrie. SymmetricDifference(jiné) @geometry.STSymDifference(@other) @geometry.STSymDifference(@other)
Geometrie. ToBinary() @geometry.STAsBinary() @geometry.STAsBinary()
Geometrie.ToText() @geometry.AsTextZM() @geometry.AsTextZM()
Geometrie. Touches(g) @geometry.STTouches(@g)
Geometrie. Union(other) @geometry.STUnion(@other) @geometry.STUnion(@other)
Geometrie. V rámci(g) @geometry.STWithin(@g) @geometry.STWithin(@g)
geometryCollection[i] @geometryCollection.STGeometryN(@i + 1) @geometryCollection.STGeometryN(@i + 1)
geometryCollection.Počet @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()
Bod M @point.M @point.M
Bod X @point.Long @point.STX
Bod Y @point.Lat @point.STY
Bod. Z @point.Z @point.Z
Mnohoúhelník. Vnější obvod @polygon.RingN(1) @polygon.STExteriorRing()
Mnohoúhelník.GetInteriorRingN(n) @polygon.RingN(@n + 2) @polygon.STInteriorRingN(@n + 1)
Mnohoúhelník. NumInteriorRings @polygon.NumRings() - 1 @polygon.STNumInteriorRing()

Agregační funkce

platforma .NET SQL Přidáno do
GeometryCombiner.Combine(group.Select(x => x.Property)) CollectionAggregate(Vlastnost) EF Core 7.0
ConvexHull.Create(group.Select(x => x.Property)) ConvexHullAggregate(– vlastnost) EF Core 7.0
UnaryUnionOp.Union(group.Select(x => x.Property)) UnionAggregate(Vlastnost) EF Core 7.0
EnvelopeCombiner.CombineAsGeometry(group.Select(x => x.Property)) EnvelopeAggregate(vlastnost) EF Core 7.0

Dodatečné zdroje