(原) Oracle Spatial: Spatial Data Types and Metadata

來源:互聯網
上載者:User

1 Simple Example: Inserting, Indexing, and Querying Spatial Data
建立表:
CREATE TABLE cola_markets (
mkt_id NUMBER PRIMARY KEY,
name VARCHAR2(32),
shape SDO_GEOMETRY);

插入資料:
INSERT INTO cola_markets VALUES(
1,
'cola_a',
SDO_GEOMETRY(
2003, -- two-dimensional polygon
NULL,
NULL,
SDO_ELEM_INFO_ARRAY(1,1003,3), -- one rectangle (1003 = exterior)
SDO_ORDINATE_ARRAY(1,1, 5,7) -- only 2 points needed to
-- define rectangle (lower left and upper right) with
-- Cartesian-coordinate data
)
);
INSERT INTO cola_markets VALUES(
2,
'cola_b',
SDO_GEOMETRY(
2003, -- two-dimensional polygon
NULL,
NULL,
SDO_ELEM_INFO_ARRAY(1,1003,1), -- one polygon (exterior polygon ring)
SDO_ORDINATE_ARRAY(5,1, 8,1, 8,6, 5,7, 5,1)
)
);

INSERT INTO cola_markets VALUES(
3,
'cola_c',
SDO_GEOMETRY(
2003, -- two-dimensional polygon
NULL,
NULL,
SDO_ELEM_INFO_ARRAY(1,1003,1), -- one polygon (exterior polygon ring)
SDO_ORDINATE_ARRAY(3,3, 6,3, 6,5, 4,5, 3,3)
)
);

INSERT INTO cola_markets VALUES(
4,
'cola_d',
SDO_GEOMETRY(
2003, -- two-dimensional polygon
NULL,
NULL,
SDO_ELEM_INFO_ARRAY(1,1003,4), -- one circle
SDO_ORDINATE_ARRAY(8,7, 10,9, 8,11)
)
);

更新視圖:USER_SDO_GEOM_METADATA
INSERT INTO user_sdo_geom_metadata
(TABLE_NAME,
COLUMN_NAME,
DIMINFO,
SRID)
VALUES (
'cola_markets',
'shape',
SDO_DIM_ARRAY( -- 20X20 grid
SDO_DIM_ELEMENT('X', 0, 20, 0.005),
SDO_DIM_ELEMENT('Y', 0, 20, 0.005)
),
NULL -- SRID
);

建立空間索引:
CREATE INDEX cola_spatial_idx
ON cola_markets(shape)
INDEXTYPE IS MDSYS.SPATIAL_INDEX;
-- Preceding statement created an R-tree index.

查詢:
    SDO_GEOM.SDO_INTERSECTION
    SDO_GEOM.RELATE
    SDO_GEOM.SDO_AREA
    SDO_GEOM.SDO_DISTANCE
    SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT

2 SDO_GEOMETRY Object Type
2.1 SDO_GTYPE  dltt
    d:維數
    l:linear referencing system (LRS)
    tt:Geometry type
    00 UNKNOWN_GEOMETRY
    01 POINT
    02 LINE or CURVE
    03 POLYGON
    04 COLLECTION
    05 MULTIPOINT
    06 MULTILINE or MULTICURVE
    07 MULTIPOLYGON
2.2 SDO_SRID
    確認coordinate system,此值為SDO_COORD_REF_SYS表中的SRID值。此值也被插入到USER_SDO_GEOM_METADATA視圖中。
2.3 SDO_POINT
    (1)SDO_ELEM_INFO and SDO_ORDINATES are both null
    (2)SDO_POINT attribute is non-null
    結論:儲存座標
2.4 SDO_ELEM_INFO
    用來解釋儲存在SDO_ORDINATES屬性中的座標資訊。
    SDO_STARTING_OFFSET:SDO_ORDINATES中的offset min為1
    SDO_ETYPE: 1, 2, 1003, and 2003 simple elements; 3 polygon ring; 4, 1005, and 2005 compound elements
    SDO_INTERPRETATION
2.5 SDO_ORDINATES
    長數組,存放空間對象的座標
2.6 Usage Considerations
    SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT 用來檢查幾何對象的一致性。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.