獲取指定類型在指定時間段內的外包框。
語法
boxndf ST_MakeBox(geometry geom);
boxndf ST_MakeBox(trajectory traj);
boxndf ST_MakeBox(geometry geom, timestamp ts, timestamp te);
boxndf ST_MakeBox(trajectory traj, timestamp ts, timestamp te);
boxndf ST_MakeBox(timestamp ts, timestamp te);
參數
參數名稱 | 描述 |
geom | 需要獲取的外包框的幾何對象。 |
traj | 需要獲取的外包框的軌跡對象。 |
ts | 指定時間段的開始時間。 |
te | 指定時間段的結束時間。 |
描述
外包框即包含某個時空物體的最小多維矩形。
對于二維或三維的空間對象,返回其對應維度的外包框。
對于指定空間對象和時間段起止時間的調用
ST_MakeBox(geometry geom, timestamp ts, timestamp te)
, 將返回目標對象在目標時間段內的外包框。對于軌跡,若無時間段參數,則返回其整體的外包框;若有時間段參數,則返回在指定時間段內子軌跡的外包框。
由于BoxNDF內部由float類型表示,因此得到的Box可能會略大于輸入的參數,例如下界比實際值略小或上界比實際值略大。
示例
WITH geom AS(
SELECT ('POLYGON((12.7243236691148 4.35238368367118,12.9102992732078 1.49748113937676,12.5926592946053 1.67643963359296' ||
',12.0197574747333 3.19258554889152,12.7243236691148 4.35238368367118))')::geometry a
)
SELECT ST_MakeBox(a),ST_MakeBox(a,'2000-01-01 00:00:10'::timestamp, '2000-01-01 02:13:20'::timestamp) from geom;
st_makebox | st_makebox
----------------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------
BOX2D(12.0197572708 1.49748110771,12.9102993011 4.35238409042) | BOX2DT(12.0197572708 1.49748110771 2000-01-01 00:00:09.999999,12.9102993011 4.35238409042 2000-01-01 02:13:20.000381)
With traj AS (
Select ST_makeTrajectory('STPOINT', 'LINESTRING(0 0, 50 50, 100 100)'::geometry,
tsrange('2000-01-01 00:00:00'::timestamp, '2000-01-01 00:01:40'::timestamp),
'{"leafcount":3,"attributes":{"velocity": {"type": "integer", "length": 2,"nullable" : true,"value": [120,130,140]}, "accuracy": {"type": "float", "length": 4, "nullable" : false,"value": [120,130,140]}, "bearing": {"type": "float", "length": 8, "nullable" : false,"value": [120,130,140]}, "acceleration": {"type": "string", "length": 20, "nullable" : true,"value": ["120","130","140"]}, "active": {"type": "timestamp", "nullable" : false,"value": ["Fri Jan 01 11:35:00 2010", "Fri Jan 01 12:35:00 2010", "Fri Jan 01 13:30:00 2010"]}}, "events": [{"2" : "Fri Jan 02 15:00:00 2010"}, {"3" : "Fri Jan 02 15:30:00 2010"}]}') a
)
SELECT ST_MakeBox(a), ST_MakeBox(a,'1999-12-31 23:00:00'::timestamp, '2000-01-01 00:00:30'::timestamp) from traj;
st_makebox | st_makebox
-------------------------------------------------------------+------------------------------------------------------------------
BOX2DT(0 0 2000-01-01 00:00:00,100 100 2000-01-01 00:01:40) | BOX2DT(0 0 2000-01-01 00:00:00,30 30 2000-01-01 00:00:30.000001)
文檔內容是否對您有幫助?