当前位置: 首页>>代码示例>>Python>>正文


Python LatLng.from_degrees方法代码示例

本文整理汇总了Python中s2sphere.LatLng.from_degrees方法的典型用法代码示例。如果您正苦于以下问题:Python LatLng.from_degrees方法的具体用法?Python LatLng.from_degrees怎么用?Python LatLng.from_degrees使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在s2sphere.LatLng的用法示例。


在下文中一共展示了LatLng.from_degrees方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: neighbor_s2_circle

# 需要导入模块: from s2sphere import LatLng [as 别名]
# 或者: from s2sphere.LatLng import from_degrees [as 别名]
def neighbor_s2_circle(location, i_dir=0.0, j_dir=0.0):  # input location can be list, tuple or Point
    if type(location) in (list, tuple):
        ll_location = LatLng.from_degrees(location[0], location[1])
    elif type(location) is Point:
        ll_location = LatLng.from_point(location)
    elif type(location) is LatLng:
        ll_location = location
    else:
        return None

    cid_large = CellId.from_lat_lng(ll_location).parent(lvl_big)

    cid_small = cid_large.child_begin(lvl_small)
    vec_to_j = (Cell(ij_offs(cid_small, 0, 1)).get_center() - Cell(cid_small).get_center()).normalize()
    vec_to_i = (Cell(ij_offs(cid_small, 1, 0)).get_center() - Cell(cid_small).get_center()).normalize()

    vec_newlocation = ll_location.to_point() + safety * HEX_R / earth_Rrect * (i_dir * 3 ** 0.5 * vec_to_i + j_dir * 1.5 * vec_to_j)

    return vec_newlocation  # output is Point 
开发者ID:seikur0,项目名称:PGO-mapscan-opt,代码行数:21,代码来源:maplib.py

示例2: cover_cell

# 需要导入模块: from s2sphere import LatLng [as 别名]
# 或者: from s2sphere.LatLng import from_degrees [as 别名]
def cover_cell(self, cid):
        lats = []
        lngs = []
        output = []
        s2_cell = Cell(cid)
        lvl = s2_cell.level()
        for i in [0, 1]:
            for j in [0, 1]:
                lats.append(s2_cell.get_latitude(i, j)/pi*180)
                lngs.append(s2_cell.get_longitude(i, j)/pi*180)
        locations = self.cover_region((min(lats),min(lngs)),(max(lats),max(lngs)))
        for location in locations:
            testid = CellId.from_lat_lng(LatLng.from_degrees(location[0],location[1])).parent(lvl)
            if testid == cid:
                output.append(location)

        return output 
开发者ID:seikur0,项目名称:PGO-mapscan-opt,代码行数:19,代码来源:maplib.py

示例3: testDistance

# 需要导入模块: from s2sphere import LatLng [as 别名]
# 或者: from s2sphere.LatLng import from_degrees [as 别名]
def testDistance(self):
        self.assertEqual(
            0.0,
            LatLng.from_degrees(90, 0).get_distance(
                LatLng.from_degrees(90, 0)
            ).radians)
        self.assertAlmostEqual(
            77.0,
            LatLng.from_degrees(-37, 25).get_distance(
                LatLng.from_degrees(-66, -155)
            ).degrees, delta=1e-13)
        self.assertAlmostEqual(
            115.0,
            LatLng.from_degrees(0, 165).get_distance(
                LatLng.from_degrees(0, -80)
            ).degrees, delta=1e-13)
        self.assertAlmostEqual(
            180.0,
            LatLng.from_degrees(47, -127).get_distance(
                LatLng.from_degrees(-47, 53)
            ).degrees, delta=2e-6) 
开发者ID:sidewalklabs,项目名称:s2sphere,代码行数:23,代码来源:sphere_test.py

示例4: testFromCenterSize

# 需要导入模块: from s2sphere import LatLng [as 别名]
# 或者: from s2sphere.LatLng import from_degrees [as 别名]
def testFromCenterSize(self):
        self.assertTrue(
            LatLngRect.from_center_size(
                LatLng.from_degrees(80, 170),
                LatLng.from_degrees(40, 60),
            ).approx_equals(self.rect_from_degrees(60, 140, 90, -160))
        )

        self.assertTrue(LatLngRect.from_center_size(
            LatLng.from_degrees(10, 40),
            LatLng.from_degrees(210, 400)).is_full()) \

        self.assertTrue(
            LatLngRect.from_center_size(
                LatLng.from_degrees(-90, 180),
                LatLng.from_degrees(20, 50),
            ).approx_equals(self.rect_from_degrees(-90, 155, -80, -155))
        ) 
