mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-24 17:20: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
|
rows *sql.Rows
|
||||||
)
|
)
|
||||||
if rows, err = rangeStmt.Query(zmin, zmax); err != nil {
|
if rows, err = rangeStmt.Query(zmin, zmax); err != nil {
|
||||||
|
log.Printf("Error in range query: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var zcode int64
|
var zcode int64
|
||||||
var data []byte
|
var data []byte
|
||||||
if err = rows.Scan(&zcode, &data); err != nil {
|
if err = rows.Scan(&zcode, &data); err != nil {
|
||||||
log.Printf("Error in range query: %s", err)
|
log.Printf("Error in scanning row: %s", err)
|
||||||
break
|
rows.Close()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
c := common.InterleavedToCoord(zcode)
|
c := common.InterleavedToCoord(zcode)
|
||||||
if cub.Contains(c) {
|
if cub.Contains(c) {
|
||||||
var encodedKey []byte
|
var encodedKey []byte
|
||||||
if encodedKey, err = common.EncodeStringToBytes(common.CoordToPlain(c)); err != nil {
|
if encodedKey, err = common.EncodeStringToBytes(common.CoordToPlain(c)); err != nil {
|
||||||
log.Printf("Key encoding failed: %s", err)
|
log.Printf("Key encoding failed: %s", err)
|
||||||
break
|
rows.Close()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
case blocks <- Block{Key: encodedKey, Data: data}:
|
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.
|
// Ordering should not be necessary.
|
||||||
from, to := order(common.CoordToPlain(a), common.CoordToPlain(b))
|
from, to := order(common.CoordToPlain(a), common.CoordToPlain(b))
|
||||||
if rows, err = rangeStmt.Query(from, to); err != nil {
|
if rows, err = rangeStmt.Query(from, to); err != nil {
|
||||||
|
log.Printf("Error in range query: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var key int64
|
var key int64
|
||||||
var data []byte
|
var data []byte
|
||||||
if err = rows.Scan(&key, &data); err != nil {
|
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
|
break
|
||||||
}
|
}
|
||||||
var encodedKey []byte
|
var encodedKey []byte
|
||||||
|
Loading…
Reference in New Issue
Block a user