[postgis-users] More details for errors

Nicolas Ribot nicolas.ribot at gmail.com
Tue Mar 27 07:39:22 PDT 2012


On 27 March 2012 16:09, Denis Rouzaud <denis.rouzaud at gmail.com> wrote:
> Hi Nicolas,
>
> Thanks again.
>
> Well, this working, but this not performant...
>
> Based on your suggestion, I tried this:
> in view1:
> ST_Multi(ST_LineMerge(ST_Union(wkb_geometry)))::geometry(MultiLineString,21781)
> AS wkb_geometry
>
> Then in view2:
> ST_CollectionHomogenize(wkb_geometry)::geometry(LineString,21781) AS
> wkb_geometry
> FROM view1
>  WHERE ST_NumGeometries(wkb_geometry) = 1;
>
> And I can detect problems by doing:
> SELECT id FROM view1  WHERE ST_NumGeometries(wkb_geometry) != 1;
>
>
> But this is slowing down a lot.
> I think that the ST_CollectionHomogenize is not the right way. Is there a
> better function to transform multiline to line if I am sure I only have
> lines?
>

I did not know this function. 2.0 ?
You can simply do:

st_setsrid(ST_geometryN(wkb_geometry), 21781) AS
wkb_geometry
FROM view1
 WHERE ST_NumGeometries(wkb_geometry) = 1;

If geoms come from linemerge, no need to cast to a linestring. It is
already one.

Nicolas



More information about the postgis-users mailing list