Computes our screen bounds, tile footprint and other useful cached metrics.
352481
protected void computeInfo (MisoSceneMetrics metrics)
    {
        // start with the screen coordinates of our origin tile
        Point tpos = MisoUtil.tileToScreen(
            metrics, info.x, info.y, new Point());

        // if the tile has an origin coordinate, use that, otherwise
        // compute it from the tile footprint
        int tox = tile.getOriginX(), toy = tile.getOriginY();
        if (tox == Integer.MIN_VALUE) {
            tox = tile.getBaseWidth() * metrics.tilehwid;
        }
        if (toy == Integer.MIN_VALUE) {
            toy = tile.getHeight();
        }

        bounds = new Rectangle(tpos.x + metrics.tilehwid - tox,
                               tpos.y + metrics.tilehei - toy,
                               tile.getWidth(), tile.getHeight());

        // compute our object footprint as well
        _frect = new Rectangle(info.x - tile.getBaseWidth() + 1,
                               info.y - tile.getBaseHeight() + 1,
                               tile.getBaseWidth(), tile.getBaseHeight());
        _footprint = MisoUtil.getFootprintPolygon(
            metrics, _frect.x, _frect.y, _frect.width, _frect.height);

        // compute our object spot if we've got one
        if (tile.hasSpot()) {
            _fspot = MisoUtil.tilePlusFineToFull(
                metrics, info.x, info.y, tile.getSpotX(), tile.getSpotY(),
                new Point());
            _sspot = MisoUtil.fullToScreen(
                metrics, _fspot.x, _fspot.y, new Point());
        }

//         Log.info("Computed object metrics " +
//                  "[tpos=" + StringUtil.coordsToString(tx, ty) +
//                  ", info=" + info +
//                  ", sbounds=" + StringUtil.toString(bounds) + "].");
    }
100674
def __initialize_cache(self):
        """"""
        if self.__cached_value_dirty is None:
            self.__cached_value_dirty = self.__cache.is_cached_value_dirty(self.__display_item, self.__cache_property_name)
            self.__cached_value = self.__cache.get_cached_value(self.__display_item, self.__cache_property_name)
310499
void computeSegmentEnergy( GrowQueue_I32 corners ) {
		if( energySegment.length < corners.size() ) {
			energySegment = new double[ corners.size() ];
		}

		for (int i = 0,j=corners.size()-1; i < corners.size(); j=i,i++) {
			energySegment[j] = computeSegmentEnergy(corners, j, i);
		}
	}
733071
protected List<TileCode> calcCodesForBounds(Bbox bounds) {
		// Calculate tile width and height for tileLevel=currentTileLevel
		double div = Math.pow(2, currentTileLevel); // tile level must be correct!
		double scale = layer.getMapModel().getMapView().getCurrentScale();
		double tileWidth = Math.ceil((scale * layerBounds.getWidth()) / div) / scale;
		double tileHeight = Math.ceil((scale * layerBounds.getHeight()) / div) / scale;

		// For safety (to prevent division by 0):
		List<TileCode> codes = new ArrayList<TileCode>();
		if (tileWidth == 0 || tileHeight == 0) {
			return codes;
		}

		// Calculate bounds relative to extents:
		Bbox clippedBounds = bounds.intersection(layerBounds);
		if (clippedBounds == null) {
			Log.logError("Map bounds outside of layer extents, check the server configuration, it is incorrect.");
			return codes;
		}
		double relativeBoundX = Math.abs(clippedBounds.getX() - layerBounds.getX());
		double relativeBoundY = Math.abs(clippedBounds.getY() - layerBounds.getY());
		currentMinX = (int) Math.floor(relativeBoundX / tileWidth);
		currentMinY = (int) Math.floor(relativeBoundY / tileHeight);
		currentMaxX = (int) Math.ceil((relativeBoundX + clippedBounds.getWidth()) / tileWidth) - 1;
		currentMaxY = (int) Math.ceil((relativeBoundY + clippedBounds.getHeight()) / tileHeight) - 1;

		// Now fill the list with the correct codes:
		for (int x = currentMinX; x <= currentMaxX; x++) {
			for (int y = currentMinY; y <= currentMaxY; y++) {
				codes.add(new TileCode(currentTileLevel, x, y));
			}
		}
		return codes;
	}
