我的github

geometry默认是16进制存储的

 

 

use database; 

 

https://blog.csdn.net/mao834099514/article/details/79094405

如果是在postgresql里是使用st_astext()函数

 开源架构Webgis解决方案

                    select * from SpatialTable a,SpatialTable b where a.geom.STContains(b.geom)=1

 https://blog.csdn.net/mao834099514/article/details/79094405

如何在SQL Server里新建Envelope?

SQL Server空间数据类型:https://docs.microsoft.com/zh-cn/sql/relational-databases/spatial/spatial-data-sql-server?view=sql-server-ver15

空间关系:https://docs.microsoft.com/zh-cn/sql/t-sql/spatial-geometry/stequals-geometry-data-type?view=sql-server-ver15

 

 

DECLARE @g1 geometry
--SET @g1 = geometry::Parse('POLYGON((153.13308571 -481.00897143,153.13308571 -479.00897143,155.13308571 -479.00897143,155.13308571 -481.00897143, 153.13308571 -481.00897143))');
--SELECT @g1.STIsValid()
SET @g1 = geometry::STGeomFromText('POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))', 0); 
--SET @g1 = @g1.MakeValid();  
select * from da.dbo.CONTROLPOINT a where @g1.STContains(a.Shape)=1

DECLARE @g1 geometry
SET @g1 = geometry::STGeomFromText('POLYGON((153 -481,153 -479,155 -479,155 -481, 153 -481))', 0); 
select * from da.dbo.CONTROLPOINT a where @g1.STContains(a.Shape)=1

>>

DECLARE @g1 geometry
SET @g1 = geometry::STGeomFromText('POLYGON((xmin ymin,xmin ymax,xmax ymax,xmax ymin, xmin ymin))', 0); 
select * from da.dbo.CONTROLPOINT a where @g1.STContains(a.Shape)=1

把最后一条语句中的@g1替换成geometry::STGeomFromText()能不能直接写成一条语句。。一条查询语句。
select OBJECTID, Shape.STPointN(1).STX as In_X,Shape.STPointN(1).STY as In_Y, Shape.STPointN(2).STX as Out_X,Shape.STPointN(2).STY as Out_Y from da.dbo.tabl1 a where 1 = 1 and ( geometry::STGeomFromText('POLYGON((
xmin ymin,xmin ymax,xmax ymax,xmax ymin, xmin ymin))',4326).STIntersects(a.Shape)=1)
posted on 2021-01-15 16:31  XiaoNiuFeiTian  阅读(574)  评论(0)    收藏  举报