Opened 4 weeks ago

Last modified 4 weeks ago

#5738 new defect

ST_OffsetCurve returns wrong geometry

Reported by: rkolka Owned by: pramsey
Priority: medium Milestone: PostGIS GEOS
Component: postgis Version: 3.4.x
Keywords: st_offsetcurve Cc:

Description

ST_OffsetCurve sometimes returns wrong geometry. Seems to happen when source geometry has 2 vertices very close.

CREATE TABLE public.offsetcurve_bug
(
    id serial primary key,
	description text,
    geometry geometry(LineString)
)
;
CREATE INDEX offsetcurve_bug_geometry_x ON public.offsetcurve_bug USING gist (geometry);

INSERT INTO public.offsetcurve_bug(
	description, geometry)
	VALUES 
	('original', 'LINESTRING(544237.894288877 6588306.70972559,544226.9710250939 6588308.03375757,544220.8010926669 6588309.418844438)'::geometry(LineString))
	,
	('original', 'LINESTRING(544172.354706179 6588303.23414166,544174.671762133 6588304.55817364,544178.8093620511 6588306.2132136)'::geometry(LineString))
;

INSERT INTO public.offsetcurve_bug
	(description, geometry)
SELECT
	'substring' as description,
	ST_LineSubstring(geometry, 0.35, 0.65) as geometry
FROM
	public.offsetcurve_bug
WHERE
	description = 'original'
;


INSERT INTO public.offsetcurve_bug
	(description, geometry)
SELECT
	'offset 6m' as description,
	ST_OffsetCurve(geometry, -6, 'quad_segs=4 join=mitre mitre_limit=1.1') as geometry
FROM
	public.offsetcurve_bug
WHERE
	description = 'substring'
;

POSTGIS=3.4.2 GEOS=3.11.1-CAPI-1.17.1

Attachments (1)

ST_OffsetCurve_bug.png (29.6 KB ) - added by rkolka 4 weeks ago.

Download all attachments as: .zip

Change History (4)

by rkolka, 4 weeks ago

Attachment: ST_OffsetCurve_bug.png added

comment:1 by mdavis, 4 weeks ago

The example provided is quite complex. Can you provide a single example showing the questionable behaviour?

Something like this:

WITH data(geom) AS (VALUES
   ('LINESTRING(544237.894288877 6588306.70972559,544226.9710250939 6588308.03375757,544220.8010926669 6588309.418844438)'::geometry)
)
SELECT geom, 
  ST_LineSubstring(geom, 0.35, 0.65) AS subline,
  ST_OffsetCurve( ST_LineSubstring(geom, 0.35, 0.65), -6, 'quad_segs=4 join=mitre mitre_limit=1.1') AS offLine
  FROM data;
Last edited 4 weeks ago by mdavis (previous) (diff)

comment:2 by mdavis, 4 weeks ago

In GEOS 3.11.3 this doesn't seem to have any issues (assuming I have the test case right).

comment:3 by robe, 4 weeks ago

Milestone: PostGIS GEOS
Note: See TracTickets for help on using tickets.