1

I have a set of streets (LINESTRING) in a PostGIS 9.1 PostGIS 2.1 database.

I need to obtain points from the lines, on the right and on the left of the street.

I offset the lines with:

   ST_OffsetCurve(the_geom, 30)

then I try to get the points:

   (ST_DumpPoints(ST_Segmentize(the_geom, 20))).geom

when i get the error:

    ERROR:  getPoint4d_p: point offset out of range

Any one can replicate the behaviour ?

4
  • It's hard to replicate without seeing the data, but haven't seen such an issue except with empty point. You have an example? Also which version of PostGIS 2.1 are you running? SELECT postgis_full_version();
    – Regina Obe
    Apr 10, 2014 at 4:32
  • POSTGIS="2.1.0SVN" GEOS="3.3.3-CAPI-1.7.4" PROJ="Rel. 4.7.1, 23 September 2009" GDAL="GDAL 1.7.3, released 2010/11/10" LIBXML="2.7.8" LIBJSON="UNKNOWN" (core procs from "2.1.0SVN" need upgrade) TOPOLOGY (topology procs from "2.1.0SVN" need upgrade) RASTER (raster procs from "2.1.0SVN" need upgrade) Apr 10, 2014 at 5:44
  • I try to segment lines, and dump their points. The error appear while segmenting the data. I verified the lines, and all are valid, although there are lines with length smaller than 20 meters, the distance to which i want to segment. Apr 10, 2014 at 5:46
  • Since you are running a pre-release version of PostGIS, I would most definitely upgrade first To 2.1.2. I know there were issues with ST_DumpPoints in 2.1.0 and some earlier issues with ST_Segmentize (though can't remember the exact ones there that were patched). If you still have an issue after upgrade, please post an example line string (or dataset) to our bug tracker instructions detailed here: postgis.net/support
    – Regina Obe
    Apr 11, 2014 at 4:41

2 Answers 2

1

Mihai, I was able to replicate the error with this simple statement:

SELECT ST_Segmentize('LINESTRING EMPTY'::geometry, 10);

and I was able to also replicate the error with your rpoints edit. I created a ticket on http://trac.osgeo.org/postgis/ticket/2712 for this. Feel free to add comments to that ticket.

In looking at the dataset you have, as expected in the rstreets it has a LINESTRING EMPTY as one of the rows which I think is triggering this error.

How you ended up with a LINESTRING EMPTY is from the ST_OffSetCurve call, which I think is a bug in GEOS.

  SELECT ST_AsText(ST_OffsetCurve('LINESTRING(1116773.8702957 7172132.24526899,1116768.15226771 7172128.54354244,1116752.61206679 7172126.30820484,1116742.74915991 7172090.05035972,1116746.60081429 7172083.8179674,1116759.05746531 7172082.54875741,1116767.82944119 7172087.37933384,1116770.23394219 7172116.41968508,1116768.15226771 7172128.54354244)'::geometry, 30));

Returns Linestring Empty. I'll submit that as a separate ticket

2
  • Mihai, I tested the ST_Segmentize on LINESTRING EMPTY on my 2.0.5 install. That also gives same error. I also get the same LINESTRING EMPTY back on my 2.0.5 running GEOS 3.4.2. Might be a bug introduced after 2.0.1 I guess. Regarding the ST_OffsetCurve issue. I think for such a big positive offset relative to your wrap around line, there is no valid answer that can be returned, so I think LINESTRING EMPTY is appropriate. I added that to the ticket just in case Sandro thinks otherwise. That would be a GEOS change not a PostGIS change.
    – Regina Obe
    Apr 12, 2014 at 4:05
  • Your point are valid indeed. I managed to run the query after checking the valid geometries with ST_IsEmpty(). Thank you! Apr 12, 2014 at 10:26
0

It is a 2.1.1 and above bug, because on "POSTGIS="2.0.1 r9979" GEOS="3.3.3-CAPI-1.7.4" PROJ="Rel. 4.8.0, 6 March 2012" LIBXML="2.7.6"", the query works. Also on POSTGIS="2.1.0SVN" GEOS="3.3.3-CAPI-1.7.4" PROJ="Rel. 4.7.1, 23 September 2009" GDAL="GDAL 1.7.3, released 2010/11/10" LIBXML="2.7.8" LIBJSON="UNKNOWN" (core procs from "2.1.0SVN" need upgrade) TOPOLOGY (topology procs from "2.1.0SVN" need upgrade) RASTER (raster procs from "2.1.0SVN" need upgrade) works.

I have upgraded to 2.1.2 and I still have the error.

Here is a link with a small portion from the dataset (.shp and sql dump), and here is the query having the problem:

    -- create the table for streets
    CREATE TABLE streets (
    gid integer NOT NULL,
    name varchar,
    geom geometry(Geometry, 3857)
    );
   -- insert the data as a shapefile or as a sql dump
   -- create the offset streets
   -- create column for right offset line
   ALTER TABLE streets ADD COLUMN rstreets geometry(Geometry, 3857);
   UPDATE streets SET rstreets = ST_OffsetCurve(geom, 30);
   -- create column for left offset line
   ALTER TABLE streets_merc ADD COLUMN lstreets geometry(Geometry, 3857);
   UPDATE streets  SET lstreets = ST_OffsetCurve(geom, -30);
   -- create the points table
   CREATE TABLE points (
       gid bigserial NOT NULL,
       name varchar,
   lineid integer,
   segmentid integer,
   geom geometry(Geometry, 3857)
    );
   -- populate the points table with the working query
   INSERT INTO points(name, lineid, segmentid, the_geom)
   SELECT name, gid, (ST_DumpPoints(ST_Segmentize(geom, 20))).path[1] AS segmentid, (ST_DumpPoints(ST_Segmentize(geom, 20))).geom AS the_geom
    FROM streets;
   -- populate the points table with the problematic query
   -- create the right points column
   ALTER TABLE points ADD COLUMN rpoints geometry(Geometry, 3857);
   INSERT INTO points(rpoints)
   SELECT (ST_DumpPoints(ST_Segmentize(rstreets, 20))).geom AS rpoints
   FROM streets;
   -- create the left points column
   ALTER TABLE points ADD COLUMN lpoints geometry(Geometry, 3857);
   INSERT INTO points(lpoints)
   SELECT (ST_DumpPoints(ST_Segmentize(lstreets, 20))).geom AS lrpoints
   FROM streets;
4
  • Mihai, Can you post this again to our bug tracker. Since it's your data, I wouldn't feel comfortable doing that myself without your official permission. trac.osgeo.org/postgis/newticket - thanks Regina
    – Regina Obe
    Apr 11, 2014 at 18:45
  • Mihai, just tried this on my PostGIS 2.1.2 install and not seeing an error. There were a couple of typos in your example I had to guess at -- so that might be it too. E.g. there is no streets_merc so had to change that to streets. There is also no the_geom column so had to change that to geom. I used the streets.* files loaded as single linestring (not the .backup since the backup came in as a multilinestring not supported by offset curve)
    – Regina Obe
    Apr 11, 2014 at 19:03
  • I will review your comments and I will submit on bug tracker. The segmentize does not work on the offset lines. Please see my edits in the rpoints and lpoints insert commands. Apr 11, 2014 at 19:10
  • I was able to replicate the error with this simple statement: SELECT ST_Segmentize('LINESTRING EMPTY'::geometry, 10); though I haven't tested this on a 2.0 install but fails on 2.1.2. which is similar to issue in : trac.osgeo.org/postgis/ticket/2108
    – Regina Obe
    Apr 12, 2014 at 2:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.