diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..3f7d229 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,80 @@ +name: Analyze + +on: + push: + branches: [ '**' ] + pull_request: + branches: [ master ] + +jobs: + bandit: + runs-on: ubuntu-24.04 + name: bandit + steps: + - uses: actions/checkout@v2 + - name: install + run: | + sudo apt update + sudo apt upgrade + sudo apt install python3 + - name: info + run: | + python3 --version + - name: bandit + run: | + pip install bandit + bandit ./world-dl.py + pylint: + runs-on: ubuntu-24.04 + name: pylint + steps: + - uses: actions/checkout@v2 + - name: install + run: | + sudo apt update + sudo apt upgrade + sudo apt install python3 libsqlite3-dev python3-gdal python3-numpy + - name: info + run: | + python3 --version + - name: pylint + run: | + pip install "pylint" "requests" "argparse" "pysqlite3" "tqdm" + pylint --disable=old-style-class --module-naming-style=any ./world-dl.py + coverage: + runs-on: ubuntu-24.04 + name: coverage + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + steps: + - uses: actions/checkout@v2 + - name: install + run: | + sudo apt update + sudo apt upgrade + sudo apt install python3 libsqlite3-dev python3-gdal python3-numpy + - name: info + run: | + python3 --version + - name: coverage + run: | + RUN() { echo -e "\033[36;1m\$ $@ \033[0m" ; "$@" ; } + RUN pip install "codecov" "coverage" "requests" "argparse" "pysqlite3" "tqdm" + + RUN coverage run world-dl.py -a init -s 131072 -b 1024 -i ./input/google_map.img -o ./out -m ./data/mask-no-ant-3857.tif + RUN coverage run --append world-dl.py -a download -ov -c LZMA -t 512 -i ./input/google_map.img -o ./out + RUN rm ./out/gmap_0_0.tif + RUN rm ./out/gmap_0_1024.tif + RUN echo "Hello" >> ./out/gmap_1024_1024.tif + RUN coverage run --append world-dl.py -a merge -v -i ./input/google_map.img -o ./out || true + RUN coverage run --append world-dl.py -a download -ov -c LZMA -t 512 -i ./input/google_map.img -o ./out + RUN coverage run --append world-dl.py -a merge -v -i ./input/google_map.img -o ./out + + RUN coverage run --append world-dl.py -a init -s 131072 -b 1024 -i ./input/google_map.img -o ./out -ml ./data/au.geojson + RUN coverage run --append world-dl.py -a download -ov -c LZMA -t 512 -i ./input/google_map.img -o ./out + + RUN coverage report --include world-dl.py + + - name: codecov + if: ${{ success() }} + run: codecov \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 06f6851..0000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: python -matrix: - include: - - python: "3.7" - dist: xenial - - python: "3.8" - dist: bionic - -addons: - apt: - - python3-gdal -script: - - pip install numpy argparse pysqlite3 - - python world-dl.py -a init -s 65536 -b 1024 -i ./input/google_map.img -o ./out -m ./data/mask-no-ant-3857.tif -ml ./data/au.geojson - - python world-dl.py -a download -ov -c LZMA -i ./input/google_map.img -o ./out diff --git a/README.md b/README.md index 39aaa9b..50e7b20 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![codefactor.io](https://www.codefactor.io/repository/github/drons/world-dl/badge?style=flat-square)](https://www.codefactor.io/repository/github/drons/world-dl) [![codecov](https://codecov.io/gh/drons/world-dl/branch/master/graph/badge.svg)](https://codecov.io/gh/drons/world-dl) -[![Build Status](https://ci.appveyor.com/api/projects/status/github/drons/world-dl?branch=master&svg=true)](https://ci.appveyor.com/project/drons/nbody/world-dl/master) +[![Build Status](https://github.com/drons/world-dl/actions/workflows/main.yml/badge.svg?branch=master](https://github.com/drons/world-dl/actions/workflows/main.yml) # Imagery download tool from web image services ## How to run diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 1334245..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,33 +0,0 @@ -image: Ubuntu2204 - -install: - - sudo apt-get update -y -q - - sudo apt-get install -y -q virtualenv python3-gdal python3-numpy - - virtualenv -p /usr/bin/python3 --system-site-packages ./venv - - source ./venv/bin/activate - - pip install --upgrade pip - - pip install --upgrade tqdm codecov coverage pylint bandit requests argparse pysqlite3 - -build: off - -test_script: - - source ./venv/bin/activate - - pylint --disable=old-style-class --module-naming-style=any ./world-dl.py - - bandit ./world-dl.py - - coverage run world-dl.py -a init -s 131072 -b 1024 -i ./input/google_map.img -o ./out -m ./data/mask-no-ant-3857.tif - - coverage run --append world-dl.py -a download -ov -c LZMA -t 512 -i ./input/google_map.img -o ./out - - rm ./out/gmap_0_0.tif - - rm ./out/gmap_0_1024.tif - - echo "Hello" >> ./out/gmap_1024_1024.tif - - coverage run --append world-dl.py -a merge -v -i ./input/google_map.img -o ./out || true - - coverage run --append world-dl.py -a download -ov -c LZMA -t 512 -i ./input/google_map.img -o ./out - - coverage run --append world-dl.py -a merge -v -i ./input/google_map.img -o ./out - - - coverage run --append world-dl.py -a init -s 131072 -b 1024 -i ./input/google_map.img -o ./out -ml ./data/au.geojson - - coverage run --append world-dl.py -a download -ov -c LZMA -t 512 -i ./input/google_map.img -o ./out - - - - coverage report --include world-dl.py - -on_success: - - codecov diff --git a/world-dl.py b/world-dl.py index 78eeb87..0bc0ea1 100644 --- a/world-dl.py +++ b/world-dl.py @@ -3,6 +3,7 @@ """ from __future__ import print_function +import math import sys import os import shutil @@ -33,10 +34,10 @@ def window(self): def mask_boundary(self, mask_scale): """:returns block's bounds at mask image""" - return (int(self.offset_x * self.scale / mask_scale), - int(self.offset_y * self.scale / mask_scale), - int((self.offset_x + self.size) * self.scale / mask_scale), - int((self.offset_y + self.size) * self.scale / mask_scale)) + return (math.floor(self.offset_x * self.scale / mask_scale), + math.floor(self.offset_y * self.scale / mask_scale), + math.ceil((self.offset_x + self.size) * self.scale / mask_scale), + math.ceil((self.offset_y + self.size) * self.scale / mask_scale)) def get_db(args): @@ -95,7 +96,11 @@ def open_mask(args, input_ds): mask_ds.RasterYSize >= input_ds.RasterYSize: print('Too big mask image. Discard it.') mask_ds = None + return mask_ds, 1 mask_scale = int(input_ds.RasterXSize / mask_ds.RasterXSize) + print('Mask scale', mask_scale) + print('Mask pixels per block', + (args.block_size * mask_ds.RasterXSize * args.scale) / input_ds.RasterXSize) if mask_scale != int(input_ds.RasterYSize / mask_ds.RasterYSize): print('WARNING: Mask image have non uniform scale relative to input dataset') mask = mask_ds.GetRasterBand(1).ReadAsArray()