Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bbox-zxy script #1

Open
arbakker opened this issue Oct 29, 2021 · 0 comments
Open

fix bbox-zxy script #1

arbakker opened this issue Oct 29, 2021 · 0 comments

Comments

@arbakker
Copy link
Owner

fix bbox-zxy script:

function get_tiles_for_bbox() {
    # bbox needs to align with RD TileMatrixSet to get valid output
    local z bbox              # input params
    local res tilesize_meters #extent origin_x origin_y # local variables
    z="$1"
    bbox="$2"
    min_x=$(echo "$bbox" | awk -F, '{print $1}')
    min_y=$(echo "$bbox" | awk -F, '{print $2}')
    max_x=$(echo "$bbox" | awk -F, '{print $3}')
    max_y=$(echo "$bbox" | awk -F, '{print $4}')
    res=$(get_resolution_for_z "$z")
    # extent=$EXTENT_RD
    # origin_x=$(echo "$extent" | cut -d, -f1)
    # origin_y=$(echo "$extent" | cut -d, -f4) # tiling schemes uses upperleft corner for origin
    tilesize_meters=$(bc -l <<<"$res*$TILESIZE_PIXELS" | xargs -I{} printf "%.2f" {})
    max_x=$(bc -l <<<"$max_x-$tilesize_meters")
    max_y=$(bc -l <<<"$max_y-$tilesize_meters")
    for x in $(seq "$min_x" "$tilesize_meters" "$max_x"); do
        x=$(printf "%.2f" "$x") # round on 2 decimals due to floating point issues
        x_max=$(bc <<<"$tilesize_meters+$x" | xargs -I{} printf "%.2f" {})
        # x_index=$(bc <<<"($x-($origin_x))/$tilesize_meters")
        for y in $(seq "$max_y" -"$tilesize_meters" "$min_y"); do
            y=$(printf "%.2f" "$y")
            # y_index=$(bc <<<"($origin_y-($y))/$tilesize_meters")
            y_max=$(bc <<<"$tilesize_meters+$y" | xargs -I{} printf "%.2f" {})
            # echo "${z}/${x_index}/${y_index}"
            echo "$x,$y,$x_max,$y_max"
        done
    done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant