| Bug #46498 | Intersection of polygon and multipolygon does not return all intersected geoms | ||
|---|---|---|---|
| Submitted: | 31 Jul 2009 16:27 | Modified: | 7 Aug 2012 12:21 |
| Reporter: | John Powell | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: GIS | Severity: | S2 (Serious) |
| Version: | mysql-5.1-wl1326 | OS: | Linux (centos 64-bit 5.2) |
| Assigned to: | Assigned Account | CPU Architecture: | Any |
| Tags: | intersection, multipolygon | ||
[31 Jul 2009 16:30]
John Powell
geometry for bug 46498
Attachment: geom.zip (application/x-zip-compressed, text), 334.56 KiB.
[31 Jul 2009 20:21]
MySQL Verification Team
Thank you for the bug report. mysql> select intersects(@bbox,geometryn(@geom,1)); +--------------------------------------+ | intersects(@bbox,geometryn(@geom,1)) | +--------------------------------------+ | 1 | +--------------------------------------+ 1 row in set (0.17 sec) mysql>
[5 Dec 2009 15:07]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/92967 2664 Alexey Botchkov 2009-12-04 Bug#46372 buffer of linestring returns multipolygon in certain cases there was a mistake in handling of 'holes' in the polygons. Fixed by adding the 'first_poly_node' pointer to the res_point structure to point to the first point of the surrounding polygon. Also a set of debugging functions was added. It doesn't affect the working fucntions, but greatly simplifies the debugging. This path fixes also bug#46498 and bug#45883 also. per-file comments: sql/gcalc_slicescan.cc Bug#46372 buffer of linestring returns multipolygon in certain cases sql/gcalc_slicescan.h Bug#46372 buffer of linestring returns multipolygon in certain cases sql/gcalc_tools.cc Bug#46372 buffer of linestring returns multipolygon in certain cases sql/gcalc_tools.h Bug#46372 buffer of linestring returns multipolygon in certain cases sql/item_geofunc.cc Bug#46372 buffer of linestring returns multipolygon in certain cases sql/spatial.cc Bug#46372 buffer of linestring returns multipolygon in certain cases
[6 Dec 2009 9:30]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/92991 2664 Alexey Botchkov 2009-12-05 Bug #46386 Intersection() and Difference() make the server disconnect there was a mistake in handling of 'holes' in the polygons. Fixed by adding the 'first_poly_node' pointer to the res_point structure to point to the first point of the surrounding polygon. Also a set of debugging functions was added. It doesn't affect the working fucntions, but greatly simplifies the debugging. This path fixes also bug#46498. per-file comments: sql/gcalc_slicescan.cc Bug #46386 Intersection() and Difference() make the server disconnect sql/gcalc_slicescan.h Bug #46386 Intersection() and Difference() make the server disconnect sql/gcalc_tools.cc Bug #46386 Intersection() and Difference() make the server disconnect sql/gcalc_tools.h Bug #46386 Intersection() and Difference() make the server disconnect sql/item_geofunc.cc Bug #46386 Intersection() and Difference() make the server disconnect sql/spatial.cc Bug #46386 Intersection() and Difference() make the server disconnect
[7 Aug 2012 12:21]
Alexander Barkov
This bug was earlier fixed in mysql-gis tree (before mysql-5.6 release).

Description: In some cases, the intersection of a polygon with a multipolygon, does not return all of the polygons of the multipolygon that are intersected. How to repeat: The multipolygon for the first step will be uploaded separately below, as too large for initial report. mysql> set @geom=geomfromtext('MULTIPOLYGON(((........ establish that we have a multipolygon. mysql> select numgeometries(geom) from @geom; +---------------------+ | numgeometries(geom) | +---------------------+ | 8 | +---------------------+ 1 row in set (0.00 sec) mysql> select geometrytype(geom) from @geom; +--------------------+ | geometrytype(geom) | +--------------------+ | MULTIPOLYGON | +--------------------+ 1 row in set (0.00 sec) find centroid of this multipolygon mysql> select astext(centroid(@geom)); +------------------------------------------+ | astext(centroid(@geom)) | +------------------------------------------+ | POINT(499857.070505126 166856.759010446) | +------------------------------------------+ create a rectangular polygon with centroid of geometry as top right mysql> set @bbox=geomfromtext('POLYGON((499857 166856, 0 166856, 0 0, 499857 0, 499857 166856))'); create intersection of box and geometry mysql> set @int=intersection(@geom,@bbox); show that this has created a single polygon with a tiny area mysql> select geometrytype(@int); +--------------------+ | geometrytype(@int) | +--------------------+ | POLYGON | +--------------------+ mysql> select area(@int); +-----------------+ | area(@int) | +-----------------+ | 1309.3600000029 | +-----------------+ now, explicitly create a new geom equal to the biggest polygon in the original multipolygon mysql> set @geom1=geometryn(@geom,1); take the intersection again with @bbox again mysql> set @int1=intersection(@geom,@bbox); show area mysql> select area(@int1); +------------------+ | area(@int1) | +------------------+ | 5399156347.52692 | +------------------+ This could be equally demonstrated by testing using intersects and geometryn mysql> select intersects(@bbox,geometryn(@geom,1)); +--------------------------------------+ | intersects(@bbox,geometryn(@geom,1)) | +--------------------------------------+ | 1 | +--------------------------------------+ So, although the bbox intersects with all 8 of the polygons in the multipolygon represented by @geom, only one of them is returned by the intersection function.