Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Difference From 4afe976081fb4cff To 25bca24c55175a98
2012-09-29
| ||
02:48 |
Add convenience API for creating tiles tables and adding zoom levels.
Also update geopackage_contents to define an informative extent. check-in: f30b241aee user: bradh tags: trunk | |
2012-09-22
| ||
03:33 |
Update to reflect 2012-09-21 version of spec.
Adds geopackage_contents and manifest tables, updates tile_table_metadata table. check-in: 25bca24c55 user: bradh tags: trunk | |
2012-09-16
| ||
10:10 | Update trigger routines to match current spec. Update tests and add new tests to match. check-in: 4afe976081 user: bradh tags: trunk | |
10:09 | Remove duplicate newlines. check-in: 610eecc80b user: bradh tags: trunk | |
Changes to src/gpkgCreateBaseTables.c.
53 53 char *sql_stmt = NULL; 54 54 sqlite3 *sqlite = NULL; 55 55 char *errMsg = NULL; 56 56 int ret = 0; 57 57 int i = 0; 58 58 59 59 const char* tableSchemas[] = { 60 + "CREATE TABLE geopackage_contents (\n" 61 + "table_name TEXT NOT NULL PRIMARY KEY,\n" 62 + "data_type TEXT NOT NULL,\n" 63 + "identifier TEXT NOT NULL DEFAULT '',\n" 64 + "description TEXT NOT NULL DEFAULT '',\n" 65 + "last_change TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ',CURRENT_TIMESTAMP)));", 66 + 60 67 /* GeoPackage specification Table 19/20 */ 61 68 "CREATE TABLE raster_columns (\n" 62 69 "r_table_name TEXT NOT NULL,\n" 63 70 "r_raster_column TEXT NOT NULL,\n" 64 71 "srid INTEGER NOT NULL DEFAULT 0,\n" 65 72 "CONSTRAINT pk_rc PRIMARY KEY (r_table_name, r_raster_column) ON CONFLICT ROLLBACK,\n" 66 73 "CONSTRAINT fk_rc_r_srid FOREIGN KEY (srid) REFERENCES spatial_ref_sys(srid));", ................................................................................ 110 117 "WHERE NEW.r_raster_column <> lower(NEW.r_raster_column);\n" 111 118 "END;", 112 119 113 120 /* GeoPackage specification Table 23/24 */ 114 121 /* TODO: see if there is a nicer way to manage this using a VIEW */ 115 122 "CREATE TABLE tile_table_metadata (\n" 116 123 "t_table_name TEXT NOT NULL PRIMARY KEY,\n" 117 - "min_x DOUBLE NOT NULL DEFAULT -180.0,\n" 118 - "min_y DOUBLE NOT NULL DEFAULT -90.0,\n" 119 - "max_x DOUBLE NOT NULL DEFAULT 180.0,\n" 120 - "max_y DOUBLE NOT NULL DEFAULT 90.0 ,\n" 121 124 "is_times_two_zoom INTEGER NOT NULL DEFAULT 1\n" 122 125 ");", 123 126 124 127 /* The next four triggers are from GeoPackage specification Table 25 */ 125 128 "CREATE TRIGGER 'tile_table_metadata_t_table_name_insert'\n" 126 129 "BEFORE INSERT ON 'tile_table_metadata'\n" 127 130 "FOR EACH ROW BEGIN\n" ................................................................................ 371 374 "CREATE TRIGGER 'metadata_reference_timestamp_update'\n" 372 375 "BEFORE UPDATE OF 'timestamp' ON 'metadata_reference'\n" 373 376 "FOR EACH ROW BEGIN\n" 374 377 "SELECT RAISE(ROLLBACK, 'update on table metadata_reference violates constraint: timestamp must be a valid time in ISO 8601 \"yyyy-mm-ddThh-mm-ss.cccZ\" form')\n" 375 378 "WHERE NOT (NEW.timestamp GLOB '[1-2][0-9][0-9][0-9]-[0-1][0-9]-[1-3][1-9]T[0-2][0-9]:[0-5][0-9]:[0-5][0-9].[0-9][0-9][0-9]Z'\n" 376 379 "AND strftime('%s',NEW.timestamp) NOT NULL);\n" 377 380 "END;", 381 + 382 + "CREATE TABLE manifest (\n" 383 + "id TEXT NOT NULL PRIMARY KEY,\n" 384 + "manifest TEXT NOT NULL\n" 385 + ");", 378 386 379 387 NULL 380 388 }; 381 389 382 390 for (i = 0; tableSchemas[i] != NULL; ++i) 383 391 { 384 392 sql_stmt = sqlite3_mprintf("%s", tableSchemas[i]);
Changes to test/check_createBaseTables.c.
92 92 if (ret != SQLITE_OK) { 93 93 fprintf(stderr, "Unexpected INSERT INTO raster_columns result: %i, (%s)\n", ret, err_msg); 94 94 sqlite3_free (err_msg); 95 95 return -101; 96 96 } 97 97 98 98 /* check tile_table_metadata table is OK */ 99 - ret = sqlite3_exec (db_handle, "INSERT INTO tile_table_metadata VALUES (\"sample_matrix_tiles\", -179.0, -89.0, 179.0, 89.0, 1)", NULL, NULL, &err_msg); 99 + ret = sqlite3_exec (db_handle, "INSERT INTO tile_table_metadata VALUES (\"sample_matrix_tiles\", 1)", NULL, NULL, &err_msg); 100 100 if (ret != SQLITE_OK) { 101 101 fprintf(stderr, "Unexpected INSERT INTO tile_table_metadata result: %i, (%s)\n", ret, err_msg); 102 102 sqlite3_free (err_msg); 103 103 return -102; 104 104 } 105 105 106 106 /* check tile_matrix_metadata table is OK */ ................................................................................ 156 156 157 157 /* check creation when the tables already exist */ 158 158 ret = sqlite3_exec (db_handle, "SELECT gpkgCreateBaseTables()", NULL, NULL, &err_msg); 159 159 if (ret != SQLITE_ERROR) { 160 160 fprintf(stderr, "Unexpected duplicate gpkgCreateBaseTables() result: %i, (%s)\n", ret, err_msg); 161 161 return -110; 162 162 } 163 - if (strcmp("table raster_columns already exists", err_msg) != 0) 163 + if (strcmp("table geopackage_contents already exists", err_msg) != 0) 164 164 { 165 165 fprintf(stderr, "Unexpected duplicate gpkgCreateBaseTables() error message: %s\n", err_msg); 166 166 return -111; 167 167 } 168 168 sqlite3_free (err_msg); 169 169 170 170 ret = sqlite3_close (db_handle);