[QGIS-trac] [Quantum GIS] #2921: Avoid intersection of new polygons.. IS BROKEN

Quantum GIS qgis at qgis.org
Sun Aug 1 18:33:48 EDT 2010


#2921: Avoid intersection of new polygons.. IS BROKEN
---------------------------------------------------------+------------------
   Reporter:  pinux                                      |              Owner:  nobody       
       Type:  bug                                        |             Status:  new          
   Priority:  critical: causes crash or data corruption  |          Milestone:  Version 1.6.0
  Component:  Digitising                                 |            Version:  1.5.0        
   Keywords:  intersection, polygons                     |   Platform_version:               
   Platform:  Windows                                    |           Must_fix:  Yes          
Status_info:  0                                          |  
---------------------------------------------------------+------------------
 In the last few month I have used a lot the "Avoid intersection of new
 polygons.." function i qgis. Yesterday I needed to do merge all the
 polygons in a postgis table, I tried it with the merge tool in qgis and it
 was not working. So I tried it in postgis And the result was one polygon
 with a lot of holes. I understood that the "Avoid intersection of new
 polygons.." function was not working well. After I corrected all the
 errors on the polygons in may table I was able to merge all the polygons
 even with qgis.
 My next step was to create a test table with a set of test views to seen
 all the error that the "Avoid intersection of new polygons.." function is
 creating in qgis.

 '''the test table:'''

 CREATE TABLE av_intersection ([[BR]]
   gid int UNIQUE,[[BR]]
   t_name varchar(50),[[BR]]
   PRIMARY KEY (gid)[[BR]]
 ) ;[[BR]]
 SELECT AddGeometryColumn ('public', 'av_intersection', 'the_geom',
 '900913', 'MULTIPOLYGON', 2);[[BR]]
 CREATE INDEX av_intersection_gidx ON av_intersection USING GIST (the_geom)
 ;[[BR]]

 '''the union view:'''

 CREATE OR REPLACE VIEW av_intersection_union AS[[BR]]
 SELECT[[BR]]
 min(p.gid) as gid,[[BR]]
 t_name,[[BR]]
 st_union(p.the_geom) AS the_geom[[BR]]
 FROM av_intersection p[[BR]]
 GROUP BY p.t_name;[[BR]]

 '''view to see if there are multiple rings:'''

 CREATE OR REPLACE VIEW av_intersection_multiple_ring AS[[BR]]
 SELECT[[BR]]
 gid,[[BR]]
 the_geom,[[BR]]
 (ST_NRings(the_geom) - ST_NumInteriorRings(the_geom)) as nrings[[BR]]
 FROM av_intersection[[BR]]
 WHERE ST_NRings(the_geom) > (1 + ST_NumInteriorRings(the_geom));

 '''and a view with all the polygons that are overlapping:'''

 CREATE OR REPLACE VIEW av_intersection_overlaps AS[[BR]]
 SELECT DISTINCT [[BR]]
 (a.gid*2+b.gid*10) as gid,[[BR]]
 a.gid a_gid,[[BR]]
 b.gid b_gid,[[BR]]
 a.the_geom[[BR]]
 FROM[[BR]]
 av_intersection a,[[BR]]
 av_intersection b[[BR]]
 WHERE[[BR]]
 a.gid != b.gid AND ST_Overlaps(b.the_geom, a.the_geom);[[BR]]

 '''The result with 11 polygons:[[BR]]'''
 - union with 2 holes[[BR]]
 - 9 polygons are overlapping[[BR]]
 - 2 polygon with multiple ring[[BR]]

 The result of the test you can see in the attachment with all the code to
 test yourself and the insert command for the polygons present in my test.

 I have done the test on 1.5 but the problem is even in trunk.

-- 
Ticket URL: <https://trac.osgeo.org/qgis/ticket/2921>
Quantum GIS <http://qgis.org>
Quantum GIS is an Open Source GIS viewer/editor supporting OGR, PostGIS, and GRASS formats


More information about the QGIS-trac mailing list