<div dir="ltr"><div>Hi Birgit ! </div><div><br></div><div>Thank you for your time and answer; actually I found a workaround to my problem. I don't know if it's the right way but actually it works.</div><div>The problem was the incorrect assignment of the result. </div>
<div>The correct way is to use an array of geometry to collect all points and then, before the restitution command , create a geometry of multipoint made by ST_collect.</div><div><br></div><div>result_pnt geometry[]; ...</div>
<div><br></div><div>result_pnt[point_id] := st_pointn(lineusp, point_id); ...</div><div><br></div><div>return ST_Collect(result_pnt);</div><div><br></div><div>As I told you, I'm pretty sure that there is a better, faster and smartest way to do it and I'll be happy to receive any suggestion to improve my solution.</div>
<div>Thank you again, </div><div><br></div><div>L. </div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-06-13 12:52 GMT+02:00 Birgit Laggner <span dir="ltr"><<a href="mailto:birgit.laggner@ti.bund.de" target="_blank">birgit.laggner@ti.bund.de</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Hi L.<br>
<br>
I would suspect the first assignment of the result_pnt (result_pnt
:= ST_Collect(result_pnt, st_pointn(lineusp, point_id));) as the
cause of the problem: Within your assignment, you try to use the
geometry of result_pnt which does not yet exist at this moment.
Maybe, you could work with an IF clause to assign some sort of start
value to your result_pnt variable.<br>
<br>
Regards,<br>
<br>
Birgit.<br>
<br>
<br>
<div>Am 11.06.2014 10:56, schrieb Pier
Lorenzo Marasco:<br>
</div>
<blockquote type="cite"><div><div class="h5">
<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>
<br>
<fieldset></fieldset>
<br>
</div></div><pre>_______________________________________________
postgis-users mailing list
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a></pre>
</blockquote>
<br>
</div>
<br>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">
<div><font face="times new roman, serif" size="4">Pier Lorenzo Marasco </font><br></div><div><font size="1">Via D.Moreni,2 </font></div><div><font size="1">50135 Firenze</font></div><div><font size="1"><br></font></div><div>
<font size="1">cell/mobile +39 329 35 37527</font></div><div><font size="1">Casa/home +39 055 011 71 20</font></div><div><font size="1">skype pl.marasco</font></div><div><br></div></div>
</div>