Partage via


Données spatiales dans le fournisseur EF Core SQL Server

Cette page contient des informations supplémentaires sur l’utilisation de données spatiales avec le fournisseur de base de données Microsoft SQL Server. Pour plus d’informations sur l’utilisation de données spatiales dans EF Core, consultez la documentation principale sur les données spatiales .

Géographie ou géométrie

Par défaut, les propriétés spatiales sont mappées aux geography colonnes dans SQL Server. Pour utiliser geometry, configurez le type de colonne dans votre modèle.

Anneaux de polygones géographiques

Lorsque vous utilisez le type de colonne geography, SQL Server impose des exigences supplémentaires sur la coque extérieure (ou l’anneau extérieur) et les anneaux intérieurs (ou trous). L’anneau extérieur doit être orienté dans le sens inverse et les anneaux intérieurs dans le sens des aiguilles d’une montre. NetTopologySuite (NTS) valide cette opération avant d’envoyer des valeurs à la base de données.

FullGlobe

SQL Server possède un type de géométrie non-standard pour représenter le globe entier lors de l'utilisation du type de colonne geography. Il a également un moyen de représenter des polygones basés sur le globe entier (sans anneau extérieur). Aucun de ces éléments n’est pris en charge par NTS.

Avertissement

FullGlobe et polygones basés sur celui-ci ne sont pas pris en charge par NTS.

Courbes

Comme mentionné dans la documentation principale sur les données spatiales , NTS ne peut actuellement pas représenter des courbes. Cela signifie que vous devez transformer les valeurs CircularString, CompoundCurve et CurePolygon à l’aide de la méthode STCurveToLine avant de les utiliser dans EF Core.

Avertissement

CircularString, CompoundCurve et CurePolygon ne sont pas pris en charge par NTS.

Mappages de fonctions spatiales

Ce tableau indique quels membres NTS sont traduits dans quelles fonctions SQL. Notez que les traductions varient selon que la colonne est de type *geography* ou *geometry*.

.NET SQL (géographie) SQL (géométrie) Ajouté à
EF.Functions.CurveToLine(geometry) @geometry.STCurveToLine() @geometry.STCurveToLine() EF Core 7.0
Géométrie. Aire @geometry.STArea() @geometry.STArea()
Géométrie.AsBinary() @geometry.STAsBinary() @geometry.STAsBinary()
Géométrie.AsText() @geometry.AsTextZM() @geometry.AsTextZM()
Géométrie. Limite @geometry.STBoundary()
Géométrie. Buffer(distance) @geometry.STBuffer(@distance) @geometry.STBuffer(@distance)
Géométrie. Centroïde @geometry.STCentroid()
Géométrie. Contains(g) @geometry.STContains(@g) @geometry.STContains(@g)
Géométrie. ConvexHull() @geometry.STConvexHull() @geometry.STConvexHull()
Géométrie. Croix(g) @geometry.STCrosses(@g)
Géométrie. Différence(autre) @geometry.STDifference(@other) @geometry.STDifference(@other)
Géométrie. Dimension @geometry.STDimension() @geometry.STDimension()
Géométrie.Disjoint(g) @geometry.STDisjoint(@g) @geometry.STDisjoint(@g)
Géométrie. Distance(g) @geometry.STDistance(@g) @geometry.STDistance(@g)
Géométrie.Enveloppe @geometry.STEnvelope()
Géométrie.estÉgaleTopologiquement(g) @geometry.STEquals(@g) @geometry.STEquals(@g)
Géométrie. GeometryType @geometry.STGeometryType() @geometry.STGeometryType()
Géométrie.GetGeometryN(n) @geometry.STGeometryN(@n + 1) @geometry.STGeometryN(@n + 1)
Géométrie. InteriorPoint @geometry.STPointOnSurface()
Géométrie. Intersection(autre) @geometry.STIntersection(@other) @geometry.STIntersection(@other)
Géométrie. Intersects(g) @geometry.STIntersects(@g) @geometry.STIntersects(@g)
Géométrie. IsEmpty @geometry.STIsEmpty() @geometry.STIsEmpty()
Géométrie.IsSimple @geometry.STIsSimple()
Géométrie. IsValid @geometry.STIsValid() @geometry.STIsValid()
Géométrie. IsWithinDistance(geom, distance) @geometry.STDistance(@geom) <= @distance @geometry.STDistance(@geom) <= @distance
Géométrie. Longueur @geometry.STLength() @geometry.STLength()
Géométrie. NumGeometries @geometry.STNumGeometries() @geometry.STNumGeometries()
Géométrie. NumPoints @geometry.STNumPoints() @geometry.STNumPoints()
Géométrie. OgcGeometryType CAS @geometry.STGeometryType() QUAND N'Point' ALORS 1 ... FIN CAS @geometry.STGeometryType() QUAND N'POINT' ALORS 1 ... FIN
Géométrie. Chevauchements(g) @geometry.STOverlaps(@g) @geometry.STOverlaps(@g)
Géométrie. PointOnSurface @geometry.STPointOnSurface()
Géométrie. Relation(g, intersectionPattern) @geometry.STRelate(@g, @intersectionPattern)
Géométrie. SRID @geometry.STSrid @geometry.STSrid
Géométrie. SymmetricDifference(other) @geometry.STSymDifference(@other) @geometry.STSymDifference(@other)
géométrie.ToBinary() @geometry.STAsBinary() @geometry.STAsBinary()
geometry.ToText() @geometry.AsTextZM() @geometry.AsTextZM()
Géométrie. Touches(g) @geometry.STTouches(@g)
Géométrie. Union(autre) @geometry.STUnion(@other) @geometry.STUnion(@other)
Géométrie. 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()
Point. M @point.M @point.M
Point. X @point.Long @point.STX
Point Y @point.Lat @point.STY
Point. Z @point.Z @point.Z
Polygone. ExtérieurRing @polygon.RingN(1) @polygon.STExteriorRing()
Polygone.GetInteriorRingN(n) @polygon.RingN(@n + 2) @polygon.STInteriorRingN(@n + 1)
Polygone. NumInteriorRings @polygon.NumRings() - 1 @polygon.STNumInteriorRing()

Fonctions d'agrégation

.NET SQL Ajouté à
GeometryCombiner.Combine(group.Select(x => x.Property)) CollectionAggregate(Property) EF Core 7.0
ConvexHull.Create(group.Select(x => x.Property)) ConvexHullAggregate(Property) EF Core 7.0
UnaryUnionOp.Union(group.Select(x => x.Property)) UnionAggregate(Propriété) EF Core 7.0
EnvelopeCombiner.CombineAsGeometry(group.Select(x => x.Property)) EnvelopeAggregate(Propriété) EF Core 7.0

Ressources additionnelles