Opened 3 years ago
Last modified 2 years ago
#1131 new defect
GEOSBufferWithStyle produce invalid geometry when quadsegs = 0
Reported by: | kalenik | Owned by: | strk |
---|---|---|---|
Priority: | major | Milestone: | 3.11.0 |
Component: | Core | Version: | main |
Severity: | Unassigned | Keywords: | |
Cc: |
Description
GEOSBufferWithStyle doesn't produce valid geometry when quadsegs = 0
13:00:35 [gis] > select ST_IsValid(ST_Buffer(ST_GeomFromEWKT('SRID=3857;POLYGON((-6523441.741981709 -3639625.53883344,-6520995.75707658 -3639625.53883344,-6520995.75707658 -3637179.55392831,-6518549.77217145 -3637179.55392831,-6516103.78726632 -3637179.55392831,-6513657.802361189 -3637179.55392831,-6513657.802361189 -3634733.56902318,-6511211.81745606 -3634733.56902318,-6511211.81745606 -3632287.58411805,-6513657.802361189 -3632287.58411805,-6513657.802361189 -3629841.59921292,-6511211.81745606 -3629841.59921292,-6511211.81745606 -3627395.61430779,-6511211.81745606 -3624949.62940266,-6508765.83255093 -3624949.62940266,-6508765.83255093 -3622503.64449753,-6508765.83255093 -3620057.6595924,-6506319.8476458 -3620057.6595924,-6506319.8476458 -3617611.67468727,-6506319.8476458 -3615165.68978214,-6503873.862740669 -3615165.68978214,-6503873.862740669 -3612719.70487701,-6503873.862740669 -3610273.71997188,-6501427.87783554 -3610273.71997188,-6498981.89293041 -3610273.71997188,-6496535.90802528 -3610273.71997188,-6496535.90802528 -3612719.70487701,-6494089.923120149 -3612719.70487701,-6491643.93821502 -3612719.70487701,-6489197.95330989 -3612719.70487701,-6486751.96840476 -3612719.70487701,-6484305.983499629 -3612719.70487701,-6484305.983499629 -3615165.68978214,-6486751.96840476 -3615165.68978214,-6486751.96840476 -3617611.67468727,-6486751.96840476 -3620057.6595924,-6486751.96840476 -3622503.64449753,-6484305.983499629 -3622503.64449753,-6484305.983499629 -3624949.62940266,-6484305.983499629 -3627395.61430779,-6484305.983499629 -3629841.59921292,-6484305.983499629 -3632287.58411805,-6481859.9985945 -3632287.58411805,-6481859.9985945 -3634733.56902318,-6481859.9985945 -3637179.55392831,-6481859.9985945 -3639625.53883344,-6479414.01368937 -3639625.53883344,-6476968.02878424 -3639625.53883344,-6476968.02878424 -3642071.52373857,-6474522.043879109 -3642071.52373857,-6472076.05897398 -3642071.52373857,-6472076.05897398 -3644517.5086437,-6469630.07406885 -3644517.5086437,-6467184.08916372 -3644517.5086437,-6464738.104258589 -3644517.5086437,-6464738.104258589 -3646963.49354883,-6462292.11935346 -3646963.49354883,-6459846.13444833 -3646963.49354883,-6459846.13444833 -3649409.47845396,-6457400.1495432 -3649409.47845396,-6457400.1495432 -3651855.46335909,-6454954.164638069 -3654301.44826422,-6454954.164638069 -3656747.43316935,-6452508.17973294 -3656747.43316935,-6452508.17973294 -3659193.41807448,-6452508.17973294 -3661639.40297961,-6450062.19482781 -3661639.40297961,-6450062.19482781 -3664085.38788474,-6447616.20992268 -3664085.38788474,-6447616.20992268 -3666531.37278987,-6450062.19482781 -3666531.37278987,-6450062.19482781 -3668977.357695,-6450062.19482781 -3671423.34260013,-6452508.17973294 -3671423.34260013,-6452508.17973294 -3673869.32750526,-6454954.164638069 -3673869.32750526,-6454954.164638069 -3676315.31241039,-6454954.164638069 -3678761.29731552,-6457400.1495432 -3678761.29731552,-6454954.164638069 -3681207.28222065,-6454954.164638069 -3683653.2671257798,-6457400.1495432 -3686099.25203091,-6459846.13444833 -3686099.25203091,-6459846.13444833 -3688545.2369360398,-6462292.11935346 -3688545.2369360398,-6464738.104258589 -3688545.2369360398,-6464738.104258589 -3690991.22184117,-6464738.104258589 -3693437.2067462998,-6464738.104258589 -3695883.19165143,-6464738.104258589 -3698329.1765565597,-6462292.11935346 -3698329.1765565597,-6459846.13444833 -3698329.1765565597,-6459846.13444833 -3700775.16146169,-6457400.1495432 -3700775.16146169,-6457400.1495432 -3703221.1463668197,-6457400.1495432 -3705667.13127195,-6454954.164638069 -3705667.13127195,-6454954.164638069 -3708113.1161770797,-6454954.164638069 -3710559.10108221,-6454954.164638069 -3713005.0859873397,-6454954.164638069 -3715451.07089247,-6457400.1495432 -3715451.07089247,-6457400.1495432 -3717897.0557975997,-6457400.1495432 -3720343.04070273,-6457400.1495432 -3722789.0256078597,-6459846.13444833 -3722789.0256078597,-6459846.13444833 -3725235.01051299,-6459846.13444833 -3727680.9954181197,-6462292.11935346 -3727680.9954181197,-6462292.11935346 -3730126.98032325,-6464738.104258589 -3730126.98032325,-6464738.104258589 -3727680.9954181197,-6467184.08916372 -3727680.9954181197,-6469630.07406885 -3727680.9954181197,-6472076.05897398 -3727680.9954181197,-6472076.05897398 -3730126.98032325,-6474522.043879109 -3730126.98032325,-6476968.02878424 -3730126.98032325,-6479414.01368937 -3730126.98032325,-6479414.01368937 -3727680.9954181197,-6481859.9985945 -3727680.9954181197,-6484305.983499629 -3727680.9954181197,-6484305.983499629 -3725235.01051299,-6486751.96840476 -3725235.01051299,-6486751.96840476 -3722789.0256078597,-6489197.95330989 -3722789.0256078597,-6489197.95330989 -3720343.04070273,-6489197.95330989 -3717897.0557975997,-6489197.95330989 -3713005.0859873397,-6486751.96840476 -3710559.10108221,-6489197.95330989 -3710559.10108221,-6489197.95330989 -3703221.1463668197,-6491643.93821502 -3703221.1463668197,-6494089.923120149 -3703221.1463668197,-6494089.923120149 -3700775.16146169,-6494089.923120149 -3698329.1765565597,-6494089.923120149 -3695883.19165143,-6496535.90802528 -3695883.19165143,-6498981.89293041 -3693437.2067462998,-6506319.8476458 -3688545.2369360398,-6506319.8476458 -3686099.25203091,-6508765.83255093 -3683653.2671257798,-6506319.8476458 -3681207.28222065,-6503873.862740669 -3681207.28222065,-6503873.862740669 -3678761.29731552,-6503873.862740669 -3676315.31241039,-6503873.862740669 -3673869.32750526,-6506319.8476458 -3671423.34260013,-6506319.8476458 -3668977.357695,-6508765.83255093 -3668977.357695,-6508765.83255093 -3666531.37278987,-6506319.8476458 -3666531.37278987,-6506319.8476458 -3664085.38788474,-6503873.862740669 -3664085.38788474,-6501427.87783554 -3664085.38788474,-6501427.87783554 -3661639.40297961,-6498981.89293041 -3661639.40297961,-6498981.89293041 -3659193.41807448,-6501427.87783554 -3659193.41807448,-6503873.862740669 -3659193.41807448,-6503873.862740669 -3656747.43316935,-6506319.8476458 -3656747.43316935,-6506319.8476458 -3654301.44826422,-6508765.83255093 -3654301.44826422,-6511211.81745606 -3654301.44826422,-6513657.802361189 -3654301.44826422,-6513657.802361189 -3651855.46335909,-6516103.78726632 -3651855.46335909,-6516103.78726632 -3649409.47845396,-6518549.77217145 -3649409.47845396,-6518549.77217145 -3646963.49354883,-6520995.75707658 -3646963.49354883,-6520995.75707658 -3644517.5086437,-6520995.75707658 -3642071.52373857,-6523441.741981709 -3642071.52373857,-6523441.741981709 -3639625.53883344))'), 2445.98490513, 0)); NOTICE: 00000: Ring Self-intersection at or near point -6503873.8627406703 -3661639.4029796096 LOCATION: pg_notice, lwgeom_pg.c:364
GEOS Version: 3.10.0dev
Attachments (2)
Change History (8)
comment:1 by , 3 years ago
comment:2 by , 3 years ago
I tried to use quadsegs = 1 for geometry in my example and still received an error about ring self-intersection but with quadsegs = 2 valid geometry is produced. If JTS produced valid buffer geometry with quadsegs = 1 it looks like GEOS bug.
by , 2 years ago
Attachment: | buffered-invalid.png added |
---|
by , 2 years ago
Attachment: | buffered-expected.png added |
---|
comment:5 by , 2 years ago
Simplified test case:
# SELECT ST_IsValid(ST_Buffer(ST_GeomFromEWKT('SRID=3857;POLYGON((-6503873.862740669 -3656747.43316935, -6481859.9985945 -3656747.43316935, -6481859.9985945 -3688545.2369360398, -6506319.8476458 -3688545.2369360398, -6506319.8476458 -3664085.38788474, -6501427.87783554 -3664085.38788474, -6501427.87783554 -3661639.40297961, -6498981.89293041 -3661639.40297961, -6498981.89293041 -3659193.41807448, -6503873.862740669 -3659193.41807448, -6503873.862740669 -3656747.43316935))'), 2445.98490513, 0)); NOTICE: Ring Self-intersection at or near point -6503873.8627406703 -3661639.4029796096 st_isvalid ------------ f (1 row)
The result depends on exact coordinate values, the error goes away when input polygon is scaled so that coordinates and buffer width are integer (divided by buffer width).
Expected result, generated with geometry precision model type changed from PrecisionModel::FLOATING
to PrecisionModel::FIXED
, scale=1010:
comment:6 by , 2 years ago
JTS recently had the buffer quadSegs behaviour improved/clarified: JTS-778.
So the first thing to do is to port that fix, and see if that solves this problem. If not can then investigate further.
Odd, this behaviour is different to JTS - it produces a valid buffer geometry.
A quadSegs value of 0 is meaningless. So the code should either limit the valid to >= 1, or raise an error. In JTS the value is limited to 1, and has the effect of creating mitred joins.
In any case, the upstream process should avoid using quadsegs = 0.