使用几何数据类型和 WKT 在 SQL Server 中存储 3D 形状
我正在查看 Sql Server 2008 中的几何数据类型,它看起来很有趣,但文档似乎不太好。我可以以 WKT 格式存储圆锥体、圆柱体和球体吗?这些特征传统上具有半径而不是数百个点。
I'm looking at the geometry data type in Sql Server 2008 and it looks interesting but the documentation does not seem that good. Would I be able to store cones, cylinders and spheres in the WKT format? These features traditionally have a radius and not hundreds of points.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
据我所知,您将不得不使用外部应用程序将形状渲染为大量点。请参阅此博客了解渲染圆圈的技术。
可以考虑的一种可能性是使用 CLR 过程来渲染所需的形状和带有索引的视图。我不知道它会表现得如何,但它可能会起作用。
To the best of my knowledge your are going to have to use an external application to render your shape as a large number of points. See this blog for a technique for rendering circles.
One possibility to consider is a CLR proc to render the shapes you need and a view with indexes. I don't know how well that will perform, but it just might work.
抱歉回复晚了。您始终可以编写自己的用户定义类型,称为圆,具有两个属性,即质心和 >半径。
在新形成的 UDT 中,创建一个采用属性 Centroid (Point3D) 和 Radius (Double) 的方法。之后,创建一个使用 SqlGeometry 和 SqlGeometryBuilder 来构建新形成的对象的方法。
首先,创建一个Geometry的Point实例。从类对象继承 Centroid 值,然后创建另一个从 Point 对象派生的 Geometry Polygon 和 STBuffer强>(半径)它。
下面是我的示例:(用 30 分钟编写)
当您在 VS2010 中使用 CLR 项目类型完成此操作后,您可以将其部署到数据库。
在 SQL 中,您可以这样调用对象::Parse(XYZM,R)
sorry for the late reply. You could always write your own User-Defined-Type called Circle, with two properties namely Centroid and Radius.
Inside the newly formed UDT, create a method that takes the properties Centroid (Point3D), and Radius (Double). After this, create a method that uses both SqlGeometry and SqlGeometryBuilder to build the newly formed object.
First, create a Point instance of Geometry. Inherit the Centroid values from the class object, then, create another Geometry Polygon that's derived from the Point object, and STBuffer(Radius) it.
Below is my example: (written in 30min)
When you've done this in VS2010 by using the CLR project type, you can deploy it to your database.
In SQL, you can call the object as such:: Parse(X Y Z M,R)
快速浏览了一下,发现这个 MSDN 页面 空间样本。它涵盖了在 WKT、WKB 和 WKT 中输入数据的所有方法。 XML(GML) 以及以人类可读形式查看的函数。它还涵盖 MakeValid、STIsValid 和STSrid。
看起来有相当多的 SQL 示例可能对您有用
Had a quick look around and found this MSDN page on Spatial Samples. It covers all the Methods to enter data in WKT, WKB & XML(GML) as well as functions to view the in Human Readable form. It also covers MakeValid, STIsValid & STSrid.
There looks to be a fair few SQL examples that you may find useful