有个朋友在做地图相关的程序,程序的需求是:地图上有好多的点,存储在数据库中,输入是一个多边形,输出是包含在这个多边形中的点。
朋友发现Oracle中有个函数,正好解决这个问题:
于是我们就了解了oracleSpatial的API,来实现查询的功能。
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
create table t2( id number,location sdo_geometry --点 );
insert into t2 values( 3,--id sdo_geometry ( 2001,32774,null,sdo_elem_info_array(1,102); box-sizing: border-box;">1),sdo_ordinate_array(1) --点的坐标1 ) );
into user_sdo_geom_metadata (table_name,column_name,srid,diminfo) values ( 't2','location',sdo_dim_array ( sdo_dim_element ( 'longitude',-180,102); box-sizing: border-box;">0.1 ),sdo_dim_element ( 'latitude',102); box-sizing: border-box;">90,102); box-sizing: border-box;">0.1 ) ) );
create index test2_index on t2(location) indextype is mdsys.spatial_index SELECT * FROM T2;
select * from T2 t where sdo_relate(t."LOCATION",SDO_GEOMETRY( 2003,-- two-dimensional polygon NULL,sdo_elem_info_array (0,102); box-sizing: border-box;">7,102); box-sizing: border-box;">0) --多边形 ),0); box-sizing: border-box;">'MASK=INSIDE')='TRUE';
参考: http://docs.oracle.com/database/122/SPATL/toc.htm http://www.52php.cn/article/p-ahvmrwqe-hs.html http://blog.sina.com.cn/s/blog_681cd80d0100ih95.html (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|