开发者ID:sidewalklabs,项目名称:s2sphere,代码行数:20,代码来源:sphere_test.py

示例5: testExpanded

# 需要导入模块: from s2sphere import LatLng [as 别名]
# 或者: from s2sphere.LatLng import from_degrees [as 别名]
def testExpanded(self):
        self.assertTrue(self.rect_from_degrees(70, 150, 80, 170)
                        .expanded(LatLng.from_degrees(20, 30))
                        .approx_equals(
                            self.rect_from_degrees(50, 120, 90, -160))
                        )
        self.assertTrue(LatLngRect.empty().expanded(
            LatLng.from_degrees(20, 30)).is_empty())
        self.assertTrue(LatLngRect.full().expanded(
            LatLng.from_degrees(20, 30)).is_full())

        self.assertTrue(self.rect_from_degrees(-90, 170, 10, 20)
                        .expanded(LatLng.from_degrees(30, 80))
                        .approx_equals(
                            self.rect_from_degrees(-90, -180, 40, 180))
                        ) 
开发者ID:sidewalklabs,项目名称:s2sphere,代码行数:18,代码来源:sphere_test.py

示例6: testGetCapBound

# 需要导入模块: from s2sphere import LatLng [as 别名]
# 或者: from s2sphere.LatLng import from_degrees [as 别名]
def testGetCapBound(self):

        # Bounding cap at center is smaller:
        self.assertTrue(
            self.rect_from_degrees(-45, -45, 45, 45)
            .get_cap_bound()
            .approx_equals(Cap.from_axis_height(Point(1, 0, 0), 0.5)))

        # Bounding cap at north pole is smaller:
        self.assertTrue(
            self.rect_from_degrees(88, -80, 89, 80)
            .get_cap_bound()
            .approx_equals(Cap.from_axis_angle(Point(0, 0, 1),
                           Angle.from_degrees(2))))

        # Longitude span > 180 degrees:
        self.assertTrue(
            self.rect_from_degrees(-30, -150, -10, 50)
            .get_cap_bound()
            .approx_equals(Cap.from_axis_angle(Point(0, 0, -1),
                           Angle.from_degrees(80)))) 
开发者ID:sidewalklabs,项目名称:s2sphere,代码行数:23,代码来源:sphere_test.py

示例7: getCells

# 需要导入模块: from s2sphere import LatLng [as 别名]
# 或者: from s2sphere.LatLng import from_degrees [as 别名]
def getCells(self, radius=10):
        origin = CellId.from_lat_lng(
            LatLng.from_degrees(
                self.latitude,
                self.longitude
            )
        ).parent(15)

        # Create walk around area
        walk = [origin.id()]
        right = origin.next()
        left = origin.prev()

        # Search around provided radius
        for _ in range(radius):
            walk.append(right.id())
            walk.append(left.id())
            right = right.next()
            left = left.prev()

        # Return everything
        return sorted(walk) 
开发者ID:cglatot,项目名称:PokeManager,代码行数:24,代码来源:location.py

示例8: cell_spiral

# 需要导入模块: from s2sphere import LatLng [as 别名]
# 或者: from s2sphere.LatLng import from_degrees [as 别名]
def cell_spiral(lat, lng, dist, level=15, step=100, res=3.6):
    cells = []

    g = Geodesic.WGS84  # @UndefinedVariable
    
    for i in range(0,dist,step):
        for rad in range(int(360/res)):
            p = g.Direct(lat, lng, rad*res, i)
            c = CellId.from_lat_lng(LatLng.from_degrees(p['lat2'],p['lon2']))
            c = c.parent(level)
            if c not in cells: cells.append(c)

    grid = []
    for cell in cells:
        grid.extend(get_cell_edges(cell))

    return grid 
开发者ID:tcmaps,项目名称:pickymap,代码行数:19,代码来源:ext.py

示例9: cover_region_s2

