[postgis-users] Check constraint violation using buffer()

Paul Ramsey pramsey at refractions.net
Fri Jan 23 11:10:06 PST 2004


Try creating a table with a looser constraint (geometry type 'GEOMETRY') or 
drop the constraint. Then run your test. Then test the geometry types of all 
the resultants. Probably an odd type coming out, like a GEOMETRYCOLLECTION or 
MULTIPOLYGON or something.

On January 23, 2004 11:07 am, Gary Sherman wrote:
> I'm attempting to buffer a LINESTRING layer and insert the resulting
> rows into a new table. The source layer has ~5,000 records. This process
> (buffer and insert) worked on a small layer with only 27 features.
> Details below. Any suggestions?
>
>
>
> Source table:
> gis_data=# \d majrivers
>             Table "public.majrivers"
>    Column   |         Type          | Modifiers
> ------------+-----------------------+-----------
>  gid        | integer               |
>  length     | double precision      |
>  decription | character varying(29) |
>  the_geom   | geometry              |
> Check constraints:
>     "$1" CHECK (srid(the_geom) = -1)
>     "$2" CHECK (geometrytype(the_geom) = 'LINESTRING'::text OR the_geom
> IS NULL)
>
> Target table:
> gis_data=# \d majrivers_buffercrash
> Table "public.majrivers_buffercrash"
>   Column  |   Type   | Modifiers
> ----------+----------+-----------
>  gid      | integer  |
>  the_geom | geometry |
> Check constraints:
>     "$1" CHECK (srid(the_geom) = -1)
>     "$2" CHECK (geometrytype(the_geom) = 'POLYGON'::text OR the_geom IS
> NULL)
>
> gis_data=# insert into majrivers_buffercrash select gid,
> buffer(the_geom,1000.0) from public.majrivers
> gis_data-# ;
> ERROR:  new row for relation "majrivers_buffercrash" violates check
> constraint "$2"
>
> -gary




More information about the postgis-users mailing list