145877
def _get_tiles(self):
        """"""
        while self._running:
            self._updated.wait()
            self._updated.clear()

            # Save off current view and find the nearest tile.
            satellite = self._satellite
            zoom = self._zoom
            size = self._size
            n = 2 ** zoom
            x_offset = self._convert_longitude(self._longitude)
            y_offset = self._convert_latitude(self._latitude)

            # Get the visible tiles around that location - getting most relevant first
            for x, y, z in [(0, 0, 0), (1, 0, 0), (0, 1, 0), (-1, 0, 0), (0, -1, 0),
                            (0, 0, -1), (0, 0, 1),
                            (1, 1, 0), (1, -1, 0), (-1, -1, 0), (-1, 1, 0)]:
                # Restart if we've already zoomed to another level
                if self._zoom != zoom:
                    break

                # Don't get tile if it falls off the grid
                x_tile = int(x_offset // size) + x
                y_tile = int(y_offset // size) + y
                z_tile = zoom + z
                if (x_tile < 0 or x_tile >= n or y_tile < 0 or y_tile >= n or
                        z_tile < 0 or z_tile > 20):
                    continue
                # noinspection PyBroadException
                try:

                    # Don't bother rendering if the tile is not visible
                    top = y_tile * size - y_offset + self._screen.height // 2
                    left = (x_tile * size - x_offset + self._screen.width // 4) * 2
                    if z == 0 and (left > self._screen.width or left + self._size * 2 < 0 or
                                   top > self._screen.height or top + self._size < 0):
                        continue

                    if satellite:
                        self._get_satellite_tile(x_tile, y_tile, z_tile)
                    else:
                        self._get_vector_tile(x_tile, y_tile, z_tile)
                # pylint: disable=broad-except
                except Exception:
                    self._oops = "{} - tile loc: {} {} {}".format(
                        traceback.format_exc(), x_tile, y_tile, z_tile)

                # Generally refresh screen after we've downloaded everything
                self._screen.force_update()
775392
def update_view_bounds(self):
        """"""
        self.view_bounds.left = self.pan.X - self.world_center.X
        self.view_bounds.top = self.pan.Y - self.world_center.Y
        self.view_bounds.width = self.world_center.X * 2
        self.view_bounds.height = self.world_center.Y * 2
1117010
private List<org.geomajas.layer.tile.RasterTile> calculateTilesForBounds(Bbox bounds) {
		List<org.geomajas.layer.tile.RasterTile> tiles = new ArrayList<org.geomajas.layer.tile.RasterTile>();

		if (bounds.getHeight() == 0 || bounds.getWidth() == 0) {
			return tiles;
		}


		return tiles;
	}
393085
private void cutCurrentCache() {

		final File lock=Configuration.getInstance().getOsmdroidTileCache();
		synchronized (lock) {

			if (mUsedCacheSpace > Configuration.getInstance().getTileFileSystemCacheTrimBytes()) {

				Log.d(IMapView.LOGTAG,"Trimming tile cache from " + mUsedCacheSpace + " to "
						+ Configuration.getInstance().getTileFileSystemCacheTrimBytes());

				final List<File> z = getDirectoryFileList(Configuration.getInstance().getOsmdroidTileCache());

				// order list by files day created from old to new
				final File[] files = z.toArray(new File[0]);
				Arrays.sort(files, new Comparator<File>() {
					@Override
					public int compare(final File f1, final File f2) {
						return Long.valueOf(f1.lastModified()).compareTo(f2.lastModified());
					}
				});

				for (final File file : files) {
					if (mUsedCacheSpace <= Configuration.getInstance().getTileFileSystemCacheTrimBytes()) {
						break;
					}

					final long length = file.length();
					if (file.delete()) {
						if (Configuration.getInstance().isDebugTileProviders()){
							Log.d(IMapView.LOGTAG,"Cache trim deleting " + file.getAbsolutePath());
						}
						mUsedCacheSpace -= length;
					}
				}

				Log.d(IMapView.LOGTAG,"Finished trimming tile cache");
			}
		}
	}
332319
private ArrayList<Rect> calculateAllBounds(Paint paint) {
        ArrayList<Rect> list = new ArrayList<Rect>();
        //For each views (If no values then add a fake one)
        final int count = mRecyclerView.getAdapter().getItemCount();
        final int width = getWidth();
        final int halfWidth = width / 2;
        for (int i = 0; i < count; i++) {
            Rect bounds = calcBounds(i, paint);
            int w = bounds.right - bounds.left;
            int h = bounds.bottom - bounds.top;
            bounds.left = (int)(halfWidth - (w / 2f) + ((i - mCurrentPage - mPageOffset) * width));
            bounds.right = bounds.left + w;
            bounds.top = 0;
            bounds.bottom = h;
            list.add(bounds);
        }

        return list;
    }
637455
private void calculateMinimapAreaBounds() {
        if (minimapBounds == null) {
            return;
        }

        if (zoom == 1f) {
            miniMapRequired = false;
        } else {
            // Calculates the bounds of the current displayed area
            float x = (-currentXOffset - toCurrentScale(currentFilteredPage * optimalPageWidth)) //
                    / toCurrentScale(optimalPageWidth) * minimapBounds.width();
            float width = getWidth() / toCurrentScale(optimalPageWidth) * minimapBounds.width();
            float y = -currentYOffset / toCurrentScale(optimalPageHeight) * minimapBounds.height();
            float height = getHeight() / toCurrentScale(optimalPageHeight) * minimapBounds.height();
            minimapScreenBounds = new RectF(minimapBounds.left + x, minimapBounds.top + y, //
                    minimapBounds.left + x + width, minimapBounds.top + y + height);
            minimapScreenBounds.intersect(minimapBounds);
            miniMapRequired = true;
        }
    }
830454
def block_widths(self):
        
        if self._widths_cache is None:
            try:
                # The first column will have the correct lengths. We have an
                # invariant that requires that all blocks be the same width in a
                # column of blocks.
                self._widths_cache = np.array(
                    ray.get([obj.width().oid for obj in self._partitions_cache[0]])
                    if len(self._partitions_cache) > 0
                    else []
                )
            except RayTaskError as e:
                handle_ray_task_error(e)
        return self._widths_cache
1158312
private static void compute(Kernel kernel, int[] in, int[] out, int width, int height, boolean alpha, int edge)
    {
        final float[] matrix = kernel.getMatrix();
        final int cols = kernel.getWidth();
        final int cols2 = cols / 2;

        for (int y = 0; y < height; y++)
        {
            int index = y;
            final int ioffset = y * width;
            for (int x = 0; x < width; x++)
            {
                compute(matrix, in, out, x, index, ioffset, cols2, width, alpha, edge);
                index += height;
            }
        }
    }
933873
private void calcInnerBounds() {
        final java.awt.Insets INSETS = getInsets();
        INNER_BOUNDS.setBounds(INSETS.left, INSETS.top, (getWidth() - INSETS.left - INSETS.right), (getHeight() - INSETS.top - INSETS.bottom));
    }
1162722
def current_view(self):
        ''''''
        state = self.state
        return (state.lat, state.lon, state.width, state.height,
                state.ground_width, state.mt.tiles_pending())
1309593
def _offsetscounts(self):
        """"""
        if self.is_contiguous:
            offset, bytecount = self.is_contiguous
            return [offset], [bytecount]
        if self.is_tiled:
            return self.dataoffsets, self.databytecounts
        return clean_offsetscounts(self.dataoffsets, self.databytecounts)
1239092
function(bounds) {
        this.events.triggerEvent("retile");

        // work out mininum number of rows and columns; this is the number of
        // tiles required to cover the viewport plus at least one for panning

        var viewSize = this.map.getSize();
        
        var origin = this.getTileOrigin();
        var resolution = this.map.getResolution(),
            serverResolution = this.getServerResolution(),
            ratio = resolution / serverResolution,
            tileSize = {
                w: this.tileSize.w / ratio,
                h: this.tileSize.h / ratio
            };

        var minRows = Math.ceil(viewSize.h/tileSize.h) + 
                      2 * this.buffer + 1;
        var minCols = Math.ceil(viewSize.w/tileSize.w) +
                      2 * this.buffer + 1;

        var tileLayout = this.calculateGridLayout(bounds, origin, serverResolution);
        this.gridLayout = tileLayout;
        
        var tilelon = tileLayout.tilelon;
        var tilelat = tileLayout.tilelat;
        
        var layerContainerDivLeft = this.map.layerContainerOriginPx.x;
        var layerContainerDivTop = this.map.layerContainerOriginPx.y;

        var tileBounds = this.getTileBoundsForGridIndex(0, 0);
        var startPx = this.map.getViewPortPxFromLonLat(
            new OpenLayers.LonLat(tileBounds.left, tileBounds.top)
        );
        startPx.x = Math.round(startPx.x) - layerContainerDivLeft;
        startPx.y = Math.round(startPx.y) - layerContainerDivTop;

        var tileData = [], center = this.map.getCenter();

        var rowidx = 0;
        do {
            var row = this.grid[rowidx];
            if (!row) {
                row = [];
                this.grid.push(row);
            }
            
            var colidx = 0;
            do {
                tileBounds = this.getTileBoundsForGridIndex(rowidx, colidx);
                var px = startPx.clone();
                px.x = px.x + colidx * Math.round(tileSize.w);
                px.y = px.y + rowidx * Math.round(tileSize.h);
                var tile = row[colidx];
                if (!tile) {
                    tile = this.addTile(tileBounds, px);
                    this.addTileMonitoringHooks(tile);
                    row.push(tile);
                } else {
                    tile.moveTo(tileBounds, px, false);
                }
                var tileCenter = tileBounds.getCenterLonLat();
                tileData.push({
                    tile: tile,
                    distance: Math.pow(tileCenter.lon - center.lon, 2) +
                        Math.pow(tileCenter.lat - center.lat, 2)
                });
     
                colidx += 1;
            } while ((tileBounds.right <= bounds.right + tilelon * this.buffer)
                     || colidx < minCols);
             
            rowidx += 1;
        } while((tileBounds.bottom >= bounds.bottom - tilelat * this.buffer)
                || rowidx < minRows);
        
        //shave off exceess rows and colums
        this.removeExcessTiles(rowidx, colidx);

        var resolution = this.getServerResolution();
        // store the resolution of the grid
        this.gridResolution = resolution;

        //now actually draw the tiles
        tileData.sort(function(a, b) {
            return a.distance - b.distance; 
        });
        for (var i=0, ii=tileData.length; i<ii; ++i) {
            tileData[i].tile.draw();
        }
    }
1300315
private static void initCaches() {

        if (m_cacheTemporary == null) {
            m_cacheTemporary = CmsMemoryMonitor.createLRUCacheMap(1024);

            m_cachePermanent = new ConcurrentHashMap<String, byte[]>(32);

            m_cacheContentDefinitions = CmsMemoryMonitor.createLRUCacheMap(CONTENT_DEFINITION_CACHE_SIZE);
        }
        if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_1_CORE_OBJECT) {
            if ((OpenCms.getMemoryMonitor() != null)
                && !OpenCms.getMemoryMonitor().isMonitoring(CmsXmlEntityResolver.class.getName() + ".cacheTemporary")) {
                // reinitialize the caches after the memory monitor is set up
                Map<String, byte[]> cacheTemporary = CmsMemoryMonitor.createLRUCacheMap(128);
                cacheTemporary.putAll(m_cacheTemporary);
                m_cacheTemporary = cacheTemporary;
                OpenCms.getMemoryMonitor().register(
                    CmsXmlEntityResolver.class.getName() + ".cacheTemporary",
                    cacheTemporary);

                Map<String, byte[]> cachePermanent = new ConcurrentHashMap<String, byte[]>(32);
                cachePermanent.putAll(m_cachePermanent);
                m_cachePermanent = cachePermanent;
                OpenCms.getMemoryMonitor().register(
                    CmsXmlEntityResolver.class.getName() + ".cachePermanent",
                    cachePermanent);

                Map<String, CmsXmlContentDefinition> cacheContentDefinitions = CmsMemoryMonitor.createLRUCacheMap(
                    CONTENT_DEFINITION_CACHE_SIZE);
                cacheContentDefinitions.putAll(m_cacheContentDefinitions);
                m_cacheContentDefinitions = cacheContentDefinitions;
                OpenCms.getMemoryMonitor().register(
                    CmsXmlEntityResolver.class.getName() + ".cacheContentDefinitions",
                    cacheContentDefinitions);
            }
        }
    }