[postgis-users] st_union and st_linemerge returns multilinestring

khorvat kresimir.horvat at in2.hr
Mon Nov 24 06:51:18 PST 2014


Hi list,

I have a problem with ST_Union and ST_LineMerge functions. I have following
query
SELECT ST_LineMerge(ST_Union(b."Geometry"))
	INTO v_union
	FROM schema."TableA" a
	INNER JOIN schema."TableB" b
		ON b."Id" = a."Id"
	WHERE a."DetailId" = 1;

Which returns 
MULTILINESTRING((301565.3582 5032543.1448,301520.4023
5032575.3387,301505.3992 5032587.1594,301478.4221 5032610.8667,301463.6862
5032640.3163,301440.7183 5032695.9716,301429.9559 5032719.8098,301422.2228
5032728.0427,301412.2265 5032733.2853,301400.7336 5032735.2842,301389.2586
5032735.2842,301381.2581 5032733.2854,301371.4223 5032726.5435,301357.9516
5032716.0579,301344.4631 5032704.0815,301315.4902 5032676.6307,301306.2425
5032670.3885,301292.2728 5032656.4133,301282.7756 5032652.1699,301267.0419
5032644.4368,301243.575 5032638.94,301211.1989 5032641.3075,301162.0735
5032649.6878,301047.3405 5032666.6039,300933.1243 5032681.6605,300871.3122
5032684.4785,300848.5937 5032684.4621,300772.0575 5032670.0314),(300772.0575
5032670.0314,300779.9036 5032718.2534,300793.8376 5032810.3296,301171.4304
5032787.5317,301219.6082 5032755.2239,301241.9853 5032782.5577,301306.0927
5032787.715,301388.1035 5032778.9493,301456.6398 5032820.2146,301546.1875
5032818.6355,301607.7843 5032966.1217,301683.8773 5032939.0456,301759.9702
5032908.5129,301785.3346 5032898.1433,301827.9927 5032872.7954,301843.0408
5032861.6841,301834.9513 5032821.7736,301826.7937 5032798.6776,301821.0173
5032791.5784,301812.6782 5032784.5007,301796.4991 5032773.3844,301784.6142
5032762.776,301768.934 5032746.8593,301755.8017 5032734.4814,301742.4023
5032717.3031,301737.0924 5032709.9796,301734.5467 5032703.7167,301740.8835
5032690.4582,301745.24 5032681.5532,301752.7649 5032671.8567,301771.181
5032651.4742,301791.7917 5032626.7147,301772.865 5032612.8079,301730.5037
5032602.1471,301712.5406 5032601.8038,301666.7967 5032634.3862,301652.4077
5032628.2238,301623.9236 5032603.2804,301634.4155 5032575.3248,301614.3054
5032522.4277))

As you can see last point of first line is same as first point of the second
line (...,300772.0575 5032670.0314),(300772.0575 5032670.0314,...). Problem
with MultiLineString is next step where I need difference of two lines. If
parameter is MultiLineString I get wrong result (I have no idea why, I tired
same thing in JTS and it works fine). For some reason PostGIS
(ST_Difference) returns expected result just for LineString parameters.

Also if I create geometry from text it will return LineString after applying
ST_LineMerge function, so problem appears only for select from table.

DO $$
DECLARE
	v_geom			geometry;
BEGIN
	
	v_geom := ST_GeomFromText('MULTILINESTRING((301565.3582
5032543.1448,301520.4023 5032575.3387,301505.3992 5032587.1594,301478.4221
5032610.8667,301463.6862 5032640.3163,301440.7183 5032695.9716,301429.9559
5032719.8098,301422.2228 5032728.0427,301412.2265 5032733.2853,301400.7336
5032735.2842,301389.2586 5032735.2842,301381.2581 5032733.2854,301371.4223
5032726.5435,301357.9516 5032716.0579,301344.4631 5032704.0815,301315.4902
5032676.6307,301306.2425 5032670.3885,301292.2728 5032656.4133,301282.7756
5032652.1699,301267.0419 5032644.4368,301243.575 5032638.94,301211.1989
5032641.3075,301162.0735 5032649.6878,301047.3405 5032666.6039,300933.1243
5032681.6605,300871.3122 5032684.4785,300848.5937 5032684.4621,300772.0575
5032670.0314),(300772.0575 5032670.0314,300779.9036 5032718.2534,300793.8376
5032810.3296,301171.4304 5032787.5317,301219.6082 5032755.2239,301241.9853
5032782.5577,301306.0927 5032787.715,301388.1035 5032778.9493,301456.6398
5032820.2146,301546.1875 5032818.6355,301607.7843 5032966.1217,301683.8773
5032939.0456,301759.9702 5032908.5129,301785.3346 5032898.1433,301827.9927
5032872.7954,301843.0408 5032861.6841,301834.9513 5032821.7736,301826.7937
5032798.6776,301821.0173 5032791.5784,301812.6782 5032784.5007,301796.4991
5032773.3844,301784.6142 5032762.776,301768.934 5032746.8593,301755.8017
5032734.4814,301742.4023 5032717.3031,301737.0924 5032709.9796,301734.5467
5032703.7167,301740.8835 5032690.4582,301745.24 5032681.5532,301752.7649
5032671.8567,301771.181 5032651.4742,301791.7917 5032626.7147,301772.865
5032612.8079,301730.5037 5032602.1471,301712.5406 5032601.8038,301666.7967
5032634.3862,301652.4077 5032628.2238,301623.9236 5032603.2804,301634.4155
5032575.3248,301614.3054 5032522.4277))', 3765);
	
	RAISE NOTICE '%', ST_AsText(ST_LineMerge(v_geom));
END $$;

Any idea what causes this problem?




--
View this message in context: http://postgis.17.x6.nabble.com/st-union-and-st-linemerge-returns-multilinestring-tp5007358.html
Sent from the PostGIS - User mailing list archive at Nabble.com.


More information about the postgis-users mailing list