forked from MTSR/mapserver
mapblock coordinates
This commit is contained in:
parent
01cc7e460e
commit
42580ee310
@ -69,7 +69,7 @@ type DBAccessor interface {
|
||||
Migrate() error
|
||||
|
||||
//Generic map objects (poi, etc)
|
||||
GetMapData(q SearchQuery) ([]*MapObject, error)
|
||||
GetMapData(q *SearchQuery) ([]*MapObject, error)
|
||||
RemoveMapData(pos *coords.MapBlockCoords) error
|
||||
AddMapData(data *MapObject) error
|
||||
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"mapserver/mapobjectdb"
|
||||
)
|
||||
|
||||
func (db *Sqlite3Accessor) GetMapData(q mapobjectdb.SearchQuery) ([]*mapobjectdb.MapObject, error) {
|
||||
func (db *Sqlite3Accessor) GetMapData(q *mapobjectdb.SearchQuery) ([]*mapobjectdb.MapObject, error) {
|
||||
rows, err := db.db.Query(getMapDataPosQuery,
|
||||
q.Type,
|
||||
q.Pos1.X, q.Pos1.Y, q.Pos1.Z,
|
||||
|
@ -71,7 +71,7 @@ func TestMapObjects(t *testing.T) {
|
||||
Type: "xy",
|
||||
}
|
||||
|
||||
objs, err := db.GetMapData(q)
|
||||
objs, err := db.GetMapData(&q)
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -3,7 +3,7 @@ var api = {
|
||||
getMapObjects: function(query){
|
||||
return m.request({
|
||||
method: "POST",
|
||||
url: "api/mapobjects",
|
||||
url: "api/mapobjects/",
|
||||
data: query
|
||||
});
|
||||
},
|
||||
|
@ -52,10 +52,10 @@ var AbstractGeoJsonOverlay = L.LayerGroup.extend({
|
||||
|
||||
var y1 = parseInt(mapLayer.from/16);
|
||||
var y2 = parseInt(mapLayer.to/16);
|
||||
var x1 = parseInt(min.lng);
|
||||
var x2 = parseInt(max.lng);
|
||||
var z1 = parseInt(min.lat);
|
||||
var z2 = parseInt(max.lat);
|
||||
var x1 = parseInt(min.lng/16);
|
||||
var x2 = parseInt(max.lng/16);
|
||||
var z1 = parseInt(min.lat/16);
|
||||
var z2 = parseInt(max.lat/16);
|
||||
|
||||
api.getMapObjects({
|
||||
pos1: { x:x1, y:y1, z:z1 },
|
||||
|
@ -67,10 +67,10 @@ var AbstractIconOverlay = L.LayerGroup.extend({
|
||||
|
||||
var y1 = parseInt(mapLayer.from/16);
|
||||
var y2 = parseInt(mapLayer.to/16);
|
||||
var x1 = parseInt(min.lng);
|
||||
var x2 = parseInt(max.lng);
|
||||
var z1 = parseInt(min.lat);
|
||||
var z2 = parseInt(max.lat);
|
||||
var x1 = parseInt(min.lng/16);
|
||||
var x2 = parseInt(max.lng/16);
|
||||
var z1 = parseInt(min.lat/16);
|
||||
var z2 = parseInt(max.lat/16);
|
||||
|
||||
api.getMapObjects({
|
||||
pos1: { x:x1, y:y1, z:z1 },
|
||||
|
@ -2,10 +2,11 @@ package web
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"mapserver/app"
|
||||
"mapserver/mapobjectdb"
|
||||
"net/http"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
type MapObjects struct {
|
||||
@ -18,7 +19,7 @@ func (t *MapObjects) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
|
||||
defer timer.ObserveDuration()
|
||||
|
||||
decoder := json.NewDecoder(req.Body)
|
||||
var q mapobjectdb.SearchQuery
|
||||
q := mapobjectdb.SearchQuery{}
|
||||
|
||||
err := decoder.Decode(&q)
|
||||
if err != nil {
|
||||
@ -27,7 +28,7 @@ func (t *MapObjects) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
objects, err := t.ctx.Objectdb.GetMapData(q)
|
||||
objects, err := t.ctx.Objectdb.GetMapData(&q)
|
||||
if err != nil {
|
||||
resp.WriteHeader(500)
|
||||
resp.Write([]byte(err.Error()))
|
||||
|
Loading…
Reference in New Issue
Block a user