Hello,
I’m developing an app with spatialite (package jsqlite) tileview AND dynamic dialogs from GIS Server.
I created Spatialite on Android from a Sqlite-Database with WKT.
On short:
dbsqlite.prepare("SELECT InitSpatialMetaData();").step();
dbsqlite.prepare("BEGIN ;").step();
for (String name : lst_tables) {
dbsqlite.prepare("SELECT AddGeometryColumn('" + name + "','GEOMETRY'," + code + ",'GEOMETRY', 'XY',0)").step();
dbsqlite.prepare("UPDATE " + name + " SET GEOMETRY=(GeomFromText(WKT," + code + "))").step();
}
dbsqlite.prepare("COMMIT ;").step();works fine.
BUT now my problem:
I want to insert data to sqlite/spatialite with SQLiteOpenHelper
For a simple, I'll create a simple record where I set only the most necessary values.
ID, INSERT_DATE, INSERT_USER
After that I want update for record with all other columns.
But now an essential problem.
While inserting new a record
with or without geometry I get an exception:
no such function: GeometryConstraints (code 1): , while compiling:
INSERT INTO MYTABLE (FID, INSERTDAT,INSERTUSER,ANDROID) VALUES ('-1','2018-02-27','Username,'2');
INSERT INTO MYTABLE (FID, INSERTDAT,INSERTUSER,ANDROID, GEOMETRY) VALUES ('-1','2018-02-27','Username','2',ST_POINT(-1,-1));
INSERT INTO MYTABLE (FID, INSERTDAT,INSERTUSER,ANDROID, GEOMETRY) VALUES ('-1','2018-02-27','Username','2',MakePoint(-1,-1,25832));I created:
SELECT AddGeometryColumn('TABLENAME','GEOMETRY',25832,'GEOMETRY', 'XY',0)
SELECT AddGeometryColumn('test_geom', ‚GEOM‘, 4326, 'POINT', 'XY', 0);https://www.gaia-gis.it/gaia-sins/spatialite-cookbook/html/new-geom.htmlNow I tested all 3 ways (nothing, 0, 1)
Everytime same result.
I’ve seen, trigger working on every update and not only while updating GEOMETRY-column.
Is this a good idea?
It didn't work.
DROP TRIGGER ggi_MYTABLE_GEOMETRY;
CREATE TRIGGER ggi_MYTABLE_GEOMETRY BEFORE INSERT ON MYTABLE
FOR EACH ROW BEGIN
SELECT RAISE(ROLLBACK, 'MYTABLE.GEOMETRY violates Geometry constraint [geom-type or SRID not allowed]')
WHERE NEW.GEOMETRY notnull AND (SELECT geometry_type FROM geometry_columns
WHERE Lower(f_table_name) = Lower('WA_VALVE') AND Lower(f_geometry_column) = Lower('GEOMETRY')
AND GeometryConstraints(NEW.GEOMETRY, geometry_type, srid) = 1) IS NULL;
END;Or do you have an other idea for me?
Thanks
Regards,
Jan