MultiLineString.fromWKT constructor
Creates a MultiLineString from a WKT String.
Example:
MultiLineString.fromWKT('MULTILINESTRING((1 2, 3 4))'); // MultiLineString([[Coordinate(1, 2), Coordinate(3, 4)]])
Implementation
@override
factory MultiLineString.fromWKT(String wkt) {
if (!wkt.startsWith('MULTILINESTRING')) {
throw ArgumentError('wkt is not a MultiLineString');
}
final wktLines = wkt.split('((')[1].split('))')[0].split('),(');
return MultiLineString(
wktLines
.map((line) => line.split(','))
.map(
(line) => line.map((point) => Coordinate.fromWKT(point)).toList())
.toList(),
);
}