[Qgis-developer] Viewing SpatiaLite views in QGis

Geo DrinX geodrinx at gmail.com
Thu Jan 23 00:26:57 PST 2014


Hello all,


I noticed a strange behavior in QGis when I am viewing  SpatiaLite views.

These are my steps:

1)  I have some SpatiaLite tables, that have  "Geometry" field.  For
example:

CREATE TABLE "Poligoni" (
"PK_UID" INTEGER PRIMARY KEY AUTOINCREMENT,
"field1" TEXT,
"Note" TEXT, "geometry" POLYGON)

2) I create a SpatiaLite view, that performs some spatial opetation, i.e.
an intersection

CREATE VIEW intersecato as
SELECT  b.field1as "field1", b."field2" AS "field2", a."field3" AS "field3",
    ST_area (a.Geometry) AS "area", b.arec as "arec",
 intersection (a.Geometry, b.Geometry) as Geometry
FROM "Poligoni" a, "otherTable" b
where
ST_intersects (a.Geometry, b.Geometry)  = 1
order by field1

3)  I insert into "geometry_columns" a record for the view:

insert into geometry_columns values
('intersecato','geometry',3,2,3003,0)


4)  I execute a query into SpatiaLite_gui to control that some record
exists.
     And...  they exist.   :)


5) I go to QGis (2.0.1 Dufour,  Windows, Linux or MacOSX :)   and connect
to SpatiaLite DB.

6) I insert my tables and view in Layer list.
We, now I see all the layers, as those corresponding to the tables, as
that correspond
to my SpatiaLite view.  But, this one do not display the correct records in
the attribute panel:  in this case, I only have a list of many "NULL", and
selecting a record, all records are selected  :(


Do you have any explanation for this?

Also I tried to add a PK_UID  in the view definition, but the result
remains the same.


Thank you for any help

Regards

Roberto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140123/e0c4ce45/attachment.html>


More information about the Qgis-developer mailing list