mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-23 16:50:18 +01:00
Improved error handling of SQLite spatial queries a bit.
This commit is contained in:
parent
f7a8c1fdec
commit
f82216807e
12
sqlite.go
12
sqlite.go
@ -333,21 +333,24 @@ func (ss *SqliteSession) interleavedSpatialQuery(first, second []byte, done chan
|
||||
rows *sql.Rows
|
||||
)
|
||||
if rows, err = rangeStmt.Query(zmin, zmax); err != nil {
|
||||
log.Printf("Error in range query: %s", err)
|
||||
return
|
||||
}
|
||||
for rows.Next() {
|
||||
var zcode int64
|
||||
var data []byte
|
||||
if err = rows.Scan(&zcode, &data); err != nil {
|
||||
log.Printf("Error in range query: %s", err)
|
||||
break
|
||||
log.Printf("Error in scanning row: %s", err)
|
||||
rows.Close()
|
||||
return
|
||||
}
|
||||
c := common.InterleavedToCoord(zcode)
|
||||
if cub.Contains(c) {
|
||||
var encodedKey []byte
|
||||
if encodedKey, err = common.EncodeStringToBytes(common.CoordToPlain(c)); err != nil {
|
||||
log.Printf("Key encoding failed: %s", err)
|
||||
break
|
||||
rows.Close()
|
||||
return
|
||||
}
|
||||
select {
|
||||
case blocks <- Block{Key: encodedKey, Data: data}:
|
||||
@ -409,13 +412,14 @@ func (ss *SqliteSession) plainSpatialQuery(first, second []byte, done chan struc
|
||||
// Ordering should not be necessary.
|
||||
from, to := order(common.CoordToPlain(a), common.CoordToPlain(b))
|
||||
if rows, err = rangeStmt.Query(from, to); err != nil {
|
||||
log.Printf("Error in range query: %s", err)
|
||||
return
|
||||
}
|
||||
for rows.Next() {
|
||||
var key int64
|
||||
var data []byte
|
||||
if err = rows.Scan(&key, &data); err != nil {
|
||||
log.Printf("Error in range query: %s", err)
|
||||
log.Printf("Error in scanning row: %s", err)
|
||||
break
|
||||
}
|
||||
var encodedKey []byte
|
||||
|
Loading…
Reference in New Issue
Block a user