Bounding box (lat and lon of top left and bottom right points, map zoom)
 Usage: OpenWeather::Current.rectangle_zone(12, 32, 15, 37, 10)
196796
def rectangle_zone(top_left_lat, top_left_lon,
                       bottom_right_lat, bottom_right_lon,
                       map_zoom, options = {})
      url = 'http://api.openweathermap.org/data/2.5/box/city'
      bbox = encode_array [top_left_lat, top_left_lon, bottom_right_lat,
              bottom_right_lon, map_zoom]
      new(options.merge(bbox: bbox)).retrieve url
    end
966569
def get_bounding_box(self):
        """"""
        from pyproj import Geod
        geod = Geod(ellps='WGS84')
        dataset_group = DATASET_KEYS[self.datasets[0]]
        idx = 0
        lons_ring = None
        lats_ring = None
        while True:
            path = 'Data_Products/{dataset_group}/{dataset_group}_Gran_{idx}/attr/'
            prefix = path.format(dataset_group=dataset_group, idx=idx)
            try:
                lats = self.file_content[prefix + 'G-Ring_Latitude']
                lons = self.file_content[prefix + 'G-Ring_Longitude']
                if lons_ring is None:
                    lons_ring = lons
                    lats_ring = lats
                else:
                    prev_lon = lons_ring[0]
                    prev_lat = lats_ring[0]
                    dists = list(geod.inv(lon, lat, prev_lon, prev_lat)[2] for lon, lat in zip(lons, lats))
                    first_idx = np.argmin(dists)
                    if first_idx == 2 and len(lons) == 8:
                        lons_ring = np.hstack((lons[:3], lons_ring[:-2], lons[4:]))
                        lats_ring = np.hstack((lats[:3], lats_ring[:-2], lats[4:]))
                    else:
                        raise NotImplementedError("Don't know how to handle G-Rings of length %d" % len(lons))

            except KeyError:
                break
            idx += 1

        return lons_ring, lats_ring
1924
public void getBounds(Rect bounds) {
        final int outerX = (int) mTargetX;
        final int outerY = (int) mTargetY;
        final int r = (int) mTargetRadius + 1;
        bounds.set(outerX - r, outerY - r, outerX + r, outerY + r);
    }
1097864
public static RectangleLength2D_F32 boundBoxInside(int srcWidth, int srcHeight,
													   PixelTransform<Point2D_F32> transform,
													   Point2D_F32 work )
	{
		List<Point2D_F32> points = computeBoundingPoints(srcWidth, srcHeight, transform, work);
		Point2D_F32 center = new Point2D_F32();
		UtilPoint2D_F32.mean(points,center);

		float x0,x1,y0,y1;
		x0 = y0 = Float.MAX_VALUE;
		x1 = y1 = -Float.MAX_VALUE;

		for (int i = 0; i < points.size(); i++) {
			Point2D_F32 p = points.get(i);
			if( p.x < x0 )
				x0 = p.x;
			if( p.x > x1 )
				x1 = p.x;
			if( p.y < y0 )
				y0 = p.y;
			if( p.y > y1 )
				y1 = p.y;
		}

		x0 -= center.x;
		x1 -= center.x;
		y0 -= center.y;
		y1 -= center.y;

		float ox0 = x0;
		float oy0 = y0;
		float ox1 = x1;
		float oy1 = y1;


		for (int i = 0; i < points.size(); i++) {
			Point2D_F32 p = points.get(i);
			float dx = p.x-center.x;
			float dy = p.y-center.y;

			// see if the point is inside the box
			if( dx > x0 && dy > y0 && dx < x1 && dy < y1 ) {
				// find smallest reduction in side length and closest to original rectangle
				float d0 = (float) (float)Math.abs(dx - x0) + x0 - ox0;
				float d1 = (float) (float)Math.abs(dx - x1) + ox1 - x1;
				float d2 = (float) (float)Math.abs(dy - y0) + y0 - oy0;
				float d3 = (float) (float)Math.abs(dy - y1) + oy1 - y1;

				if ( d0 <= d1 && d0 <= d2 && d0 <= d3) {
					x0 = dx;
				} else if (d1 <= d2 && d1 <= d3) {
					x1 = dx;
				} else if (d2 <= d3) {
					y0 = dy;
				} else {
					y1 = dy;
				}
			}
		}

		return new RectangleLength2D_F32(x0+center.x,y0+center.y,x1-x0,y1-y0);
	}
611416
def get_boundingbox(self):
        
        b = BoundingBox()
        for rx,rz in self.regionfiles.keys():
            region = self.get_region(rx,rz)
            rx,rz = 32*rx,32*rz
            for cc in region.get_chunk_coords():
                x,z = (rx+cc['x'],rz+cc['z'])
                b.expand(x,None,z)
        return b
