Given a newline-delimited file containing tile coordinates in
    `zoom/column/row` format, load those tiles into the tiles of interest.
178189
def tilequeue_load_tiles_of_interest(cfg, peripherals):
    
    logger = make_logger(cfg, 'load_tiles_of_interest')

    toi_filename = "toi.txt"
    logger.info('Loading tiles of interest from %s ... ', toi_filename)

    with open(toi_filename, 'r') as f:
        new_toi = load_set_from_fp(f)

    logger.info('Loading tiles of interest from %s ... done', toi_filename)
    logger.info('Setting new TOI (with %s tiles) ... ', len(new_toi))

    peripherals.toi.set_tiles_of_interest(new_toi)
    emit_toi_stats(new_toi, peripherals)

    logger.info('Setting new TOI (with %s tiles) ... done', len(new_toi))

    logger.info('Loading tiles of interest ... done')
919332
private static int readGeoPackageFormatTiles(GeoPackage geoPackage,
			String tileTable, String imageFormat, boolean rawImage,
			TileDirectory tileDirectory) throws SQLException, IOException {

		int created = 0;

		TileProperties properties = new TileProperties(tileDirectory.directory);
		properties.load();

		int epsg = properties.getIntegerProperty(
				TileProperties.GEOPACKAGE_PROPERTIES_EPSG, true);
		double minX = properties.getDoubleProperty(
				TileProperties.GEOPACKAGE_PROPERTIES_MIN_X, true);
		double maxX = properties.getDoubleProperty(
				TileProperties.GEOPACKAGE_PROPERTIES_MAX_X, true);
		double minY = properties.getDoubleProperty(
				TileProperties.GEOPACKAGE_PROPERTIES_MIN_Y, true);
		double maxY = properties.getDoubleProperty(
				TileProperties.GEOPACKAGE_PROPERTIES_MAX_Y, true);

		// Create the user tile table
		List<TileColumn> columns = TileTable.createRequiredColumns();
		TileTable table = new TileTable(tileTable, columns);
		geoPackage.createTileTable(table);

		// Get SRS value
		SpatialReferenceSystemDao srsDao = geoPackage
				.getSpatialReferenceSystemDao();
		SpatialReferenceSystem srs = srsDao.getOrCreateFromEpsg(epsg);

		// Create the Tile Matrix Set and Tile Matrix tables
		geoPackage.createTileMatrixSetTable();
		geoPackage.createTileMatrixTable();

		// Create new Contents
		ContentsDao contentsDao = geoPackage.getContentsDao();

		Contents contents = new Contents();
		contents.setTableName(tileTable);
		contents.setDataType(ContentsDataType.TILES);
		contents.setIdentifier(tileTable);
		// contents.setDescription("");
		// contents.setLastChange(new Date());
		contents.setMinX(minX);
		contents.setMinY(minY);
		contents.setMaxX(maxX);
		contents.setMaxY(maxY);
		contents.setSrs(srs);

		// Create the contents
		contentsDao.create(contents);
		table.setContents(contents);

		// Create new Tile Matrix Set
		TileMatrixSetDao tileMatrixSetDao = geoPackage.getTileMatrixSetDao();

		TileMatrixSet tileMatrixSet = new TileMatrixSet();
		tileMatrixSet.setContents(contents);
		tileMatrixSet.setSrs(srs);
		tileMatrixSet.setMinX(minX);
		tileMatrixSet.setMinY(minY);
		tileMatrixSet.setMaxX(maxX);
		tileMatrixSet.setMaxY(maxY);
		tileMatrixSetDao.create(tileMatrixSet);

		// Create new Tile Matrix and tile table rows by going through each zoom
		// level
		TileMatrixDao tileMatrixDao = geoPackage.getTileMatrixDao();
		TileDao tileDao = geoPackage.getTileDao(tileMatrixSet);

		Integer lastZoom = null;
		Integer lastMatrixWidth = null;
		Integer lastMatrixHeight = null;

		for (ZoomDirectory zoomDirectory : tileDirectory.zooms.values()) {

			int zoomCount = 0;

			Integer tileWidth = null;
			Integer tileHeight = null;

			// Determine the matrix width and height
			Integer matrixWidth = properties.getIntegerProperty(
					TileProperties.getMatrixWidthProperty(zoomDirectory.zoom),
					false);
			Integer matrixHeight = properties.getIntegerProperty(
					TileProperties.getMatrixHeightProperty(zoomDirectory.zoom),
					false);

			// If the matrix width is not configured as a property, try to
			// determine it
			if (matrixWidth == null) {
				if (lastZoom != null) {
					// Determine the width by a factor of 2 for each zoom level
					matrixWidth = lastMatrixWidth;
					for (int i = lastZoom; i < zoomDirectory.zoom; i++) {
						matrixWidth *= 2;
					}
				} else {
					// Assume the max x is the width
					matrixWidth = zoomDirectory.maxX + 1;
				}
			}

			// If the matrix height is not configured as a property, try to
			// determine it
			if (matrixHeight == null) {
				if (lastZoom != null) {
					// Determine the height by a factor of 2 for each zoom level
					matrixHeight = lastMatrixHeight;
					for (int i = lastZoom; i < zoomDirectory.zoom; i++) {
						matrixHeight *= 2;
					}
				} else {
					// Assume the max y is the height
					matrixHeight = zoomDirectory.maxY + 1;
				}
			}

			// Set values for the next zoom level
			lastZoom = zoomDirectory.zoom;
			lastMatrixWidth = matrixWidth;
			lastMatrixHeight = matrixHeight;

			LOGGER.log(Level.INFO, "Zoom Level: " + zoomDirectory.zoom
					+ ", Width: " + matrixWidth + ", Height: " + matrixHeight
					+ ", Max Tiles: " + (matrixWidth * matrixHeight));

			for (XDirectory xDirectory : zoomDirectory.xValues.values()) {

				for (YFile yFile : xDirectory.yValues.values()) {

					BufferedImage image = null;

					// Set the tile width and height
					if (tileWidth == null || tileHeight == null) {
						image = ImageIO.read(yFile.file);
						tileWidth = image.getWidth();
						tileHeight = image.getHeight();
					}

					TileRow newRow = tileDao.newRow();

					newRow.setZoomLevel(zoomDirectory.zoom);
					newRow.setTileColumn(xDirectory.x);
					newRow.setTileRow(yFile.y);
					if (rawImage) {
						byte[] rawImageBytes = GeoPackageIOUtils
								.fileBytes(yFile.file);
						newRow.setTileData(rawImageBytes);
					} else {
						if (image == null) {
							image = ImageIO.read(yFile.file);
						}
						newRow.setTileData(image, imageFormat);
					}

					tileDao.create(newRow);

					zoomCount++;

					if (zoomCount % ZOOM_PROGRESS_FREQUENCY == 0) {
						LOGGER.log(Level.INFO, "Zoom " + zoomDirectory.zoom
								+ " Tile Progress... " + zoomCount);
					}
				}
			}

			LOGGER.log(Level.INFO, "Zoom " + zoomDirectory.zoom + " Tiles: "
					+ zoomCount);

			// If tiles were saved for the zoom level, create the tile matrix
			// row
			if (zoomCount > 0) {

				double pixelXSize = (maxX - minX) / matrixWidth / tileWidth;
				double pixelYSize = (maxY - minY) / matrixHeight / tileHeight;

				TileMatrix tileMatrix = new TileMatrix();
				tileMatrix.setContents(contents);
				tileMatrix.setZoomLevel(zoomDirectory.zoom);
				tileMatrix.setMatrixWidth(matrixWidth);
				tileMatrix.setMatrixHeight(matrixHeight);
				tileMatrix.setTileWidth(tileWidth);
				tileMatrix.setTileHeight(tileHeight);
				tileMatrix.setPixelXSize(pixelXSize);
				tileMatrix.setPixelYSize(pixelYSize);
				tileMatrixDao.create(tileMatrix);

				created += zoomCount;
			}

		}

		return created;
	}
