forked from MTSR/mapserver
working psql initial scan
This commit is contained in:
parent
309c88e8bb
commit
32bc5900d4
@ -22,6 +22,11 @@ clean:
|
|||||||
rm -rf $(STATIC_VFS)
|
rm -rf $(STATIC_VFS)
|
||||||
rm -rf $(OUT_DIR)
|
rm -rf $(OUT_DIR)
|
||||||
|
|
||||||
|
clean-all: clean
|
||||||
|
rm -rf mapserver.sqlite*
|
||||||
|
rm -rf mapserver.tiles
|
||||||
|
rm -rf mapserver.json
|
||||||
|
|
||||||
build-docker:
|
build-docker:
|
||||||
sudo docker run --rm -it -v $(shell pwd)/:/app -v mapserver-volume:/root/go -w /app mapserver-builder make
|
sudo docker run --rm -it -v $(shell pwd)/:/app -v mapserver-volume:/root/go -w /app mapserver-builder make
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ const (
|
|||||||
func (this *PostgresAccessor) FindNextInitialBlocks(s settings.Settings, layers []*layer.Layer, limit int) (*db.InitialBlocksResult, error) {
|
func (this *PostgresAccessor) FindNextInitialBlocks(s settings.Settings, layers []*layer.Layer, limit int) (*db.InitialBlocksResult, error) {
|
||||||
|
|
||||||
lastlayer := s.GetInt(SETTING_LAST_LAYER, 0)
|
lastlayer := s.GetInt(SETTING_LAST_LAYER, 0)
|
||||||
lastxblock := s.GetInt(SETTING_LAST_X_BLOCK, -128)
|
lastxblock := s.GetInt(SETTING_LAST_X_BLOCK, -129)
|
||||||
lastyblock := s.GetInt(SETTING_LAST_Y_BLOCK, -128)
|
lastyblock := s.GetInt(SETTING_LAST_Y_BLOCK, -128)
|
||||||
|
|
||||||
if lastxblock >= 128 {
|
if lastxblock >= 128 {
|
||||||
@ -58,50 +58,53 @@ func (this *PostgresAccessor) FindNextInitialBlocks(s settings.Settings, layers
|
|||||||
fromY := int(currentlayer.From / 16)
|
fromY := int(currentlayer.From / 16)
|
||||||
toY := int(currentlayer.To / 16)
|
toY := int(currentlayer.To / 16)
|
||||||
|
|
||||||
tcr := coords.GetMapBlockRangeFromTile(tc, fromY)
|
tcr := coords.GetMapBlockRangeFromTile(tc, 0)
|
||||||
tcr.Pos1.Y = toY
|
tcr.Pos1.Y = fromY
|
||||||
|
tcr.Pos2.Y = toY
|
||||||
|
|
||||||
fields := logrus.Fields{
|
fields := logrus.Fields{
|
||||||
"layerId": lastlayer,
|
"layerId": lastlayer,
|
||||||
"pos1": tcr.Pos1,
|
"pos1": tcr.Pos1,
|
||||||
"pos2": tcr.Pos2,
|
"pos2": tcr.Pos2,
|
||||||
"lastxblock": lastxblock,
|
"tile": tc,
|
||||||
"lastyblock": lastyblock,
|
|
||||||
}
|
}
|
||||||
log.WithFields(fields).Debug("Initial-Query")
|
log.WithFields(fields).Info("Initial-Query")
|
||||||
|
|
||||||
minX := math.Min(float64(tcr.Pos1.X), float64(tcr.Pos2.X))
|
minX := int(math.Min(float64(tcr.Pos1.X), float64(tcr.Pos2.X)))
|
||||||
maxX := math.Max(float64(tcr.Pos1.X), float64(tcr.Pos2.X))
|
maxX := int(math.Max(float64(tcr.Pos1.X), float64(tcr.Pos2.X)))
|
||||||
minY := math.Min(float64(tcr.Pos1.Y), float64(tcr.Pos2.Y))
|
minY := int(math.Min(float64(tcr.Pos1.Y), float64(tcr.Pos2.Y)))
|
||||||
maxY := math.Max(float64(tcr.Pos1.Y), float64(tcr.Pos2.Y))
|
maxY := int(math.Max(float64(tcr.Pos1.Y), float64(tcr.Pos2.Y)))
|
||||||
minZ := math.Min(float64(tcr.Pos1.Z), float64(tcr.Pos2.Z))
|
minZ := int(math.Min(float64(tcr.Pos1.Z), float64(tcr.Pos2.Z)))
|
||||||
maxZ := math.Max(float64(tcr.Pos1.Z), float64(tcr.Pos2.Z))
|
maxZ := int(math.Max(float64(tcr.Pos1.Z), float64(tcr.Pos2.Z)))
|
||||||
|
|
||||||
stridecount := this.intQuery(`
|
if lastxblock <= -128 {
|
||||||
select count(*) from blocks
|
//first x entry, check z stride
|
||||||
where posx >= $1 and posx <= $2
|
stridecount := this.intQuery(`
|
||||||
and posy >= $3 and posy <= $4
|
select count(*) from blocks
|
||||||
and mtime = 0`,
|
where posz >= $1 and posz <= $2
|
||||||
minX, maxX,
|
and posy >= $3 and posy <= $4
|
||||||
minY, maxY,
|
and mtime = 0`,
|
||||||
)
|
minZ, maxZ,
|
||||||
|
minY, maxY,
|
||||||
|
)
|
||||||
|
|
||||||
if stridecount == 0 {
|
if stridecount == 0 {
|
||||||
fields = logrus.Fields{
|
fields = logrus.Fields{
|
||||||
"minX": minX,
|
"minX": minX,
|
||||||
"maxX": maxX,
|
"maxX": maxX,
|
||||||
"minY": minY,
|
"minY": minY,
|
||||||
"maxY": maxY,
|
"maxY": maxY,
|
||||||
|
}
|
||||||
|
log.WithFields(fields).Debug("Skipping stride")
|
||||||
|
|
||||||
|
s.SetInt(SETTING_LAST_LAYER, lastlayer)
|
||||||
|
s.SetInt(SETTING_LAST_X_BLOCK, -129)
|
||||||
|
s.SetInt(SETTING_LAST_Y_BLOCK, lastyblock+1)
|
||||||
|
|
||||||
|
result := &db.InitialBlocksResult{}
|
||||||
|
result.HasMore = true
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
log.WithFields(fields).Info("Skipping stride")
|
|
||||||
|
|
||||||
s.SetInt(SETTING_LAST_LAYER, lastlayer)
|
|
||||||
s.SetInt(SETTING_LAST_X_BLOCK, lastxblock)
|
|
||||||
s.SetInt(SETTING_LAST_Y_BLOCK, lastyblock)
|
|
||||||
|
|
||||||
result := &db.InitialBlocksResult{}
|
|
||||||
result.HasMore = true
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, err := this.db.Query(getBlocksByInitialTileQuery,
|
rows, err := this.db.Query(getBlocksByInitialTileQuery,
|
||||||
|
Loading…
Reference in New Issue
Block a user