Convertir un valor temporal espacial a un cuadro delimitador espaciotemporal
tspatial::stbox
SELECT tgeompoint '[Point(1 1)@2001-01-01, Point(3 3)@2001-01-03]'::tstzspan; -- [2001-01-01, 2001-01-03] SELECT tgeompoint '[Point(1 1)@2001-01-01, Point(3 3)@2001-01-03]'::stbox; -- STBOX XT(((1,1),(3,3)),[2001-01-01, 2001-01-03]) SELECT tgeography '[Point(1 1 1)@2001-01-01, Point(3 3 3)@2001-01-03]'::stbox; -- SRID=4326;GEODSTBOX ZT(((1,1,1),(3,3,3)),[2001-01-01, 2001-01-03])
Convertir entre una geometría temporal y una geografía temporal
tgeometry::tgeography
tgeography::tgeometry
tgeompoint::tgeogpoint
tgeogpoint::tgeompoint
SELECT asText((tgeompoint '[Point(0 0)@2001-01-01, Point(0 1)@2001-01-02)')::tgeogpoint); -- [POINT(0 0)@2001-01-01, POINT(0 1)@2001-01-02) SELECT asText((tgeography 'Linestring(0 0,1 1)@2001-01-01')::tgeometry); -- LINESTRING(0 0,1 1)@2001-01-01
Una forma común de almacenar puntos temporales en PostGIS es representarlos como geometrías de tipo LINESTRING M
y utilizar la dimensión M para codificar marcas de tiempo como segundos desde 1970-01-01 00:00:00. Estas geometrías aumentadas con tiempo, llamadas trayectorias, se pueden validar con la función ST_IsValidTrajectory
para verificar quel el valor M está creciendo de cada vértice al siguiente. Las trayectorias se pueden manipular con las funciones ST_ClosestPointOfApproach
, ST_DistanceCPA
y ST_CPAWithin
. Los valores de puntos temporales se pueden convertir a/desde trayectorias de PostGIS.
Convertir entre un punto temporal y una trayectoria PostGIS
tpoint::geo
geo::tpoint
SELECT ST_AsText((tgeompoint 'Point(0 0)@2001-01-01')::geometry); -- POINT M (0 0 978307200) SELECT ST_AsText((tgeompoint '{Point(0 0)@2001-01-01, Point(1 1)@2001-01-02, Point(1 1)@2001-01-03}')::geometry); -- MULTIPOINT M (0 0 978307200,1 1 978393600,1 1 978480000) SELECT ST_AsText((tgeompoint '[Point(0 0)@2001-01-01, Point(1 1)@2001-01-02)')::geometry); -- LINESTRING M (0 0 978307200,1 1 978393600) SELECT ST_AsText((tgeompoint '{[Point(0 0)@2001-01-01, Point(1 1)@2001-01-02), [Point(1 1)@2001-01-03, Point(1 1)@2001-01-04), [Point(1 1)@2001-01-05, Point(0 0)@2001-01-06)}')::geometry); /* MULTILINESTRING M ((0 0 978307200,1 1 978393600),(1 1 978480000,1 1 978566400), (1 1 978652800,0 0 978739200)) */ SELECT ST_AsText((tgeompoint '{[Point(0 0)@2001-01-01, Point(1 1)@2001-01-02), [Point(1 1)@2001-01-03], [Point(1 1)@2001-01-05, Point(0 0)@2001-01-06)}')::geometry); /* GEOMETRYCOLLECTION M (LINESTRING M (0 0 978307200,1 1 978393600), POINT M (1 1 978480000),LINESTRING M (1 1 978652800,0 0 978739200)) */
SELECT asText(geometry 'LINESTRING M (0 0 978307200,0 1 978393600, 1 1 978480000)'::tgeompoint); -- [POINT(0 0)@2001-01-01, POINT(0 1)@2001-01-02, POINT(1 1)@2001-01-03] SELECT asText(geometry 'GEOMETRYCOLLECTION M (LINESTRING M (0 0 978307200,1 1 978393600), POINT M (1 1 978480000),LINESTRING M (1 1 978652800,0 0 978739200))'::tgeompoint); /* {[POINT(0 0)@2001-01-01, POINT(1 1)@2001-01-02], [POINT(1 1)@2001-01-03], [POINT(1 1)@2001-01-05, POINT(0 0)@2001-01-06]} */