33527
def bounds(self):
        """"""
        google_x, google_y = self.google
        pixel_x_west, pixel_y_north = google_x * TILE_SIZE, google_y * TILE_SIZE
        pixel_x_east, pixel_y_south = (google_x + 1) * TILE_SIZE, (google_y + 1) * TILE_SIZE

        point_min = Point.from_pixel(pixel_x=pixel_x_west, pixel_y=pixel_y_south, zoom=self.zoom)
        point_max = Point.from_pixel(pixel_x=pixel_x_east, pixel_y=pixel_y_north, zoom=self.zoom)
        return point_min, point_max
1186598
def bounds(self, pixelbuffer=0):
        
        left = self._left
        bottom = self._bottom
        right = self._right
        top = self._top
        if pixelbuffer:
            offset = self.pixel_x_size * float(pixelbuffer)
            left -= offset
            bottom -= offset
            right += offset
            top += offset
        # on global grids clip at northern and southern TilePyramid bound
        if self.tp.grid.is_global:
            top = min([top, self.tile_pyramid.top])
            bottom = max([bottom, self.tile_pyramid.bottom])
        return Bounds(left, bottom, right, top)
1233230
def bounding_box(positions):
    '''
    '''
    (x0, y0, z0) = (x1, y1, z1) = positions[0]
    for x, y, z in positions:
        x0 = min(x0, x)
        y0 = min(y0, y)
        z0 = min(z0, z)
        x1 = max(x1, x)
        y1 = max(y1, y)
        z1 = max(z1, z)
    return (x0, y0, z0), (x1, y1, z1)
892337
def circle_zone(lat, lon, count, options = {})
      url = 'http://api.openweathermap.org/data/2.5/find'
      new(options.merge(lat: lat, lon: lon, cnt: count)).retrieve url
    end
943612
function (position) {
        if (position instanceof OpenLayers.Bounds) {
            var bounds,
                targetCenterPx = position.getCenterPixel();
            if (!this.out) {
                var minXY = this.map.getLonLatFromPixel({
                    x: position.left,
                    y: position.bottom
                });
                var maxXY = this.map.getLonLatFromPixel({
                    x: position.right,
                    y: position.top
                });
                bounds = new OpenLayers.Bounds(minXY.lon, minXY.lat,
                                               maxXY.lon, maxXY.lat);
            } else {
                var pixWidth = position.right - position.left;
                var pixHeight = position.bottom - position.top;
                var zoomFactor = Math.min((this.map.size.h / pixHeight),
                    (this.map.size.w / pixWidth));
                var extent = this.map.getExtent();
                var center = this.map.getLonLatFromPixel(targetCenterPx);
                var xmin = center.lon - (extent.getWidth()/2)*zoomFactor;
                var xmax = center.lon + (extent.getWidth()/2)*zoomFactor;
                var ymin = center.lat - (extent.getHeight()/2)*zoomFactor;
                var ymax = center.lat + (extent.getHeight()/2)*zoomFactor;
                bounds = new OpenLayers.Bounds(xmin, ymin, xmax, ymax);
            }
            // always zoom in/out 
            var lastZoom = this.map.getZoom(),
                size = this.map.getSize(),
                centerPx = {x: size.w / 2, y: size.h / 2},
                zoom = this.map.getZoomForExtent(bounds),
                oldRes = this.map.getResolution(),
                newRes = this.map.getResolutionForZoom(zoom);
            if (oldRes == newRes) {
                this.map.setCenter(this.map.getLonLatFromPixel(targetCenterPx));
            } else {
              var zoomOriginPx = {
                    x: (oldRes * targetCenterPx.x - newRes * centerPx.x) /
                        (oldRes - newRes),
                    y: (oldRes * targetCenterPx.y - newRes * centerPx.y) /
                        (oldRes - newRes)
                };
                this.map.zoomTo(zoom, zoomOriginPx);
            }
            if (lastZoom == this.map.getZoom() && this.alwaysZoom == true){ 
                this.map.zoomTo(lastZoom + (this.out ? -1 : 1)); 
            }
        } else if (this.zoomOnClick) { // it's a pixel
            if (!this.out) {
                this.map.zoomTo(this.map.getZoom() + 1, position);
            } else {
                this.map.zoomTo(this.map.getZoom() - 1, position);
            }
        }
    }
1366565
def coord(self, offset=(0,0)):
		''''''
		(tilex, tiley) = self.tile
		(offsetx, offsety) = offset
		world_tiles = 1<<self.zoom
		x = ( tilex + 1.0*offsetx/TILES_WIDTH ) / (world_tiles/2.) - 1
		y = ( tiley + 1.0*offsety/TILES_HEIGHT) / (world_tiles/2.) - 1
		lon = x * 180.0
		y = math.exp(-y*2*math.pi)
		e = (y-1)/(y+1)
		lat = 180.0/math.pi * math.asin(e)
		return (lat, lon)
