Opened 10 years ago

Closed 10 years ago

#920 closed defect (fixed)

ST_LineToCurve generating invalid CURVEPOLYGON

Reported by: debe Owned by: pramsey
Priority: medium Milestone: PostGIS 2.0.0
Component: postgis Version: 1.5.X
Keywords: Cc:

Description

Hi, i have a problem with this geometry:

CURVEPOLYGON(COMPOUNDCURVE((724190.669216162 120573.733407055),CIRCULARSTRING(724190.669216162 120573.733407055,724190.12214281 120573.55
7014059,724189.632 120573.341),(724189.632 120573.341,724189.874 120573.455,724190.122 120573.557,724190.375 120573.647,724190.631 120573.
724,724190.669216162 120573.733407055)))

that is generated from (that polygon is a result of a st_intersection with others geometries):

st_linetocurve(st_geomfromtext('POLYGON((724190.669216162 120573.733407055,724190.631098529 120573.723945555,724190.3745717 120573.646726888,724190.12214281 120573.557014059,724189.874419981 120573.455023195,724189.632 120573.341,724189.874 120573.455,724190.122 120573.557,724190.375 120573.647,724190.631 120573.724,724190.669216162 120573.733407055))'))

if i convert it to text and i convert it back to geometry

st_geomfromtext(st_astext(geometry))

i receive this error:

ERROR:  geometry requires more points
HINT:  "...E((724190.669216162 120573.733407055)" <-- parse error at position 62 within geometry

is this a bug or i'm doing something wrong?

                                        postgis_full_version
-----------------------------------------------------------------------------------------------------
 POSTGIS="1.5.2" GEOS="3.2.2-CAPI-1.6.2" PROJ="Rel. 4.6.1, 21 August 2008" LIBXML="2.6.32" USE_STATS

Change History (5)

comment:1 Changed 10 years ago by robe

debe,

I looked at this and I don't think it's a bug but just an unfortunate consequence of converting from geometry to text representation. The first geometry in your compound curve is a linestring with only one point which is clearly invalid. What I suspect happened is that the linestring in binary form had 2 points, but when converted to ST_AsText which only keeps 15 decimal places or so, because the points were so close, it got reduced to 1 point and thus became invalid.

To determine this, can you send us the binary or hex of the geometry

e.g. do a SELECT geometry (should output as hex)

or a SELECT ST_AsBinary(geometry) ...

comment:2 in reply to:  1 Changed 10 years ago by debe

here is another case with the same problem:

select st_astext(st_linetocurve(a.the_geom))
from (select (st_dump(st_intersection(
	st_geomfromtext('MULTIPOLYGON(((712689.216 93000.59,712688.76 92998.407,712688.51 93000.12,712686.158 92989.673,712687.745 92991.988,712690.604 92992.607,712744.133 92982.662,712745.72 92993.198,712748.125 93010.567,712754.121 93047.863,712759.68 93082.452,712760.038 93084.678,712763.038 93103.339,712766.084 93122.291,712769.096 93141.025,712769.512 93142.974,712769.818 93145.835,712729.62 93152.531,712725.856 93155.219,712724.852 93159.263,712721.511 93144.296,712724.049 93147.062,712728.895 93148.428,712759.991 93143.31,712763.796 93140.681,712765.057 93136.483,712763.882 93126.566,712760.999 93109.576,712757.33 93087.96,712751.997 93052.948,712748.734 93031.529,712745.399 93009.635,712743.16 92996.77,712741.116 92991.556,712737.223 92988.483,712732.131 92988.048,712718.157 92990.536,712692.299 92995.698,712692.146430423 92995.7326960549,712691.956537615 92995.7847712311,712691.76942875 92995.8461012788,712691.585554588 92995.9165384487,712691.405358098 92995.9959130514,712691.229273391 92996.0840338666,712691.057724668 92996.1806886035,712690.891125207 92996.2856444124,712690.729876359 92996.3986484455,712690.574366588 92996.5194284663,712690.42497053 92996.647693505,712690.282048093 92996.78313456,712690.14594359 92996.925425342,712690.016984909 92997.0742230598,712689.895482722 92997.2291692469,712689.781729739 92997.3898906243,712689.676 92997.556,712689.666391782 92997.5738378773,712689.566317179 92997.772173345,712689.476094981 92997.9751803369,712689.39594254 92998.1823697915,712689.326052951 92998.3932425711,712689.266594584 92998.6072906649,712689.21771068 92998.8239984121,712689.179519003 92999.0428437448,712689.152111562 92999.2632994455,712689.135554382 92999.4848344171,712689.129887353 92999.7069149624,712689.135124125 92999.9290060699,712689.151252083 93000.1505727028,712689.178232374 93000.3710810874,712689.216 93000.59)))')
	,
	st_geomfromtext('MULTIPOLYGON(((712688.51 93000.12,712688.76 92998.407,712689.216 93000.59,712689.178 93000.371,712689.151 93000.151,712689.135 92999.929,712689.13 92999.707,712689.136 92999.485,712689.152 92999.263,712689.18 92999.043,712689.218 92998.824,712689.267 92998.607,712689.326 92998.393,712689.396 92998.182,712689.476 92997.975,712689.566 92997.772,712689.666 92997.574,712689.676 92997.556,712689.782 92997.39,712689.895 92997.229,712690.017 92997.074,712690.146 92996.925,712690.282 92996.783,712690.425 92996.648,712690.574 92996.519,712690.73 92996.399,712690.891 92996.286,712691.058 92996.181,712691.229 92996.084,712691.405 92995.996,712691.586 92995.917,712691.769 92995.846,712691.95792995.785,712692.146 92995.733,712692.299 92995.698,712718.157 92990.536,712732.131 92988.048,712737.223 92988.483,712741.116 92991.556,712743.16 92996.77,712745.399 93009.635,712748.734 93031.529,712751.997 93052.948,712757.33 93087.96,712760.999 93109.576,712763.882 93126.566,712765.057 93136.483,712763.796 93140.681,712759.991 93143.31,712728.895 93148.428,712724.049 93147.062,712721.511 93144.296,712719.191 93133.901,712715.238 93116.662,712710.232 93095.495,712702.672 93062.116,712695.398 93030.153,712688.51 93000.12)))')
))).geom as the_geom) a where geometrytype(a.the_geom)='POLYGON';

