[postgis-users] get the biggest intersection

Fred Lehodey lehodey at gmail.com
Wed Jun 20 05:23:39 PDT 2012


Hi,
Robustness issues?
You can try reducing the precision of your input (ST_SnapToGrid)

Fred




On Wed, Jun 20, 2012 at 12:54 PM, Denis Rouzaud <denis.rouzaud at gmail.com>wrote:

> Hi all,
>
> I have a table of line and a table of polygons. For a given line, I would
> like to get the polygon which has the biggest intersection with the line.
> I tried something like this:
>
> CREATE OR REPLACE FUNCTION distribution.get_zone_id(**geometry) RETURNS
> integer AS '
>    DECLARE
>        inputgeom ALIAS FOR $1;
>        id_poly integer;
>    BEGIN
>        SELECT id INTO id_poly
>            FROM  polygons
>            WHERE ST_Intersects(inputgeom,**geometry) IS TRUE
>            ORDER BY ST_Length(ST_Intersection(**inputgeom,geometry)) DESC
>            LIMIT 1;
>        RETURN id_poly;
>    END
> ' LANGUAGE 'plpgsql';
>
> But I have the following error:
> ERROR:  Error performing intersection: TopologyException: side location
> conflict at 553524.92178241001 147945.03792368001
>
> If anyone has any idea, tip or whatever, it is very welcome!
>
> Greetings,
>
> Denis
> ______________________________**_________________
> postgis-users mailing list
> postgis-users at postgis.**refractions.net<postgis-users at postgis.refractions.net>
> http://postgis.refractions.**net/mailman/listinfo/postgis-**users<http://postgis.refractions.net/mailman/listinfo/postgis-users>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20120620/ea7b3419/attachment.html>


More information about the postgis-users mailing list