186611
private void expandBoundingBox(BoundingBox boundingBox, LatLng latLng) {

        double latitude = latLng.latitude;
        double longitude = latLng.longitude;

        if (boundingBox.getMinLongitude() <= 3 * ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH && boundingBox.getMaxLongitude() >= 3 * -ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH) {
            if (longitude < boundingBox.getMinLongitude()) {
                if (boundingBox.getMinLongitude()
                        - longitude > (longitude + (2 * ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH)) - boundingBox.getMaxLongitude()) {
                    longitude += (2 * ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH);
                }
            } else if (longitude > boundingBox.getMaxLongitude()) {
                if (longitude - boundingBox.getMaxLongitude() > boundingBox.getMinLongitude()
                        - (longitude - (2 * ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH))) {
                    longitude -= (2 * ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH);
                }
            }
        }

        if (latitude < boundingBox.getMinLatitude()) {
            boundingBox.setMinLatitude(latitude);
        }
        if (latitude > boundingBox.getMaxLatitude()) {
            boundingBox.setMaxLatitude(latitude);
        }
        if (longitude < boundingBox.getMinLongitude()) {
            boundingBox.setMinLongitude(longitude);
        }
        if (longitude > boundingBox.getMaxLongitude()) {
            boundingBox.setMaxLongitude(longitude);
        }

    }
1373736
def bound(self, p1, p2=None):
    """"""
    r = Rect(p1, p2)
    return Point(min(max(self.x, r.l), r.r), min(max(self.y, r.t), r.b))
174272
def check_bounding_rect(rect_pos):
    """"""

    if not isinstance(rect_pos, Iterable):
        raise ValueError('rectangle spect must be a tuple of floats '
                         'specifying (left, right, width, height)')

    left, bottom, width, height = rect_pos
    for val, name in zip((left, bottom, width, height),
                         ('left', 'bottom', 'width', 'height')):
        if val < 0.0 or val > 1.0:
            raise ValueError("{}'s value must be >=0 and <= 1.0. "
                             "It is now {}".format(name, val))

    if left + width > 1.0:
        print('rect would extend beyond the width of figure/axis by {}'.format(left + width - 1.0))

    if bottom + height > 1.0:
        print('rect would extend beyond the height of figure/axis by {}'.format(
            bottom + height - 1.0))

    return rect_pos
367921
public static BoundingBox getBoundingBox(int x, int y, int zoom) {

		int tilesPerSide = tilesPerSide(zoom);
		double tileWidthDegrees = tileWidthDegrees(tilesPerSide);
		double tileHeightDegrees = tileHeightDegrees(tilesPerSide);

		double minLon = -180.0 + (x * tileWidthDegrees);
		double maxLon = minLon + tileWidthDegrees;

		double maxLat = 90.0 - (y * tileHeightDegrees);
		double minLat = maxLat - tileHeightDegrees;

		BoundingBox box = new BoundingBox(minLon, minLat, maxLon, maxLat);

		return box;
	}
1340608
function zoomCondition(zoom) {
    var zooms = [];
    for (var i = 0; i <= _carto2['default'].tree.Zoom.maxZoom; i++) {
        if (zoom & 1 << i) {
            zooms.push(i);
        }
    }

    var zoomRanges = detectZoomRanges(zooms),
        value,
        operator;
    if (zoomRanges.length > 1) {
        operator = 'IN';
        value = zooms;
    } else {
        var range = zoomRanges[0];
        if (range[0] === 0) {
            operator = '<=';
            value = range[1];
        } else if (range[1] === _carto2['default'].tree.Zoom.maxZoom) {
            operator = '>=';
            value = range[0];
        } else {
            // We're only handling >=, <= and IN right now
            operator = 'IN';
            value = zooms;
        }
    }

    if (value.length === 0) {
        return null;
    }
    return [{
        operator: operator,
        type: 'zoom',
        value: value
    }];
}
1320099
def bounding_boxes(self):
        

        w2 = self.w_out / 2.
        h2 = self.h_out / 2.
        cos_theta = math.cos(self.theta)
        sin_theta = math.sin(self.theta)
        dx1 = abs(w2 * cos_theta - h2 * sin_theta)
        dy1 = abs(w2 * sin_theta + h2 * cos_theta)
        dx2 = abs(w2 * cos_theta + h2 * sin_theta)
        dy2 = abs(w2 * sin_theta - h2 * cos_theta)
        dx = max(dx1, dx2)
        dy = max(dy1, dy2)

        xmin = self.positions[:, 0] - dx
        xmax = self.positions[:, 0] + dx
        ymin = self.positions[:, 1] - dy
        ymax = self.positions[:, 1] + dy

        return [BoundingBox._from_float(x0, x1, y0, y1)
                for x0, x1, y0, y1 in zip(xmin, xmax, ymin, ymax)]