mapserver: Fix unzoom gen

This commit is contained in:
Pascal Engélibert 2022-02-21 19:34:30 +01:00
parent c40541963f
commit 2e9c8a6975
Signed by: tuxmain
GPG Key ID: 3504BC6D362F7DCA
3 changed files with 56 additions and 64 deletions

24
mapserver/Cargo.lock generated
View File

@ -604,16 +604,6 @@ dependencies = [
]
[[package]]
name = "ctrlc"
version = "3.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a19c6cedffdc8c03a3346d723eb20bd85a13362bb96dc2ac000842c6381ec7bf"
dependencies = [
"nix",
"winapi",
]
[[package]]
name = "dashmap"
version = "4.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@ -1097,7 +1087,6 @@ version = "0.1.0"
dependencies = [
"async-std",
"crossbeam-channel",
"ctrlc",
"http-types",
"image",
"log",
@ -1157,19 +1146,6 @@ dependencies = [
]
[[package]]
name = "nix"
version = "0.23.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6"
dependencies = [
"bitflags",
"cc",
"cfg-if 1.0.0",
"libc",
"memoffset",
]
[[package]]
name = "num-integer"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"

View File

@ -6,7 +6,6 @@ edition = "2021"
[dependencies]
async-std = { version = "1.6.5", features = ["attributes"] }
crossbeam-channel = "0.5.2"
ctrlc = "3.2.1"
http-types = "2.12.0"
image = "0.24.1"
log = "0.4.14"

View File

@ -120,49 +120,66 @@ fn generate_tile(
run_minetestmapper(z, x, y, tile_dir, tile_path, config)?
}
std::cmp::Ordering::Less => {
let tile1_path =
get_dep_tile(z + 1, x * 2, y * 2, tasks.clone(), config.clone())?;
let tile2_path = get_dep_tile(
z + 1,
x * 2,
y * 2 + 1,
tasks.clone(),
config.clone(),
)?;
let tile3_path = get_dep_tile(
z + 1,
x * 2 + 1,
y * 2,
tasks.clone(),
config.clone(),
)?;
let tile4_path = get_dep_tile(
z + 1,
x * 2 + 1,
y * 2 + 1,
tasks.clone(),
config.clone(),
)?;
let tile1 = image::open(tile1_path).map_err(Error::Image)?.into_rgb8();
let tile2 = image::open(tile2_path).map_err(Error::Image)?.into_rgb8();
let tile3 = image::open(tile3_path).map_err(Error::Image)?.into_rgb8();
let tile4 = image::open(tile4_path).map_err(Error::Image)?.into_rgb8();
let mut tile = image::ImageBuffer::<image::Rgb<u8>, Vec<u8>>::new(
config.tile_size as u32 * 2,
config.tile_size as u32 * 2,
);
image::imageops::replace(&mut tile, &tile1, 0, 0);
image::imageops::replace(&mut tile, &tile2, 0, config.tile_size as i64);
image::imageops::replace(&mut tile, &tile3, config.tile_size as i64, 0);
image::imageops::replace(
&mut tile,
&tile4,
config.tile_size as i64,
config.tile_size as i64,
);
tile.save(tile_path).map_err(Error::Image)?;
if let Ok(ntile_path) =
get_dep_tile(z + 1, x * 2, y * 2, tasks.clone(), config.clone())
{
if let Ok(ntile) = image::open(ntile_path) {
image::imageops::replace(&mut tile, &ntile.into_rgb8(), 0, 0);
}
}
if let Ok(ntile_path) =
get_dep_tile(z + 1, x * 2, y * 2 + 1, tasks.clone(), config.clone())
{
if let Ok(ntile) = image::open(ntile_path) {
image::imageops::replace(
&mut tile,
&ntile.into_rgb8(),
0,
config.tile_size as i64,
);
}
}
if let Ok(ntile_path) =
get_dep_tile(z + 1, x * 2 + 1, y * 2, tasks.clone(), config.clone())
{
if let Ok(ntile) = image::open(ntile_path) {
image::imageops::replace(
&mut tile,
&ntile.into_rgb8(),
config.tile_size as i64,
0,
);
}
}
if let Ok(ntile_path) = get_dep_tile(
z + 1,
x * 2 + 1,
y * 2 + 1,
tasks.clone(),
config.clone(),
) {
if let Ok(ntile) = image::open(ntile_path) {
image::imageops::replace(
&mut tile,
&ntile.into_rgb8(),
config.tile_size as i64,
config.tile_size as i64,
);
}
}
image::imageops::resize(
&tile,
config.tile_size as u32,
config.tile_size as u32,
image::imageops::Triangle,
)
.save(tile_path)
.map_err(Error::Image)?;
}
std::cmp::Ordering::Greater => Err(Error::Todo)?,
}