Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#183 closed defect (fixed)

ST_LineToCurve gives getPoint4d_p offset error

Reported by: robe Owned by: robe
Priority: low Milestone: PostGIS 1.4.0
Component: postgis Version: 1.4
Keywords: Cc:

Description

I tried to do this:

SELECT ST_LineToCurve(ST_LineMerge(ST_Collect(ST_CurveToLine(ST_GeomFromEWKT('CIRCULARSTRING(0 0, 1 1, 1 0)')),

ST_GeomFromEWKT('LINESTRING(1 0, 0 1)') ))) ;

And was hoping to get this: COMPOUNDCURVE(CIRCULARSTRING(0 0, 1 1, 1 0),(1 0, 0 1))

But instead got error: getPoint4d_p: point offset out of range

Attachments (1)

postgis-linetocurve.patch (1.8 KB) - added by mcayland 10 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 Changed 10 years ago by robe

Slight update. The above example is not a simple line. This seems to behave more or less as expected when I tested with a simple line.

SELECT ST_AsEWKT(ST_LineToCurve(ST_LineMerge(ST_Collect(ST_GeomFromEWKT('LINESTRING(2 2, 2.5 2.5)'), ST_CurveToLine(ST_GeomFromEWKT('CIRCULARSTRING(2.5 2.5,4.5 2.5, 3.5 3.5)')) ))));

Result: COMPOUNDCURVE((2 2,2.5 2.5),CIRCULARSTRING(2.5 2.5,4.20710678118655 1.79289321881345,3.5 3.5))

comment:2 Changed 10 years ago by mcayland

Was this fixed with Mark's last patch? If so, can we close?

ATB,

Mark.

comment:3 Changed 10 years ago by robe

Owner: changed from pramsey to robe
Status: newassigned

No so still open. But like I said - this appears to be only an issue with non-simple lines

comment:4 Changed 10 years ago by mcayland

Milestone: postgis 1.4.1postgis 1.4.0

Yeah I see. Removing the outer ST_LineToCurve() function from your example above gives the following:

select st_linetocurve(st_geomfromtext('LINESTRING(0 0,-0.0239315652662951 0.0251361090611227,-0.0466009335008786 0.0514162068286816,-0.0679534922100711 0.0787769822452901,-0.0879378012096791 0.107152520806448,-0.106505716548904 0.136474463354359,-0.123612506493335 0.166672170761126,-0.13921695928762 0.197672894104599,-0.153281482438188 0.229401949926901,-0.165772193276862 0.261782900153418,-0.176659000587176 0.29473773623882,-0.185915677096747 0.328187067096473,-0.193519922661073 0.362050310358527,-0.199453417986539 0.396245886505893,-0.203701868763191 0.430691415400453,-0.206255040100989 0.465303914746028,-0.207106781186548 0.499999999999998,-0.206255040100989 0.534696085253969,-0.203701868763192 0.569308584599544,-0.199453417986539 0.603754113494104,-0.193519922661074 0.63794968964147,-0.185915677096747 0.671812932903525,-0.176659000587177 0.705262263761177,-0.165772193276864 0.738217099846577,-0.15328148243819 0.770598050073094,-0.139216959287623 0.802327105895394,-0.123612506493337 0.833327829238871,-0.106505716548901 0.863525536645645,-0.0879378012096717 0.892847479193563,-0.067953492210058 0.921223017754728,-0.0466009335008591 0.948583793171342,-0.0239315652662687 0.974863890938906,3.39173134022985e-14 1.00000000000003,0.0251361090611646 1.02393156526633,0.0514162068287321 1.04660093350092,0.0787769822453494 1.06795349221012,0.107152520806517 1.08793780120972,0.136474463354438 1.10650571654895,0.166672170761214 1.12361250649338,0.197672894104697 1.13921695928767,0.229401949927009 1.15328148243823,0.261782900153537 1.1657721932769,0.294737736238949 1.17665900058722,0.328187067096612 1.18591567709678,0.362050310358676 1.1935199226611,0.396245886506051 1.19945341798656,0.43069141540062 1.20370186876321,0.465303914746205 1.206255040101,0.500000000000184 1.20710678118655,0.534696085254163 1.20625504010098,0.569308584599746 1.20370186876317,0.603754113494313 1.19945341798651,0.637949689641685 1.19351992266103,0.671812932903745 1.18591567709669,0.705262263761404 1.17665900058711,0.73821709984681 1.16577219327678,0.770598050073331 1.15328148243809,0.8023271058956 1.13921695928753,0.83332782923904 1.12361250649325,0.863525536645775 1.10650571654882,0.892847479193655 1.08793780120961,0.921223017754785 1.06795349221002,0.948583793171366 1.04660093350084,0.9748638909389 1.02393156526628,0.999999999999999 1,1.02393156526627 0.974863890938902,1.04660093350084 0.948583793171368,1.06795349221001 0.921223017754787,1.08793780120961 0.892847479193658,1.10650571654882 0.863525536645777,1.12361250649325 0.833327829239042,1.13921695928752 0.802327105895602,1.15328148243809 0.770598050073334,1.16577219327677 0.738217099846851,1.17665900058708 0.705262263761483,1.18591567709666 0.671812932903865,1.193519922661 0.637949689641846,1.19945341798648 0.603754113494515,1.20370186876315 0.569308584599989,1.20625504010097 0.534696085254447,1.20710678118655 0.500000000000509,1.20625504010102 0.465303914746569,1.20370186876325 0.430691415401024,1.19945341798663 0.396245886506491,1.1935199226612 0.362050310359152,1.18591567709691 0.328187067097122,1.17665900058738 0.29473773623949,1.16577219327711 0.261782900154107,1.15328148243848 0.229401949927606,1.13921695928796 0.197672894105317,1.12361250649372 0.166672170761855,1.10650571654934 0.136474463355095,1.08793780121017 0.107152520807188,1.06795349221062 0.0787769822460299,1.04660093350148 0.0514162068294181,1.02393156526696 0.0251361090618519,1 0,0 1)'));

