Skip to content

Commit

Permalink
fix: rounding error (resolve #13)
Browse files Browse the repository at this point in the history
  • Loading branch information
muety committed May 2, 2024
1 parent 8222ca5 commit 58bf13a
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ Pip installation is only tested for Linux and Mac, yet. If you encounter problem

### From archive
```bash
$ wget https://github.com/muety/pyquadkey2/releases/download/0.3.0/pyquadkey2-0.3.0.tar.gz
$ pip install pyquadkey2-0.3.0.tar.gz
$ wget https://github.com/muety/pyquadkey2/releases/download/0.3.1/pyquadkey2-0.3.1.tar.gz
$ pip install pyquadkey2-0.3.1.tar.gz
```

### From source
Expand Down
4 changes: 2 additions & 2 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Pip installation is only tested for Linux and Mac, yet. If you encounter problem

### From archive
```bash
$ wget https://github.com/muety/pyquadkey2/releases/download/0.3.0/pyquadkey2-0.3.0.tar.gz
$ pip install pyquadkey2-0.3.0.tar.gz
$ wget https://github.com/muety/pyquadkey2/releases/download/0.3.1/pyquadkey2-0.3.1.tar.gz
$ pip install pyquadkey2-0.3.1.tar.gz
```

### From source
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setup(
name='pyquadkey2',
version='0.3.0',
version='0.3.1',
description='Python implementation of geographical tiling using QuadKeys as proposed by Microsoft',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down
2 changes: 1 addition & 1 deletion src/pyquadkey2/quadkey/tilesystem/tilesystem.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ cpdef (double, double) pixel_to_geo((double, double) pixel, const long level):
y = 0.5 - (clip(pixel_y, (0, ms - 1)) / ms)
lat = 90 - 360 * math.atan(math.exp(-y * 2 * math.pi)) / math.pi
lon = 360 * x
return math.round(lat * 1e12) / 1e12, math.round(lon * 1e12) / 1e12
return int(lat * 1e12) / 1e12, int(lon * 1e12) / 1e12

cpdef (long, long) pixel_to_tile(const (long, long) pixel):
return pixel[0] // 256, pixel[1] // 256
Expand Down
1 change: 1 addition & 0 deletions tests/test_quadkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def testInitInvalidKey(self):

def testFromGeo(self):
self.assertEqual('1202032333311320', quadkey.from_geo((49.014205, 8.420025), 16).key)
self.assertEqual('311213', quadkey.from_geo((-27.052395, 152.97702), 6).key) # https://github.com/muety/pyquadkey2/issues/13

def testFromGeoInvalidLevel(self):
with self.assertRaises(AssertionError):
Expand Down

0 comments on commit 58bf13a

Please sign in to comment.