Skip to content

Commit

Permalink
_funcs.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jaybo committed Dec 27, 2023
0 parents commit 12bcd98
Show file tree
Hide file tree
Showing 38 changed files with 4,856 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
max-line-length = 88
ignore = E203, E266, E501, W503, F403, F401, E741
max-complexity = 18
select = B,C,E,F,W,T4,B9
54 changes: 54 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package test

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
os: ["ubuntu-22.04"]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
env:
CURL_CA_BUNDLE: /etc/ssl/certs/ca-certificates.crt
run: |
python -m pip install --upgrade pip
pip install -e .[test]
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 tilematrix --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 tilematrix --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
env:
CURL_CA_BUNDLE: /etc/ssl/certs/ca-certificates.crt
run: |
pytest -v --cov tilematrix
- name: Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
coveralls --service=github
31 changes: 31 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

on:
release:
types: [created]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install hatch
- name: Build and publish
env:
HATCH_INDEX_USER: ${{ secrets.PYPI_USERNAME }}
HATCH_INDEX_AUTH: ${{ secrets.PYPI_PASSWORD }}
run: |
hatch build
hatch publish
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*.pyc
dist/
build/
testenv/
*.egg-info
test/testdata/out/*
venv/
.cache
.eggs
.coverage
htmlcov
.pytest*
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
repos:
- repo: https://github.com/ambv/black
rev: 23.3.0
hooks:
- id: black
language_version: python3
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v1.2.3
hooks:
- id: flake8
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/PyCQA/autoflake
rev: v2.1.1
hooks:
- id: autoflake
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
args: ["--profile", "black"]
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true
}
]
}
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"python.testing.pytestArgs": [
"test"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
214 changes: 214 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
#########
Changelog
#########

2023.12.0 - 2022-12-15
----------------------
* fix grid warning
* add more pre-commit hooks


2022.12.0 - 2022-12-16
----------------------
* make fit for `Shapely 2.0`


2022.11.3 - 2022-11-08
----------------------
* replace `setuptools` with `hatch`


2022.11.2 - 2022-11-08
----------------------
* remove `conda` build files
* `tilematrix-feedstock <https://github.com/conda-forge/tilematrix-feedstock>`_ `conda-forge feedstock` repository for releasing new versions on `conda-forge`


2022.11.1 - 2022-11-03
----------------------
* fix `conda` & `pip ` builds


2022.11.0 - 2022-11-03
----------------------
* test also for python `3.9`
* renaming `master` branch to `main`
* add ``conda`` publish to github actions (workflows)


2022.3.0 - 2022-03-15
---------------------
* add option to exactly get intersection tiles using `TilePyramid.tiles_from_geom(exact=True)`


2021.11.0 - 2021-11-12
----------------------
* enable yielding tiles in batches by either row or column for following methods:
* `TilePyramid.tiles_from_bounds()`
* `TilePyramid.tiles_from_bbox()`
* `TilePyramid.tiles_from_geom()`

* convert TilePyramid arguments into keyword arguments


0.21
----
* allow metatiling up to 512
* use GitHub actions instead of travis
* use black and flake8 pre-commit checks


0.20
----
* fixed pixel size calculation on irregular grids with metatiling (closing #33)
* ``TilePyramid.tile_x_size()``, ``TilePyramid.tile_y_size()``, ``TilePyramid.tile_height()``, ``TilePyramid.tile_width()`` are deprecated
* metatiles are clipped to ``TilePyramid.bounds`` but ``pixelbuffer`` of edge tiles can exceed them unless it is a global grid

0.19
----
* Python 2 not supported anymore
* ``TilePyramid.srid`` and ``TilePyramid.type`` are deprecated
* ``GridDefinition`` can now be loaded from package root
* ``GridDefinition`` got ``to_dict()`` and ``from_dict()`` methods


0.18
----
* order of ``Tile.shape`` swapped to ``(height, width)`` in order to match rasterio array interpretation

0.17
----
* make ``Tile`` iterable to enable ``tuple(Tile)`` return the tile index as tuple

0.16
----
* make ``Tile`` objects hashable & comparable

0.15
----
* add ``snap_bounds()`` function
* add ``snap_bounds`` command to ``tmx``
* add ``snap_bbox`` command to ``tmx``
* in ``tile_from_xy()`` add ``on_edge_use`` option specify behavior when point hits grid edges
* cleaned up ``_tiles_from_cleaned_bounds()`` and ``tile_from_xy()`` functions

------
0.14.2
------
* attempt to fix ``tmx`` command when installing tilematrix via pip

----
0.14
----
* add ``tmx`` CLI with subcommands:
* `bounds`: Print bounds of given Tile.
* `bbox`: Print bounding box geometry of given Tile.
* `tile`: Print Tile covering given point.
* `tiles`: Print Tiles covering given bounds.

----
0.13
----
* fixed ``tiles_from_geom()`` bug when passing on a Point (#19)
* add ``tile_from_xy()`` function

----
0.12
----
* added better string representations for ``Tile`` and ``TilePyramid``
* added ``GridDefinition`` to better handle custom grid parameters
* ``TilePyramid`` instances are now comparable by ``==`` and ``!=``

----
0.11
----
* custom grid defnitions enabled

---
0.10
---
* new tag for last version to fix Python 3 build

---
0.9
---
* added Python 3 support
* use NamedTuple for Tile index

---
0.8
---
* ``intersecting`` function fixed (rounding error caused return of wrong tiles)

---
0.7
---
* converted tuples for bounds and shape attributes to namedtuples

---
0.6
---
* added ``pytest`` and test cases
* fixed metatiling shape error on low zoom levels
* split up code into internal modules
* travis CI and coveralls.io integration

---
0.5
---
* ``intersection()`` doesn't return invalid tiles.
* Moved copyright to EOX IT Services

---
0.4
---
* Decision to remove ``MetaTilePyramid`` class (now returns a ``DeprecationWarning``).
* TilePyramid now has its own ``metatiling`` parameter.
* ``intersecting()`` function for ``Tile`` and ``TilePyramid`` to relate between ``TilePyramids`` with different ``metatiling`` settings.

---
0.3
---
* fixed duplicate tile return in tiles_from_bounds()
* rasterio's CRS() class replaced CRS dict

---
0.2
---
* introduced handling of antimeridian:
* ``get_neighbor()`` also gets tiles from other side
* ``.shape()`` returns clipped tile shape
* added ``tiles_from_bounds()``
* added ``clip_geometry_to_srs_bounds()``

---
0.1
---
* added Spherical Mercator support
* removed IO module (moved to `mapchete <https://github.com/ungarj/mapchete>`_)
* removed deprecated ``OutputFormats``
* introduced ``get_parent()`` and ``get_children()`` functions for ``Tile``

-----
0.0.4
-----
* introduced ``Tile`` object
* read_raster_window() is now a generator which returns only a numpy array
* read_vector_window() is a generator which returns a GeoJSON-like object with a geometry clipped to tile boundaries
* proper error handling (removed ``sys.exit(0)``)

-----
0.0.3
-----
* rewrote io module
* separated and enhanced OutputFormats

-----
0.0.2
-----
* fixed wrong link to github repository

-----
0.0.1
-----
* basic functionality
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 - 2019 EOX IT Services GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 12bcd98

Please sign in to comment.