地理围栏:如何使用 oracle 空间查找点或形状是否在多边形内 [英] Geo Fence: how to find if a point or a shape is inside a polygon using oracle spatial

查看:30
本文介绍了地理围栏:如何使用 oracle 空间查找点或形状是否在多边形内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 oracle 空间 SQL 查询查找一个点或一个多边形是否在另一个多边形内

How do i find if a point or a polygon is inside another polygon using oracle spatial SQL query

这是场景;

我有一个表(STATE_TABLE),其中包含一个空间类型(sdo_geometry),它是一个多边形(比如说一个州),我有另一个表(UNIVERSITY_TABLE),其中包含空间数据(sdo_geometry)(点/多边形),其中包含大学;

I have a table (STATE_TABLE) which contains a spatial type (sdo_geometry) which is a polygon (of say a State), I have another table (UNIVERSITY_TABLE) which contains spatial data (sdo_geometry) (point/polygon) which contains Universities;

现在我如何使用 SQL select 语句查找所选大学是否处于给定状态.

Now how do i find if a selected University('s) are in a given State using SQL select statement.

主要是我想在地理围栏中找到给定对象的存在.

Primarily i want to locate existence of given object(s) in a geofence.

谢谢.

推荐答案

您将需要使用带有CONTAINS"掩码的 SDO_CONTAINS 或 SDO_RELATE

You're going to need to use either SDO_CONTAINS or SDO_RELATE with a mask of 'CONTAINS'

请参阅位于

SDO_CONTAINShttp://download.oracle.com/docs/cd/E11882_01/appdev.112/e11830/sdo_operat.htm#sthref1064 for

SDO_CONTAINS http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11830/sdo_operat.htm#sthref1064 for

SDO_RELATEhttp://download.oracle.com/docs/cd/E11882_01/appdev.112/e11830/sdo_operat.htm#i78531

其中任何一个您都可以执行以下操作(假设您的空间信息包含在空间索引的名为GEOM"的列中):

Either one of these you'd do something like the following (assuming your spatial information is contained in a column called 'GEOM' that is spatially indexed):

select 
    ST.NAME, UT.UNIVERSITY_NAME
from
    STATE_TABLE ST
    INNER JOIN UNIVERSITY_TABLE UT
      ON SDO_CONTAINS(ST.GEOM, UT.GEOM) = 'TRUE'

请原谅我,因为我不记得正确的语法,而且我不知道上面的连接是否能正常工作.不过,这应该足以为您指明正确的方向.

You'll have to forgive me as I don't specifically remember the correct syntax for this and I don't know if the above join will work properly at all. This should be enough to point you in the right direction though.

这篇关于地理围栏:如何使用 oracle 空间查找点或形状是否在多边形内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