在使用Oracle spatial做空间查询和展示时,经常会遇到展示或者查询过慢,这时候我可以通过空间数据抽稀来优化查询展示效率。
在Oracle spatial中的抽稀函数为:SDO_UTIL.SIMPLIFY
它内部采用了道格拉斯抽稀算法。
构造函数:
SDO_UTIL.SIMPLIFY(
geometry IN SDO_GEOMETRY,//输入的geometry
threshold IN NUMBER//抽吸阀值 该值为正树(如果该值为零,则表示输入geometry和输出geometry相同,不做处理) ,如果输入geometry是地理坐标,则该值用米来表示。如果不是地理坐标,则表示与之相关的单位。
tolerance IN NUMBER DEFAULT 0.0000005//容差 不能比阀值大 为了取得较理想的抽稀效果,它的取值不能与阀值相等,如果阀值越大,返回geometry的点越少。
) RETURN SDO_GEOMETRY;
使用样例:
SELECT SDO_UTIL.SIMPLIFY(
SDO_GEOMETRY(
3302, — line string, 3 dimensions (X,Y,M), 3rd is linear ref. dimension
NULL,
NULL,
SDO_ELEM_INFO_ARRAY(1,2,1), — one line string, straight segments
SDO_ORDINATE_ARRAY(
2,2,0, — Starting point – Exit1; 0 is measure from start.
2,4,2, — Exit2; 2 is measure from start.
8,4,8, — Exit3; 8 is measure from start.
12,4,12, — Exit4; 12 is measure from start.
12,10,NULL, — Not an exit; measure automatically calculated and filled.
8,10,22, — Exit5; 22 is measure from start.
5,14,27) — Ending point (Exit6); 27 is measure from start.
),
6, — threshold value for geometry simplification
0.5 — tolerance
) FROM DUAL;
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/4454.html