[postgis-devel] PostGIS 1.4 SVN geometry parser hints

Mark Cave-Ayland mark.cave-ayland at siriusit.co.uk
Thu Oct 16 01:39:36 PDT 2008


Mark Cave-Ayland wrote:

>> postgis2=# select 'MULTIPOYGON(((0 0, 0 0, 0 0,0 0),(0 0, 0 0, 0 0,0
>> 0),(0 0, 0 0, 0 0,0 0),(0 0, 0 0, 0 0,0 0),(0 0, 0 0, 0 0,0
>> 0)))'::geometry;
>> ERROR:  parse error - invalid geometry
>> HINT:  "" <-- parse error at position 0 within geometry
> 
> I think this is because MULTIPOLYGON is a token in the grammar, and so 
> since the first token doesn't match the current position is still zero 
> when the error occurs. I'm not sure if there is a way of getting the 
> current character offset from within flex at this point...

Okay. Since the first item in a WKT input is always a string 
representation of the geometry type such as POINT etc, I've added a 
different message to SVN trunk to catch the special case where the error 
location is zero. Your test case now looks like this:


postgis=# select 'MULTIPOYGON(((0 0, 0 0, 0 0,0 0),(0 0, 0 0, 0 0,0
0),(0 0, 0 0, 0 0,0 0),(0 0, 0 0, 0 0,0 0),(0 0, 0 0, 0 0,0
0)))'::geometry;
ERROR:  parse error - invalid geometry
HINT:  You must specify a valid OGC WKT geometry type such as POINT, 
LINESTRING or POLYGON


...which I think is a lot more helpful.


ATB,

Mark.

-- 
Mark Cave-Ayland
Sirius Corporation - The Open Source Experts
http://www.siriusit.co.uk
T: +44 870 608 0063



More information about the postgis-devel mailing list