diff --git a/.gitignore b/.gitignore index 9be4aa0..1c5efe0 100644 --- a/.gitignore +++ b/.gitignore @@ -40,4 +40,6 @@ nosetests.xml # Virtualenv venv/ -.idea \ No newline at end of file +.idea/ + +site/ \ No newline at end of file diff --git a/README.md b/README.md index af41f6a..e50965c 100644 --- a/README.md +++ b/README.md @@ -24,14 +24,17 @@ This library requires **Python 3.6** or higher. To compile it by yourself, Cytho ### Using Pip * `pip3 install pyquadkey2` -Currently, there are pre-built `linux_x86_64` for Python 3.6, 3.7 and 3.8. If you're on a Linux system, you can simply use pip without any additional requirements. -On other systems, you might need to install Cython first (`pip3 install cython`). If you encounter problems while installing, please report them as a new issue. - -### From Source -* `git clone https://github.com/n1try/pyquadkey2` -* `pip3 install cython` -* `cd pyquadkey2/quadkey/tilesystem && python3 setup.py build_ext --inplace && ../../` -* `pip3 install .` +If you encounter problems while installing, please report them as a new issue. + +### From archive +* Download the latest [release](https://github.com/n1try/pyquadkey2/releases) as archive (`.tar.gz`) or wheel (`.whl`), e.g. `0.1.1.tar.gz` +* Install it with pip: `pip3 install 0.1.1.tar.gz` + +### From source +* Clone repository: `git clone https://github.com/n1try/pyquadkey2` +* Make sure Cython is installed: `pip3 install cython` +* Compile Cython modules: `cd pyquadkey2/quadkey/tilesystem && python3 setup.py build_ext --inplace && ../../` +* Install the library with Pip: `pip3 install .` ### Troubleshooting * `ImportError: cannot import name 'tilesystem'`: Simply try `pip3 install --upgrade pyquadkey2` once again. Second time usually works, as required build extensions are installed then. This is a known issue and will be fixed in the future. diff --git a/docs/installation.md b/docs/installation.md index 4f37639..bc41d7c 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -1,17 +1,22 @@ +# Installation + ## Requirements This library requires **Python 3.6** or higher. To compile it by yourself, Cython is required in addition. ## Using Pip * `pip3 install pyquadkey2` -Currently, there are pre-built `linux_x86_64` for Python 3.6, 3.7 and 3.8. If you're on a Linux system, you can simply use pip without any additional requirements. -On other systems, you might need to install Cython first (`pip3 install cython`). If you encounter problems while installing, please report them as a new issue. +If you encounter problems while installing, please report them as a new issue. + +## From archive +* Download the latest [release](https://github.com/n1try/pyquadkey2/releases) as archive (`.tar.gz`) or wheel (`.whl`), e.g. `0.1.1.tar.gz` +* Install it with pip: `pip3 install 0.1.1.tar.gz` -## From Source -* `git clone https://github.com/n1try/pyquadkey2` -* `pip3 install cython` -* `cd pyquadkey2/quadkey/tilesystem && python3 setup.py build_ext --inplace && ../../` -* `pip3 install .` +## From source +* Clone repository: `git clone https://github.com/n1try/pyquadkey2` +* Make sure Cython is installed: `pip3 install cython` +* Compile Cython modules: `cd pyquadkey2/quadkey/tilesystem && python3 setup.py build_ext --inplace && ../../` +* Install the library with Pip: `pip3 install .` ## Troubleshooting -* `ImportError: cannot import name 'tilesystem'`: Simply try `pip3 install --upgrade pyquadkey2` once again. Second time usually works, as required build extensions are installed then. This is a known issue and will be fixed in the future. \ No newline at end of file +* `ImportError: cannot import name 'tilesystem'`: Simply try `pip3 install --upgrade pyquadkey2` once again. Second time usually works, as required build extensions are installed then. This is a known issue and will be fixed in the future. diff --git a/docs/instantiation.md b/docs/instantiation.md index 5b5c252..5d4168f 100644 --- a/docs/instantiation.md +++ b/docs/instantiation.md @@ -1,19 +1,36 @@ +# Instantiation + There are **three ways** of instantiating a QuadKey. ## From string representation +Creates a new `QuadKey` object from a tile's string representation. + `from_str(qk_str: str) -> 'QuadKey'` **Example:** -``` +```python import quadkey qk = quadkey.from_str('010302121') # -> 010302121 ``` ## From integer representation +Creates a new `QuadKey` object from a tile's integer representation + `from_int(qk_int: int) -> 'QuadKey'` **Example:** -``` +```python import quadkey qk = quadkey.from_int(1379860704579813385) # -> 010302121 +``` + +## From coordinates +Creates a new `QuadKey` object from geo / GNSS coordinates + +`from_geo(geo: Tuple[float, float], level: int) -> 'QuadKey'` + +**Example:** +```python +import quadkey +qk = quadkey.from_geo((49.011011, 8.414971), 9) # -> 120203233 ``` \ No newline at end of file diff --git a/docs/methods.md b/docs/methods.md index 76e3821..e38edf8 100644 --- a/docs/methods.md +++ b/docs/methods.md @@ -1,3 +1,5 @@ +# Methods + ## children `children(self, at_level: int = -1) -> List['QuadKey']` diff --git a/quadkey/__init__.py b/quadkey/__init__.py index ce2f3ac..207a99b 100644 --- a/quadkey/__init__.py +++ b/quadkey/__init__.py @@ -3,7 +3,11 @@ from enum import IntEnum from typing import Tuple, List, Iterable, Generator, Dict -from .tilesystem import tilesystem +try: + from pyquadkey2 import tilesystem +except ModuleNotFoundError: + from .tilesystem import tilesystem + from .util import precondition LAT_STR: str = 'lat' diff --git a/setup.py b/setup.py index 5080e68..a56c7e0 100644 --- a/setup.py +++ b/setup.py @@ -1,39 +1,41 @@ #!/usr/bin/env python # https://packaging.python.org/tutorials/packaging-projects/ -import os +# python3 setup.py sdist bdist_wheel +# python3 -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*.tar.gz +# mkdocs build +from setuptools import Extension from setuptools import setup, find_packages -from setuptools.glob import glob -try: - from Cython.Distutils.extension import Extension - from Cython.Build import build_ext -except ImportError: - from setuptools import Extension - - USING_CYTHON = False -else: - USING_CYTHON = True - -ext = 'pyx' if USING_CYTHON else 'c' -sources = glob('quadkey/tilesystem/*.%s' % (ext,)) -extensions = [Extension(source.split('.')[0].replace(os.path.sep, '.'), sources=[source]) for source in sources] -cmdclass = {'build_ext': build_ext} if USING_CYTHON else {} +with open('README.md', 'r') as fh: + long_description = fh.read() setup( name='pyquadkey2', - version='0.1.0', + version='0.1.1', description='Python implementation of geographical tiling using QuadKeys as proposed by Microsoft', + long_description=long_description, + long_description_content_type='text/markdown', author='Ferdinand Mütsch', author_email='ferdinand@muetsch.io', url='https://github.com/n1try/pyquadkey2', packages=find_packages(), + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python :: 3', + 'Programming Language :: Cython', + 'License :: OSI Approved :: Apache Software License', + 'Operating System :: OS Independent', + 'Natural Language :: English', + 'Topic :: Scientific/Engineering :: GIS', + 'Typing :: Typed' + ], project_urls={ 'Bug Tracker': 'https://github.com/n1try/pyquadkey2/issues', 'Source Code': 'https://github.com/n1try/pyquadkey2', }, keywords='tiling quadkey quadtile geospatial geohash', python_requires='>=3.6', - ext_modules=extensions, - cmdclass=cmdclass + ext_modules=[Extension('tilesystem', ['quadkey/tilesystem/tilesystem.c'])], + ext_package='pyquadkey2' )