STIntersection (type de données geography)
S’applique à : SQL Server
Azure SQL Database
Azure SQL Managed Instance
Base de données SQL dans Microsoft Fabric
Retourne un objet qui représente les points où une instance geography entre en intersection avec une autre instance geography.
Syntaxe
.STIntersection ( other_geography )
Arguments
other_geography
Autre instance geography à comparer à l’instance sur laquelle STIntersection() est appelé.
Types de retour
Type de retour SQL Server : geography
Type de retour CLR : SqlGeography
Notes
L'intersection de deux instances géographiques est retournée.
STIntersection() retourne toujours une valeur Null si les SRID (identificateurs de référence spatiale) des instances geography ne correspondent pas.
SQL Server prend en charge des instances spatiales qui sont plus grandes qu'un hémisphère. SQL Server peut inclure des instances FullGlobe dans le jeu de résultats possibles retournés sur le serveur.
Le résultat peut contenir des segments d'arc de cercle uniquement si les instances d'entrée contiennent des segments d'arc de cercle.
Exemples
R. Calcul de l'intersection d'une instance Polygon et LineString
L'exemple suivant utilise STIntersection()
pour calculer l'intersection d'un Polygon
et d'un LineString
.
DECLARE @g geography;
DECLARE @h geography;
SET @g = geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326);
SET @h = geography::STGeomFromText('LINESTRING(-122.360 47.656, -122.343 47.656)', 4326);
SELECT @g.STIntersection(@h).ToString();
B. Calcul de l'intersection d'une instance Polygon et CurvePolygon
L'exemple suivant retourne une instance qui contient un segment d'arc de cercle.
DECLARE @g geography;
DECLARE @h geography;
SET @g = geography::STGeomFromText('POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326);
SET @h = geography::STGeomFromText('CURVEPOLYGON(CIRCULARSTRING(-122.351 47.656, -122.341 47.656, -122.341 47.661, -122.351 47.661, -122.351 47.656))', 4326);
SELECT @g.STIntersection(@h).ToString();
C. Calcul de la différence symétrique avec FullGlobe
L'exemple suivant compare la différence symétrique d'un Polygon
avec FullGlobe
.
DECLARE @g geography = 'POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))';
SELECT @g.STIntersection('FULLGLOBE').ToString();