Пример #1
0
 def latLngRectFromQueryRectangleInput(
         self, QueryRectangleRequest: 'QueryRectangleRequest'):
     queryRectangleRequest = QueryRectangleRequest
     minPoint = queryRectangleRequest.getMinPoint()
     maxPoint = queryRectangleRequest.getMaxPoint()
     latLngRect = None
     if minPoint is not None and maxPoint is not None:
         minLatLng = S2LatLng.from_degrees(minPoint.getLatitude(),
                                           minPoint.getLongitude())
         maxLatLng = S2LatLng.from_degrees(maxPoint.getLatitude(),
                                           maxPoint.getLongitude())
         latLngRect = S2LatLngRect.from_point_pair(minLatLng, maxLatLng)
     return latLngRect
Пример #2
0
def cover_square(lat, lng, width, level=15):
    offset = int(width / 2)
    g = Geodesic.WGS84  # @UndefinedVariable
    r = RegionCoverer()
    r.min_level, r.min_level = level, level
    g1 = g.Direct(lat, lng, 360, offset)
    g1 = g.Direct(g1['lat2'], g1['lon2'], 270, offset)
    p1 = LatLng.from_degrees(g1['lat2'], g1['lon2'])
    g2 = g.Direct(lat, lng, 180, offset)
    g2 = g.Direct(g2['lat2'], g2['lon2'], 90, offset)
    p2 = LatLng.from_degrees(g2['lat2'], g2['lon2'])
    cells = r.get_covering(LatLngRect.from_point_pair(p1, p2))
    return cells
Пример #3
0
def cover_square(lat, lng, width, level=15):
    offset = int(width / 2)
    g = Geodesic.WGS84  # @UndefinedVariable
    r = RegionCoverer()
    r.min_level, r.min_level = level, level
    g1 = g.Direct(lat, lng, 360, offset)
    g1 = g.Direct(g1['lat2'],g1['lon2'],270,offset)
    p1 = LatLng.from_degrees(g1['lat2'],g1['lon2'])
    g2 = g.Direct(lat, lng, 180, offset)
    g2 = g.Direct(g2['lat2'],g2['lon2'], 90,offset)
    p2 = LatLng.from_degrees(g2['lat2'],g2['lon2'])
    cells = r.get_covering(LatLngRect.from_point_pair(p1, p2))
    return cells
Пример #4
0
def _bbox_polyfill(
    geo_json,
    res,
):
    """returns list of S2 ids"""

    lat, lon = _geo_json_to_extremes(geo_json)

    p1 = LatLng.from_degrees(min(lat), min(lon))
    p2 = LatLng.from_degrees(max(lat), max(lon))

    region = LatLngRect.from_point_pair(p1, p2)

    coverer = RegionCoverer()
    coverer.min_level = res
    coverer.max_level = res
    return coverer.get_covering(region)