forked from MTSR/mapserver
map obj data stub
This commit is contained in:
parent
4d1426a466
commit
e2cfa9857a
@ -24,7 +24,6 @@ type MapObject struct {
|
||||
X, Y, Z int
|
||||
|
||||
Type string
|
||||
Data string
|
||||
Mtime int64
|
||||
Attributes map[string]string
|
||||
}
|
||||
|
@ -8,10 +8,48 @@ func (db *Sqlite3Accessor) GetMapData(q SearchQuery) ([]MapObject, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
const removeMapDataQuery = `
|
||||
delete from objects where posx = ? and posy = ? and posz = ?
|
||||
`
|
||||
|
||||
func (db *Sqlite3Accessor) RemoveMapData(pos coords.MapBlockCoords) error {
|
||||
return nil
|
||||
_, err := db.db.Exec(removeMapDataQuery, pos.X, pos.Y, pos.Z)
|
||||
return err
|
||||
}
|
||||
|
||||
const addMapDataQuery = `
|
||||
insert into
|
||||
objects(x,y,z,posx,posy,posz,type,mtime)
|
||||
values(?, ?, ?, ?, ?, ?, ?, ?)
|
||||
returning id
|
||||
`
|
||||
|
||||
const addMapDataAttributeQuery = `
|
||||
insert into
|
||||
object_attributes(objectid, key, value)
|
||||
values(?, ?, ?)
|
||||
`
|
||||
|
||||
func (db *Sqlite3Accessor) AddMapData(data MapObject) error {
|
||||
_, err := db.db.Exec(addMapDataQuery,
|
||||
data.X, data.Y, data.Z,
|
||||
data.MBPos.X, data.MBPos.Y, data.MBPos.Z,
|
||||
data.Type, data.Mtime)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//TODO
|
||||
id := 1
|
||||
|
||||
for k, v := range data.Attributes {
|
||||
_, err := db.db.Exec(addMapDataAttributeQuery, id, k, v)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ create table if not exists objects(
|
||||
posy int,
|
||||
posz int,
|
||||
type varchar,
|
||||
data blob,
|
||||
mtime bigint
|
||||
);
|
||||
|
||||
@ -29,11 +28,11 @@ create index if not exists objects_pos on objects(posx,posy,posz);
|
||||
create index if not exists objects_pos_type on objects(posx,posy,posz,type);
|
||||
|
||||
create table if not exists object_attributes(
|
||||
id integer primary key autoincrement,
|
||||
objectid integer not null,
|
||||
key varchar not null,
|
||||
value varchar not null,
|
||||
FOREIGN KEY (objectid) references objects(id) ON DELETE CASCADE
|
||||
primary key(objectid, key)
|
||||
);
|
||||
|
||||
create table if not exists tiles(
|
||||
|
Loading…
Reference in New Issue
Block a user