irstv/H2GIS — pull request #68 by agouge (2013-12-09 10:52:26+00:00)
Title: Add ST_MakeLine (deprecates ST_PointsToLine)

Here we introduce ST_MakeLine, which will replace the old GDMS function
ST_PointsToLine. It can accept any number of POINTs or MULTIPOINTs and can be
used in scalar or aggregate (in conjunction with ST_Accum) form. See examples
below.

See #41.

## Examples
### Scalar forms
#### POINT to POINT(S)
```mysql
SELECT ST_MakeLine(ST_GeomFromText('POINT(1 2 3)'), ST_GeomFromText('POINT(4 5 6)'));
```
Answer: `LINESTRING(1 2 3, 4 5 6)`
```mysql
SELECT ST_MakeLine(ST_GeomFromText('POINT(1 2)'), ST_GeomFromText('POINT(4 5)'));
```
Answer: `LINESTRING(1 2, 4 5)`
```mysql
SELECT ST_MakeLine(ST_GeomFromText('POINT(1 2)'), ST_GeomFromText('POINT(4 5)'), ST_GeomFromText('POINT(7 8)'));
```
Answer: `LINESTRING(1 2, 4 5, 7 8)`
#### POINT to MULTIPOINT
```mysql
SELECT ST_MakeLine(ST_GeomFromText('POINT(1 2)'), ST_GeomFromText('MULTIPOINT(4 5, 12 9)'));
```
Answer: `LINESTRING(1 2, 4 5, 12 9)`
#### MULTIPOINT to MULTIPOINT
```mysql
SELECT ST_MakeLine(ST_GeomFromText('MULTIPOINT(1 2, 17 6)'), ST_GeomFromText('MULTIPOINT(4 5, 7 9, 18 -1)'));
```
Answer: `LINESTRING(1 2, 17 6, 4 5, 7 9, 18 -1)`

#### A single MULTIPOINT

```mysql
SELECT ST_MakeLine(ST_Accum(ST_GeomFromText('MULTIPOINT(1 2, 3 4)')));
```
Answer: `LINESTRING(1 2, 3 4)`

### Aggregate forms
#### POINTs only
```mysql
SELECT ST_MakeLine(ST_Accum(point)) FROM input_table;
```
|point Point|
|-----|
|POINT(1 2)|
|POINT(3 4)|
|POINT(5 6)|
|POINT(7 8)|
|POINT(9 10)|
Answer: `LINESTRING(1 2, 3 4, 5 6, 7 8, 9 10)`
#### POINTs and MULTIPOINTs
```mysql
SELECT ST_MakeLine(ST_Accum(point)) FROM input_table;
```
|point Geometry|
|-----|
|POINT(5 5)|
|MULTIPOINT(1 2, 7 9, 18 -4)|
|POINT(3 4)|
|POINT(99 3)|
Answer: `LINESTRING(5 5, 1 2, 7 9, 18 -4, 3 4, 99 3)`
#### MULTIPOINTs only
```mysql
SELECT ST_MakeLine(ST_Accum(multi_point)) FROM input_table;
```
|multi_point MultiPoint|
|-----|
|MULTIPOINT(5 5, 1 2, 3 4, 99 3)|
|MULTIPOINT(-5 12, 11 22, 34 41, 65 124)|
|MULTIPOINT(1 12, 5 -21, 9 41, 32 124)|
Answer: `LINESTRING(5 5, 1 2, 3 4, 99 3, -5 12, 11 22, 34 41, 65 124, 1 12, 5 -21, 9 41, 32 124)`