Fixes #14. mtseeder and mtwebmapper now have command line flags -ymin=block and -ymax=block to limit the y range of mapping. Defaults to full range.

This commit is contained in:
Sascha L. Teichmann
2015-07-27 19:03:47 +02:00
parent 464ccbf670
commit e606e2700f
6 changed files with 66 additions and 28 deletions

View File

@ -18,10 +18,15 @@ const (
yOrderCapacity = 512
)
const (
MaxHeight = 1934
MinHeight = -1934
)
// To scan the whole height in terms of the y coordinate
// the database is queried in height units defined in the tileDepths table.
var tileDepths = [...][2]int16{
{1024, 1934},
{1024, MaxHeight},
{256, 1023},
{128, 255},
{64, 127},
@ -40,7 +45,7 @@ var tileDepths = [...][2]int16{
{-128, -65},
{-256, -129},
{-1024, -257},
{-1934, -1025}}
{MinHeight, -1025}}
var BackgroundColor = color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
@ -49,6 +54,8 @@ type BaseTileCreator struct {
colors *Colors
renderer *Renderer
yOrder *YOrder
yMin int16
yMax int16
baseDir string
update bool
emptyImage []byte
@ -57,15 +64,19 @@ type BaseTileCreator struct {
func NewBaseTileCreator(
client *RedisClient,
colors *Colors,
yMin, yMax int16,
transparent bool,
baseDir string,
update bool) *BaseTileCreator {
renderer := NewRenderer(tileWidth, tileHeight, transparent)
yMin, yMax = Order16(yMin, yMax)
return &BaseTileCreator{
client: client,
colors: colors,
renderer: renderer,
yOrder: NewYOrder(renderer, yOrderCapacity),
yMin: yMin,
yMax: yMax,
baseDir: baseDir,
update: update}
}
@ -95,8 +106,11 @@ func (btc *BaseTileCreator) CreateTile(x, z int16, i, j int) error {
X2: int16(tileWidth) - 1, Z2: int16(tileHeight) - 1}
for _, yRange := range tileDepths {
c1.Y = yRange[0]
c2.Y = yRange[1]
if yRange[0] > btc.yMax || yRange[1] < btc.yMin {
continue
}
c1.Y = max16(yRange[0], btc.yMin)
c2.Y = min16(yRange[1], btc.yMax)
nareas = btc.renderer.UncoveredAreas(nareas, oareas)

View File

@ -63,6 +63,20 @@ func Clamp32f(x, a, b float32) float32 {
return x
}
func Order(a, b int) (int, int) {
if a < b {
return a, b
}
return b, a
}
func Order16(a, b int16) (int16, int16) {
if a < b {
return a, b
}
return b, a
}
func Order64(a, b int64) (int64, int64) {
if a < b {
return a, b