649737
def load_tile(self, tile):
        ''''''

        # see if its in the tile cache
        key = tile.key()
        if key in self._tile_cache:
            img = self._tile_cache[key]
            if np.array_equal(img, self._unavailable):
                img = self.load_tile_lowres(tile)
                if img is None:
                    img = self._unavailable
            return img


        path = self.tile_to_path(tile)
        ret = cv2.imread(path)
        if ret is not None:
            # if it is an old tile, then try to refresh
            if os.path.getmtime(path) + self.refresh_age < time.time():
                try:
                        self._download_pending[key].refresh_time()
                except Exception:
                        self._download_pending[key] = tile
                self.start_download_thread()
                    
            # add it to the tile cache
            self._tile_cache[key] = ret
            while len(self._tile_cache) > self.cache_size:
                self._tile_cache.popitem(0)
            return ret

        if not self.download:
            img = self.load_tile_lowres(tile)
            if img is None:
                img = self._unavailable
            return img

        try:
            self._download_pending[key].refresh_time()
        except Exception:
            self._download_pending[key] = tile
        self.start_download_thread()

        img = self.load_tile_lowres(tile)
        if img is None:
            img = self._loading
        return img
715149
def load_contents(self):
        
        with open(self.name + ".csv") as f:
            list_of_rows = f.readlines()

        list_of_rows = map(
            lambda x: x.strip(),
            map(
                lambda x: x.replace("\"", ""),
                list_of_rows
            )
        )

        for row in list_of_rows:
            self.put_row(make_row(self.columns, row.split(',')))
