Border tile placement #1

Closed
opened 2025-02-19 22:11:51 +00:00 by andolg · 5 comments
andolg commented 2025-02-19 22:11:51 +00:00 (Migrated from github.com)

Hey, I tested your program and noticed that the border tiles on the top and left sides of the image are shifted and sometimes overlap, like in this case:

"tl": "52.57867508992417, 5.68805453553596",
"br": "52.55494609768789, 5.719032918935248",
"zoom": "15"

Image

Image

Hey, I tested your program and noticed that the border tiles on the top and left sides of the image are shifted and sometimes overlap, like in this case: "tl": "52.57867508992417, 5.68805453553596", "br": "52.55494609768789, 5.719032918935248", "zoom": "15" ![Image](https://github.com/user-attachments/assets/0425a26f-15d4-482f-8b24-30c4bbfd73f4) ![Image](https://github.com/user-attachments/assets/6d3de886-ff53-44d2-921c-a998dc5cd17f)
LeviLovie commented 2025-02-26 12:32:11 +00:00 (Migrated from github.com)

Oh, that must be because of the subtract with overflow error i have been having. I'll look into it, thanks!

Oh, that must be because of the subtract with overflow error i have been having. I'll look into it, thanks!
LeviLovie commented 2025-02-26 12:38:31 +00:00 (Migrated from github.com)

Here, this code is a temporary solution i forgot to look into:

                let mut tl_rel_x = tile_x * tile_size as i32 - tl_pixel_x;
                let mut tl_rel_y = tile_y * tile_size as i32 - tl_pixel_y;
                if tl_rel_x < 0 {
                    tl_rel_x = 0;
                }
                if tl_rel_y < 0 {
                    tl_rel_y = 0;
                }

If the if statements are removed, the error shows up:

thread '<unnamed>' panicked at src/lib.rs:87:29:
Image index (4294967107, 602) out of bounds (722, 910)
Here, this code is a temporary solution i forgot to look into: ```rust let mut tl_rel_x = tile_x * tile_size as i32 - tl_pixel_x; let mut tl_rel_y = tile_y * tile_size as i32 - tl_pixel_y; if tl_rel_x < 0 { tl_rel_x = 0; } if tl_rel_y < 0 { tl_rel_y = 0; } ``` If the `if` statements are removed, the error shows up: ``` thread '<unnamed>' panicked at src/lib.rs:87:29: Image index (4294967107, 602) out of bounds (722, 910) ```
LeviLovie commented 2025-02-26 12:41:53 +00:00 (Migrated from github.com)

Moving the check inside the loop fixes the issue:

for y in 0..tile_h {
    for x in 0..tile_w {
        let pixel = tile.get_pixel(x, y);
        if tl_rel_x < 0 || tl_rel_y < 0 {
            continue;
        }
        img.put_pixel((tl_rel_x as u32) + x, (tl_rel_y as u32) + y, pixel);
    }
}

Image

Moving the check inside the loop fixes the issue: ```rust for y in 0..tile_h { for x in 0..tile_w { let pixel = tile.get_pixel(x, y); if tl_rel_x < 0 || tl_rel_y < 0 { continue; } img.put_pixel((tl_rel_x as u32) + x, (tl_rel_y as u32) + y, pixel); } } ``` ![Image](https://github.com/user-attachments/assets/5269b9e8-2825-4020-bc3c-7f526c867660)
LeviLovie commented 2025-02-26 12:47:25 +00:00 (Migrated from github.com)

I released v0.2.3. Thank you for the issue!

I released `v0.2.3`. Thank you for the issue!
andolg commented 2025-03-06 20:05:12 +00:00 (Migrated from github.com)

Hi!
It seems there's only the alpha channel where border tiles should be.
Also, bin.rs still reads the removed "channels" on line 106, which causes an error.

Hi! It seems there's only the alpha channel where border tiles should be. Also, bin.rs still reads the removed "channels" on line 106, which causes an error.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
levi/satellite-imagery#1
No description provided.