Spatialite function to generate a blob from a geometry
Using QGIS Python API, I want to avoid updating geometry with an UPDATE sql command.
Why? I'm using a
QSqlRelationalTableModel(see model-view programming if curious) and there are built-in editing strategy I want to benefit.
My issue is that for geometry, I should update the model content with a Spatialite geometry blob (specs).
I didn't found any blob functions in Spatialite for geometry, so I could do
function_transform_geometry_to_spatialite_blob(MakePoint(0, 0, 4326))and it returns a blob with geometry embedded as a text I can use to update my Geometry field within the model. Are there any I missed?
Maybe, it's not the right approach. You may have another suggestions/opinions.
PS: I know about http://blog.vitu.ch/10112013-1201/qgis-relations and I've seen this discussion but it does not seem as flexible as
QDataWidgetMapper (but I could be wrong)
It was obvious and I didn't read well the RTFM. See this discussion on the Spatialite mailing list.
The answer is:
SELECT ST_GeomFromText('POINT(1 2)', 4326);
SELECT MakePoint(1, 2, 4326);
To make result as a text, do:
SELECT hex(MakePoint(1, 2, 4326));