573615
def load(fp):
    '''
    
    '''
    reader = reading.Reader(fp)
    keys = reader.fields
    columns = {k: [] for k in keys}
    for row in reader:
        for key, value in zip(keys, row):
            columns[key].append(value)
    return columns
614290
def load_map_coordinates(map_file):
    
    if map_file[-4:] == ".pkl":
        map_data = pickle.load(open(map_file))
        lon = map_data['lon']
        lat = map_data['lat']
    else:
        map_data = Dataset(map_file)
        if "lon" in map_data.variables.keys():
            lon = map_data.variables['lon'][:]
            lat = map_data.variables['lat'][:]
        else:
            lon = map_data.variables["XLONG"][0]
            lat = map_data.variables["XLAT"][0]
    return lon, lat
1097381
def _tiles_from_cleaned_bounds(tp, bounds, zoom):
    """"""
    lb = _tile_from_xy(tp, bounds.left, bounds.bottom, zoom, on_edge_use="rt")
    rt = _tile_from_xy(tp, bounds.right, bounds.top, zoom, on_edge_use="lb")
    for tile_id in product([zoom], range(rt.row, lb.row + 1), range(lb.col, rt.col + 1)):
        yield tp.tile(*tile_id)
978449
private void loadTileCollisions(MapTileCollision mapCollision, Tile tile)
    {
        final TileCollision tileCollision;
        if (!tile.hasFeature(TileCollision.class))
        {
            tileCollision = new TileCollisionModel(tile);
            tile.addFeature(tileCollision);
        }
        else
        {
            tileCollision = tile.getFeature(TileCollision.class);
        }
        tileCollision.removeCollisionFormulas();
        addTileCollisions(mapCollision, tileCollision, tile);
    }
1155847
def load_kb_mappings_file(kbname, kbfile, separator):
    """"""
    num_added = 0
    with open(kbfile) as kb_fd:
        for line in kb_fd:
            if not line.strip():
                continue
            try:
                key, value = line.split(separator)
            except ValueError:
                # bad split, pass
                current_app.logger.error("Error splitting: {0}".format(line))
                continue
            add_kb_mapping(kbname, key, value)
            num_added += 1
    return num_added
388464
def pad(lines, delim):
	
	"""
	Populates text into chunks. If the delim was & then
	['12 & 344', '344 & 8', '8 & 88'] would be stored in chunks as
	[['12', '344', '8'], ['344', '8', '88']]
	"""
	chunks = []
	for i in range(len(lines)):
		line = lines[i]
		sections = line.split(delim)
		for j in range(len(sections)):
			if len(chunks) <= j:
				chunks.append([])
			chunks[j].append(sections[j])

	"""
	Calculates & Stores the max length of chunks
	"""
	max_lengths = []
	for i in range(len(chunks)):
		_max = max([len(j) for j in chunks[i]])
		max_lengths.append(_max)

	"""
	Pads the children of chunks according to the chunk's max length" \
	"""
	for i in range(len(chunks)):
		for j in range(len(chunks[i])):
			chunks[i][j] += (max_lengths[i] - len(chunks[i][j])) * ' '
	new_lines = ['' for i in range(len(lines))]

	for i in range(len(chunks)):
		for j in range(len(chunks[i])):
			new_lines[j] += chunks[i][j]
	return new_lines
