Skip to content

Commit

Permalink
2016-02-24
Browse files Browse the repository at this point in the history
Fix a bug in by_coordinate()
  • Loading branch information
MacHu-GWU committed Feb 24, 2016
1 parent 52692aa commit 06d46c6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
5 changes: 3 additions & 2 deletions source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import uszipcode
import sys
import os
import shlex
Expand Down Expand Up @@ -67,9 +68,9 @@
# built documents.
#
# The short X.Y version.
version = '0.0.7'
version = uszipcode.__version__
# The full version, including alpha/beta/rc tags.
release = '0.0.7'
release = uszipcode.__version__

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion uszipcode/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

from .searchengine import ZipcodeSearchEngine

__version__ = "0.0.8"
__version__ = "0.0.9"
__short_description__ = ("USA zipcode programmable database, includes "
"up-to-date census and geometry information.")
6 changes: 4 additions & 2 deletions uszipcode/searchengine.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import math
import json


class Zipcode(object):
"""Zipcode class. Attributes includes:
Expand Down Expand Up @@ -79,6 +80,7 @@ def __bool__(self):

_DEFAULT_LIMIT = 5


class ZipcodeSearchEngine(object):
"""A fast, powerful index optimized zipcode object search engine class.
Expand Down Expand Up @@ -183,8 +185,8 @@ def by_coordinate(self, lat, lng, radius=20, standard_only=True,
# define lat lng boundary
dist_btwn_lat_deg = 69.172
dist_btwn_lon_deg = math.cos(lat) * 69.172
lat_degr_rad = radius * 1.0/dist_btwn_lat_deg
lon_degr_rad = radius * 1.0/dist_btwn_lon_deg
lat_degr_rad = abs(radius * 1.0/dist_btwn_lat_deg)
lon_degr_rad = abs(radius * 1.0/dist_btwn_lon_deg)

lat_lower = lat - lat_degr_rad
lat_upper = lat + lat_degr_rad
Expand Down
26 changes: 16 additions & 10 deletions uszipcode/zzz_manual_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,16 @@
"""

from __future__ import print_function, unicode_literals
import hashlib, site, shutil, os
import hashlib
import site
import shutil
import os

_ROOT = os.getcwd()
_PACKAGE_NAME = os.path.basename(_ROOT)
_DST = os.path.join(site.getsitepackages()[1], _PACKAGE_NAME)



def md5_of_file(abspath):
"""Md5 value of a file.
"""
Expand All @@ -137,6 +141,7 @@ def md5_of_file(abspath):
m.update(data)
return m.hexdigest()


def check_need_install():
"""Check if installed package are exactly the same to this one.
"""
Expand All @@ -153,7 +158,8 @@ def check_need_install():
else:
return True
return need_install_flag



def install():
"""Manual install main script.
"""
Expand All @@ -164,29 +170,29 @@ def install():
print("\tpackage is up-to-date, no need to install.")
return
print("Difference been found, start installing ...")

# remove __pycache__ folder and *.pyc file
print("Remove *.pyc file ...")
print("Remove *.pyc file ...")
pyc_folder_list = list()
for root, _, basename_list in os.walk(_ROOT):
if os.path.basename(root) == "__pycache__":
pyc_folder_list.append(root)

for folder in pyc_folder_list:
shutil.rmtree(folder)
print("\tall *.pyc file has been removed.")

# install this package to all python version
print("Uninstall %s from %s ..." % (_PACKAGE_NAME, _DST))
try:
shutil.rmtree(_DST)
print("\tSuccessfully uninstall %s" % _PACKAGE_NAME)
except Exception as e:
print("\t%s" % e)

print("Install %s to %s ..." % (_PACKAGE_NAME, _DST))
shutil.copytree(_ROOT, _DST)
shutil.copytree(_ROOT, _DST)
print("\tComplete!")

if __name__ == "__main__":
install()

0 comments on commit 06d46c6

Please sign in to comment.