A friend is doing map-related programs, the requirements of the program is: There are a lot of points on the map, stored in the database, input is a polygon, output is contained in this polygon point.
A friend discovers that there is a function in Oracle that solves this problem:
We then learned about the Oracle spatial API to implement the query functionality.
--Create TABLE t2 (ID number, location sdo_geometry-point) with the information of the point. --insert data into T2 values (3,--id sdo_geometry (2001, 32774, NULL, Sdo_el
Em_info_array (1,1,1), Sdo_ordinate_array (1,1)-point coordinates 1,1); --Insert space meta data insert into User_sdo_geom_metadata (table_name,column_name,srid,diminfo) VALUES (' T2 ', ' location ', 32774, S
Do_dim_array (sdo_dim_element (' longitude ', -180, 180, 0.1), sdo_dim_element (' latitude '),
-90, 90, 0.1));
--Establish the spatial index create index test2_index on T2 (location) Indextype are Mdsys.spatial_index SELECT * from T2; --Queries whether the points in the table T2 select * from T2 t where Sdo_relate (T.) in the given polygon. LOCATION ", Sdo_geometry (2003,--Two-dimensional polygon 32774, NULL, Sdo_elem_info_array (1,2003,1) , Sdo_ordinate_array (0,0, 0, 3, 7, 1, 0,0)-Polygon, ' mask=inside ') = ' TRUE ';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 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 7, 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
Reference:
Http://docs.oracle.com/database/122/SPATL/toc.htm
http://blog.csdn.net/qwlovedzm/article/details/5337662
Http://blog.sina.com.cn/s/blog_681cd80d0100ih95.html