:param bbox: a bounding box in lon, lat
    :param lonlat_index: an rtree index in lon, lat
    :returns: array of indices within the bounding box
488324
def within(bbox, lonlat_index):
    
    lon1, lat1, lon2, lat2 = bbox
    set_ = set()
    for l1, l2 in normalize_lons(lon1, lon2):
        box = (l1, lat1, l2, lat2)
        set_ |= set(lonlat_index.intersection(box))
    return numpy.array(sorted(set_), numpy.uint32)
762439
private static ProjectorBounds getBounds(String crs, String s, String version) {
		if (s == null)
			return null;
		String[] items = s.split(",");
		double minLong;
		double minLat;
		double maxLong;
		double maxLat;
		/**
		 * there is some confusion about order of bbox parameters. The OpenGIS
		 * WMS 1.3.0 spec says:
		 * http://portal.opengeospatial.org/files/?artifact_id=14416, 7.3.3.6:
		 * The value of the BBOX parameter in a GetMap request is a list of
		 * comma-separated real numbers (see 6.5) in the form
		 * "minx,miny,maxx,maxy". These values specify the minimum X, minimum Y,
		 * maximum X, and maximum Y values of a region in the Layer CRS of the
		 * request.
		 * 
		 * Yet, the GeoServer doco says:
		 * 
		 * http://docs.geoserver.org/stable/en/user/services/wms/basics.html
		 *
		 * Apparently the bbox parameter order is now that determined by the CRS
		 * definition. EPSG:3857 for instance has this in its WKT: AXIS [X,
		 * "EAST"] AXIS[Y,"NORTH"]. Still can't suss it but getting closer!
		 * 
		 **/

		if (("1.1.1".equals(version) || ("1.1.0".equals(version)) || !("CRS:84".equals(crs)))) {
			minLong = Double.parseDouble(items[0]);
			minLat = Double.parseDouble(items[1]);
			maxLong = Double.parseDouble(items[2]);
			maxLat = Double.parseDouble(items[3]);
		} else {
			// this is the order for CRS:84 but EPSG:4326 apparently not
			minLat = Double.parseDouble(items[0]);
			minLong = Double.parseDouble(items[1]);
			maxLat = Double.parseDouble(items[2]);
			maxLong = Double.parseDouble(items[3]);
		}
		ProjectorBounds bounds = new ProjectorBounds(crs, minLong, minLat, maxLong, maxLat);

		return bounds;
	}
336256
def update_bbox(self):
        

        xmins, ymins, xmaxs, ymaxs = zip(*(feat.geometry.bbox for feat in self if feat.geometry.type != "Null"))
        bbox = [min(xmins), min(ymins), max(xmaxs), max(ymaxs)] 
        self._data["bbox"] = bbox
933048
def bbox(self):
        bbox = self._df[['id', 'x1', 'y1', 'x2', 'y2']].copy()
        # TODO: Fix this to become x, y, w, h
        if self.bbox_with_size:
            bbox['y2'] -= bbox['y1']
            bbox['x2'] -= bbox['x1']

        

        return to_array_list(bbox)
225730
function parseBBox(result) {
  if (result.geometry) {
    if (result.geometry.viewport) {
      const viewport = result.geometry.viewport
      return [viewport.southwest.lng, viewport.southwest.lat, viewport.northeast.lng, viewport.northeast.lat]
    }
  }
}
9079
def bbox2array(vol, bbox, order='F', readonly=False, lock=None, location=None):
  """"""
  location = location or vol.shared_memory_id
  shape = list(bbox.size3()) + [ vol.num_channels ]
  return ndarray(shape=shape, dtype=vol.dtype, location=location, 
    readonly=readonly, lock=lock, order=order)
771310
def bounding_box(lat, lng, zoom)
      top, left = MapKit.shift_latlng(lat, lng, @shift_x - @peak_x, @shift_y - @peak_y, zoom)
      bottom, right = MapKit.shift_latlng(top, left, @width, @height, zoom)
      MapKit::BoundingBox.new(top, left, bottom, right, zoom)
    end
890395
def reverse(self):
        
        return BBox((self.min_y, self.min_x, self.max_y, self.max_x), crs=self.crs)
10031
def index_lonlat_in_pixels(lon,lat,pixels,nside,sort=False,outside=-1):
    

    pix = ang2pix(nside,lon,lat)
    return index_pix_in_pixels(pix,pixels,sort,outside)
1268632
def set_query_latlon(self):
        '''
        
        '''

        if (isinstance(self.longitude, list) and
                isinstance(self.latitude, list)):
            self.lbox = True
            # west, east, south, north
            self.query.lonlat_box(self.longitude[0], self.longitude[1],
                                  self.latitude[0], self.latitude[1])
        else:
            self.lbox = False
            self.query.lonlat_point(self.longitude, self.latitude)
604532
def index_to_coordinates(self, index):
        
        self.validate_index(index)
        x = int(index % self.length)
        y = int((index - x) / self.length)
        return x, y
472469
def from_points(lons, lats):
        
        north, west = max(lats), min(lons)
        south, east = min(lats), max(lons)
        return BoundingBox(north=north, west=west, south=south, east=east)
586281
def __geo_multipoint(lat, lon, elev):
        
        logger_noaa_lpd.info("enter geo_multipoint")
        geo_dict = OrderedDict()
        geometry_dict = OrderedDict()
        coordinates = []
        # bbox = []
        temp = [None, None]
        # 4 unique values
        # # Creates bounding box
        # for index, point in enumerate(lat):
        #     bbox.append(lat[index])
        #     bbox.append(lon[index])

        # Creates coordinates list
        for i in lat:
            temp[0] = i
            for j in lon:
                temp[1] = j
                coordinates.append(copy.copy(temp))
        if elev:
            coordinates = coordinates + elev
        # Create geometry block
        geometry_dict['type'] = 'Polygon'
        geometry_dict['coordinates'] = coordinates
        # Create geo block
        geo_dict['type'] = 'Feature'
        # geo_dict['bbox'] = bbox
        geo_dict['geometry'] = geometry_dict

        return geo_dict
301703
def from_bboxes(bboxes):
        
        north = max([b.north for b in bboxes])
        south = min([b.south for b in bboxes])
        west = min([b.west for b in bboxes])
        east = max([b.east for b in bboxes])
        return BoundingBox(north=north, west=west, south=south, east=east)
1037823
def nearest_loc_obs(self, lat, lon):
        
        sitelist = self.loc_observations(SITELIST)
        sites = parse_sitelist(sitelist)
        site = get_nearest_site(sites, lat, lon)
        return self.loc_observations(site)
1355607
def get_bounding_box(points):
    
    assert len(points) > 0, "At least one point has to be given."
    min_x, max_x = points[0]['x'], points[0]['x']
    min_y, max_y = points[0]['y'], points[0]['y']
    for point in points:
        min_x, max_x = min(min_x, point['x']), max(max_x, point['x'])
        min_y, max_y = min(min_y, point['y']), max(max_y, point['y'])
    p1 = Point(min_x, min_y)
    p2 = Point(max_x, max_y)
    return BoundingBox(p1, p2)
775347
def get_coord_box(centre_x, centre_y, distance):
    """Todo: return coordinates inside a circle, rather than a square"""
    return {
        'top_left': (centre_x - distance, centre_y + distance),
        'top_right': (centre_x + distance, centre_y + distance),
        'bottom_left': (centre_x - distance, centre_y - distance),
        'bottom_right': (centre_x + distance, centre_y - distance),
    }