The ST_MLineFromGML() function

The ST_MLineFromGML() function takes a GML2 or GML3 string representation of an ST_MultiLineString and an optional spatial reference ID and returns a multipart polyline object.

Syntax

ST_MLineFromGML(gmlstring lvarchar)
ST_MLineFromGML(gmlstring lvarchar, SRID integer)

Return type

ST_MultiLineString

Example

The gml_linetest table is created with the SMALLINT column gid and the ST_MultiLineString column ln1:
CREATE TABLE gml_linetest(gid smallint, ln1 ST_MultiLineString);

INSERT INTO gml_linetest VALUES (1, ST_MLineFromGML('<gml:MultiLineString>
             <gml:LineStringMember><gml:LineString><gml:posList>-110.45 45.256 
             -109.48 46.46 -109.86 43.84</gml:posList></gml:LineString>
             </gml:LineStringMember><gml:LineStringMember><gml:LineString>
             <gml:posList>-99.45 33.256 -99.48 36.46 -99.86 33.84</gml:posList>
             </gml:LineString></gml:LineStringMember></gml:MultiLineString>',4));

INSERT INTO gml_linetest VALUES (2, ST_MLineFromGML('<gml:MultiLineString 
            srsName="EPSG:4326" srsDimension="3"><gml:LineStringMember>
            <gml:LineString srsName="EPSG:4326" srsDimension="3"><gml:posList 
            dimension="3">-110.449999933 45.2559999343 10 -109.47999994 
            46.4600005499 10 -109.86000008 43.8400000201 20</gml:posList>
            </gml:LineString></gml:LineStringMember><gml:LineStringMember>
            <gml:LineString srsName="EPSG:4326" srsDimension="3"><gml:posList 
            dimension="3">-99.45 33.256 10 -99.48 36.46 10 -99.86 33.84 20
            </gml:posList></gml:LineString></gml:LineStringMember>
            </gml:MultiLineString>'));

INSERT INTO gml_linetest VALUES (3, ST_MLineFromGML('<gml:MultiLineString 
            srsName="EPSG:4326" srsDimension="4"><gml:LineStringMember>
            <gml:LineString srsName="EPSG:4326" srsDimension="4"><gml:posList 
            dimension="4">-110.449999933 45.2559999343 10 54 -109.47999994 
            46.4600005499 10 58 -109.86000008 43.8400000201 20 64</gml:posList>
            </gml:LineString></gml:LineStringMember><gml:LineStringMember>
            <gml:LineString srsName="EPSG:4326" srsDimension="4"><gml:posList 
            dimension="4">-99.45 33.256 10 54 -99.48 36.46 10 58 -99.86 33.84 20 64
            </gml:posList></gml:LineString></gml:LineStringMember>
            </gml:MultiLineString>'));

The first record specifies a spatial reference ID of 4 (WGS84) and a default dimension of 2. The second and third records contain Z and M measures and pass the spatial reference ID through the srsName attribute.

Output:
SELECT * FROM gml_linetest;

gid  1
ln1  4 MULTILINESTRING ((-110.449999933 45.2559999343, -109.47999994 46.4600000
     469, -109.86000008 43.8400000201),(-99.4499999329 33.2559999343, -99.47999
     99397 36.4600000469, -99.8600000805 33.8400000201))

gid  2
ln1  4 MULTILINESTRING Z ((-110.449999933 45.2559999343 10, -109.47999994 46.46
     00005499 10, -109.86000008 43.8400000201 20),(-99.4499999329 33.2559999343
      10, -99.4799999397 36.4600000469 10, -99.8600000805 33.8400000201 20))

gid  3
ln1  4 MULTILINESTRING ZM ((-110.449999933 45.2559999343 10 54, -109.47999994 4
     6.4600005499 10 58, -109.86000008 43.8400000201 20 64),(-99.4499999329 33.
     2559999343 10 54, -99.4799999397 36.4600000469 10 58, -99.8600000805 33.84
     00000201 20 64))

3 row(s) retrieved.