Thanks Remi. I test your function on my example and I have the same problem with ST_Split.
Maybe some is wrong in geometry, but I don't understand where is the error. 2013/10/28 Rémi Cura <[email protected]> > Hey, you may want to use a function I wrote as a wrapper around ST_Split > to allow splitting a (multi-)line with (multi) points. > > Here it is. > It still thinks it should be somewhere is the core. > > Cheers, > > Rémi-C > > --creating a simple wrapper around ST_Split to allow splitting line by > multipoints > DROP FUNCTION IF EXISTS public.Split_multi(input_geom geometry ,blade > geometry); > CREATE FUNCTION public.Split_multi(input_geom geometry ,blade geometry) > RETURNS geometry AS > $BODY$ > --this function is a wrapper around the function ST_Split to allow > splitting mutli_lines with multi_points > -- > DECLARE > result geometry; > simple_blade geometry; > blade_geometry_type text := GeometryType(blade); geom_geometry_type text > := GeometryType(input_geom); > blade_coded_type SMALLINT; geom_coded_type SMALLINT; > BEGIN > > --finding type of input : mixed type are not allowed > --if type is not multi, simply splitting and returning result > > IF blade_geometry_type NOT ILIKE 'MULTI%' THEN > --RAISE NOTICE 'input geom is simple, doing regular split'; > RETURN ST_Split(input_geom,blade); > ELSIF blade_geometry_type ILIKE '%POINT' THEN > blade_coded_type:= 1; > ELSIF blade_geometry_type ILIKE '%LINESTRING' THEN > blade_coded_type:= 2; > ELSIF blade_geometry_type ILIKE '%POLYGON' THEN > blade_coded_type:= 3; > ELSE > RAISE NOTICE 'mutliple input geometry types for the blade : should be > homogenous '; > RETURN NULL; > END IF; > > IF geom_geometry_type ILIKE '%POINT' THEN > geom_coded_type:= 1; > ELSIF geom_geometry_type ILIKE '%LINESTRING' THEN > geom_coded_type:= 2; > ELSIF geom_geometry_type ILIKE '%POLYGON' THEN > geom_coded_type:= 3; > ELSE > RAISE NOTICE 'mutliple input geometry types for the geom: should be > homogenous '; > RETURN NULL; > END IF; > > result := input_geom; > --Loop on all the geometry in the blade > FOR simple_blade IN SELECT (ST_Dump(ST_CollectionExtract(blade, > blade_coded_type))).geom > LOOP > result:= > ST_CollectionExtract(ST_Split(result,simple_blade),geom_coded_type); > END LOOP; > RETURN result; > END; > $BODY$ > LANGUAGE plpgsql IMMUTABLE; > ---- > --Testing the function > SELECT ST_AsText(Split_multi(geom, blade)) > FROM ( > SELECT ST_GeomFromText('Multilinestring((-3 0, 3 0),(-1 0,1 0))') AS > geom, > ST_GeomFromText('MULTIPOINT((-0.5 0),(0.5 0))') AS blade > --ST_GeomFromText('POINT(-0.5 0)') AS blade > --ST_GeomFromText('MULTILINESTRING((0 1, 0 -1),(0 2,0 -2))') AS blade > --ST_GeomFromText('MULTIPOLYGON(((0 1,0 -1 ,1 -1,0 1)),((0 2,0 -2,1 -2,0 > 2)))') AS blade > ) AS toto > > > 2013/10/28 franco base <[email protected]> > >> Hi. >> I have a set of linestring and point on linestring. >> I want cut the linestring on the point. >> I can have n points for one linestring, >> so I use ST_Split >> (insted of ST_Line_Interpolate_Point and ST_Line_Substring) >> but it doesn't work. >> >> line;geom_line;point;geom_point >> >> 7646;"0102000020BB0B000006000000A4703D0A471F37412D211F04AF335341FAEDEBE0491F3741325530C2AE335341BD5296014F1F37418FC2F578AE3353414694F606521F3741D2DEE07BAE3353412D211F74541F37418FC2F578AE33534123B9FC675020374112143FF6BC335341";11764;"0101000020BB0B00005713362F611F37410D996234AF335341" >> >> 7646;"0102000020BB0B000006000000A4703D0A471F37412D211F04AF335341FAEDEBE0491F3741325530C2AE335341BD5296014F1F37418FC2F578AE3353414694F606521F3741D2DEE07BAE3353412D211F74541F37418FC2F578AE33534123B9FC675020374112143FF6BC335341";11769;"0101000020BB0B00005EF0DD584620374139BF2762BC335341" >> >> 7646;"0102000020BB0B000006000000A4703D0A471F37412D211F04AF335341FAEDEBE0491F3741325530C2AE335341BD5296014F1F37418FC2F578AE3353414694F606521F3741D2DEE07BAE3353412D211F74541F37418FC2F578AE33534123B9FC675020374112143FF6BC335341";11762;"0101000020BB0B0000A5CBC785841F374156A2A33CB1335341" >> >> ST_GeometryType(St_Split(geom_line, geom_point)) >> give "ST_GeometryCollection" >> >> but >> >> (ST_Dump(ST_Split(geom_line, geom_point))).geom >> >> return only 3 linestring (one for record) and the geometry is egual to >> geom_line >> >> >> thanks. >> >> fb >> >> _______________________________________________ >> postgis-users mailing list >> [email protected] >> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users >> > > > _______________________________________________ > postgis-users mailing list > [email protected] > http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users >
_______________________________________________ postgis-users mailing list [email protected] http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
