Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Python 3 #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions proximityhash2/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
Copyright 2017 Ashwin Nair <https://www.linkedin.com/in/nairashwin7>

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

from .proximityhash import in_circle_check, get_centroid, convert_to_latlon, create_geohash
7 changes: 4 additions & 3 deletions proximityhash.py → proximityhash2/proximityhash.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Geohash
import geohash2
import georaptor
import math
import time
Expand Down Expand Up @@ -80,7 +80,7 @@ def create_geohash(latitude, longitude, radius, precision, georaptor_flag=False,


for point in points:
geohashes += [Geohash.encode(point[0], point[1], precision)]
geohashes += [geohash2.encode(point[0], point[1], precision)]

if georaptor_flag:
georaptor_out = georaptor.compress(set(geohashes), int(minlevel), int(maxlevel))
Expand Down Expand Up @@ -140,7 +140,8 @@ def main():
puts('\n')
puts(colored.red('Output:'))

print(create_geohash(float(latitude), float(longitude), float(radius), int(precision_level), georaptor_flag, int(minlevel), int(maxlevel)))
print((create_geohash(float(latitude), float(longitude), float(radius),
int(precision_level), georaptor_flag, int(minlevel), int(maxlevel))))

et = time.time() - start_time

Expand Down
22 changes: 11 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
import setuptools

setup(
name = 'proximityhash',
py_modules = ['proximityhash'],
version = '1.0.1',
description = 'Geohashes in proximity',
name = 'proximityhash2',
py_modules = ['proximityhash2'],
version = '1.1',
description = '(Fixed for Python 3) Geohashes in proximity',
long_description = open('README.rst').read(),
author = 'Ashwin Nair',
author_email = 'ashwinnair.ua@gmail.com',
author = 'Ashwin Nair, Reid Maulsby',
author_email = 'reid.maulsby@gmail.com',
license = "MIT",
url = 'https://github.com/ashwin711/proximityhash',
download_url = 'https://github.com/ashwin711/proximityhash/tarball/1.0.1',
url = 'https://github.com/rmaulsby/proximityhash',
download_url = 'https://github.com/rmaulsby/proximityhash/tarball/1.1',
keywords = ['geohash', 'optimizer', 'compression', 'geo', 'latitude', 'longitude', 'coordinates', 'proximity', 'circle'],
classifiers = [
'Development Status :: 5 - Production/Stable',
'Development Status :: 3 - Alpha',
'Environment :: Console',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
Expand All @@ -26,10 +26,10 @@
'clint',
'argparse',
'georaptor>=2.0.3',
'Geohash'
'geohash2'
],
entry_points='''
[console_scripts]
proximityhash=proximityhash:main
proximityhash2=proximityhash2:main
'''
)
14 changes: 7 additions & 7 deletions test/test_proximityhash.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
import unittest2
import proximityhash

class in_circle_test_case(unittest.TestCase):
class in_circle_test_case(unittest2.TestCase):
"""Tests for `in_circle_check`."""
def test_in_circle_check_true(self):
expected = True
Expand All @@ -13,27 +13,27 @@ def test_in_circle_check_false(self):
output = proximityhash.in_circle_check(12, 77, 23, 87, 100)
self.assertEqual(output, expected)

class centroid_test_case(unittest.TestCase):
class centroid_test_case(unittest2.TestCase):
"""Tests for `get_centroid`."""
def test_get_centroid(self):
expected = (15, 15)
output = proximityhash.get_centroid(10,10,10,10)
self.assertEqual(output, expected)

class latlon_convert_test_case(unittest.TestCase):
class latlon_convert_test_case(unittest2.TestCase):
"""Tests for `convert_to_latlon`."""
def test_convert_to_latlon(self):
expected = (12.008993216059187, 77.0091941298557)
output = proximityhash.convert_to_latlon(1000.0,1000.0, 12.0, 77.0)
self.assertEqual(output, expected)

class create_geohash_test_case(unittest.TestCase):
class create_geohash_test_case(unittest2.TestCase):
"""Tests for `create_geohash`."""
def test_create_geohash(self):
expected = 'tdnu20t9,tdnu20t8,tdnu20t3,tdnu20t2,tdnu20mz,tdnu20mx,tdnu20tc,tdnu20tb,tdnu20td,tdnu20tf'
output = proximityhash.create_geohash(12.0, 77.0, 20.0, 8, georaptor_flag=False, minlevel=1, maxlevel=12)
self.assertEqual(output, expected)
self.assertItemsEqual(output.split(","), expected.split(","))


if __name__ == '__main__':
unittest.main()
unittest2.main()