[postgis-users] Spike finder

Birgit Laggner birgit.laggner at ti.bund.de
Fri Jun 13 03:52:53 PDT 2014


Hi L.

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.

Regards,

Birgit.


Am 11.06.2014 10:56, schrieb Pier Lorenzo Marasco:
> 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.
>
> CREATE OR REPLACE FUNCTION ST_SpikeFinder (geometry, angle double 
> precision)
>      returns geometry as
>      $body$
>      DECLARE
>      ingeom alias for $1;
>      angle  alias for $2;
>      lineusp geometry;
>      newgeom geometry;
>      numpoints integer;
>      point_id integer;
>      result_pnt geometry;
>
>     begin
>             -- input geometry or rather set as default for the output
>         newgeom := ingeom;
>        -- check polygon
>         if (select st_geometrytype(ingeom)) = 'ST_Polygon' then
>             if (select st_numinteriorrings(ingeom)) = 0 then
>             lineusp := st_boundary(ingeom) as line;
>                     numpoints := st_numpoints(lineusp);
>             point_id := 0;
>                 -- the geometry passes pointwisely
>             while (point_id <= numpoints) loop
>                         result_pnt := ST_Collect(result_pnt, 
> st_pointn(lineusp, point_id));
>                     -- the check of the angle at the current point of 
> a spike including the special case, that it is the first point.
>                     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),
>                                 st_pointn(lineusp, point_id)) - 
> st_azimuth(st_pointn(lineusp, point_id), st_pointn(lineusp, point_id + 
> 1))))) <= angle then
>         (probably the problem is here)      --->  result_pnt := 
> ST_Union(result_pnt, st_pointn(lineusp, point_id));
> end if;
>             point_id = point_id + 1;
>             end loop;
>         end if;
>         end if;
>             return result_pnt;
>      end;
>      $body$
>        language 'plpgsql' volatile;
>
> Any idea ?
> Thank you in advance.
>
>
> L.
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20140613/6ab31055/attachment.html>


More information about the postgis-users mailing list