So I'm not sure I agree with your diagnosis on simple lines. This is another crasher we need to fix for 1.4 then :(

comment:5 Changed 10 years ago by robe

Milestone: postgis 1.4.0postgis 1.4.1

Its not a crasher, just gives an error so a bit of a slap on the wrist rather than taking the server down. The other one I mentioned is more serious since that really does crash unless you think these two are related.

Mark, you worry too much. We are more liable to break something more important in the process of trying to fix this. Don't worry be happy :).

comment:6 Changed 10 years ago by mcayland

It's equivalent to an assertion. At the very least we need to find out what is happening in this code before we make that call.

ATB,

Mark.

comment:7 Changed 10 years ago by robe

Milestone: postgis 1.4.1postgis 1.3.7

This does the same for 1.3 so we need to backpatch to 1.3 to close this out. I'm personally of the opinion that if we are going to be fixing bugs that exist in 1.3 as we should do it at the same time as we patch 1.3 and that we should be foxusing on bugs introduced in 1.4 (this is a long standing one). Which is why I really am not in a rush to fix this right now.

SELECT ST_LineToCurve(ST_LineMerge(ST_Collect(ST_CurveToLine(ST_GeomFromEWKT('CIRCULARSTRING(0 0, 1 1, 1 0)')), ST_GeomFromEWKT('LINESTRING(1 0, 0 1)') ))) ;

Changed 10 years ago by mcayland

Attachment: postgis-linetocurve.patch added

comment:8 Changed 10 years ago by mcayland

Okay. Looks like the curve conversion code needs to peek one point ahead to determine the type of the next segment, and of course if you end your curve at the end of your set of points then this will fail.

Can you try the attached patch which seems to resolve this for me?

ATB,

Mark.

comment:9 Changed 10 years ago by mcayland

Milestone: postgis 1.3.7postgis 1.4.0
Resolution: fixed
Status: assignedclosed

Applied to 1.4 as r4269 and trunk as r4270. I don't feel the need to backpatch this to 1.3, given that there are several other curve fixes from Mark that won't get backpatched. I think we'd be better off stating that people who want to use curves should go for 1.4 as a minimum.

ATB,

Mark.

comment:10 Changed 10 years ago by robe

fair enough

comment:11 Changed 10 years ago by robe

Just tested seems okay.

Note: See TracTickets for help on using tickets.