Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add spatial views #6

Closed
brownag opened this issue May 22, 2023 · 2 comments · Fixed by #12
Closed

add spatial views #6

brownag opened this issue May 22, 2023 · 2 comments · Fixed by #12
Assignees
Labels
enhancement New feature or request

Comments

@brownag
Copy link
Owner

brownag commented May 22, 2023

Add a convenience method for the creation of spatial views: https://gdal.org/drivers/vector/gpkg.html#spatial-views

For example:

CREATE VIEW my_view AS SELECT foo.fid AS OGC_FID, foo.geom, ... FROM foo JOIN another_table ON foo.some_id = another_table.other_id
INSERT INTO gpkg_contents (table_name, identifier, data_type, srs_id) VALUES ( 'my_view', 'my_view', 'features', 4326)
INSERT INTO gpkg_geometry_columns (table_name, column_name, geometry_type_name, srs_id, z, m) values ('my_view', 'my_geom', 'GEOMETRY', 4326, 0, 0)
@brownag brownag added the enhancement New feature or request label May 22, 2023
@brownag brownag self-assigned this May 22, 2023
@brownag
Copy link
Owner Author

brownag commented Jun 17, 2023

Also, add support for this!

Starting with GDAL 3.7.1, it is possible to define a geometry column as the result of a Spatialite spatial function. Note however that this is an extension likely to be non-interoperable with other software that does not activate Spatialite for the SQLite3 database connection. Such geometry column should be registered into the gpkg_extensions using the gdal_spatialite_computed_geom_column extension name (cf GeoPackage Spatialite computed geometry column extension), like below:

CREATE VIEW my_view AS SELECT foo.fid AS OGC_FID, AsGBP(ST_Multi(foo.geom)) FROM foo;
INSERT INTO gpkg_contents (table_name, identifier, data_type, srs_id) VALUES ('my_view', 'my_view', 'features', 4326);
INSERT INTO gpkg_geometry_columns (table_name, column_name, geometry_type_name, srs_id, z, m) VALUES ('my_view', 'my_geom', 'MULTIPOLYGON', 4326, 0, 0);
INSERT INTO gpkg_extensions (table_name, column_name, extension_name, definition, scope) VALUES ('my_view', 'my_geom', 'gdal_spatialite_computed_geom_column', 'https://gdal.org/drivers/vector/gpkg_spatialite_computed_geom_column.html', 'read-write');

@brownag
Copy link
Owner Author

brownag commented Dec 7, 2023

Closed by #12

@brownag brownag linked a pull request Dec 7, 2023 that will close this issue
@brownag brownag closed this as completed Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant