forked from MTSR/mapserver
working psql rendering
This commit is contained in:
parent
b625d9ad75
commit
fc6549e612
@ -1,11 +1,13 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"mapserver/coords"
|
||||
"mapserver/db"
|
||||
"mapserver/layer"
|
||||
"mapserver/settings"
|
||||
"math"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -53,18 +55,30 @@ func (this *PostgresAccessor) FindNextInitialBlocks(s settings.Settings, layers
|
||||
tc := coords.NewTileCoords(lastxblock, lastyblock, 9, lastlayer)
|
||||
currentlayer := layer.FindLayerById(layers, lastlayer)
|
||||
|
||||
tcr := coords.GetMapBlockRangeFromTile(tc, currentlayer.From)
|
||||
fromY := int(currentlayer.From / 16)
|
||||
toY := int(currentlayer.To / 16)
|
||||
|
||||
tcr := coords.GetMapBlockRangeFromTile(tc, fromY)
|
||||
tcr.Pos1.Y = toY
|
||||
|
||||
fields := logrus.Fields{
|
||||
"layerId": lastlayer,
|
||||
"pos1": tcr.Pos1,
|
||||
"pos2": tcr.Pos2,
|
||||
"layerId": lastlayer,
|
||||
"pos1": tcr.Pos1,
|
||||
"pos2": tcr.Pos2,
|
||||
"lastxblock": lastxblock,
|
||||
"lastyblock": lastyblock,
|
||||
}
|
||||
log.WithFields(fields).Info("Initial-Query")
|
||||
|
||||
minX := math.Min(float64(tcr.Pos1.X), float64(tcr.Pos2.X))
|
||||
maxX := math.Max(float64(tcr.Pos1.X), float64(tcr.Pos2.X))
|
||||
minY := math.Min(float64(tcr.Pos1.Y), float64(tcr.Pos2.Y))
|
||||
maxY := math.Max(float64(tcr.Pos1.Y), float64(tcr.Pos2.Y))
|
||||
minZ := math.Min(float64(tcr.Pos1.Z), float64(tcr.Pos2.Z))
|
||||
maxZ := math.Max(float64(tcr.Pos1.Z), float64(tcr.Pos2.Z))
|
||||
|
||||
rows, err := this.db.Query(getBlocksByInitialTileQuery,
|
||||
tcr.Pos1.X, tcr.Pos1.X, tcr.Pos1.X,
|
||||
tcr.Pos2.X, tcr.Pos2.X, tcr.Pos2.X,
|
||||
minX, minY, minZ, maxX, maxY, maxZ,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
@ -88,6 +102,10 @@ func (this *PostgresAccessor) FindNextInitialBlocks(s settings.Settings, layers
|
||||
blocks = append(blocks, mb)
|
||||
}
|
||||
|
||||
s.SetInt(SETTING_LAST_LAYER, lastlayer)
|
||||
s.SetInt(SETTING_LAST_X_BLOCK, lastxblock)
|
||||
s.SetInt(SETTING_LAST_Y_BLOCK, lastyblock)
|
||||
|
||||
result := &db.InitialBlocksResult{}
|
||||
result.List = blocks
|
||||
result.HasMore = true
|
||||
|
@ -72,7 +72,7 @@ func (this *PostgresAccessor) FindBlocksByMtime(gtmtime int64, limit int) ([]*db
|
||||
func (this *PostgresAccessor) CountBlocks(frommtime, tomtime int64) (int, error) {
|
||||
rows, err := this.db.Query(countBlocksQuery, frommtime, tomtime)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
panic(err)
|
||||
}
|
||||
|
||||
defer rows.Close()
|
||||
@ -117,7 +117,7 @@ func (this *PostgresAccessor) GetBlock(pos *coords.MapBlockCoords) (*db.Block, e
|
||||
}
|
||||
|
||||
func New(connStr string) (*PostgresAccessor, error) {
|
||||
db, err := sql.Open("postgres", connStr)
|
||||
db, err := sql.Open("postgres", connStr+" sslmode=disable")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -4,29 +4,29 @@ const getBlocksByInitialTileQuery = `
|
||||
select posx,posy,posz,data,mtime
|
||||
from blocks b
|
||||
where b.mtime = 0
|
||||
and b.posx >= ?
|
||||
and b.posy >= ?
|
||||
and b.posz >= ?
|
||||
and b.posx <= ?
|
||||
and b.posy <= ?
|
||||
and b.posz <= ?
|
||||
and b.posx >= $1
|
||||
and b.posy >= $2
|
||||
and b.posz >= $3
|
||||
and b.posx <= $4
|
||||
and b.posy <= $5
|
||||
and b.posz <= $6
|
||||
`
|
||||
|
||||
const getBlocksByMtimeQuery = `
|
||||
select posx,posy,posz,data,mtime
|
||||
from blocks b
|
||||
where b.mtime > ?
|
||||
where b.mtime > $1
|
||||
order by b.mtime asc
|
||||
limit ?
|
||||
limit $2
|
||||
`
|
||||
|
||||
const countBlocksQuery = `
|
||||
select count(*) from blocks b where b.mtime >= ? and b.mtime <= ?
|
||||
select count(*) from blocks where mtime >= $1 and mtime <= $2
|
||||
`
|
||||
|
||||
const getBlockQuery = `
|
||||
select posx,posy,posz,data,mtime from blocks b
|
||||
where b.posx = ?
|
||||
and b.posy = ?
|
||||
and b.posz = ?
|
||||
where b.posx = $1
|
||||
and b.posy = $2
|
||||
and b.posz = $3
|
||||
`
|
||||
|
@ -22,8 +22,26 @@ func renderMapblocks(ctx *app.App, jobs chan *coords.TileCoords, mblist []*mapbl
|
||||
for i := 12; i >= 1; i-- {
|
||||
for _, mb := range mblist {
|
||||
//13
|
||||
|
||||
fields := logrus.Fields{
|
||||
"pos": mb.Pos,
|
||||
}
|
||||
logrus.WithFields(fields).Debug("Tile render job part")
|
||||
|
||||
tc := coords.GetTileCoordsFromMapBlock(mb.Pos, ctx.Config.Layers)
|
||||
|
||||
if tc == nil {
|
||||
panic("mapblock outside of layer!")
|
||||
}
|
||||
|
||||
fields = logrus.Fields{
|
||||
"X": tc.X,
|
||||
"Y": tc.Y,
|
||||
"Zoom": tc.Zoom,
|
||||
"LayerId": tc.LayerId,
|
||||
}
|
||||
logrus.WithFields(fields).Debug("Tile render job part")
|
||||
|
||||
//12-1
|
||||
tc = tc.ZoomOut(13 - i)
|
||||
|
||||
@ -35,14 +53,6 @@ func renderMapblocks(ctx *app.App, jobs chan *coords.TileCoords, mblist []*mapbl
|
||||
|
||||
tileRenderedMap[key] = true
|
||||
|
||||
fields := logrus.Fields{
|
||||
"X": tc.X,
|
||||
"Y": tc.Y,
|
||||
"Zoom": tc.Zoom,
|
||||
"LayerId": tc.LayerId,
|
||||
}
|
||||
logrus.WithFields(fields).Debug("Dispatching tile rendering (z12-1)")
|
||||
|
||||
tilecount++
|
||||
|
||||
//dispatch re-render
|
||||
|
Loading…
Reference in New Issue
Block a user