Opened 10 years ago

Closed 10 years ago

#2964 closed defect (invalid)

ST_OffSetCurve returns EMPTY geometries and other issues

Reported by: drbullit Owned by: pramsey
Priority: medium Milestone: PostGIS 2.1.6
Component: postgis Version: 2.1.x
Keywords: st_offsetcurve Cc:

Description

First issue is that when using negative offset values, st_offsetcurve returns an EMPTY geometry in some cases.

Reference geometry: LINESTRING(-76.941839 38.915428,-76.941883 38.915476,-76.94189 38.915497)

Both st_astext(st_offsetcurve(geom, -15)) and st_astext(st_offsetcurve(geom, -1)) return LINESTRING EMPTY

Positive offset values do not return empty geometries, but do seem to affect length of the geometry. I was under the assumption these result geometries would only be 'shifted parallelly' not see significant geometry changes:

original geometry length — st_length(geom, true) —> 4879.15614361318

result of st_length(st_offsetcurve(geom, 1),true) —> 168892.068090029

SRID of original geometry is 4326

Attachments (1)

screenshot_239.png (7.8 KB ) - added by pramsey 10 years ago.
select st_astext(st_offsetcurve('LINESTRING(-76.941839 38.915428,-76.941883 38.915476,-76.94189 38.915497)',-0.0001));

Download all attachments as: .zip

Change History (3)

comment:1 by pramsey, 10 years ago

Milestone: PostGIS 2.1.5PostGIS 2.1.6

by pramsey, 10 years ago

Attachment: screenshot_239.png added

select st_astext(st_offsetcurve('LINESTRING(-76.941839 38.915428,-76.941883 38.915476,-76.94189 38.915497)',-0.0001));

comment:2 by pramsey, 10 years ago

Resolution: invalid
Status: newclosed

The first issue is related directly to the second. An offset curve does not just "shift" things (if you want that, maybe look at ST_Affine) it produces a line that could be used along with other lines to produce a cartographic rendering. For lines that "bend" to the right, the left-hand offset will be somewhat longer than the line which will in turn be somewhat longer than the right-hand offset.

Your initial example is offsetting a relatively "short" line by a relatively "huge" amount, and since the line is concave in the direction you're offsetting it, the offset shrinks away to nothing. Empty. I took your example and just started reducing the offset distance until I got an answer back. You'll see the picture of it attached.

Note: See TracTickets for help on using tickets.