<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body 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 class="moz-cite-prefix">Am 11.06.2014 10:56, schrieb Pier
Lorenzo Marasco:<br>
</div>
<blockquote
cite="mid:CACkDYLiiEokXr_C0ddU=X7PxPqC3XqvEL-6gKy+x7q1Q4NWarw@mail.gmail.com"
type="cite">
<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 class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
postgis-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a></pre>
</blockquote>
<br>
</body>
</html>