if that result i convert back to geometry i get the

ERROR:  geometry requires more points 

comment:3 Changed 10 years ago by robe

Summary: CURVEPOLYGON problem when converting to/from textST_LineToCurve generating invalid CURVEPOLYGON

Debe,

I stand corrected. This is a bug. We might have it listed elsewhere though so this is possibly a duplicate.

SELECT ST_AsBinary(st_linetocurve((a.dmp).geom))::geometry, (a.dmp).path[1]
from (select (st_dump(st_intersection(
	st_geomfromtext('MULTIPOLYGON(((712689.216 93000.59,712688.76 92998.407,712688.51 93000.12,712686.158 92989.673,712687.745 92991.988,712690.604 92992.607,712744.133 92982.662,712745.72 92993.198,712748.125 93010.567,712754.121 93047.863,712759.68 93082.452,712760.038 93084.678,712763.038 93103.339,712766.084 93122.291,712769.096 93141.025,712769.512 93142.974,712769.818 93145.835,712729.62 93152.531,712725.856 93155.219,712724.852 93159.263,712721.511 93144.296,712724.049 93147.062,712728.895 93148.428,712759.991 93143.31,712763.796 93140.681,712765.057 93136.483,712763.882 93126.566,712760.999 93109.576,712757.33 93087.96,712751.997 93052.948,712748.734 93031.529,712745.399 93009.635,712743.16 92996.77,712741.116 92991.556,712737.223 92988.483,712732.131 92988.048,712718.157 92990.536,712692.299 92995.698,712692.146430423 92995.7326960549,712691.956537615 92995.7847712311,712691.76942875 92995.8461012788,712691.585554588 92995.9165384487,712691.405358098 92995.9959130514,712691.229273391 92996.0840338666,712691.057724668 92996.1806886035,712690.891125207 92996.2856444124,712690.729876359 92996.3986484455,712690.574366588 92996.5194284663,712690.42497053 92996.647693505,712690.282048093 92996.78313456,712690.14594359 92996.925425342,712690.016984909 92997.0742230598,712689.895482722 92997.2291692469,712689.781729739 92997.3898906243,712689.676 92997.556,712689.666391782 92997.5738378773,712689.566317179 92997.772173345,712689.476094981 92997.9751803369,712689.39594254 92998.1823697915,712689.326052951 92998.3932425711,712689.266594584 92998.6072906649,712689.21771068 92998.8239984121,712689.179519003 92999.0428437448,712689.152111562 92999.2632994455,712689.135554382 92999.4848344171,712689.129887353 92999.7069149624,712689.135124125 92999.9290060699,712689.151252083 93000.1505727028,712689.178232374 93000.3710810874,712689.216 93000.59)))')
	,
	st_geomfromtext('MULTIPOLYGON(((712688.51 93000.12,712688.76 92998.407,712689.216 93000.59,712689.178 93000.371,712689.151 93000.151,712689.135 92999.929,712689.13 92999.707,712689.136 92999.485,712689.152 92999.263,712689.18 92999.043,712689.218 92998.824,712689.267 92998.607,712689.326 92998.393,712689.396 92998.182,712689.476 92997.975,712689.566 92997.772,712689.666 92997.574,712689.676 92997.556,712689.782 92997.39,712689.895 92997.229,712690.017 92997.074,712690.146 92996.925,712690.282 92996.783,712690.425 92996.648,712690.574 92996.519,712690.73 92996.399,712690.891 92996.286,712691.058 92996.181,712691.229 92996.084,712691.405 92995.996,712691.586 92995.917,712691.769 92995.846,712691.95792995.785,712692.146 92995.733,712692.299 92995.698,712718.157 92990.536,712732.131 92988.048,712737.223 92988.483,712741.116 92991.556,712743.16 92996.77,712745.399 93009.635,712748.734 93031.529,712751.997 93052.948,712757.33 93087.96,712760.999 93109.576,712763.882 93126.566,712765.057 93136.483,712763.796 93140.681,712759.991 93143.31,712728.895 93148.428,712724.049 93147.062,712721.511 93144.296,712719.191 93133.901,712715.238 93116.662,712710.232 93095.495,712702.672 93062.116,712695.398 93030.153,712688.51 93000.12)))')
))) as dmp) a where geometrytype((a.dmp).geom)='POLYGON' AND (a.dmp).path[1] = 23;

Since this results in an error: LineString? must have at least two points and binary should have kept the precision if it was a precision issue.

Seems ot be an issue in our 2.0 as well.

comment:4 Changed 10 years ago by robe

Milestone: PostGIS 1.5.3PostGIS 2.0.0

comment:5 Changed 10 years ago by pramsey

Resolution: fixed
Status: newclosed

Fixed in trunk at r8945

This was actually a complete re-working of the curve-finding code, so it's a little tighter than before and doesn't even find a curve in the supplied polygon (which, if you plot it, is a pretty ugly thing).

Note: See TracTickets for help on using tickets.