mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-01-11 09:20:17 +01:00
Fixed interleaved sqlite spatial query.
This commit is contained in:
parent
edbd790268
commit
06c8ef8f88
@ -366,50 +366,50 @@ func (ss *SqliteSession) interleavedSpatialQuery(
|
|||||||
zmin, zmax = order(zmin, zmax)
|
zmin, zmax = order(zmin, zmax)
|
||||||
cub := common.Cuboid{P1: c1, P2: c2}
|
cub := common.Cuboid{P1: c1, P2: c2}
|
||||||
rangeStmt := ss.txStmt(ss.backend.rangeStmt)
|
rangeStmt := ss.txStmt(ss.backend.rangeStmt)
|
||||||
var (
|
|
||||||
err error
|
zcode := zmin
|
||||||
rows *sql.Rows
|
|
||||||
)
|
|
||||||
loop:
|
loop:
|
||||||
// log.Printf("query %d %d\n", zmin, zmax)
|
|
||||||
if rows, err = rangeStmt.Query(zmin, zmax); err != nil {
|
rows, err := rangeStmt.Query(zcode, zmax)
|
||||||
log.Printf("Error in range query: %s\n", err)
|
if err != nil {
|
||||||
|
log.Printf("error: fetching range failed: %s\n", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
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 scanning row: %s\n", err)
|
|
||||||
rows.Close()
|
rows.Close()
|
||||||
|
log.Printf("error: scanning row failed: %s\n", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// log.Printf("zcode: %d\n", zcode)
|
|
||||||
c := common.InterleavedToCoord(zcode)
|
c := common.InterleavedToCoord(zcode)
|
||||||
if cub.Contains(c) {
|
if cub.Contains(c) {
|
||||||
var encodedKey []byte
|
key := common.StringToBytes(common.CoordToPlain(c))
|
||||||
if encodedKey, err = common.EncodeStringToBytes(common.CoordToPlain(c)); err != nil {
|
//fmt.Printf("sending: %q\n", c)
|
||||||
log.Printf("Key encoding failed: %s\n", err)
|
|
||||||
rows.Close()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
select {
|
select {
|
||||||
case blocks <- Block{Key: encodedKey, Data: data}:
|
case blocks <- Block{Key: key, Data: data}:
|
||||||
case <-done:
|
case <-done:
|
||||||
rows.Close()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else { // Left the cuboid
|
} else {
|
||||||
// log.Printf("Left cuboid %d\n", zcode)
|
if err = rows.Close(); err != nil {
|
||||||
rows.Close()
|
log.Printf("error: closing range failed: %s\n", err)
|
||||||
zmin = common.BigMin(zmin, zmax, zcode)
|
return
|
||||||
|
}
|
||||||
|
zcode = common.BigMin(zmin, zmax, zcode)
|
||||||
goto loop
|
goto loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = rows.Err(); err != nil {
|
if err = rows.Err(); err != nil {
|
||||||
log.Printf("Error in range query: %s\n", err)
|
log.Printf("error: iterating range failed: %s\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = rows.Close(); err != nil {
|
||||||
|
log.Printf("error: closing range failed: %s\n", err)
|
||||||
}
|
}
|
||||||
rows.Close()
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user