ST_MakeLine repeated point behavior

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ST_MakeLine repeated point behavior

Paul Norman
I was working on extending ST_MakePoint to handle MULTIPOINTs when I ran
across some inconsistent behavior.

When ST_MakeLine is called with an array, the LINESTRINGs in it are
added to the output with removal of duplicate points, but POINTs are
called without removal. The regression tests cover the former but not
the latter. The linestring behavior is documented, but there is no
mention of removal or not for repeated points.

As an example, calling it with a linestring from A to B and one from to
B to C results in a linestring from A to B to C. Calling it with points
at A, B, B, and C results in a linestring from A to B to B to C. Both
are valid linestrings.

I do not see that there are validity implications for the behavior -
invalid single-vertex linestrings can be generated with either behavior.

What is the best behavior to use here? It would make the code cleaner if
there was consistent behavior for points and linestrings.
_______________________________________________
postgis-devel mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-devel
Reply | Threaded
Open this post in threaded view
|

Re: ST_MakeLine repeated point behavior

Sandro Santilli-2
On Wed, Feb 24, 2016 at 05:15:40PM +0100, Paul Norman wrote:
> I was working on extending ST_MakePoint to handle MULTIPOINTs when I
> ran across some inconsistent behavior.
>
> When ST_MakeLine is called with an array, the LINESTRINGs in it are
> added to the output with removal of duplicate points, but POINTs are
> called without removal. The regression tests cover the former but
> not the latter. The linestring behavior is documented, but there is
> no mention of removal or not for repeated points.

For linestrings, only the join point is made unique,
not the internal ones:

  SELECT ST_AsText(ST_MakeLine(
    'LINESTRING(0 0,0 0,10 0)'::geometry,
    'LINESTRING(10 0,20 0,20 0)'::geometry
  ));

  LINESTRING(0 0,0 0,10 0,20 0,20 0)

The rationale for that is that you'd use ST_MakeLine(line,line)
to sew them togheter, whether or not they are noded already
(when they are not, an additional segment is added between the two).

Internal point removal can be obtained as a later step,
using ST_RemoveRepeatedPoints.

--strk;
_______________________________________________
postgis-devel mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/postgis-devel