<div dir="ltr"><div>I tried to modify spikeRemover from Schmidt & Krüger to obtain just the spike position. For some reason, that I can't figure out, my script fails and I don't obtain a multipoint position. Probably there is a problem in the aggregation of different points but I don't know how to manage it in another way. I tried with ST_collect and ST_union but with both I don't obtain a right geometry. </div>
<div><br></div><div>CREATE OR REPLACE FUNCTION ST_SpikeFinder (geometry, angle double precision)</div><div>     returns geometry as <br></div><div>     $body$<br></div><div>     DECLARE<br></div><div>     ingeom alias for $1;<br>
</div><div>     angle  alias for $2;<br></div><div>     lineusp geometry;<br></div><div>     newgeom geometry;<br></div><div>     numpoints integer;<br></div><div>     point_id integer;<br></div><div>     result_pnt geometry;<br>
</div><div><br></div><div>    begin</div><div>            -- input geometry or rather set as default for the output <br></div><div>        newgeom := ingeom;<br></div><div>       -- check polygon<br></div><div>        if (select st_geometrytype(ingeom)) = 'ST_Polygon' then<br>
</div><div>            if (select st_numinteriorrings(ingeom)) = 0 then<br></div><div>            lineusp := st_boundary(ingeom) as line;<br></div><div>                    numpoints := st_numpoints(lineusp);<br></div><div>
            point_id := 0;<br></div><div>                -- the geometry passes pointwisely<br></div><div>            while (point_id <= numpoints) loop<br></div><div>                        result_pnt := ST_Collect(result_pnt, st_pointn(lineusp, point_id));<br>
</div><div>                    -- the check of the angle at the current point of a spike including the special case, that it is the first point.<br></div><div>                    if (select abs(pi() - abs(st_azimuth(st_pointn(lineusp, case when point_id= 1 then st_numpoints(lineusp) - 1 else point_id - 1 end), <br>
</div><div>                                st_pointn(lineusp, point_id)) - st_azimuth(st_pointn(lineusp, point_id), st_pointn(lineusp, point_id + 1))))) <= angle then<br></div><div>        (probably the problem is here)      --->        result_pnt := ST_Union(result_pnt, st_pointn(lineusp, point_id));<br>
</div><div>end if;<br></div><div>            point_id = point_id + 1;<br></div><div>            end loop;<br></div><div>        end if;<br></div><div>        end if;<br></div><div>            return result_pnt;<br></div><div>
     end;<br></div><div>     $body$<br></div><div>       language 'plpgsql' volatile;<br></div><div><br></div><div>Any idea ? <br></div><div>Thank you in advance.<br></div><div><br></div><div><br></div><div>L.</div>
</div>