# 需要导入模块: from s2sphere import LatLng [as 别名]
# 或者: from s2sphere.LatLng import from_degrees [as 别名]
def cover_region_s2(location1,location2):
    rc = RegionCoverer()
    rc.max_level = lvl_big
    rc.min_level = lvl_big
    rc.max_cells = 1000
    locations = []

    if location1[0] > location2[0]:
        lat1,lat2 = location2[0],location1[0]
    else:
        lat1, lat2 = location1[0], location2[0]


    if location1[1] > location2[1]:
        lng1, lng2 = location2[1], location1[1]
    else:
        lng1, lng2 = location1[1], location2[1]

    lng1 = (lng1 + 180) % 360 - 180
    lng2 = (lng2 + 180) % 360 - 180

    lngs = []
    if lng2 > lng1:
        lngs.append((lng1,lng2))
    elif lng2 < lng1:
        lngs.append((-180.0,lng2))
        lngs.append((lng1,180.0))

    for lng1,lng2 in lngs:
        cids = rc.get_covering(LatLngRect(LatLng.from_degrees(lat1,lng1),LatLng.from_degrees(lat2,lng2)))

        for cid in cids:
            ll_cid = cid.to_lat_lng()
            locations.append((ll_cid.lat().degrees,ll_cid.lng().degrees))
    return locations 
开发者ID:seikur0,项目名称:PGO-mapscan-opt,代码行数:37,代码来源:maplib.py

示例10: getNeighbors

# 需要导入模块: from s2sphere import LatLng [as 别名]
# 或者: from s2sphere.LatLng import from_degrees [as 别名]
def getNeighbors(location):
    level = 15
    origin = CellId.from_lat_lng(LatLng.from_degrees(location[0], location[1])).parent(level)

    max_size = 1 << 30
    size = origin.get_size_ij(level)

    face, i, j = origin.to_face_ij_orientation()[0:3]
    walk = [origin.id(),
            origin.from_face_ij_same(face, i, j - size, j - size >= 0).parent(level).id(),
            origin.from_face_ij_same(face, i, j + size, j + size < max_size).parent(level).id(),
            origin.from_face_ij_same(face, i - size, j, i - size >= 0).parent(level).id(),
            origin.from_face_ij_same(face, i + size, j, i + size < max_size).parent(level).id(),
            origin.from_face_ij_same(face, i - size, j - size, j - size >= 0 and i - size >= 0).parent(level).id(),
            origin.from_face_ij_same(face, i + size, j - size, j - size >= 0 and i + size < max_size).parent(level).id(),
            origin.from_face_ij_same(face, i - size, j + size, j + size < max_size and i - size >= 0).parent(level).id(),
            origin.from_face_ij_same(face, i + size, j + size, j + size < max_size and i + size < max_size).parent(level).id()]
            #origin.from_face_ij_same(face, i, j - 2*size, j - 2*size >= 0).parent(level).id(),
            #origin.from_face_ij_same(face, i - size, j - 2*size, j - 2*size >= 0 and i - size >=0).parent(level).id(),
            #origin.from_face_ij_same(face, i + size, j - 2*size, j - 2*size >= 0 and i + size < max_size).parent(level).id(),
            #origin.from_face_ij_same(face, i, j + 2*size, j + 2*size < max_size).parent(level).id(),
            #origin.from_face_ij_same(face, i - size, j + 2*size, j + 2*size < max_size and i - size >=0).parent(level).id(),
            #origin.from_face_ij_same(face, i + size, j + 2*size, j + 2*size < max_size and i + size < max_size).parent(level).id(),
            #origin.from_face_ij_same(face, i + 2*size, j, i + 2*size < max_size).parent(level).id(),
            #origin.from_face_ij_same(face, i + 2*size, j - size, j - size >= 0 and i + 2*size < max_size).parent(level).id(),
            #origin.from_face_ij_same(face, i + 2*size, j + size, j + size < max_size and i + 2*size < max_size).parent(level).id(),
            #origin.from_face_ij_same(face, i - 2*size, j, i - 2*size >= 0).parent(level).id(),
            #origin.from_face_ij_same(face, i - 2*size, j - size, j - size >= 0 and i - 2*size >=0).parent(level).id(),
            #origin.from_face_ij_same(face, i - 2*size, j + size, j + size < max_size and i - 2*size >=0).parent(level).id()]
    return walk 
开发者ID:seikur0,项目名称:PGO-mapscan-opt,代码行数:32,代码来源:main0.py

示例11: get_cell_ids

# 需要导入模块: from s2sphere import LatLng [as 别名]
# 或者: from s2sphere.LatLng import from_degrees [as 别名]
def get_cell_ids(lat, long, radius=500):
    if radius > 500:
        radius = 500
    region = Cap.from_axis_angle(LatLng.from_degrees(lat, long).to_point(), Angle.from_degrees(360*radius/(2*math.pi*EARTH_RADIUS)))
    coverer = RegionCoverer()
    coverer.min_level = 15
    coverer.max_level = 15
    cells = coverer.get_covering(region)
    cells = cells[:21]
    return sorted([x.id() for x in cells]) 
