[postgis-users] Problem with a zero length line

Bruce Rindahl rindahl at lrcwe.com
Sat Sep 23 07:55:18 PDT 2006


I didn't check the IsValid function - just AsText(LineFromText('LINESTRING(1
0.5,1 0.5)');
If the standard is to return a point then I will add a test to catch it.
I like the extreme prejudice wording.
Bruce Rindahl


-----Original Message-----
From: Michael Fuhr [mailto:mike at fuhr.org] 
Sent: Friday, September 22, 2006 10:51 PM
To: rindahl at lrcwe.com; PostGIS Users Discussion
Subject: Re: [postgis-users] Problem with a zero length line

On Fri, Sep 22, 2006 at 04:43:14PM -0600, Bruce Rindahl wrote:
> select AsText(Intersection(
> LineFromText('LINESTRING(1 0.5,2 0.5)'),
> PolyFromText('POLYGON((0 0,1 0,1 1,0 1,0 0))')
> ))
> 
> Result:
> "POINT(1 0.5)"
> 
> While this is technically correct, I think the result should be:
> "LINESTRING(1 0.5,1 0.5)" 
> 
> Note this result is a valid geometry and returns a length of 0.

IsValid() doesn't think that geometry is valid:

test=> SELECT IsValid(LineFromText('LINESTRING(1 0.5,1 0.5)'));
NOTICE:  Too few points in geometry component at or near point 1 0.5 0.5
 isvalid 
---------
 f
(1 row)

I don't know if the following is applicable or if the document is
still in use, but The OpenGIS Abstract Specification: An Object
Model for Interoperable Geoprocessing, Revision 1 (96-015R1) has
the following among the assertions for line strings (3.15.3.2):

  1. Each line must have at least 2 distinct vertexes, each represented
     by a coordinate in the sequence.

  2. 'Degenerate' one point lines should use point structures.

  4. Sequential vertexes should be distinct.  Repeated (sequential)
     vertexes are ignored and discouraged with extreme prejudice.

  6. A line string (with 4 or more vertices) may be self-intersecting.

Can anybody more familiar with current standards comment?

-- 
Michael Fuhr





More information about the postgis-users mailing list