Skip to content

Commit

Permalink
Redefined module structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
muety committed Nov 8, 2019
1 parent 380fe1c commit 24e68e4
Show file tree
Hide file tree
Showing 16 changed files with 46 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This library requires **Python 3.6** or higher. To compile it by yourself, Cytho
### Using Pip
* `pip3 install pyquadkey2`

Pip installation is only tested for Linux, yet. If you encounter problems with the installation on Mac or Windows, please report them as a new issue.
Pip installation is only tested for Linux and Mac, yet. If you encounter problems with the installation on Windows, 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`
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This library requires **Python 3.6** or higher. To compile it by yourself, Cytho
## Using Pip
* `pip3 install pyquadkey2`

If you encounter problems while installing, please report them as a new issue.
Pip installation is only tested for Linux and Mac, yet. If you encounter problems with the installation on Windows, 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`
Expand Down
6 changes: 3 additions & 3 deletions docs/instantiation.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Creates a new `QuadKey` object from a tile's string representation.

**Example:**
```python
import quadkey
from pyquadkey2 import quadkey
qk = quadkey.from_str('010302121') # -> 010302121
```

Expand All @@ -20,7 +20,7 @@ Creates a new `QuadKey` object from a tile's integer representation

**Example:**
```python
import quadkey
from pyquadkey2 import quadkey
qk = quadkey.from_int(1379860704579813385) # -> 010302121
```

Expand All @@ -31,6 +31,6 @@ Creates a new `QuadKey` object from geo / GNSS coordinates

**Example:**
```python
import quadkey
from pyquadkey2 import quadkey
qk = quadkey.from_geo((49.011011, 8.414971), 9) # -> 120203233
```
16 changes: 8 additions & 8 deletions docs/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Get all children of the specified level.
* `at_level` (default: 1): Level of the children keys to be returned. Has to be less than the current QuadKey's level.

**Example:**
```
from quadkey import QuadKey
```python
from pyquadkey2.quadkey import QuadKey
qk = QuadKey('0')
qk.children(at_level=2) # -> ['000', '001', '002', '003', '010', '011', '012', '013', '020', '021', '022', '023', '030', '031', '032', '033']
```
Expand All @@ -32,8 +32,8 @@ Get all QuadKeys at the same level that are in the current key's neighborhood of

Left: `n=1`, right: `n=2`

```
from quadkey import QuadKey
```python
from pyquadkey2.quadkey import QuadKey
qk = QuadKey('032')
qk.nearby() # -> ['021', '031', '023', '033', '201', '032', '030', '211', '210']
qk.nearby(n=2) # -> ['023', '012', '022', '212', '210', '021', '033', '300', '203', '200', '030', '102', '003', '031', '302', '201', '032', '202', '120', '213', '002', '013', '122', '211', '020']
Expand Down Expand Up @@ -74,8 +74,8 @@ Returns all keys of the same level that are "between" (in two-dimensional space)

![](img/pyquadkey_difference.png)

```
from quadkey import QuadKey
```python
from pyquadkey2.quadkey import QuadKey
qk1 = QuadKey('032')
qk2 = QuadKey('011')
qk1.difference(qk1) # -> [011, 013, 031, 033, 010, 012, 030, 032]
Expand Down Expand Up @@ -112,8 +112,8 @@ Returns the current key as 64-bit integer for better space efficiency.

Similar to [difference](#difference), but as a static method. In addition this method accepts multiple keys and returns all keys, that are contained in a bounding box spanned by the two outer-most `quadkeys`.

```
from quadkey import QuadKey
```python
from pyquadkey2.quadkey import QuadKey
qks = [QuadKey('032'), QuadKey('011')]
QuadKey.bbox(qks) # -> [011, 013, 031, 033, 010, 012, 030, 032]
```
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@

setup(
name='pyquadkey2',
version='0.1.1',
version='0.2.0',
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='[email protected]',
url='https://github.com/n1try/pyquadkey2',
packages=find_packages(),
packages=find_packages('src'),
package_dir={'': 'src'},
classifiers=[
'Development Status :: 4 - Beta',
'Programming Language :: Python :: 3',
Expand All @@ -39,6 +40,6 @@
},
keywords='tiling quadkey quadtile geospatial geohash',
python_requires='>=3.6',
ext_modules=[Extension('tilesystem', ['quadkey/tilesystem/tilesystem.c'])],
ext_modules=[Extension('tilesystem', ['src/pyquadkey2/quadkey/tilesystem/tilesystem.c'])],
ext_package='pyquadkey2'
)
File renamed without changes.
2 changes: 1 addition & 1 deletion quadkey/__init__.py → src/pyquadkey2/quadkey/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

try:
from pyquadkey2 import tilesystem
except ModuleNotFoundError:
except (ModuleNotFoundError, ImportError):
from .tilesystem import tilesystem

from .util import precondition
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions quadkey/util.py → src/pyquadkey2/quadkey/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ def wrapper(*args, **kwargs): # NOTE: no self
if postcondition is not None:
assert postcondition(retval)
return retval

return wrapper

return decorator


Expand Down
8 changes: 6 additions & 2 deletions test/__init__.py → tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import os
import sys
from unittest import TestLoader, TestSuite, TextTestRunner

sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))


def run():
from test import test_quadkey, test_util
from test.tilesystem import test_tilesystem
from tests import test_quadkey, test_util
from tests.tilesystem import test_tilesystem

loader: TestLoader = TestLoader()
suite: TestSuite = TestSuite()
Expand Down
6 changes: 5 additions & 1 deletion test/test_quadkey.py → tests/test_quadkey.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import os
import sys
import unittest
from operator import attrgetter
from unittest import TestCase

import quadkey
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../src'))

from pyquadkey2 import quadkey


class QuadKeyTest(TestCase):
Expand Down
12 changes: 10 additions & 2 deletions test/test_util.py → tests/test_util.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import os
import sys
import unittest
from unittest import TestCase

from quadkey.util import *
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), '../src'))

from pyquadkey2.quadkey.util import *

class UtilTest(TestCase):

class UtilTest(TestCase):
def testPrecondition(self):
self.assertTrue(self.pre(True))
with self.assertRaises(AssertionError):
Expand All @@ -16,3 +20,7 @@ def testPostcondition(self):
@precondition(lambda c, x: x is True)
def pre(self, x):
return x


if __name__ == '__main__':
unittest.main()
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import sys
import unittest
from unittest import TestCase

from quadkey import TileAnchor
from quadkey.tilesystem import tilesystem
sys.path.append('../src')

from pyquadkey2.quadkey import TileAnchor
from pyquadkey2.quadkey.tilesystem import tilesystem


class TileSystemTest(TestCase):
Expand Down

0 comments on commit 24e68e4

Please sign in to comment.