java oracle spatial_oracle spatial 查询

本文介绍了如何使用Oracle Spatial的SDO_FILTER和SDO_RELATE函数进行空间查询,包括查询类型和关系类型的应用,以及如何筛选在特定区域内的几何对象。示例展示了如何查询在定义矩形内的小船。
摘要由CSDN通过智能技术生成

Oracle Spatial查询数据包括二个处理过程:

1.只通过索引查询候选项。通过函数SDO_FILTER实现:

SDO_FILTER(geometry1 MDSYS.SDO_GEOMETRY, geometry2 MDSYS.SDO_GEOMETRY, params VARCHAR2)

geometry1:必须是被索引的几何数据

geometry2:不一定是表中的空间字段,也不要求被索引

params:Filter类型

querytype=WINDOW:geometry2不要求来自表

querytype=JOIN:geometry2必须来自表

SELECT name boat_name

FROM mylake t

WHERE feature_id = 12

AND SDO_FILTER(t.shape, mdsys.sdo_geometry(2003,NULL,NULL,

mdsys.sdo_elem_info_array(1,1003,1),

mdsys.sdo_ordinate_array(2,2, 5,2, 5,5, 2,5, 2,2)),

'querytype=WINDOW') = 'TRUE';

2.再检查每个候选项是否和条件精确匹配。通过函数SDO_RELATE实现:

SDO_RELATE(geometry1 MDSYS.SDO_GEOMETRY, geometry2 MDSYS.SDO_GEOMETRY, params VARCHAR2)

params:masktype类型

DISJOINT — the boundaries and interiors do not intersect

TOUCH — the boundaries intersect but the interiors do not intersect

OVERLAPBDYDISJOINT — the interior of one object intersects the boundary and interior of the other object, but the two boundaries do not intersect. This relationship occurs, for example, when a line originates outside a polygon and ends inside that polygon.

OVERLAPBDYINTERSECT — the boundaries and interiors of the two objects intersect

EQUAL — the two objects have the same boundary and interior

CONTAINS — the interior and boundary of one object is completely contained in the interior of the other object

COVERS — the interior of one object is completely contained in the interior of the other object and their boundaries intersect

INSIDE — the opposite of CONTAINS. A INSIDE B implies B CONTAINS A.

COVEREDBY — the opposite of COVERS. A COVEREDBY B implies B COVERS A.

ON — the interior and boundary of one object is on the boundary of the other object (and the second object covers the first object). This relationship occurs, for example, when a line is on the boundary of a polygon.

ANYINTERACT — the objects are non-disjoint.

// 选择在定义矩形内的所有小船

SELECT name boat_name

FROM mylake t

WHERE feature_id = 12

AND SDO_FILTER(t.shape, mdsys.sdo_geometry(2003,NULL,NULL,

mdsys.sdo_elem_info_array(1,1003,1),

mdsys.sdo_ordinate_array(2,2, 5,2, 5,5, 2,5, 2,2)),

'querytype=WINDOW') = 'TRUE'

AND SDO_RELATE(t.shape, mdsys.sdo_geometry(2003,NULL,NULL,

mdsys.sdo_elem_info_array(1,1003,1),

mdsys.sdo_ordinate_array(2,2, 5,2, 5,5, 2,5, 2,2)),

'masktype=INSIDE querytype=WINDOW') = 'TRUE'

// masktype可联合使用

SELECT feature_id id

FROM mylake t

WHERE feature_id = 12

AND SDO_FILTER(t.shape, mdsys.sdo_geometry(2003,NULL,NULL,

mdsys.sdo_elem_info_array(1,1003,1),

mdsys.sdo_ordinate_array(2,2, 5,2, 5,5, 2,5, 2,2)),

'querytype=WINDOW') = 'TRUE'

AND SDO_RELATE(t.shape, mdsys.sdo_geometry(2003,NULL,NULL,

mdsys.sdo_elem_info_array(1,1003,1),

mdsys.sdo_ordinate_array(2,2, 5,2, 5,5, 2,5, 2,2)),

'masktype=INSIDE+TOUCH querytype=WINDOW') = 'TRUE'

Oracle Spatial 提供的其他查询函数:

Query Description

SDO_NN Nearest neighbor

SDO_SDO_WITHIN_DISTANCE All geometries with a certain distance

Functions Description

SDO_GEOM.SDO_MBR The minimum bounding rectangle for a geometry

SDO_GEOM.SDO_DISTANCE The distance between two geometries

SDO_GEOM.SDO_INTERSECTION Provides the intersection point of two geometries

posted on 2009-05-15 11:39 棋剑小秋 阅读(840) 评论(0)  编辑  收藏 所属分类: 数据库

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值