[postgis-devel] PostGIS 1.4 SVN geometry parser hints

Kevin Neufeld kneufeld at refractions.net
Wed Oct 15 08:53:46 PDT 2008


Nice work Mark.  I like it.  That should definitely help with assisting 
newcomers with WKT syntax.

Is it possible to put it on other ERROR messages, like "ERROR:  GEOS 
intersects() threw an error!"?  It could suggest they snap to a grid to 
avoid topology errors or perhaps simply a "You found a bug" and provide 
a url to the bug tracker.

Nice :)

Kevin

Mark Cave-Ayland wrote:
> Hi everyone,
> 
> Just so that it doesn't come as too much of a surprise, I remembered 
> that with the new parser API in place within SVN trunk, we can now 
> return extra information from the parse phase, including the position of 
> any errors. Since we are now using a minimum of PostgreSQL 8.1, it means 
> we can use the HINT functionality to tag this additional information to 
> the original ERROR message.
> 
> So as of SVN trunk, you now see an extract of the input geometry up to 
> the point where the parse failed (marked with an arrow), followed by the 
> absolute position of the error like this:
> 
> 
> postgis=# select 'test1', astext(geomfromtext('LINESTRINGA(0 0)'));
> ERROR:  parse error - invalid geometry
> HINT:  "LINESTRING" <-- parse error at position 10 within geometry
> CONTEXT:  SQL function "geomfromtext" statement 1
> 
> postgis=# select 'test2', astext(geomfromtext('LINESTRING(0 0)'));
> ERROR:  geometry requires more points
> HINT:  "LINESTRING(0 0)" <-- parse error at position 15 within geometry
> CONTEXT:  SQL function "geomfromtext" statement 1
> 
> postgis=# select 'test3', astext(geosnoop('POLYGON((0 0, 0 1, 1 1, 2 1, 
> 3 1, 4 1, 5 1, 6 1, 7 1, 8 1))'));
> ERROR:  geometry contains non-closed rings
> HINT:  "... 1 1, 2 1, 3 1, 4 1, 5 1, 6 1, 7 1, 8 1)" <-- parse error at 
> position 58 within geometry
> 
> 
> Nice :)  I'm not 100% set upon the HINT output format (it was the 
> clearest I could come up with to fit on one line after a bit of playing 
> around), so if anyone can think of anything better, please shout.
> 
> ATB,
> 
> Mark.
> 



More information about the postgis-devel mailing list