1338798
def convert_coord_object(coord):
    """"""
    assert isinstance(coord, Coordinate)
    coord = coord.container()
    return Tile(int(coord.zoom), int(coord.column), int(coord.row))
525189
def load_tile(self, tile):
		''''''

		# see if its in the tile cache
		key = tile.key()
		if key in self._tile_cache:
			img = self._tile_cache[key]
			if img == self._unavailable:
				img = self.load_tile_lowres(tile)
				if img is None:
					img = self._unavailable
				return img


		path = self.tile_to_path(tile)
		try:
			ret = cv.LoadImage(path)
			# if it is an old tile, then try to refresh
			if os.path.getmtime(path) + self.refresh_age < time.time():
				try:
					self._download_pending[key].refresh_time()
				except Exception:
					self._download_pending[key] = tile
					self.start_download_thread()
			# add it to the tile cache
			self._tile_cache[key] = ret
			while len(self._tile_cache) > self.cache_size:
				self._tile_cache.popitem(0)
			return ret
		except IOError as e:
			# windows gives errno 0 for some versions of python, treat that as ENOENT
			# and try a download
			if not e.errno in [errno.ENOENT,0]:
				raise
			pass
		if not self.download:
			img = self.load_tile_lowres(tile)
			if img is None:
				img = self._unavailable
			return img

		try:
			self._download_pending[key].refresh_time()
		except Exception:
			self._download_pending[key] = tile
		self.start_download_thread()

		img = self.load_tile_lowres(tile)
		if img is None:
			img = self._loading
		return img
201955
def load(cls, filename, encoding):
        """"""
        if encoding is None:
            encoding = cls.encoding

        with io.open(filename, 'r', encoding=encoding) as fd:
            source = fd.read()

        if cls.normalize_newlines:
            source = source.replace('\r\n', '\n').replace('\r', '\n')
        return cls.loads(source)
738355
public static TileColumn createTileDataColumn(int index) {
		return new TileColumn(index, TileTable.COLUMN_TILE_DATA,
				GeoPackageDataType.BLOB, null, true, null, false);
	}
402835
public static void getTile (int width, int height, int tileWidth, int tileHeight, int tileIndex,
                                Rectangle bounds)
    {
        // figure out from whence to crop the tile
        int tilesPerRow = width / tileWidth;

        // if we got a bogus region, return bogus tile bounds
        if (tilesPerRow == 0) {
            bounds.setBounds(0, 0, width, height);

        } else {
            int row = tileIndex / tilesPerRow;
            int col = tileIndex % tilesPerRow;
            // crop the tile-sized image chunk from the full image
            bounds.setBounds(tileWidth*col, tileHeight*row, tileWidth, tileHeight);
        }
    }
653388
function() {
        var buffer = this.buffer + 1;
        while(true) {
            var tlTile = this.grid[0][0];
            var tlViewPort = {
                x: tlTile.position.x +
                    this.map.layerContainerOriginPx.x,
                y: tlTile.position.y +
                    this.map.layerContainerOriginPx.y
            };
            var ratio = this.getServerResolution() / this.map.getResolution();
            var tileSize = {
                w: Math.round(this.tileSize.w * ratio),
                h: Math.round(this.tileSize.h * ratio)
            };
            if (tlViewPort.x > -tileSize.w * (buffer - 1)) {
                this.shiftColumn(true, tileSize);
            } else if (tlViewPort.x < -tileSize.w * buffer) {
                this.shiftColumn(false, tileSize);
            } else if (tlViewPort.y > -tileSize.h * (buffer - 1)) {
                this.shiftRow(true, tileSize);
            } else if (tlViewPort.y < -tileSize.h * buffer) {
                this.shiftRow(false, tileSize);
            } else {
                break;
            }
        }
    }
869824
function(row, col) {
        var origin = this.getTileOrigin();
        var tileLayout = this.gridLayout;
        var tilelon = tileLayout.tilelon;
        var tilelat = tileLayout.tilelat;
        var startcol = tileLayout.startcol;
        var startrow = tileLayout.startrow;
        var rowSign = this.rowSign;
        return new OpenLayers.Bounds(
            origin.lon + (startcol + col) * tilelon,
            origin.lat - (startrow + row * rowSign) * tilelat * rowSign,
            origin.lon + (startcol + col + 1) * tilelon,
            origin.lat - (startrow + (row - 1) * rowSign) * tilelat * rowSign
        );
    }