Skip to content

Commit

Permalink
added to/from on QuadKey
Browse files Browse the repository at this point in the history
  • Loading branch information
Buck Heroux authored and Buck Heroux committed Apr 21, 2014
1 parent b54bca7 commit e161684
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions quadkey/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ def area(self):
def to_tile(self):
return TileSystem.quadkey_to_tile(self.key)

def to_geo(self):
ret = TileSystem.quadkey_to_tile(self.key)
tile = ret[0]
lvl = ret[1]
pixel = TileSystem.tile_to_pixel(tile)
return TileSystem.pixel_to_geo(pixel, lvl)

def __eq__(self, other):
return self.key == other.key

Expand All @@ -79,3 +86,7 @@ def from_geo(geo, level):
tile = TileSystem.pixel_to_tile(pixel)
key = TileSystem.tile_to_quadkey(tile, level)
return QuadKey(key)

@staticmethod
def from_tile(tile, level):
return QuadKey(TileSystem.tile_to_quadkey(tile, level))
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import setup

setup(name="quadkey",
version="0.0.1",
version="0.0.3",
description="Python Implementation for Geospatial Quadkeys",
author="Buck Heroux",
url="https://github.com/buckheroux/QuadKey",
Expand Down

0 comments on commit e161684

Please sign in to comment.