[postgis-devel] [PostGIS] #1998: Crash of topogeo_AddPolygon() with "ERROR: query string argument of EXECUTE is null"

PostGIS trac at osgeo.org
Tue Sep 18 03:10:11 PDT 2012


#1998: Crash of topogeo_AddPolygon() with "ERROR:  query string argument of
EXECUTE is null"
--------------------------------+-------------------------------------------
 Reporter:  wimned              |       Owner:  strk         
     Type:  defect              |      Status:  new          
 Priority:  medium              |   Milestone:  PostGIS 2.0.2
Component:  topology            |     Version:  trunk        
 Keywords:  topogeo_AddPolygon  |  
--------------------------------+-------------------------------------------

Comment(by wimned):

 Created a workaround: After call of ST_ModEdgeHeal() the first point of
 geometry of the new edge is checked against the geometry of the start
 node.
 When not, points are shifted in the edge geometry until the first point
 matches the start node. The edge is removed using ST_RemEdgeModFace(). The
 fixed geometry is added using topogeo_AddLineString()

 The code (probably could be made less clumsy...):

 {{{
 CREATE OR REPLACE FUNCTION cleanse_node(passed_node_id integer)
   returns void AS
 $$
   DECLARE edge_ids integer[];
   DECLARE start_node_id integer;
   DECLARE node_geom geometry;
   DECLARE edge_geom geometry;
   DECLARE edge_sz integer;
 BEGIN
     --raise notice 'check node %', passed_node_id;
     select array_agg(abs(t.edge)) into edge_ids
         from GetNodeEdges('wimpy', passed_node_id) as t(seq,edge);

     if array_length(edge_ids,1) = 2 and edge_ids[1] != edge_ids[2]
     then
         raise notice 'remove node %', passed_node_id;

         perform ST_ModEdgeHeal('wimpy', edge_ids[1], edge_ids[2]);

         select e.start_node into start_node_id from
             wimpy.edge_data as e where e.edge_id = edge_ids[1];
         select e.geom into edge_geom from
             wimpy.edge_data as e where e.edge_id = edge_ids[1];
         select n.geom into node_geom from
             wimpy.node as n where n.node_id = start_node_id;

         if not ST_Equals(node_geom, ST_PointN(edge_geom,1))
         then
             raise notice 'edge % needs fixing at %', edge_ids[1],
 ST_ASText(node_geom);
             edge_geom = ST_RemovePoint(edge_geom, 0);
             edge_sz = ST_NPoints(edge_geom);
             for i in 1..edge_sz
             loop
                 exit when ST_Equals(node_geom, ST_PointN(edge_geom,1));
                 edge_geom = ST_AddPoint(edge_geom, ST_PointN(edge_geom,1),
 -1);
                 edge_geom = ST_RemovePoint(edge_geom, 0);
             end loop;
             edge_geom = ST_AddPoint(edge_geom, node_geom, -1);
             perform ST_RemEdgeModFace('wimpy', edge_ids[1]);
             perform topogeo_AddLineString('wimpy', edge_geom);
         end if;
     end if;
 END
 $$

 }}}

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/1998#comment:8>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-devel mailing list