mapserver: fix generation & allow .png url

This commit is contained in:
Pascal Engélibert 2022-02-21 18:00:48 +01:00
parent 57fcb38e25
commit 7aa17e3de3
Signed by: tuxmain
GPG Key ID: 3504BC6D362F7DCA
1 changed files with 4 additions and 3 deletions

View File

@ -67,7 +67,7 @@ fn run_minetestmapper(
&format!(
"{}:{}+{}+{}",
x * config.tile_size as i32,
-1 - z * config.tile_size as i32,
-1 - y * config.tile_size as i32,
config.tile_size,
config.tile_size
),
@ -85,7 +85,7 @@ fn read_tile_file(tile_path: &str) -> Result<Vec<u8>, Error> {
let mut tile_content = Vec::new();
std::fs::File::open(&tile_path)
.map_err(Error::Io)?
.read(&mut tile_content)
.read_to_end(&mut tile_content)
.map_err(Error::Io)?; // TODO resp_tile if error
Ok(tile_content)
}
@ -152,7 +152,8 @@ async fn req_tile(
) -> tide::Result {
let z: i32 = req.param("z")?.parse()?;
let x: i32 = req.param("x")?.parse()?;
let y: i32 = req.param("y")?.parse()?;
let y = req.param("y")?;
let y = y.strip_suffix(".png").unwrap_or(y).parse()?;
let tile_dir = format!("{}{}/{}", config.output_path, z, x);
let tile_path = format!("{}/{}.png", tile_dir, y);