Skip to content

Commit

Permalink
修复文件输出格式可能错误,file->文件夹存储模式输出文件格式跟随format类型
Browse files Browse the repository at this point in the history
  • Loading branch information
exlimit committed Aug 27, 2022
1 parent c768296 commit 0295045
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion task.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (task *Task) savePipe() {
//SaveTile 保存瓦片
func (task *Task) saveTile(tile Tile) error {
// defer task.wg.Done()
err := saveToFiles(tile, filepath.Base(task.File))
err := saveToFiles(tile, task)
if err != nil {
log.Errorf("create %v tile file error ~ %s", tile.T, err)
}
Expand Down
5 changes: 3 additions & 2 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ func saveToMBTile(tile Tile, db *sql.DB) error {
return nil
}

func saveToFiles(tile Tile, rootdir string) error {
func saveToFiles(tile Tile, task *Task) error {
rootdir := filepath.Base(task.File)
dir := filepath.Join(rootdir, fmt.Sprintf(`%d`, tile.T.Z), fmt.Sprintf(`%d`, tile.T.X))
os.MkdirAll(dir, os.ModePerm)
fileName := filepath.Join(dir, fmt.Sprintf(`%d.png`, tile.T.Y))
fileName := filepath.Join(dir, fmt.Sprintf(`%d.%s`, tile.T.Y, task.TileMap.Format))
err := ioutil.WriteFile(fileName, tile.C, os.ModePerm)
if err != nil {
return err
Expand Down

0 comments on commit 0295045

Please sign in to comment.