MCPcopy Create free account
hub / github.com/MacHu-GWU/uszipcode-project / by_coordinates

Method by_coordinates

uszipcode/search.py:683–712  ·  view source on GitHub ↗

Search zipcode information near a coordinates on a map. Returns multiple results. :param lat: center latitude. :param lng: center longitude. :param radius: only returns zipcode within X miles from ``lat``, ``lng``. **中文文档** 1. 计算出在中心坐标处, 每

(self,
                       lat,
                       lng,
                       radius=25.0,
                       zipcode_type=ZipcodeType.Standard,
                       sort_by=SORT_BY_DIST,
                       ascending=True,
                       returns=DEFAULT_LIMIT)

Source from the content-addressed store, hash-verified

681 )
682
683 def by_coordinates(self,
684 lat,
685 lng,
686 radius=25.0,
687 zipcode_type=ZipcodeType.Standard,
688 sort_by=SORT_BY_DIST,
689 ascending=True,
690 returns=DEFAULT_LIMIT):
691 """
692 Search zipcode information near a coordinates on a map.
693
694 Returns multiple results.
695
696 :param lat: center latitude.
697 :param lng: center longitude.
698 :param radius: only returns zipcode within X miles from ``lat``, ``lng``.
699
700 **中文文档**
701
702 1. 计算出在中心坐标处, 每一经度和纬度分别代表多少miles.
703 2. 以给定坐标为中心, 画出一个矩形, 长宽分别为半径的2倍多一点, 找到该
704 矩形内所有的Zipcode.
705 3. 对这些Zipcode计算出他们的距离, 然后按照距离远近排序。距离超过我们
706 限定的半径的直接丢弃.
707 """
708 return self.query(
709 lat=lat, lng=lng, radius=radius,
710 sort_by=sort_by, zipcode_type=zipcode_type,
711 ascending=ascending, returns=returns,
712 )
713
714 def by_population(self,
715 lower=-1,

Callers 2

test_by_coordinatesMethod · 0.80
test_edge_caseMethod · 0.80

Calls 1

queryMethod · 0.95

Tested by 2

test_by_coordinatesMethod · 0.64
test_edge_caseMethod · 0.64