forked from MTSR/mapserver
rework layer system, switch to mapblock pos in mapserver.json
This commit is contained in:
parent
7ab1f1c9d2
commit
126ed07ef8
@ -93,7 +93,7 @@ More layers can be added here:
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
```
|
```
|
||||||
*from* and *to* are in blocks (not mapblocks)
|
*from* and *to* are in mapblocks (16x16x16 blocks)
|
||||||
Don't reuse the `id` after the tiles are generated.
|
Don't reuse the `id` after the tiles are generated.
|
||||||
If you make more substantial changes here you may have to remove all
|
If you make more substantial changes here you may have to remove all
|
||||||
existing tiles and start rendering from scratch.
|
existing tiles and start rendering from scratch.
|
||||||
|
@ -98,14 +98,14 @@ func ParseConfig(filename string) (*Config, error) {
|
|||||||
&layer.Layer{
|
&layer.Layer{
|
||||||
Id: 0,
|
Id: 0,
|
||||||
Name: "Ground",
|
Name: "Ground",
|
||||||
From: -16,
|
From: -1,
|
||||||
To: 160,
|
To: 10,
|
||||||
},
|
},
|
||||||
&layer.Layer{
|
&layer.Layer{
|
||||||
Id: 1,
|
Id: 1,
|
||||||
Name: "Sky",
|
Name: "Sky",
|
||||||
From: 160,
|
From: 11,
|
||||||
To: 320,
|
To: 24,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ func GetTileCoordsFromMapBlock(mbc *MapBlockCoords, layers []*layer.Layer) *Tile
|
|||||||
|
|
||||||
var layerid *int
|
var layerid *int
|
||||||
for _, l := range layers {
|
for _, l := range layers {
|
||||||
if (mbc.Y*16) >= l.From && (mbc.Y*16) <= l.To {
|
if mbc.Y >= l.From && mbc.Y <= l.To {
|
||||||
layerid = &l.Id
|
layerid = &l.Id
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -90,12 +90,9 @@ func (this *PostgresAccessor) FindNextInitialBlocks(s settings.Settings, layers
|
|||||||
tc := coords.NewTileCoords(lastxblock, lastyblock, 9, lastlayer)
|
tc := coords.NewTileCoords(lastxblock, lastyblock, 9, lastlayer)
|
||||||
currentlayer := layer.FindLayerById(layers, lastlayer)
|
currentlayer := layer.FindLayerById(layers, lastlayer)
|
||||||
|
|
||||||
fromY := int(currentlayer.From / 16)
|
|
||||||
toY := int(currentlayer.To / 16)
|
|
||||||
|
|
||||||
tcr := coords.GetMapBlockRangeFromTile(tc, 0)
|
tcr := coords.GetMapBlockRangeFromTile(tc, 0)
|
||||||
tcr.Pos1.Y = fromY
|
tcr.Pos1.Y = currentlayer.From
|
||||||
tcr.Pos2.Y = toY
|
tcr.Pos2.Y = currentlayer.To
|
||||||
|
|
||||||
fields := logrus.Fields{
|
fields := logrus.Fields{
|
||||||
"layerId": lastlayer,
|
"layerId": lastlayer,
|
||||||
@ -112,20 +109,6 @@ func (this *PostgresAccessor) FindNextInitialBlocks(s settings.Settings, layers
|
|||||||
minZ := int(math.Min(float64(tcr.Pos1.Z), float64(tcr.Pos2.Z)))
|
minZ := int(math.Min(float64(tcr.Pos1.Z), float64(tcr.Pos2.Z)))
|
||||||
maxZ := int(math.Max(float64(tcr.Pos1.Z), float64(tcr.Pos2.Z)))
|
maxZ := int(math.Max(float64(tcr.Pos1.Z), float64(tcr.Pos2.Z)))
|
||||||
|
|
||||||
//upper left: https://pandorabox.io/map/tiles/0/9/-121/-121
|
|
||||||
//lower right: https://pandorabox.io/map/tiles/0/9/120/120
|
|
||||||
// INFO[0007] Initial rendering elapsed=24.749287ms mapblocks=0 progress%=2 tiles=0
|
|
||||||
//INFO[0007] Initial-Query layerId=0 pos1="&{-1968 -1 1935}" pos2="&{-1953 10 1920}" prefix=postgres-db tile="&{-123 -121 9 0}"
|
|
||||||
//INFO[0007] Initial rendering elapsed=24.587519ms mapblocks=0 progress%=2 tiles=0
|
|
||||||
//INFO[0007] Initial-Query layerId=0 pos1="&{-1952 -1 1935}" pos2="&{-1937 10 1920}" prefix=postgres-db tile="&{-122 -121 9 0}"
|
|
||||||
//INFO[0007] Initial rendering elapsed=24.607329ms mapblocks=0 progress%=2 tiles=0
|
|
||||||
//INFO[0007] Initial-Query layerId=0 pos1="&{-1936 -1 1935}" pos2="&{-1921 10 1920}" prefix=postgres-db tile="&{-121 -121 9 0}"
|
|
||||||
//INFO[0007] Initial rendering elapsed=25.090037ms mapblocks=0 progress%=2 tiles=0
|
|
||||||
//INFO[0007] Initial-Query layerId=0 pos1="&{-1920 -1 1935}" pos2="&{-1905 10 1920}" prefix=postgres-db tile="&{-120 -121 9 0}"
|
|
||||||
//INFO[0007] Initial rendering elapsed=24.754558ms mapblocks=0 progress%=2 tiles=0
|
|
||||||
//INFO[0007] Initial-Query layerId=0 pos1="&{-1904 -1 1935}" pos2="&{-1889 10 1920}" prefix=postgres-db tile="&{-119 -121 9 0}"
|
|
||||||
//INFO[0007] Initial rendering elapsed=24.711348ms mapblocks=0 progress%=2 tiles=0
|
|
||||||
|
|
||||||
if lastxblock <= -128 {
|
if lastxblock <= -128 {
|
||||||
//first x entry, check z stride
|
//first x entry, check z stride
|
||||||
stridecount := this.intQuery(`
|
stridecount := this.intQuery(`
|
||||||
|
@ -71,7 +71,7 @@ func (this *Sqlite3Accessor) FindNextInitialBlocks(s settings.Settings, layers [
|
|||||||
// new position
|
// new position
|
||||||
lastpos = pos
|
lastpos = pos
|
||||||
|
|
||||||
blockcoordy := mb.Pos.Y * 16
|
blockcoordy := mb.Pos.Y
|
||||||
currentlayer := layer.FindLayerByY(layers, blockcoordy)
|
currentlayer := layer.FindLayerByY(layers, blockcoordy)
|
||||||
|
|
||||||
if currentlayer != nil {
|
if currentlayer != nil {
|
||||||
|
@ -52,7 +52,7 @@ func (a *MapBlockAccessor) FindMapBlocksByMtime(lastmtime int64, limit int, laye
|
|||||||
|
|
||||||
inLayer := false
|
inLayer := false
|
||||||
for _, l := range layerfilter {
|
for _, l := range layerfilter {
|
||||||
if (block.Pos.Y*16) >= l.From && (block.Pos.Y*16) <= l.To {
|
if block.Pos.Y >= l.From && block.Pos.Y <= l.To {
|
||||||
inLayer = true
|
inLayer = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,8 @@ var AbstractGeoJsonOverlay = L.LayerGroup.extend({
|
|||||||
var min = this._map.getBounds().getSouthWest();
|
var min = this._map.getBounds().getSouthWest();
|
||||||
var max = this._map.getBounds().getNorthEast();
|
var max = this._map.getBounds().getNorthEast();
|
||||||
|
|
||||||
var y1 = parseInt(mapLayer.from/16);
|
var y1 = parseInt(mapLayer.from);
|
||||||
var y2 = parseInt(mapLayer.to/16);
|
var y2 = parseInt(mapLayer.to);
|
||||||
var x1 = parseInt(min.lng/16);
|
var x1 = parseInt(min.lng/16);
|
||||||
var x2 = parseInt(max.lng/16);
|
var x2 = parseInt(max.lng/16);
|
||||||
var z1 = parseInt(min.lat/16);
|
var z1 = parseInt(min.lat/16);
|
||||||
|
@ -65,8 +65,8 @@ var AbstractIconOverlay = L.LayerGroup.extend({
|
|||||||
var min = this.map.getBounds().getSouthWest();
|
var min = this.map.getBounds().getSouthWest();
|
||||||
var max = this.map.getBounds().getNorthEast();
|
var max = this.map.getBounds().getNorthEast();
|
||||||
|
|
||||||
var y1 = parseInt(mapLayer.from/16);
|
var y1 = parseInt(mapLayer.from);
|
||||||
var y2 = parseInt(mapLayer.to/16);
|
var y2 = parseInt(mapLayer.to);
|
||||||
var x1 = parseInt(min.lng/16);
|
var x1 = parseInt(min.lng/16);
|
||||||
var x2 = parseInt(max.lng/16);
|
var x2 = parseInt(max.lng/16);
|
||||||
var z1 = parseInt(min.lat/16);
|
var z1 = parseInt(min.lat/16);
|
||||||
|
@ -55,7 +55,7 @@ var PlayerOverlay = L.LayerGroup.extend({
|
|||||||
isPlayerInCurrentLayer: function(player){
|
isPlayerInCurrentLayer: function(player){
|
||||||
var mapLayer = this.layerMgr.getCurrentLayer()
|
var mapLayer = this.layerMgr.getCurrentLayer()
|
||||||
|
|
||||||
return (player.pos.y >= mapLayer.from && player.pos.y <= mapLayer.to)
|
return (player.pos.y >= (mapLayer.from*16) && player.pos.y <= (mapLayer.to*16))
|
||||||
},
|
},
|
||||||
|
|
||||||
onMinetestUpdate: function(info){
|
onMinetestUpdate: function(info){
|
||||||
|
@ -103,15 +103,9 @@ func (tr *TileRenderer) renderImage(tc *coords.TileCoords, recursionDepth int) (
|
|||||||
timer := prometheus.NewTimer(renderDuration)
|
timer := prometheus.NewTimer(renderDuration)
|
||||||
defer timer.ObserveDuration()
|
defer timer.ObserveDuration()
|
||||||
|
|
||||||
var layer *layer.Layer
|
currentLayer := layer.FindLayerById(tr.layers, tc.LayerId)
|
||||||
|
|
||||||
for _, l := range tr.layers {
|
if currentLayer == nil {
|
||||||
if l.Id == tc.LayerId {
|
|
||||||
layer = l
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if layer == nil {
|
|
||||||
return nil, nil, errors.New("No layer found")
|
return nil, nil, errors.New("No layer found")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,8 +116,8 @@ func (tr *TileRenderer) renderImage(tc *coords.TileCoords, recursionDepth int) (
|
|||||||
if tc.Zoom == 13 {
|
if tc.Zoom == 13 {
|
||||||
//max zoomed in on mapblock level
|
//max zoomed in on mapblock level
|
||||||
mbr := coords.GetMapBlockRangeFromTile(tc, 0)
|
mbr := coords.GetMapBlockRangeFromTile(tc, 0)
|
||||||
mbr.Pos1.Y = layer.From
|
mbr.Pos1.Y = currentLayer.From
|
||||||
mbr.Pos2.Y = layer.To
|
mbr.Pos2.Y = currentLayer.To
|
||||||
|
|
||||||
img, err := tr.mapblockrenderer.Render(mbr.Pos1, mbr.Pos2)
|
img, err := tr.mapblockrenderer.Render(mbr.Pos1, mbr.Pos2)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user