Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
Questa pagina include informazioni aggiuntive sull'uso di dati spaziali con il provider di database di Microsoft SQL Server. Per informazioni generali sull'uso dei dati spaziali in EF Core, vedere la documentazione principale relativa ai dati spaziali.
Geografia o geometria
Per impostazione predefinita, le proprietà spaziali vengono mappate alle geography colonne in SQL Server. Per usare geometry, configurare il tipo di colonna nel modello.
Anelli poligoni geografici
Quando si usa il geography tipo di colonna, SQL Server impone requisiti aggiuntivi per l'anello esterno (o la shell) e gli anelli interni (o fori). L'anello esterno deve essere orientato in senso antiorario e gli anelli interni in senso orario. NetTopologySuite (NTS) convalida questo valore prima di inviare valori al database.
Fullglobe
SQL Server ha un tipo di geometria non standard per rappresentare il globo completo quando si usa il geography tipo di colonna. Ha anche un modo per rappresentare poligoni basati sul globo completo (senza un anello esterno). Nessuno di questi elementi è supportato da NTS.
Avviso
FullGlobe e poligoni basati su di esso non sono supportati da NTS.
Curve
Come indicato nella documentazione principale relativa ai dati spaziali, NTS attualmente non può rappresentare le curve. Ciò significa che è necessario trasformare i valori CircularString, CompoundCurve e CurePolygon usando il metodo STCurveToLine prima di usarli in EF Core.
Avviso
CircularString, CompoundCurve e CurePolygon non sono supportati da NTS.
Mapping delle funzioni spaziali
Questa tabella mostra i membri NTS convertiti in quali funzioni SQL. Si noti che le traduzioni variano a seconda che la colonna sia di tipo geography o geometry.
| .NET | SQL (geography) | SQL (geometria) | Aggiunta in |
|---|---|---|---|
| EF. Functions.CurveToLine(geometry) | @geometry.STCurveToLine() | @geometry.STCurveToLine() | EF Core 7.0 |
| Geometria. Zona | @geometry.STArea() | @geometry.STArea() | |
| Geometria. AsBinary() | @geometry.STAsBinary() | @geometry.STAsBinary() | |
| Geometria. AsText() | @geometry.AsTextZM() | @geometry.AsTextZM() | |
| Geometria. Confine | @geometry.STBoundary() | ||
| Geometria. Buffer(distance) | @geometry.STBuffer(@distance) | @geometry.STBuffer(@distance) | |
| Geometria. Baricentro | @geometry.STCentroid() | ||
| Geometria. Contains(g) | @geometry.STContains(@g) | @geometry.STContains(@g) | |
| Geometria. ConvexHull() | @geometry.STConvexHull() | @geometry.STConvexHull() | |
| Geometria. Crosses(g) | @geometry.STCrosses(@g) | ||
| Geometria. Differenza (altro) | @geometry.STDifference(@other) | @geometry.STDifference(@other) | |
| Geometria. Dimensione | @geometry.STDimension() | @geometry.STDimension() | |
| Geometria. Disgiunto(g) | @geometry.STDisjoint(@g) | @geometry.STDisjoint(@g) | |
| Geometria. Distance(g) | @geometry.STDistance(@g) | @geometry.STDistance(@g) | |
| Geometria. Busta | @geometry.STEnvelope() | ||
| Geometria. EqualsTopologically(g) | @geometry.STEquals(@g) | @geometry.STEquals(@g) | |
| Geometria. GeometryType | @geometry.STGeometryType() | @geometry.STGeometryType() | |
| Geometria. GetGeometryN(n) | @geometry.STGeometryN(@n + 1) | @geometry.STGeometryN(@n + 1) | |
| Geometria. InteriorPoint | @geometry.STPointOnSurface() | ||
| Geometria. Intersezione (altro) | @geometry.STIntersection(@other) | @geometry.STIntersection(@other) | |
| Geometria. Intersects(g) | @geometry.STIntersects(@g) | @geometry.STIntersects(@g) | |
| Geometria. Isempty | @geometry.STIsEmpty() | @geometry.STIsEmpty() | |
| Geometria. IsSimple | @geometry.STIsSimple() | ||
| Geometria. IsValid | @geometry.STIsValid() | @geometry.STIsValid() | |
| Geometria. IsWithinDistance(geom, distance) | @geometry.STDistance(@geom)<= @distance | @geometry.STDistance(@geom)<= @distance | |
| Geometria. Lunghezza | @geometry.STLength() | @geometry.STLength() | |
| Geometria. NumGeometries | @geometry.STNumGeometries() | @geometry.STNumGeometries() | |
| Geometria. NumPoint | @geometry.STNumPoints() | @geometry.STNumPoints() | |
| Geometria. OgcGeometryType | CA edizione Standard @geometry.STGeometryType() WHEN N'Point' THEN 1 ... FINE | CA edizione Standard @geometry.STGeometryType() WHEN N'Point' THEN 1 ... FINE | |
| Geometria. Sovrapposizioni (g) | @geometry.STOverlaps(@g) | @geometry.STOverlaps(@g) | |
| Geometria. PointOnSurface | @geometry.STPointOnSurface() | ||
| Geometria. Relate(g, intersezionePattern) | @geometry.STRelate(@g, @intersectionPattern) | ||
| Geometria. SRID | @geometry.STSrid | @geometry.STSrid | |
| Geometria. SymmetricDifference(other) | @geometry.STSymDifference(@other) | @geometry.STSymDifference(@other) | |
| Geometria. ToBinary() | @geometry.STAsBinary() | @geometry.STAsBinary() | |
| Geometria. ToText() | @geometry.AsTextZM() | @geometry.AsTextZM() | |
| Geometria. Touches(g) | @geometry.STTouches(@g) | ||
| Geometria. Union(altro) | @geometry.STUnion(@other) | @geometry.STUnion(@other) | |
| Geometria. 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() | |
| Punto. M | @point.M | @point.M | |
| Punto. X | @point.Long | @point.STX | |
| Punto. Y | @point.Lat | @point.STY | |
| Punto. Z | @point.Z | @point.Z | |
| Poligono. ExteriorRing | @polygon.RingN(1) | @polygon.STExteriorRing() | |
| Poligono. GetInteriorRingN(n) | @polygon.RingN(@n + 2) | @polygon.STInteriorRingN(@n + 1) | |
| Poligono. NumInteriorRings | @polygon.NumRings() -1 | @polygon.STNumInteriorRing() |
Funzioni di aggregazione
| .NET | SQL | Aggiunta in |
|---|---|---|
| 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(Property) | EF Core 7.0 |
| EnvelopeCombiner.CombineAsGeometry(group. Select(x => x.Property)) | EnvelopeAggregate(Property) | EF Core 7.0 |