日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

ST_JaccardSimilarity

計算軌跡或子軌跡的Jaccard相似系數(shù)(Jaccard index)。

語法

record ST_JaccardSimilarity(trajectory tr1, trajectory tr2, double tol_dist, 
                            text unit default '{}', interval tol_time default NULL, 
                            timestamp ts default '-infinity', timestamp te default 'infinity') ; 

參數(shù)

參數(shù)名稱

描述

tr1

軌跡對象1。

tr2

軌跡對象2。

tol_dist

空間容差,單位為米。

unit

描述距離計算方式的JSON字符串。

tol_time

時間容差。默認為NULL,當值為NULL或負值時表示只進行空間匹配不考慮時間。

ts

開始時間。默認為-infinity,只關注在起止時間之間的子軌跡。

te

結束時間。默認為infinity,只關注在起止時間之間的子軌跡。

unit參數(shù)說明如下。

參數(shù)名稱

類型

默認值

說明

Projection

string

重新投影的目標坐標系。取值:

  • auto:根據(jù)經(jīng)緯度坐標動態(tài)選擇最合適的坐標系(Lambert Azimuthal、UTM等),并投影到此坐標系進行計算。不需要額外指定Unit,單位為米。

  • srid:需要重投影到的空間參考系ID。

說明

不傳本參數(shù)時,依照原有坐標系計算。

Unit

string

null

度量單位。取值:

  • null:即無單位,直接按照軌跡點坐標的歐式距離進行計算。

  • M:按照所在空間參考系基于的單位進行距離計算,通常為米。

useSpheroid

bool

true

是否使用橢球體計算。當Unit設置為M時,可以指定此項。取值:

  • true:使用橢球體并計算更精確的距離。

  • false:使用球體表示地球并計算近似的距離。

返回參數(shù)說明如下。

參數(shù)名稱

類型

說明

nleaf1

int

軌跡1與軌跡2相交的點數(shù)量。

nleaf2

int

軌跡2與軌跡1相交的點數(shù)量。

說明

nleaf1不一定相同,例如可能軌跡1兩次經(jīng)過軌跡2的同一個點,則nleaf1為1,nleaf2為2。

inter1

int

軌跡1到軌跡2的距離同時滿足時間容差和空間容差的點數(shù)量。

inter2

int

軌跡2到軌跡1的距離同時滿足時間容差和空間容差的點數(shù)量。

jaccard_lower

double

Jaccard距離下限。計算公式:inter/(nleaf1+nleaf2-inter)

說明

inter為inter1inter2中較小的值。

jaccard_upper

double

Jaccard距離上限。計算公式:inter/(nleaf1+nleaf2-inter)

說明

inter為inter1inter2中較大的值。

描述

兩個集合的Jaccard index指兩個集合交集的元素數(shù)量除以兩個集合并集的元素數(shù)量。對于兩條軌跡,我們擴展了Jaccard index的定義,分別計算在軌跡1與軌跡2相交的點數(shù)量,以及在軌跡2上與軌跡1相交的點數(shù)量,并通過上文jaccard_lowerjaccard_upper的公式計算距離。

示例

With traj as(
SELECT ST_makeTrajectory('STPOINT'::leaftype, 'SRID=4326;LINESTRING(114.49211 37.97921,114.49211 37.97921,114.49211 37.97921,114.49211 37.97921)'::geometry,
    ARRAY[to_timestamp(1590287775) AT TIME ZONE 'UTC', to_timestamp(1590287778) AT TIME ZONE 'UTC', to_timestamp(1590302169) AT TIME ZONE 'UTC',to_timestamp(1590302171) AT TIME ZONE 'UTC'], '{}') a,
    ST_makeTrajectory('STPOINT'::leaftype, 'SRID=4326;LINESTRING(114.49211 37.97921,114.49211 37.97921,114.49211 37.97921,114.49211 37.97921,114.49145 37.97781,114.49145 37.97781,114.49145 37.97781,114.49145 37.97781,114.49145 37.97781,114.49145 37.97781,114.49145 37.97781,114.49145 37.97781,114.49145 37.97781,114.49145 37.97781,114.49211 37.97921,114.49211 37.97921,114.49211 37.97921,114.49211 37.97921,114.49211 37.97921,114.49211 37.97921)'::geometry,
    ARRAY[ to_timestamp(1590287765) AT TIME ZONE 'UTC', to_timestamp(1590287771) AT TIME ZONE 'UTC', to_timestamp(1590287778) AT TIME ZONE 'UTC', to_timestamp(1590287780) AT TIME ZONE 'UTC', to_timestamp(1590295992) AT TIME ZONE 'UTC', to_timestamp(1590295997) AT TIME ZONE 'UTC', to_timestamp(1590296013) AT TIME ZONE 'UTC', to_timestamp(1590296018) AT TIME ZONE 'UTC',  to_timestamp(1590296025) AT TIME ZONE 'UTC', to_timestamp(1590296032) AT TIME ZONE 'UTC', to_timestamp(1590296055) AT TIME ZONE 'UTC', to_timestamp(1590296073) AT TIME ZONE 'UTC', to_timestamp(1590296081) AT TIME ZONE 'UTC', to_timestamp(1590296081) AT TIME ZONE 'UTC', to_timestamp(1590302169) AT TIME ZONE 'UTC', to_timestamp(1590302174) AT TIME ZONE 'UTC',  to_timestamp(1590302176) AT TIME ZONE 'UTC', to_timestamp(1590302176) AT TIME ZONE 'UTC', to_timestamp(1590302172) AT TIME ZONE 'UTC', to_timestamp(1590302176) AT TIME ZONE 'UTC'],'{}') b
)
select ST_JaccardSimilarity(a,b, 100,'{"unit":"M"}','20 second', '2020-05-23'::timestamptz AT TIME ZONE 'UTC', '2020-05-26'::timestamptz AT TIME ZONE 'UTC') from traj;
       st_jaccardsimilarity        
-----------------------------------
 (4,20,4,10,0.2,0.7142857142857143)
(1 row)