-
Notifications
You must be signed in to change notification settings - Fork 2
GEOPACKAGE_QUERY_R09 geopaparazzi specific
mj10777 edited this page Oct 26, 2018
·
7 revisions
This is a collection of geopaparazzi
specific sql-querys used to determine
- if this database has valid geopackage based on Revision 9
- support for this is now discontinued
Note:
- there is only a
minimal
support of GeoPackage files- due to the lack of extensive samples - or - otherwise the usage of this format
- this has been tested with the only GeoPackage files R9 that I have seen
Luciad_GeoPackage.gpkg
Sample_Geopackage_Haiti.gpkg
--
--> 'List of Database-Designing'
--> 'List of Geopaparazzi Specific Themes'
--> 'List of Geometry Layers-Querys'
--> 'List of RasterLite2 Layers-Querys'
There are 3 categories:
- return only
valid
results- if invalid an empty result will be returned
- return only
invalid
results- if valid an empty result will be returned
- return
minimal
results- if valid or invalid the same results will be returned
* for GeoPackage R9 with a valid `geopackage_contents` table * **GEOPACKAGE_QUERY_EXTENT_VALID_R9** * this query will only return ***valid*** records
SELECT DISTINCT
table_name||';'||
CASE
WHEN data_type = 'features' THEN 'shape'
WHEN data_type = 'tiles' THEN 'tile_data'
WHEN data_type = 'featuresWithRasters' THEN 'location'
END||';'||
CASE
WHEN data_type = 'features' THEN 'GeoPackage_features'
WHEN data_type = 'tiles' THEN 'GeoPackage_tiles'
WHEN data_type = 'featuresWithRasters' THEN 'GeoPackage_featuresWithRasters'
END||';'||
CASE
WHEN data_type = 'features' THEN 'ROWID'
WHEN data_type = 'tiles' THEN
(
SELECT min(zoom_level) FROM tile_matrix_metadata
WHERE t_table_name = ''||table_name||''
)
WHEN data_type = 'featuresWithRasters' THEN 'ROWID'
END||';'||
CASE
WHEN data_type = 'features' THEN '-1'
WHEN data_type = 'tiles' THEN
(
SELECT max(zoom_level) FROM tile_matrix_metadata
WHERE t_table_name = ''||table_name||''
)
WHEN data_type = 'featuresWithRasters' THEN 'picture'
END AS vector_key,
CASE
WHEN data_type = 'features' THEN 'ROWID'
WHEN data_type = 'tiles' THEN
(
SELECT min(zoom_level) FROM tile_matrix_metadata
WHERE t_table_name = ''||table_name||''
)
WHEN data_type = 'featuresWithRasters' THEN 'ROWID'
END||';'||
REPLACE(description,';','-')||';'||
CASE
WHEN srid = '1' THEN '4326'
WHEN srid = '2' THEN '3857'
ELSE srid
END||';'||
REPLACE(identifier,';','-')||';' AS vector_data,
'-1'||';'||
min_x||';'||
min_y||';'||
max_x||';'||
max_y||';'||
last_change AS vector_extent
FROM
geopackage_contents
WHERE
(last_change IS NOT NULL) AND
(min_x IS NOT NULL) AND
(min_y IS NOT NULL) AND
(max_x IS NOT NULL) AND
(max_y IS NOT NULL)
ORDER BY
table_name ASC,
identifier ASC;
This will return 3 fields:
-
vector_key
lakemead_clipped;shape;GeoPackage_features;ROWID;-1
o18229_tif_tiles;tile_data;GeoPackage_tiles;0;4
-
observations;location;GeoPackage_featuresWithRasters;ROWID;picture
-
table_name
-
geometry_field
- for
features
andfeaturesWithRasters
- the (hopefully) default name of the geometry-field
shape
- the (hopefully) default name of the geometry-field
- for
tiles
- the (hopefully) default name of the tiles-field
location
- the (hopefully) default name of the tiles-field
- for
-
data_type
-
features
will be replaced withGeoPackage_features
-
tiles
will be replaced withGeoPackage_tiles
-
featuresWithRasters
will be replaced withGeoPackage_featuresWithRasters
-
-
Primary-Key
:- for
tiles
- the max Zoom-level
- for
features
andfeaturesWithRasters
-
ROWID
: not used
-
- for
-
picture
:- for
featuresWithRasters
- the (hopefully) default name of the tiles-field
picture
- the (hopefully) default name of the tiles-field
- for
features
andtiles
-
-1
: not used
-
- for
-
-
vector_data
lakemead_clipped;Lake Mead (Clipped);4326;-1;
o18229.tif;Hoover Dam Aerial;3857;-1;
-
observations;Observations;3857;-1;
-
geometry_type
:- for features
and
featuresWithRasters`- the geometry_type
- for ``tiles`
-
-1
: not used
-
- for features
-
description
:- any
;
will be replaced with-
- any
-
srid
: the set srid- if
1
was used: will set as4326
- if
2
was used: will set as3857
- if
-
identifier
:- any
;
will be replaced with-
- any
-
-
vector_extent
-
-1;-114.739703991949;36.0133552500798;-114.7260476107;36.0226841914896;2013-01-18T17:37:23.000Z
-
nothing
: not used -
bounds
: separated with a,
x_min
y_min
x_max
y_max
-
date-time stamp
: not used by geopaparazzi
-
-
-- This will return the same 3 fields above:
- only those fields have no valid value
- will return the
field-name
- in this way we can attempt why it is invalid
- thus need not be loaded into geopaparazzi
- will return the
SELECT DISTINCT
table_name||';'||
CASE
WHEN data_type = 'features' THEN 'shape'
WHEN data_type = 'tiles' THEN 'tile_data'
WHEN data_type = 'featuresWithRasters' THEN 'location'
END||';'||
CASE
WHEN data_type = 'features' THEN 'GeoPackage_features'
WHEN data_type = 'tiles' THEN 'GeoPackage_tiles'
WHEN data_type = 'featuresWithRasters' THEN 'GeoPackage_featuresWithRasters'
END||';'||
CASE
WHEN data_type = 'features' THEN 'ROWID'
WHEN data_type = 'tiles' THEN
(
SELECT min(zoom_level) FROM tile_matrix_metadata
WHERE t_table_name = ''||table_name||''
)
WHEN data_type = 'featuresWithRasters' THEN 'ROWID'
END||';'||
CASE
WHEN data_type = 'features' THEN '-1'
WHEN data_type = 'tiles' THEN
(
SELECT max(zoom_level) FROM tile_matrix_metadata
WHERE t_table_name = ''||table_name||''
)
WHEN data_type = 'featuresWithRasters' THEN 'picture'
END AS vector_key,
REPLACE(identifier,';','-')||';'||
REPLACE(description,';','-')||';'||
'-1'||';'||
CASE
WHEN srid = '1' THEN '4326'
WHEN srid = '2' THEN '3857'
ELSE srid
END||';'||
srid||';'||
REPLACE(identifier,';','-')||';' AS vector_data,
'-1'||';'||
CASE
WHEN min_x IS NULL
THEN 'min_x'
ELSE min_x
END||','||
CASE
WHEN min_y IS NULL
THEN 'min_y'
ELSE min_y
END||','||
CASE
WHEN max_x IS NULL
THEN 'max_x'
ELSE max_x
END||','||
CASE
WHEN max_y IS NULL
THEN 'max_y'
ELSE max_y
END||';'||
CASE
WHEN last_change IS NULL
THEN 'last_change'
ELSE last_change
END
AS vector_extent
FROM
geopackage_contents
WHERE
(last_change IS NULL) OR
(min_x IS NULL) OR
(min_y IS NULL) OR
(max_x IS NULL) OR
(max_y IS NULL)
ORDER BY
table_name ASC,
identifier ASC;
--
* This query will attempt to return information that should never fail: * **GEOPACKAGE_QUERY_EXTENT_LIST_R9** * this query will retrieve minimal information on a ***valid*** or ***invalid*** databaseSELECT DISTINCT
table_name||';'||
CASE
WHEN data_type = 'features' THEN 'shape'
WHEN data_type = 'tiles' THEN 'tile_data'
WHEN data_type = 'featuresWithRasters' THEN 'location'
END||';'||
CASE
WHEN data_type = 'features' THEN 'GeoPackage_features'
WHEN data_type = 'tiles' THEN 'GeoPackage_tiles'
WHEN data_type = 'featuresWithRasters' THEN 'GeoPackage_featuresWithRasters'
END||';'||
CASE
WHEN data_type = 'features' THEN 'ROWID'
WHEN data_type = 'tiles' THEN
(
SELECT min(zoom_level) FROM tile_matrix_metadata
WHERE t_table_name = ''||table_name||''
)
WHEN data_type = 'featuresWithRasters' THEN 'ROWID'
END||';'||
CASE
WHEN data_type = 'features' THEN '-1'
WHEN data_type = 'tiles' THEN
(
SELECT max(zoom_level) FROM tile_matrix_metadata
WHERE t_table_name = ''||table_name||''
)
WHEN data_type = 'featuresWithRasters' THEN 'picture'
END AS vector_key
FROM
geopackage_contents
ORDER BY
table_name ASC,
identifier ASC;
This will return the first 2 fields above:
- this query may not be needed since
-
GEOPACKAGE_QUERY_EXTENT_INVALID_R9
- will now be used
-
GEOPACKAGE_QUERY_EXTENT_INVALID_R9
2014-05-10: Mark Johnson, Berlin Germany