Opened 3 years ago

Closed 3 years ago

#4881 closed defect (fixed)

Lineal TopoGeometry objects loose their direction upon casting to Geometry

Reported by: strk Owned by: strk
Priority: medium Milestone: PostGIS 3.2.0
Component: topology Version: 1.5.X
Keywords: Cc:

Description

Simple testcase:

SELECT CreateTopology('t');
CREATE TABLE t.f(i serial primary key);
SELECT AddTopoGeometryColumn('t','t','f','g','LINE');
SELECT ST_AsText(toTopoGeom('LINESTRING(0 0, 10 0)', 't', 1, 0)::geometry);
select ST_AsText(toTopoGeom(ST_Reverse('LINESTRING(0 0, 10 0)'), 't', 1, 0)::geometry);

The last two queries are creating a TopoGeometry with two LINESTRING objects in opposite direction. When casting these two objects back to a GEOMETRY object the _same_ LINESTRING comes back, regardless of the original direction.

I verified this is NOT a problem with toTopoGeom but with the cast to geometry, because changing the sign of the element_id in the relation table does NOT change the output of the ::geometry cast.

This limitation is probably as old as the Topology support in PostGIS.

MULTILINESTRING((0 0,10 0))

Change History (6)

comment:2 by strk, 3 years ago

Summary: Lineal TopoGeometry objects do not conserve their directionLineal TopoGeometry objects do not preserve their direction

A related ticket is about GetTopoGeomElements NOT returning the sign of elements: #4882

comment:3 by strk, 3 years ago

I spoke too early: while the TopoGeometry::Geometry cast IS BOGUS as verified by manually changing sign of the element_id fields in the relation table, the toTopoGeom function is ALSO BOGUS in that it doesn't correctly set those element_id field signs, see #4884

comment:4 by strk, 3 years ago

Summary: Lineal TopoGeometry objects do not preserve their directionLineal TopoGeometry objects loose their direction upon casting to Geometry

comment:5 by strk, 3 years ago

Milestone: PostGIS 3.1.2PostGIS 3.2.0

comment:6 by Sandro Santilli <strk@…>, 3 years ago

Resolution: fixed
Status: newclosed

In fea3aac/git:

Rewrite TopoGeometry::geometry cast for lineals to retain direction

Includes test

Closes #4881 in main branch (3.2.0dev)

Note: See TracTickets for help on using tickets.