[postgis-users] Split multi-linestrings

Andrea Peri 2007 aperi2007 at gmail.com
Wed Aug 19 09:35:49 PDT 2009


Hi,

I found the bug !

It wasn't the ST_Dump, but was in the definition of MultiLineString ...

See-ing  the WKT I notice the MultiLineStrings was all like this:

MULTILINESTRING(
	(1678894.55 4826636.25,1678897.55 4826640.38),
	(1678897.55 4826640.38,1678898.8 4826643.69),
	(1678898.8 4826643.69,1678899.51 4826647.72),
	(1678899.51 4826647.72,1678899.42 4826653.53),
	(1678899.42 4826653.53,1678898.82 4826658.83),
	(1678898.82 4826658.83,1678897.59 4826663.34),
	(1678897.59 4826663.34,1678895.56 4826668.36)
)

So when I use the ST_Dump it produce this results:

LINESTRING(1678894.55 4826636.25,1678897.55 4826640.38)
LINESTRING(1678897.55 4826640.38,1678898.8 4826643.69)
LINESTRING(1678898.8 4826643.69,1678899.51 4826647.72)
LINESTRING(1678899.51 4826647.72,1678899.42 4826653.53)
LINESTRING(1678899.42 4826653.53,1678898.82 4826658.83
LINESTRING(1678898.82 4826658.83,1678897.59 4826663.34)
LINESTRING(1678897.59 4826663.34,1678895.56 4826668.36)

So I realized the bug was before...

Because I gave the MultiLineString from a command

ST_Multi(ST_Intersection(ST_Boundary(geom1),ST_Boundary(geom2)))
(where the geoms are polygons.)

See-ing the WKT of this result I notice all the results are MultiLines
Like this:

MULTILINESTRING(
	(1678894.55 4826636.25,1678897.55 4826640.38),
	(1678897.55 4826640.38,1678898.8 4826643.69),
	(1678898.8 4826643.69,1678899.51 4826647.72),
	(1678899.51 4826647.72,1678899.42 4826653.53),
	(1678899.42 4826653.53,1678898.82 4826658.83),
	(1678898.82 4826658.83,1678897.59 4826663.34),
	(1678897.59 4826663.34,1678895.56 4826668.36)
)

But are always multilines of always segments with 2 only vertex !

So to resolve the problem I add an ST_LineMerge

ST_Multi(ST_LineMerge(ST_Intersection(ST_Boundary(a.geom),ST_Boundary(b.geom))))

Now the WKT is:

MULTILINESTRING(
	(
		1678894.55 4826636.25,
		1678897.55 4826640.38,
		1678898.8 4826643.69,
		1678899.51 4826647.72,
		1678899.42 4826653.53,
		1678898.82 4826658.83,
		1678897.59 4826663.34,
		1678895.56 4826668.36
	)
)

And doing the ST_Dump the result of the ST_Dump was:

LINESTRING(
	1678894.55 4826636.25,
	1678897.55 4826640.38,
	1678898.8 4826643.69,
	1678899.51 4826647.72,
	1678899.42 4826653.53,
	1678898.82 4826658.83,
	1678897.59 4826663.34,
	1678895.56 4826668.36
)


Thx for the suggestions ..

Andrea.

>>/ (ST_Dump(geom)).geom
/>>/ But unfortunately it give me again all segments with only 2 vertex :(
/>>/ 
/>>/ So from 1 MultiLineString with 2 parts each with 20+ vertex give me many
/>>/ LineStrings with only 2 vertex each :(
/
>Could we have the example ?





More information about the postgis-users mailing list