Hi Stefen, Hi Fred,
Thank you both for your answer.
There was effectively an invalidity in a geometry.
Now my function is working great.
But still, do you think it is a good idea to use an "order by" and
"limit 1" to have the desired result?
Thanks again,
Denis
On 06/20/2012 04:27 PM, Stephen Woodbridge wrote:
Try:
select count(*) from polygons where not isvalid(geometry);
if count > 0 then
select count(*) from polygons where not isvalid(geometry) and not
isvalid(st_buffer(geometry, 0.0));
you can do an update to fix these:
update polygons set geometry=st_buffer(geometry, 0.0) where not
isvalid(geometry);
-Steve W
On 6/20/2012 7:54 AM, Denis Rouzaud 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@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users