Advertisement
MagnusArias

SBO | Spatiale

Oct 5th, 2019
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 2.02 KB | None | 0 0
  1. DECLARE @a geometry, @b geometry, @c geometry
  2.  
  3. SET @a = geometry::STGeomFromText('POLYGON((3 0, 3 2, 5 2, 5 0, 3 0))', 0)
  4. SET @b = geometry::STGeomFromText('LINESTRING(0 2, 2.5 3, 5 2)', 0)
  5. SET @c = geometry::STGeomFromText('POLYGON((0 0, 0 2, 2 2, 2 0, 0 0), (0.5 0.5, 1.5 0.5, 1.5 1.5, 0.5 1.5, 0.5 0.5))', 0)
  6.  
  7. -- SELECT @a.STAsText(), @b.STAsText(), @c.STAsText()
  8. -- SELECT @a.STAsBinary(), @b.STAsBinary(), @c.STAsBinary()
  9. SELECT @a.ToString(), @b.ToString(), @c.ToString()
  10.  
  11. SELECT @a AS geom1, 'A' AS etykieta1
  12. UNION ALL
  13. SELECT @b AS geom2, 'B'
  14. UNION ALL
  15. SELECT @c AS geom3, 'C'
  16.  
  17.  
  18.  
  19. DECLARE @e geometry;  
  20. DECLARE @f geometry;  
  21. DECLARE @g geometry;  
  22. DECLARE @h geometry;
  23. DECLARE @i geometry;
  24.  
  25. SET @e =  geometry::STGeomFromText('CIRCULARSTRING(0 0, 0 5, 5 5, 5 0, 0 0)', 0);
  26. SET @f = geometry::STGeomFromText('CURVEPOLYGON(CIRCULARSTRING(10 10, 10 5, 5 5, 5 10, 10 10))', 0);
  27. SET @g = geometry::STGeomFromText('CURVEPOLYGON(CIRCULARSTRING(0 5, 5 0, 0 -5, -5 0, 0 5), (0 5, 5 0, 0 -5, -5 0, 0 5))',0);
  28. SET @h = geometry::STGeomFromText('COMPOUNDCURVE(CIRCULARSTRING(10 0, 0 10, -10 0), (-10 0, 0 0))', 0);
  29. SET @i = geometry::STGeomFromText('CURVEPOLYGON(COMPOUNDCURVE(CIRCULARSTRING(5 5, 0 10, -5 5), (-5 5, 5 5)))', 0);
  30.  
  31. -- SELECT @e UNION ALL SELECT @f UNION ALL SELECT @g UNION ALL SELECT @h UNION ALL SELECT @i
  32.  
  33. SELECT @e
  34.  
  35.  
  36.  
  37. DECLARE @g geometry;
  38. DECLARE @f geometry;
  39. DECLARE @h geometry;
  40.  
  41. SET @f = geometry::STGeomFromText('POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))', 0);
  42. SET @g = geometry::STGeomFromText('POLYGON((0 0, 1 1, 0 2 , 0 0))', 0);
  43. SET @h = geometry::STGeomFromText('POLYGON((3 3, 1 1, 2 3, 3 3))', 0);
  44.  
  45. SELECT @f.STArea(), @g.STArea(), @h.STArea();
  46. SELECT @f.STLength(), @g.STLength(), @h.STLength();
  47.  
  48. SELECT @f
  49. UNION ALL
  50. SELECT @g
  51. UNION ALL
  52. SELECT @h
  53.  
  54.  
  55. SELECT  @f.STCentroid().ToString() AS CentroidF,
  56.         @g.STCentroid().ToString() AS CentroidG,
  57.         @h.STCentroid().ToString() AS CentroidH;
  58.  
  59.  
  60. SELECT @f.STCentroid().STDistance(@g.STCentroid()) AS FminG; --distance between centroids
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement