1
0
forked from MTSR/mapserver
This commit is contained in:
NatureFreshMilk 2019-01-23 15:13:44 +01:00
parent e88787a75a
commit 7622760c05
2 changed files with 8 additions and 3 deletions

View File

@ -13,6 +13,8 @@ delete from objects where posx = ? and posy = ? and posz = ?
`
func (db *Sqlite3Accessor) RemoveMapData(pos coords.MapBlockCoords) error {
mutex.Lock()
defer mutex.Unlock()
_, err := db.db.Exec(removeMapDataQuery, pos.X, pos.Y, pos.Z)
return err
}
@ -30,6 +32,8 @@ values(?, ?, ?)
`
func (db *Sqlite3Accessor) AddMapData(data MapObject) error {
mutex.Lock()
defer mutex.Unlock()
tx, err := db.db.Begin()

View File

@ -7,6 +7,8 @@ import (
"sync"
)
var mutex = &sync.RWMutex{}
const getTileQuery = `
select data,mtime from tiles t
where t.layerid = ?
@ -48,7 +50,6 @@ func (db *Sqlite3Accessor) GetTile(pos *coords.TileCoords) (*Tile, error) {
return nil, nil
}
var mutex = &sync.RWMutex{}
const setTileQuery = `
insert or replace into tiles(x,y,zoom,layerid,data,mtime)
@ -57,8 +58,8 @@ values(?, ?, ?, ?, ?, ?)
func (db *Sqlite3Accessor) SetTile(tile *Tile) error {
mutex.Lock()
defer mutex.Unlock()
_, err := db.db.Exec(setTileQuery, tile.Pos.X, tile.Pos.Y, tile.Pos.Zoom, tile.Pos.LayerId, tile.Data, tile.Mtime)
mutex.Unlock()
return err
}
@ -69,8 +70,8 @@ where x = ? and y = ? and zoom = ? and layerid = ?
func (db *Sqlite3Accessor) RemoveTile(pos *coords.TileCoords) error {
mutex.Lock()
defer mutex.Unlock()
_, err := db.db.Exec(removeTileQuery, pos.X, pos.Y, pos.Zoom, pos.LayerId)
mutex.Unlock()
return err
}