0

With MariaDB 10.1, I get a simplified LINESTRING when I provide two lines can be joined.

SELECT ST_AsText(geom)
FROM (
  SELECT ST_Union(
    LineString(Point(0,0),Point(1,1)),
    LineString(Point(1,1),Point(2,2))
  ) AS geom
) AS t;
+---------------------+
| ST_AsText(geom)     |
+---------------------+
| LINESTRING(0 0,2 2) |
+---------------------+

But with PostGIS I get a MULTILINESTRING

SELECT ST_AsText(geom)
FROM (
  SELECT ST_Union(
    ST_MakeLine(ST_Point(0,0),ST_Point(1,1)),
    ST_MakeLine(ST_Point(1,1),ST_Point(2,2))
  ) AS geom
) AS t;
             st_astext               
--------------------------------------
 MULTILINESTRING((0 0,1 1),(1 1,2 2))

It's important that the return type in MySQL seems to be dependent on the geometeries, change the second line to ST_MakeLine(ST_Point(2,2),ST_Point(3,3)) and you'll get the same thing in both.

SELECT ST_AsText(geom)
FROM ST_Union(
    ST_MakeLine(ST_Point(0,0),ST_Point(1,1)),
    ST_MakeLine(ST_Point(2,2),ST_Point(3,3))
  ) AS geom
) AS t;
+--------------------------------------+                                  
| ST_AsText(geom)                      |                                  
+--------------------------------------+                                  
| MULTILINESTRING((0 0,1 1),(2 2,3 3)) |                                  
+--------------------------------------+                                  

              st_astext               
--------------------------------------
 MULTILINESTRING((0 0,1 1),(2 2,3 3))

With MySQL on ST_Union of LineString(Point(0,0),Point(1,1)) and LineString(Point(1,1),Point(1,0)) you actually get back LINESTRING(0 0,1 1,1 0)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.