Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
U-NORTHAMERICA\taheroux authored and U-NORTHAMERICA\taheroux committed Apr 4, 2014
1 parent d43b2c0 commit b54bca7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
QuadKey
=======

Quad key object used for Geospatial segmentation
Quad key object used for Geospatial segmentation. Based off the idea of a quadtree and used as the Bing Maps tile system.

Given a (lat, lon) and level produce a quadkey to be used in Bing Maps.
Can also supply methods to generate a Google Maps TileXYZ

Built off of the TileSystem static class outlined here: http://msdn.microsoft.com/en-us/library/bb259689.aspx

Converts a lat,lon to pixel space to tile space to a quadkey


from quadkey import QuadKey

qk = QuadKey((-105, 40) 17)
qk = QuadKey.from_geo((-105, 40), 17)
print qk.key # => 02310101232121212
assert qk.level is 17
copy = QuadKey.from_str(qk.key)
tile = qk.to_tile() # => [(x, y), z]
4 changes: 4 additions & 0 deletions quadkey/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
class QuadKey:

@precondition(lambda c, key: valid_key(key))

def __init__(self, key):
"""
A quadkey must be between 1 and 23 digits and can only contain digit[0-3]
Expand Down Expand Up @@ -50,6 +51,9 @@ def area(self):
side = (size / 2) * res
return side*side

def to_tile(self):
return TileSystem.quadkey_to_tile(self.key)

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

Expand Down

0 comments on commit b54bca7

Please sign in to comment.