-- relate
select st_geomfromtext('LINESTRING(-1 1, 0 0, 1 0, 3 1)') as geom
union
select st_geomfromtext('LINESTRING(-1 -1, 0 0, 1 0, 3 -1)') as geom;
select st_relate(
st_geomfromtext('LINESTRING(-1 1, 0 0, 1 0, 3 1)'),
st_geomfromtext('LINESTRING(-1 -1, 0 0, 1 0, 3 -1)'),
'1*1***1**'
);
select st_geomfromtext('POLYGON((0 0, 1 0, 2 1, 3 2, 3 3, 0 3, 0 0))') as geom
union
select st_geomfromtext('LINESTRING(2.5 0, 2 2)') as geom;
select st_relate(
st_geomfromtext('POLYGON((0 0, 1 0, 2 1, 3 2, 3 3, 0 3, 0 0))'),
--st_geomfromtext('LINESTRING(1 1, 0.5 2)'),
--st_geomfromtext('LINESTRING(1 0, 2 1, 1.5 2)'),
--st_geomfromtext('LINESTRING(2 1, 1.5 2)'),
st_geomfromtext('LINESTRING(2.5 0, 2 2)'),
'10*T0*F**'
);
-- equals
select st_geomfromtext('LINESTRING(0 0, 1 1)') as geom
union
select st_geomfromtext('LINESTRING(0 0, 1 1)') as geom;
select st_relate(
st_geomfromtext('LINESTRING(0 0, 1 1)'),
st_geomfromtext('LINESTRING(0 0, 1 1)'),
'TFFFTFFFT'
);
-- disjoint
select st_geomfromtext('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))') as geom
union
select st_geomfromtext('POLYGON((2 0, 3 0, 3 1, 2 1, 2 0))') as geom;
select st_relate(
st_geomfromtext('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))'),
st_geomfromtext('POLYGON((2 0, 3 0, 3 1, 2 1, 2 0))'),
'FF*FF****'
);
-- intersects
select st_geomfromtext('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))') as geom
union
select st_geomfromtext('POLYGON((0.5 0, 1.5 0, 1.5 1, 1.5 1, 0.5 0))') as geom;
select st_relate(
st_geomfromtext('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))'),
st_geomfromtext('POLYGON((0.5 0, 1.5 0, 1.5 1, 1.5 1, 0.5 0))'),
'TT*TT****'
);
-- touches
select st_geomfromtext('LINESTRING(0 0, 2 0)') as geom
union
select st_geomfromtext('LINESTRING(1 0, 1 1)') as geom;
select st_relate(
st_geomfromtext('LINESTRING(0 0, 2 0)'),
st_geomfromtext('LINESTRING(1 0, 1 1)'),
'FT*******'
);
select st_geomfromtext('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))') as geom
union
select st_geomfromtext('POLYGON((1 0, 2 0, 2 1, 2 1, 1 0))') as geom;
select st_relate(
st_geomfromtext('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))'),
st_geomfromtext('POLYGON((1 0, 2 0, 2 1, 2 1, 1 0))'),
'F***T****'
);
-- crosses
select st_geomfromtext('LINESTRING(0 0, 2 2)') as geom
union
select st_geomfromtext('LINESTRING(2 0, 0 2)') as geom;
select st_relate(
st_geomfromtext('LINESTRING(0 0, 2 2)'),
st_geomfromtext('LINESTRING(2 0, 0 2)'),
'0********'
);
select st_geomfromtext('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))') as geom
union
select st_geomfromtext('LINESTRING(0.5 0.5, 2 2)') as geom;
select st_relate(
st_geomfromtext('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))'),
st_geomfromtext('LINESTRING(0.5 0.5, 2 2)'),
'T*T******'
);
-- within
select st_geomfromtext('LINESTRING(0.5 0.5, 1 1)') as geom
union
select st_geomfromtext('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))') as geom;
select st_relate(
st_geomfromtext('LINESTRING(0.5 0.5, 1 1)'),
st_geomfromtext('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))'),
'T*F**F***'
);
-- contains
select st_geomfromtext('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))') as geom
union
select st_geomfromtext('LINESTRING(0.5 0.5, 0.9 0.9)') as geom;
select st_relate(
st_geomfromtext('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))'),
st_geomfromtext('LINESTRING(0.5 0.5, 0.9 0.9)'),
'T*T**T***'
);