Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | fixing CheckSpatialIndex accordingly to recent changes introduce by SQLite 3.8.5 |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
aca5fb5346bcd74143ac25adf65b5fd2 |
User & Date: | sandro 2014-07-05 20:57:02 |
Context
2014-07-09
| ||
15:29 | fixing the MSVC build scripts check-in: 1ff8a143ee user: sandro tags: trunk | |
2014-07-05
| ||
20:57 | fixing CheckSpatialIndex accordingly to recent changes introduce by SQLite 3.8.5 check-in: aca5fb5346 user: sandro tags: trunk | |
2014-06-29
| ||
11:34 | fixing a bug in SHP import - MultiPoint Z, M and ZM check-in: 25557ad55e user: sandro tags: trunk | |
Changes
Changes to src/spatialite/spatialite.c.
5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 .... 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 .... 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 .... 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 ..... 17242 17243 17244 17245 17246 17247 17248 17249 17250 17251 17252 17253 17254 17255 17256 17257 17258 17259 ..... 17267 17268 17269 17270 17271 17272 17273 17274 17275 17276 17277 17278 17279 17280 17281 17282 17283 ..... 26024 26025 26026 26027 26028 26029 26030 26031 26032 26033 26034 26035 26036 26037 26038 ..... 26108 26109 26110 26111 26112 26113 26114 26115 26116 26117 26118 26119 26120 26121 26122 26123 26124 26125 26126 26127 26128 26129 26130 26131 |
char sql[1024]; char *sql_statement; int ret; int is_defined = 0; sqlite3_stmt *stmt; sqlite3_int64 count_geom; sqlite3_int64 count_rtree; double g_xmin; double g_ymin; double g_xmax; double g_ymax; int ok_g_xmin; int ok_g_ymin; int ok_g_xmax; ................................................................................ } sqlite3_finalize (stmt); if (count_geom != count_rtree) { /* unexpected count difference */ goto mismatching_zero; } /* checking the geometry-table against the corresponding R*Tree */ sql_statement = sqlite3_mprintf ("SELECT MbrMinX(g.\"%s\"), MbrMinY(g.\"%s\"), " "MbrMaxX(g.\"%s\"), MbrMaxY(g.\"%s\"), i.xmin, i.ymin, i.xmax, i.ymax\n" "FROM \"%s\" AS g\nLEFT JOIN \"%s\" AS i ON (g.ROWID = i.pkid)", xgeom, xgeom, xgeom, xgeom, xtable, xidx_name); ret = sqlite3_prepare_v2 (sqlite, sql_statement, strlen (sql_statement), &stmt, NULL); sqlite3_free (sql_statement); if (ret != SQLITE_OK) { spatialite_e ("CheckSpatialIndex SQL error: %s\n", sqlite3_errmsg (sqlite)); goto err_label; } while (1) { ret = sqlite3_step (stmt); if (ret == SQLITE_DONE) break; if (ret == SQLITE_ROW) { /* checking a row */ ok_g_xmin = 1; ok_g_ymin = 1; ok_g_xmax = 1; ok_g_ymax = 1; ok_i_xmin = 1; ok_i_ymin = 1; ok_i_xmax = 1; ok_i_ymax = 1; if (sqlite3_column_type (stmt, 0) == SQLITE_NULL) ok_g_xmin = 0; else g_xmin = sqlite3_column_double (stmt, 0); if (sqlite3_column_type (stmt, 1) == SQLITE_NULL) ok_g_ymin = 0; else g_ymin = sqlite3_column_double (stmt, 1); if (sqlite3_column_type (stmt, 2) == SQLITE_NULL) ok_g_xmax = 0; else g_xmax = sqlite3_column_double (stmt, 2); if (sqlite3_column_type (stmt, 3) == SQLITE_NULL) ok_g_ymax = 0; else g_ymax = sqlite3_column_double (stmt, 3); if (sqlite3_column_type (stmt, 4) == SQLITE_NULL) ok_i_xmin = 0; else i_xmin = sqlite3_column_double (stmt, 4); if (sqlite3_column_type (stmt, 5) == SQLITE_NULL) ok_i_ymin = 0; else i_ymin = sqlite3_column_double (stmt, 5); if (sqlite3_column_type (stmt, 6) == SQLITE_NULL) ok_i_xmax = 0; else i_xmax = sqlite3_column_double (stmt, 6); if (sqlite3_column_type (stmt, 7) == SQLITE_NULL) ok_i_ymax = 0; else i_ymax = sqlite3_column_double (stmt, 7); if (eval_rtree_entry (ok_g_xmin, g_xmin, ok_i_xmin, i_xmin) == 0) goto mismatching; if (eval_rtree_entry (ok_g_ymin, g_ymin, ok_i_ymin, i_ymin) == 0) goto mismatching; if (eval_rtree_entry (ok_g_xmax, g_xmax, ok_i_xmax, i_xmax) == 0) goto mismatching; if (eval_rtree_entry (ok_g_ymax, g_ymax, ok_i_ymax, i_ymax) == 0) goto mismatching; } else { spatialite_e ("sqlite3_step() error: %s\n", sqlite3_errmsg (sqlite)); sqlite3_finalize (stmt); goto err_label; } } /* we have now to finalize the query [memory cleanup] */ sqlite3_finalize (stmt); /* now we'll check the R*Tree against the corresponding geometry-table */ sql_statement = sqlite3_mprintf ("SELECT MbrMinX(g.\"%s\"), MbrMinY(g.\"%s\"), " "MbrMaxX(g.\"%s\"), MbrMaxY(g.\"%s\"), i.xmin, i.ymin, i.xmax, i.ymax\n" "FROM \"%s\" AS i\nLEFT JOIN \"%s\" AS g ON (g.ROWID = i.pkid)", xgeom, xgeom, xgeom, xgeom, xidx_name, xtable); ................................................................................ { ret = sqlite3_step (stmt); if (ret == SQLITE_DONE) break; if (ret == SQLITE_ROW) { /* checking a row */ ok_g_xmin = 1; ok_g_ymin = 1; ok_g_xmax = 1; ok_g_ymax = 1; ok_i_xmin = 1; ok_i_ymin = 1; ok_i_xmax = 1; ................................................................................ spatialite_e ("sqlite3_step() error: %s\n", sqlite3_errmsg (sqlite)); sqlite3_finalize (stmt); goto err_label; } } sqlite3_finalize (stmt); strcpy (sql, "Check SpatialIndex: is valid"); updateSpatiaLiteHistory (sqlite, (const char *) table, (const char *) geom, sql); free (xgeom); free (xtable); free (xidx_name); return 1; ................................................................................ line = geo->FirstLinestring; while (line) { /* Linestrings */ l = gaiaGeodesicTotalLength (a, b, rf, line-> DimensionModel, line->Coords, line->Points); if (l < 0.0) { length = -1.0; break; } length += l; line = line->Next; ................................................................................ polyg = geo->FirstPolygon; while (polyg) { /* exterior Ring */ ring = polyg->Exterior; l = gaiaGeodesicTotalLength (a, b, rf, ring->DimensionModel, ring->Coords, ring->Points); if (l < 0.0) { length = -1.0; break; } length += l; for (ib = 0; ................................................................................ } length += l; for (ib = 0; ib < polyg->NumInteriors; ib++) { /* interior Rings */ ring = polyg->Interiors + ib; l = gaiaGeodesicTotalLength (a, b, rf, ring->DimensionModel, ring->Coords, ring->Points); if (l < 0.0) { length = -1.0; break; } ................................................................................ polyg = geo->FirstPolygon; while (polyg) { /* exterior Ring */ ring = polyg->Exterior; length += gaiaGreatCircleTotalLength (a, b, ring->DimensionModel, ring->Coords, ring->Points); for (ib = 0; ib < polyg->NumInteriors; ib++) { /* interior Rings */ ring = polyg->Interiors + ib; length += gaiaGreatCircleTotalLength (a, b, ring->DimensionModel, ring->Coords, ring->Points); } polyg = polyg->Next; } } sqlite3_result_double (context, length); |
> < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > > > > < | > | > | > | > | > | > | > | |
5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 .... 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 .... 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 .... 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 ..... 17158 17159 17160 17161 17162 17163 17164 17165 17166 17167 17168 17169 17170 17171 17172 17173 17174 17175 17176 ..... 17184 17185 17186 17187 17188 17189 17190 17191 17192 17193 17194 17195 17196 17197 17198 17199 17200 17201 17202 17203 ..... 25944 25945 25946 25947 25948 25949 25950 25951 25952 25953 25954 25955 25956 25957 25958 25959 ..... 26029 26030 26031 26032 26033 26034 26035 26036 26037 26038 26039 26040 26041 26042 26043 26044 26045 26046 26047 26048 26049 26050 26051 26052 26053 26054 |
char sql[1024]; char *sql_statement; int ret; int is_defined = 0; sqlite3_stmt *stmt; sqlite3_int64 count_geom; sqlite3_int64 count_rtree; sqlite3_int64 count_rev = 0; double g_xmin; double g_ymin; double g_xmax; double g_ymax; int ok_g_xmin; int ok_g_ymin; int ok_g_xmax; ................................................................................ } sqlite3_finalize (stmt); if (count_geom != count_rtree) { /* unexpected count difference */ goto mismatching_zero; } /* now we'll check the R*Tree against the corresponding geometry-table */ sql_statement = sqlite3_mprintf ("SELECT MbrMinX(g.\"%s\"), MbrMinY(g.\"%s\"), " "MbrMaxX(g.\"%s\"), MbrMaxY(g.\"%s\"), i.xmin, i.ymin, i.xmax, i.ymax\n" "FROM \"%s\" AS i\nLEFT JOIN \"%s\" AS g ON (g.ROWID = i.pkid)", xgeom, xgeom, xgeom, xgeom, xidx_name, xtable); ................................................................................ { ret = sqlite3_step (stmt); if (ret == SQLITE_DONE) break; if (ret == SQLITE_ROW) { /* checking a row */ count_rev++; ok_g_xmin = 1; ok_g_ymin = 1; ok_g_xmax = 1; ok_g_ymax = 1; ok_i_xmin = 1; ok_i_ymin = 1; ok_i_xmax = 1; ................................................................................ spatialite_e ("sqlite3_step() error: %s\n", sqlite3_errmsg (sqlite)); sqlite3_finalize (stmt); goto err_label; } } sqlite3_finalize (stmt); if (count_geom != count_rev) goto mismatching; strcpy (sql, "Check SpatialIndex: is valid"); updateSpatiaLiteHistory (sqlite, (const char *) table, (const char *) geom, sql); free (xgeom); free (xtable); free (xidx_name); return 1; ................................................................................ line = geo->FirstLinestring; while (line) { /* Linestrings */ l = gaiaGeodesicTotalLength (a, b, rf, line->DimensionModel, line-> Coords, line-> Points); if (l < 0.0) { length = -1.0; break; } length += l; line = line->Next; ................................................................................ polyg = geo->FirstPolygon; while (polyg) { /* exterior Ring */ ring = polyg->Exterior; l = gaiaGeodesicTotalLength (a, b, rf, ring-> DimensionModel, ring-> Coords, ring-> Points); if (l < 0.0) { length = -1.0; break; } length += l; for (ib = 0; ................................................................................ } length += l; for (ib = 0; ib < polyg->NumInteriors; ib++) { /* interior Rings */ ring = polyg->Interiors + ib; l = gaiaGeodesicTotalLength (a, b, rf, ring-> DimensionModel, ring->Coords, ring->Points); if (l < 0.0) { length = -1.0; break; } ................................................................................ polyg = geo->FirstPolygon; while (polyg) { /* exterior Ring */ ring = polyg->Exterior; length += gaiaGreatCircleTotalLength (a, b, ring-> DimensionModel, ring->Coords, ring->Points); for (ib = 0; ib < polyg->NumInteriors; ib++) { /* interior Rings */ ring = polyg->Interiors + ib; length += gaiaGreatCircleTotalLength (a, b, ring-> DimensionModel, ring->Coords, ring->Points); } polyg = polyg->Next; } } sqlite3_result_double (context, length); |
Changes to test/check_spatialindex.c.
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
....
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
|
if (results[1] == NULL) { fprintf (stderr, "unexpected NULL CheckSpatialIndex(rowid-1)\n"); sqlite3_free_table (results); sqlite3_close (handle); return -208; } if (strcmp (results[1], "0") != 0) { fprintf (stderr, "unexpected CheckSpatialIndex(rowid-1): %s\n", results[1]); sqlite3_free_table (results); sqlite3_close (handle); return -209; } ................................................................................ if (results[1] == NULL) { fprintf (stderr, "unexpected NULL RecoverSpatialIndex(rowid-1)\n"); sqlite3_free_table (results); sqlite3_close (handle); return -212; } if (strcmp (results[1], "0") != 0) { fprintf (stderr, "unexpected RecoverSpatialIndex(rowid-1): %s\n", results[1]); sqlite3_free_table (results); sqlite3_close (handle); return -213; } |
|
|
|
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
....
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
|
if (results[1] == NULL) { fprintf (stderr, "unexpected NULL CheckSpatialIndex(rowid-1)\n"); sqlite3_free_table (results); sqlite3_close (handle); return -208; } if (strcmp (results[1], "1") != 0) { fprintf (stderr, "unexpected CheckSpatialIndex(rowid-1): %s\n", results[1]); sqlite3_free_table (results); sqlite3_close (handle); return -209; } ................................................................................ if (results[1] == NULL) { fprintf (stderr, "unexpected NULL RecoverSpatialIndex(rowid-1)\n"); sqlite3_free_table (results); sqlite3_close (handle); return -212; } if (strcmp (results[1], "1") != 0) { fprintf (stderr, "unexpected RecoverSpatialIndex(rowid-1): %s\n", results[1]); sqlite3_free_table (results); sqlite3_close (handle); return -213; } |