Issues geometry constraints

24 views
Skip to first unread message

kk mensah

unread,
May 12, 2018, 9:27:23 AM5/12/18
to SpatiaLite Users
HI All,

I am facing a brick wall and need some assistance.

I am using spalialite_gui and running a small project on motorways, my issue is with a timy part of my code.

CREATE TABLE motorway_buffers(

                id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,

                mortorway_number TEXT NOT NULL,

                buffer_name TEXT NOT NULL)

 

SELECT AddGeometryColumn('motorway_buffers', 'geometry', 27700, 'MULTIPOLYGON', 'XY')

 

INSERT INTO motorway_buffers

                (id, mortorway_number, buffer_name, geometry)

SELECT NULL, number, 'buffers < 1km',

                CastToMultipolygon(ST_Buffer(geometry, 1000.0))        

FROM motorway


The area highlighted are gives an error saying : 


SQL error: motorway_buffers.geometry violated geometry constraint [geom-type or SRID not allowed]


kindly help break through this wall. Thanks

andrea antonello

unread,
May 12, 2018, 9:34:19 AM5/12/18
to spatiali...@googlegroups.com
Hi Mensah,
From your query I do not see where the geometry comes from, but when
you create it, you need to do it supplying the srid. I guess the
geometry you are inserting doesn't have it defined, hence the
violation.

Ciao,
Andrea


>
>
> kindly help break through this wall. Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "SpatiaLite Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to spatialite-use...@googlegroups.com.
> To post to this group, send email to spatiali...@googlegroups.com.
> Visit this group at https://groups.google.com/group/spatialite-users.
> For more options, visit https://groups.google.com/d/optout.

mj10777

unread,
May 12, 2018, 9:45:44 AM5/12/18
to SpatiaLite Users
The geometry must be (at least) a POLYGON and have the srid 27700 (which you defined) 

Mark

kk mensah

unread,
May 12, 2018, 10:05:01 AM5/12/18
to SpatiaLite Users
Thanks MJ,

the code looks ok but cant seem to find what it is im missing. Any suggestions?

kk mensah

unread,
May 12, 2018, 10:06:18 AM5/12/18
to SpatiaLite Users
Thanks Moovida,

I am still working on it. Nothing seem to work though

a.fu...@lqt.it

unread,
May 12, 2018, 10:45:54 AM5/12/18
to spatiali...@googlegroups.com
On Sat, 12 May 2018 06:27:23 -0700 (PDT), kk mensah wrote:
> SQL error: motorway_buffers.geometry violated geometry constraint
> [geom-type or SRID not allowed]
>

Hi,

rule number zero: always carefully check your data so to
discover what is causing troubles.
you've created the destination geometry column as:

SELECT AddGeometryColumn('motorway_buffers', 'geometry',
27700, 'MULTIPOLYGON', 'XY');

and consequently the possible causes for a constraint
violation are the followings:

1. any GeometryType different from MULTIPOLYGON
2. any SRID different from 27700
3. any Dimension different from XY

now, your first check should be to carefully verify
which values is actually returning your SQL query;
and in order do to this you just have to execute a
rather trivial diagnostic query such as:

SELECT GeometryType(g.g) AS type, Srid(g.g) AS srid,
CoordDimension(g.g) AS dims, Count(*) AS count
FROM
(
SELECT CastToMultiPolygon(ST_Buffer(geometry, 1000.0)) AS g
FROM motorway
) AS g
GROUP BY type, srid, dims;

after performing this very basic check you'll be probably
able to resolve the problem by yourself.
if not, you can eventually post a new message by specifying
your actual findings and asking for further help.

bye Sandro

kk mensah

unread,
May 12, 2018, 11:02:33 AM5/12/18
to SpatiaLite Users
Wow Thanks Sandro,

The query returned srid as 0, hence the error. Now to fix that.

thanks again
Reply all
Reply to author
Forward
0 new messages