La mayoría de las funciones para tipos temporales descritas en los capítulos precendentes se pueden aplicar para tipos de puntos de red temporales. Por lo tanto, en las firmas de las funciones, la notación base
también representa un npoint
y las notaciones ttype
, tpoint
y tgeompoint
también representan un tnpoint
. Además, las funciones que tienen un argumento de tipo geometry
aceptan además un argumento de tipo npoint
. Para evitar la redundancia, a continuación solo presentamos algunos ejemplos de estas funciones y operadores para puntos de red temporales.
Transformar un punto de red temporal en otro subtipo
tnpointInst(tnpoint) → tnpointInst
tnpointSeq(tnpoint,interp) → tnpointSeq
tnpointSeqSet(tnpoint) → tnpointSeqSet
SELECT tnpointSeq(tnpoint 'NPoint(1, 0.5)@2001-01-01', 'discrete'); -- {NPoint(1,0.5)@2001-01-01} SELECT tnpointSeq(tnpoint 'NPoint(1, 0.5)@2001-01-01'); -- [NPoint(1,0.5)@2001-01-01] SELECT tnpointSeqSet(tnpoint 'NPoint(1, 0.5)@2001-01-01'); -- {[NPoint(1,0.5)@2001-01-01]}
Transformar un punto de red temporal en otra interpolación
setInterp(tnpoint, interp) → tnpoint
SELECT setInterp(tnpoint 'NPoint(1,0.2)@2001-01-01','linear'); -- [NPoint(1,0.2)@2001-01-01] SELECT setInterp(tnpoint '{[NPoint(1,0.1)@2001-01-01], [NPoint(1,0.2)@2001-01-02]}', 'discrete'); -- {NPoint(1,0.1)@2001-01-01, NPoint(1,0.2)@2001-01-02}
Redondear la fracción del punto de red temporal en el número de lugares decimales
round(tnpoint,integer=0) → tnpoint
SELECT round(tnpoint '{[NPoint(1,0.123456789)@2001-01-01, NPoint(1,0.5)@2001-01-02)}', 6); -- {[NPoint(1,0.123457)@2001-01-01 00:00:00+01, NPoint(1,0.5)@2001-01-02 00:00:00+01)}
Obtener los valores
getValues(tnpoint) → npoint[]
SELECT getValues(tnpoint '{[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-02)}'); -- {"NPoint(1,0.3)","NPoint(1,0.5)"} SELECT getValues(tnpoint '{[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.3)@2001-01-02)}'); -- {"NPoint(1,0.3)"}
Obtener los identificadores de ruta
routes(tnpoint) → bigintset
SELECT routes(tnpoint '{NPoint(3, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-02}'); -- {1, 3}
Obtener el valor en una marca de tiempo
valueAtTimestamp(tnpoint,timestamptz) → npoint
SELECT valueAtTimestamp(tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-03)', '2001-01-02'); -- NPoint(1,0.4)
Obtener la longitud atravesada por el punto de red temporal
length(tnpoint) → float
SELECT length(tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-02]'); -- 54.3757408468784
Obtener la longitud acumulada atravesada por el punto de red temporal
cumulativeLength(tnpoint) → tfloat
SELECT cumulativeLength(tnpoint '{[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-02, NPoint(1, 0.5)@2001-01-03], [NPoint(1, 0.6)@2001-01-04, NPoint(1, 0.7)@2001-01-05]}'); /* {[0@2001-01-01, 54.3757408468784@2001-01-02, 54.3757408468784@2001-01-03], [54.3757408468784@2001-01-04, 81.5636112703177@2001-01-05]} */
Obtener la velocidad del punto de red temporal en unidades por segundo
speed({tnpointSeq, tnpointSeqSet}) → tfloatSeqSet
SELECT speed(tnpoint '[NPoint(1, 0.1)@2001-01-01, NPoint(1, 0.4)@2001-01-02, NPoint(1, 0.6)@2001-01-03]') * 3600 * 24; /* Interp=Step;[21.4016800272077@2001-01-01, 14.2677866848051@2001-01-02, 14.2677866848051@2001-01-03] */
Construir el cuadro delimitador a partir de un punto de red y, opcionalmente, una marca de tiempo o un período
stbox(npoint) → stbox
stbox(npoint,{timestamptz,period}) → stbox
SELECT stbox(npoint 'NPoint(1,0.3)'); -- STBOX X((48.711754,20.92568),(48.711758,20.925682)) SELECT stbox(npoint 'NPoint(1,0.3)', timestamptz '2001-01-01'); -- STBOX XT((62.786633,80.143555),(62.786636,80.143562),[2001-01-01,2001-01-01]) SELECT stbox(npoint 'NPoint(1,0.3)', period '[2001-01-01,2001-01-02]'); -- STBOX XT((62.786633,80.143555),(62.786636,80.143562),[2001-01-01,2001-01-02])
Obtener el centroide ponderado en el tiempo
twCentroid(tnpoint) → geometry(Point)
SELECT st_astext(twCentroid(tnpoint '{[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-02, NPoint(1, 0.5)@2001-01-03, NPoint(1, 0.7)@2001-01-04)}')); -- POINT(79.9787466444847 46.2385558051041)
Obtener el acimut temporal
azimuth(tnpoint) → tfloat
SELECT azimuth(tnpoint '[NPoint(2, 0.3)@2001-01-01, NPoint(2, 0.7)@2001-01-02]'); /* {[0.974681063778863@2001-01-01 00:00:00+01, 0.974681063778863@2001-01-01 23:54:36.721091+01), [3.68970843029227@2001-01-01 23:54:36.721091+01, 3.68970843029227@2001-01-02 00:00:00+01)} */
Dado que la geometría subyacente asociada a una ruta puede tener varios vértices, el valor de acimut puede cambiar entre instantes del punto de red temporal de entrada, como se muestra en el ejemplo anterior.
Obtener el instante del primer punto de red temporal en el que los dos argumentos están a la distancia más cercana
nearestApproachInstant({geo,npoint,tpoint},{geo,npoint,tpoint}) → tpoint
SELECT nearestApproachInstant(tnpoint '[NPoint(2, 0.3)@2001-01-01, NPoint(2, 0.7)@2001-01-02]', geometry 'Linestring(50 50,55 55)'); -- NPoint(2,0.349928)@2001-01-01 02:59:44.402905+01 SELECT nearestApproachInstant(tnpoint '[NPoint(2, 0.3)@2001-01-01, NPoint(2, 0.7)@2001-01-02]', npoint 'NPoint(1, 0.5)'); -- NPoint(2,0.592181)@2001-01-01 17:31:51.080405+01
Obtener la distancia más pequeña entre los dos argumentos
nearestApproachDistance({geo,npoint,tpoint},{geo,npoint,tpoint}) → float
SELECT nearestApproachDistance(tnpoint '[NPoint(2, 0.3)@2001-01-01, NPoint(2, 0.7)@2001-01-02]', geometry 'Linestring(50 50,55 55)'); -- 1.41793220500979 SELECT nearestApproachDistance(tnpoint '[NPoint(2, 0.3)@2001-01-01, NPoint(2, 0.7)@2001-01-02]', npoint 'NPoint(1, 0.5)'); -- NPoint(2,0.592181)@2001-01-01 17:31:51.080405+01
La función nearestApproachDistance
tiene un operador asociado |=|
que se puede utilizar para realizar búsquedas más cercanas utilizando un índice GiST (ver “Indexación”).
Obtener la línea que conecta el punto de aproximación más cercano entre los dos argumentos
shortestLine({geo,npoint,tpoint},{geo,npoint,tpoint}) → geometry
The function will only return the first line that it finds if there are more than one
SELECT st_astext(shortestLine(tnpoint '[NPoint(2, 0.3)@2001-01-01, NPoint(2, 0.7)@2001-01-02]', geometry 'Linestring(50 50,55 55)')); -- LINESTRING(50.7960725266492 48.8266286733015,50 50) SELECT st_astext(shortestLine(tnpoint '[NPoint(2, 0.3)@2001-01-01, NPoint(2, 0.7)@2001-01-02]', npoint 'NPoint(1, 0.5)')); -- LINESTRING(77.0902838115125 66.6659083092593,90.8134936900394 46.4385792121146)
Restringir a un valor
atValue(tnpoint,base) → tnpoint
minusValue(tnpoint,base) → tnpoint
SELECT atValue(tnpoint '[NPoint(2, 0.3)@2001-01-01, NPoint(2, 0.7)@2001-01-03]', 'NPoint(2, 0.5)'); -- {[NPoint(2,0.5)@2001-01-02]} SELECT minusValue(tnpoint '[NPoint(2, 0.3)@2001-01-01, NPoint(2, 0.7)@2001-01-03]', 'NPoint(2, 0.5)'); /* {[NPoint(2,0.3)@2001-01-01, NPoint(2,0.5)@2001-01-02), (NPoint(2,0.5)@2001-01-02, NPoint(2,0.7)@2001-01-03]} */
Restringir a una geometría
atGeometry(tnpoint,geometry) → tnpoint
minusGeometry(tnpoint,geometry) → tnpoint
SELECT atGeometry(tnpoint '[NPoint(2, 0.3)@2001-01-01, NPoint(2, 0.7)@2001-01-03]', 'Polygon((40 40,40 50,50 50,50 40,40 40))'); SELECT minusGeometry(tnpoint '[NPoint(2, 0.3)@2001-01-01, NPoint(2, 0.7)@2001-01-03]', 'Polygon((40 40,40 50,50 50,50 40,40 40))'); /* {(NPoint(2,0.342593)@2001-01-01 05:06:40.364673+01, NPoint(2,0.7)@2001-01-03 00:00:00+01]} */
Operadores de comparación tradicionales
tnpoint = tnpoint → boolean
tnpoint <> tnpoint → boolean
tnpoint < tnpoint → boolean
tnpoint > tnpoint → boolean
tnpoint <= tnpoint → boolean
tnpoint >= tnpoint → boolean
SELECT tnpoint '{[NPoint(1, 0.1)@2001-01-01, NPoint(1, 0.3)@2001-01-02), [NPoint(1, 0.3)@2001-01-02, NPoint(1, 0.5)@2001-01-03]}' = tnpoint '[NPoint(1, 0.1)@2001-01-01, NPoint(1, 0.5)@2001-01-03]'; -- true SELECT tnpoint '{[NPoint(1, 0.1)@2001-01-01, NPoint(1, 0.5)@2001-01-03]}' <> tnpoint '[NPoint(1, 0.1)@2001-01-01, NPoint(1, 0.5)@2001-01-03]'; -- false SELECT tnpoint '[NPoint(1, 0.1)@2001-01-01, NPoint(1, 0.5)@2001-01-03]' < tnpoint '[NPoint(1, 0.1)@2001-01-01, NPoint(1, 0.6)@2001-01-03]'; -- true
Operadores de comparación temporales
tnpoint #= tnpoint → tbool
tnpoint #<> tnpoint → tbool
SELECT tnpoint '[NPoint(1, 0.2)@2001-01-01, NPoint(1, 0.4)@2001-01-03)' #= npoint 'NPoint(1, 0.3)'; -- {[f@2001-01-01, t@2001-01-02], (f@2001-01-02, f@2001-01-03)} SELECT tnpoint '[NPoint(1, 0.2)@2001-01-01, NPoint(1, 0.8)@2001-01-03)' #<> tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.7)@2001-01-03)'; -- {[t@2001-01-01, f@2001-01-02], (t@2001-01-02, t@2001-01-03)}
Operadores de igualdad alguna vez y siempre
tnpoint ?= tnpoint → boolean
tnpoint %= tnpoint → boolean
SELECT tnpoint '[Npoint(1, 0.2)@2001-01-01, Npoint(1, 0.4)@2001-01-04)' ?= Npoint(1, 0.3); -- true SELECT tnpoint '[Npoint(1, 0.2)@2001-01-01, Npoint(1, 0.2)@2001-01-04)' &= Npoint(1, 0.2); -- true
Operadores de posición
tnpoint << tnpoint → boolean
tnpoint &< tnpoint → boolean
tnpoint >> tnpoint → boolean
tnpoint &> tnpoint → boolean
tnpoint <<| tnpoint → boolean
tnpoint &<| tnpoint → boolean
tnpoint |>> tnpoint → boolean
tnpoint |&> tnpoint → boolean
tnpoint <<# tnpoint → boolean
tnpoint &<# tnpoint → boolean
tnpoint #>> tnpoint → boolean
tnpoint #&> tnpoint → boolean
SELECT tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-02]' << npoint 'NPoint(1, 0.2)' -- false SELECT tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-02]' <<| stbox(npoint 'NPoint(1, 0.5)') -- false SELECT tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-02]' &> npoint 'NPoint(1, 0.3)'::geometry -- true SELECT tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-02]' >># tnpoint '[NPoint(1, 0.3)@2001-01-03, NPoint(1, 0.5)@2001-01-05]' -- true
Operadores topológicos
tnpoint && tnpoint → boolean
tnpoint <@ tnpoint → boolean
tnpoint @> tnpoint → boolean
tnpoint ~= tnpoint → boolean
tnpoint -|- tnpoint → boolean
SELECT tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-02]' && npoint 'NPoint(1, 0.5)' -- true SELECT tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-02]' @> stbox(npoint 'NPoint(1, 0.5)') -- true SELECT npoint 'NPoint(1, 0.5)'::geometry <@ tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-02]' -- true SELECT tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-03]' ~= tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.35)@2001-01-02, NPoint(1, 0.5)@2001-01-03]' -- true
Obtener la distancia más pequeña entre los dos argumentos
tgeompoint |=| tnpoint → float
SELECT tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-03]' |=| npoint 'NPoint(1, 0.2)'; -- 2.34988300875063 SELECT tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-03]' |=| geometry 'Linestring(2 2,2 1,3 1)'; -- 82.2059262761477
Obtener la distancia temporal
tgeompoint <-> tnpoint → tfloat
SELECT tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-03]' <-> npoint 'NPoint(1, 0.2)'; -- [2.34988300875063@2001-01-02 00:00:00+01, 2.34988300875063@2001-01-03 00:00:00+01] SELECT tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-03]' <-> geometry 'Point(50 50)'; -- [25.0496666945044@2001-01-01 00:00:00+01, 26.4085688426232@2001-01-03 00:00:00+01] SELECT tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-03]' <-> tnpoint '[NPoint(1, 0.3)@2001-01-02, NPoint(1, 0.5)@2001-01-04]' -- [2.34988300875063@2001-01-02 00:00:00+01, 2.34988300875063@2001-01-03 00:00:00+01]
Relaciones espaciales alguna vez
eContains(geometry,tnpoint) → boolean
aContains(geometry,tnpoint) → boolean
eDisjoint({geometry,npoint,tnpoint},{geometry,npoint,tnpoint}) → boolean
aDisjoint({geometry,npoint,tnpoint},{geometry,npoint,tnpoint}) → boolean
eIntersects({geometry,npoint,tnpoint},{geometry,npoint,tnpoint}) → boolean
aIntersects({geometry,npoint,tnpoint},{geometry,npoint,tnpoint}) → boolean
eTouches({geometry,npoint,tnpoint},{geometry,npoint,tnpoint}) → boolean
aTouches({geometry,npoint,tnpoint},{geometry,npoint,tnpoint}) → boolean
eDwithin({geometry,npoint,tnpoint},{geometry,npoint,tnpoint},float) → boolean
aDwithin({geometry,npoint,tnpoint},{geometry,npoint,tnpoint},float) → boolean
SELECT eContains(geometry 'Polygon((0 0,0 50,50 50,50 0,0 0))', tnpoint '[NPoint(1, 0.1)@2001-01-01, NPoint(1, 0.3)@2001-01-03)'); -- false SELECT eDisjoint(npoint 'NPoint(2, 0.0)', tnpoint '[NPoint(1, 0.1)@2001-01-01, NPoint(1, 0.3)@2001-01-03)'); -- true SELECT eIntersects(tnpoint '[NPoint(1, 0.1)@2001-01-01, NPoint(1, 0.3)@2001-01-03)', tnpoint '[NPoint(2, 0.0)@2001-01-01, NPoint(2, 1)@2001-01-03)'); -- false
Relaciones espaciales temporales
tContains(geometry,tnpoint) → boolean
tDisjoint({geometry,npoint,tnpoint},{geometry,npoint,tnpoint}) → boolean
tIntersects({geometry,npoint,tnpoint},{geometry,npoint,tnpoint}) → boolean
tTouches({geometry,npoint,tnpoint},{geometry,npoint,tnpoint}) → boolean
tDwithin({geometry,npoint,tnpoint},{geometry,npoint,tnpoint},float) → boolean
SELECT tDisjoint(geometry 'Polygon((0 0,0 50,50 50,50 0,0 0))', tnpoint '[NPoint(1, 0.1)@2001-01-01, NPoint(1, 0.3)@2001-01-03)'); -- {[t@2001-01-01 00:00:00+01, t@2001-01-03 00:00:00+01)} SELECT tDwithin(tnpoint '[NPoint(1, 0.3)@2001-01-01, NPoint(1, 0.5)@2001-01-03)', tnpoint '[NPoint(1, 0.5)@2001-01-01, NPoint(1, 0.3)@2001-01-03)', 1); /* {[t@2001-01-01 00:00:00+01, t@2001-01-01 22:35:55.379053+01], (f@2001-01-01 22:35:55.379053+01, t@2001-01-02 01:24:04.620946+01, t@2001-01-03 00:00:00+01)} */