zoukankan      html  css  js  c++  java
  • 用Oracle的函数,判断点是否在多边形内

    转自:http://blog.csdn.net/familyshizhouna/article/details/68944683

    参考:http://blog.csdn.net/qwlovedzm/article/details/5337662

    投影坐标系(PCS):http://support.supermap.com.cn/DataWarehouse/WebDocHelp/iServer/Appendix/CoordSystem/PCS_Code.htm

    ps:sql语句中注释掉的32774是坐标系代码.而sql语句中默认使用的坐标系是null

    --create table
    create table t5(
        id number,
        location sdo_geometry --
    );
    
    --插入空间元数据
    insert into user_sdo_geom_metadata
    (table_name,column_name,srid,diminfo)
    values
    (
     't5',
     'location',
      NULL,--32774,
     sdo_dim_array
     (
       sdo_dim_element
       (
      'longitude',
      -180,
      180,
      0.1
      ),
       sdo_dim_element
      (
       'latitude',
       -90,
       90,
       0.1
       )
     )
    );
    
    --建立空间索引
    create index test5_index on t5(location)
     indextype is mdsys.spatial_index;
    
    --插入数据1
    insert into t5 values(
        1, --id
        sdo_geometry
        (
            2001,
            --32774,
            NULL,
            SDO_POINT_TYPE(-33,40,NULL),
            NULL,
            NULL
        )
    );
    
    --查询表T5中的点是否在给定的多边形中
    select * from T5 where
    sdo_inside("LOCATION", SDO_GEOMETRY(
        2003,  -- two-dimensional polygon
        NULL,--32774,
        NULL,
        sdo_elem_info_array (1,2003,2),
        SDO_ORDINATE_ARRAY(-122.526398,40.708813, -122.526398,40.822802, 40.822802,-122.373962, -122.373962,40.708813, -122.526398,40.708813) --多边形
      ))='TRUE';
    
    
    select * from T5 where
    sdo_relate("LOCATION", SDO_GEOMETRY(
        2003,  -- two-dimensional polygon
        NULL ,--32774,
        NULL,
        sdo_elem_info_array (1,2003,2),
      SDO_ORDINATE_ARRAY(-122.526398,40.708813, -122.526398,40.822802, 40.822802,-122.373962, -122.373962,40.708813, -122.526398,40.708813) --多边形
      )
    ,'MASK=INSIDE')='TRUE';
  • 相关阅读:
    WEBAPP开发技巧
    手机中的javascript事件
    I6下实现FIXED
    vim 使用帮助
    javascript小技巧
    webkitbox & translate CSS3动画详解
    backbone中的实例中文注释
    getClientRect和getBoundingClientRect获取节点的屏幕距离
    javascript判定不同浏览器
    jQuery中的trigger(type, [data]) 原生实现方法
  • 原文地址:https://www.cnblogs.com/lpxblog/p/8276115.html
Copyright © 2011-2022 走看看