Skip to content

Commit 06d46c6

Browse files
committed
2016-02-24
Fix a bug in by_coordinate()
1 parent 52692aa commit 06d46c6

4 files changed

Lines changed: 24 additions & 15 deletions

File tree

source/conf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# All configuration values have a default; values that are commented out
1414
# serve to show the default.
1515

16+
import uszipcode
1617
import sys
1718
import os
1819
import shlex
@@ -67,9 +68,9 @@
6768
# built documents.
6869
#
6970
# The short X.Y version.
70-
version = '0.0.7'
71+
version = uszipcode.__version__
7172
# The full version, including alpha/beta/rc tags.
72-
release = '0.0.7'
73+
release = uszipcode.__version__
7374

7475
# The language for content autogenerated by Sphinx. Refer to documentation
7576
# for a list of supported languages.

uszipcode/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
from .searchengine import ZipcodeSearchEngine
55

6-
__version__ = "0.0.8"
6+
__version__ = "0.0.9"
77
__short_description__ = ("USA zipcode programmable database, includes "
88
"up-to-date census and geometry information.")

uszipcode/searchengine.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import math
1212
import json
1313

14+
1415
class Zipcode(object):
1516
"""Zipcode class. Attributes includes:
1617
@@ -79,6 +80,7 @@ def __bool__(self):
7980

8081
_DEFAULT_LIMIT = 5
8182

83+
8284
class ZipcodeSearchEngine(object):
8385
"""A fast, powerful index optimized zipcode object search engine class.
8486
@@ -183,8 +185,8 @@ def by_coordinate(self, lat, lng, radius=20, standard_only=True,
183185
# define lat lng boundary
184186
dist_btwn_lat_deg = 69.172
185187
dist_btwn_lon_deg = math.cos(lat) * 69.172
186-
lat_degr_rad = radius * 1.0/dist_btwn_lat_deg
187-
lon_degr_rad = radius * 1.0/dist_btwn_lon_deg
188+
lat_degr_rad = abs(radius * 1.0/dist_btwn_lat_deg)
189+
lon_degr_rad = abs(radius * 1.0/dist_btwn_lon_deg)
188190

189191
lat_lower = lat - lat_degr_rad
190192
lat_upper = lat + lat_degr_rad

uszipcode/zzz_manual_install.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,16 @@
118118
"""
119119

120120
from __future__ import print_function, unicode_literals
121-
import hashlib, site, shutil, os
121+
import hashlib
122+
import site
123+
import shutil
124+
import os
122125

123126
_ROOT = os.getcwd()
124127
_PACKAGE_NAME = os.path.basename(_ROOT)
125128
_DST = os.path.join(site.getsitepackages()[1], _PACKAGE_NAME)
126-
129+
130+
127131
def md5_of_file(abspath):
128132
"""Md5 value of a file.
129133
"""
@@ -137,6 +141,7 @@ def md5_of_file(abspath):
137141
m.update(data)
138142
return m.hexdigest()
139143

144+
140145
def check_need_install():
141146
"""Check if installed package are exactly the same to this one.
142147
"""
@@ -153,7 +158,8 @@ def check_need_install():
153158
else:
154159
return True
155160
return need_install_flag
156-
161+
162+
157163
def install():
158164
"""Manual install main script.
159165
"""
@@ -164,29 +170,29 @@ def install():
164170
print("\tpackage is up-to-date, no need to install.")
165171
return
166172
print("Difference been found, start installing ...")
167-
173+
168174
# remove __pycache__ folder and *.pyc file
169-
print("Remove *.pyc file ...")
175+
print("Remove *.pyc file ...")
170176
pyc_folder_list = list()
171177
for root, _, basename_list in os.walk(_ROOT):
172178
if os.path.basename(root) == "__pycache__":
173179
pyc_folder_list.append(root)
174-
180+
175181
for folder in pyc_folder_list:
176182
shutil.rmtree(folder)
177183
print("\tall *.pyc file has been removed.")
178-
184+
179185
# install this package to all python version
180186
print("Uninstall %s from %s ..." % (_PACKAGE_NAME, _DST))
181187
try:
182188
shutil.rmtree(_DST)
183189
print("\tSuccessfully uninstall %s" % _PACKAGE_NAME)
184190
except Exception as e:
185191
print("\t%s" % e)
186-
192+
187193
print("Install %s to %s ..." % (_PACKAGE_NAME, _DST))
188-
shutil.copytree(_ROOT, _DST)
194+
shutil.copytree(_ROOT, _DST)
189195
print("\tComplete!")
190-
196+
191197
if __name__ == "__main__":
192198
install()

0 commit comments

Comments
 (0)