简体   繁体   中英

SQL Server Spatial Issue

I am trying to create a curved line between two points so that I can use it with the mapping product MapBox and use it in the co-ordinates section. I am having some issues with it and am unclear about how to control the curve

The Microsoft documentation talks about curving the line

https://docs.microsoft.com/en-us/sql/t-sql/spatial-geometry/stcurvetoline-geometry-data-type?view=sql-server-ver15

I started playing with code from their site which is below. How do you have more control over the curve? At the moment it generates 65 points? I am looking at implementing this and using it with GeoJson but this would create a large number of co-ordinates

Questions: - How do you control the number of points? - How do you calculate the centre point?

 DECLARE @g1 geometry, @g2 geometry; 
 SET @g1 = geometry::Parse('CIRCULARSTRING(10 0, 0 10, 15 15)'); 
 SET @g2 = @g1.STCurveToLine(); 

 SELECT @g1.STGeometryType() AS [G1 Type], @g2.STGeometryType() AS [G2 Type], @g1.STLength() AS [G1 Perimeter], @g2.STLength() AS [G2 Perimeter]
 SELECT @g2.ToString() AS [G2 Def]; 
 SELECT @g1.STNumPoints(), @g2.STNumPoints();

CIRCULARSTRING "defines" the curve

https://docs.microsoft.com/en-us/sql/relational-databases/spatial/circularstring?view=sql-server-ver15

 DECLARE @g1 geometry, @g2 geometry; 
 SET @g1 = geometry::Parse('CIRCULARSTRING(10 0, 0 10, 15 15)'); 
 SELECT @g1 --and check the spatial results in sssms

"The Microsoft documentation talks about curving the line", it is actually the other way around, STCurveToLine() is lining the curve.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM