2019-01-18 17:51:10 +03:00
|
|
|
package mapobjectdb
|
2019-01-18 15:50:59 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
"mapserver/coords"
|
|
|
|
)
|
|
|
|
|
2019-01-23 10:20:27 +03:00
|
|
|
/*
|
|
|
|
sqlite perf: https://stackoverflow.com/questions/1711631/improve-insert-per-second-performance-of-sqlite?rq=1
|
|
|
|
PRAGMA synchronous = OFF
|
|
|
|
PRAGMA journal_mode = MEMORY
|
|
|
|
*/
|
|
|
|
|
2019-01-21 17:13:33 +03:00
|
|
|
type Tile struct {
|
|
|
|
Pos *coords.TileCoords
|
|
|
|
Data []byte
|
|
|
|
Mtime int64
|
|
|
|
}
|
|
|
|
|
2019-01-18 17:51:10 +03:00
|
|
|
type MapObject struct {
|
2019-01-18 15:50:59 +03:00
|
|
|
//mapblock position
|
2019-01-23 10:37:40 +03:00
|
|
|
MBPos *coords.MapBlockCoords
|
2019-01-18 17:18:42 +03:00
|
|
|
|
2019-01-18 15:50:59 +03:00
|
|
|
//block position
|
|
|
|
X, Y, Z int
|
2019-01-18 17:10:46 +03:00
|
|
|
|
2019-01-18 17:18:42 +03:00
|
|
|
Type string
|
|
|
|
Data string
|
|
|
|
Mtime int64
|
2019-01-23 10:37:40 +03:00
|
|
|
Attributes map[string]string
|
2019-01-18 15:50:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type SearchQuery struct {
|
|
|
|
//block position (not mapblock)
|
|
|
|
Pos1, Pos2 coords.MapBlockCoords
|
2019-01-18 17:10:46 +03:00
|
|
|
Type string
|
2019-01-18 15:50:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type DBAccessor interface {
|
|
|
|
Migrate() error
|
2019-01-21 17:13:33 +03:00
|
|
|
|
|
|
|
//Generic map objects (poi, etc)
|
2019-01-18 17:51:10 +03:00
|
|
|
GetMapData(q SearchQuery) ([]MapObject, error)
|
2019-01-18 17:10:46 +03:00
|
|
|
RemoveMapData(pos coords.MapBlockCoords) error
|
2019-01-18 17:51:10 +03:00
|
|
|
AddMapData(data MapObject) error
|
2019-01-21 17:13:33 +03:00
|
|
|
|
|
|
|
//tile data
|
|
|
|
GetTile(pos *coords.TileCoords) (*Tile, error)
|
|
|
|
SetTile(tile *Tile) error
|
|
|
|
RemoveTile(pos *coords.TileCoords) error
|
2019-01-18 15:50:59 +03:00
|
|
|
}
|