开发者ID:PokeHunterProject,项目名称:pogom-linux,代码行数:12,代码来源:utilities.py

示例12: testPiRadiansExactly180Degrees

# 需要导入模块: from s2sphere import LatLng [as 别名]
# 或者: from s2sphere.LatLng import from_degrees [as 别名]
def testPiRadiansExactly180Degrees(self):
        self.assertEqual(Angle.from_radians(math.pi).radians, math.pi)
        self.assertEqual(Angle.from_radians(math.pi).degrees, 180.0)
        self.assertEqual(Angle.from_degrees(180).radians, math.pi)
        self.assertEqual(Angle.from_degrees(180).degrees, 180.0)

        self.assertEqual(Angle.from_radians((-math.pi / 2)).degrees, -90.0)
        self.assertEqual(Angle.from_degrees((-45)).radians, -math.pi / 4) 
开发者ID:sidewalklabs,项目名称:s2sphere,代码行数:10,代码来源:sphere_test.py

示例13: testBasics

# 需要导入模块: from s2sphere import LatLng [as 别名]
# 或者: from s2sphere.LatLng import from_degrees [as 别名]
def testBasics(self):
        ll_rad = LatLng.from_radians(math.pi / 4, math.pi / 2)
        self.assertEqual(ll_rad.lat().radians, math.pi / 4)
        self.assertEqual(ll_rad.lng().radians, math.pi / 2)
        self.assertTrue(ll_rad.is_valid())

        ll_deg = LatLng.from_degrees(45, 90)
        self.assertEqual(ll_rad, ll_deg)
        self.assertFalse(LatLng.from_degrees(-91, 0).is_valid())
        self.assertFalse(LatLng.from_degrees(0, 181).is_valid())

        bad = LatLng.from_degrees(120, 200)
        self.assertFalse(bad.is_valid())
        better = bad.normalized()
        self.assertTrue(better.is_valid())
        self.assertEqual(Angle.from_degrees(90), better.lat())
        self.assertEqual(Angle.from_degrees(-160).radians,
                         better.lng().radians)

        self.assertTrue(
            (LatLng.from_degrees(10, 20) + LatLng.from_degrees(20, 30))
            .approx_equals(LatLng.from_degrees(30, 50)))
        self.assertTrue(
            (LatLng.from_degrees(10, 20) - LatLng.from_degrees(20, 30))
            .approx_equals(LatLng.from_degrees(-10, -10)))
        # self.assertTrue((0.5 * LatLng.from_degrees(10, 20)).approx_equals(
        #            LatLng.from_degrees(5, 10)))

        invalid = LatLng.invalid()
        self.assertFalse(invalid.is_valid())

        default_ll = LatLng.default()
        self.assertTrue(default_ll.is_valid())
        self.assertEqual(0, default_ll.lat().radians)
        self.assertEqual(0, default_ll.lng().radians) 
开发者ID:sidewalklabs,项目名称:s2sphere,代码行数:37,代码来源:sphere_test.py

示例14: testConversion

# 需要导入模块: from s2sphere import LatLng [as 别名]
# 或者: from s2sphere.LatLng import from_degrees [as 别名]
def testConversion(self):
        self.assertEqual(LatLng.from_point(LatLng.from_degrees(
            90.0, 65.0).to_point()).lat().degrees, 90.0)

        self.assertEqual(LatLng.from_point(LatLng.from_radians(
            -math.pi / 2, 1).to_point()).lat().radians, -math.pi / 2)

        self.assertEqual(abs(LatLng.from_point(LatLng.from_degrees(
            12.2, 180.0).to_point()).lng().degrees), 180.0)

        self.assertEqual(abs(LatLng.from_point(LatLng.from_radians(
            0.1, -math.pi).to_point()).lng().radians), math.pi) 
开发者ID:sidewalklabs,项目名称:s2sphere,代码行数:14,代码来源:sphere_test.py

示例15: get_cell_id

# 需要导入模块: from s2sphere import LatLng [as 别名]
# 或者: from s2sphere.LatLng import from_degrees [as 别名]
def get_cell_id(lat, lng):
        return CellId.from_lat_lng(LatLng.from_degrees(lat, lng)) 
开发者ID:sidewalklabs,项目名称:s2sphere,代码行数:4,代码来源:sphere_test.py


注:本文中的s2sphere.LatLng.from_degrees方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。