get tile json for layer
16467
function(layer, callback) {
    layer = layer == undefined ? 0: layer;
    var self = this;
    this.getTiles(function(urls) {
      if(!urls) {
        callback(null);
        return;
      }
      if(callback) {
        callback(self._tileJSONfromTiles(layer, urls));
      }
    });
  }
327613
def show(self, id):
        """"""
        # url('LayerTemplates', id=ID)
        lt = meta.Session.query(LayerTemplate).get(id)
        # use following query for getting a layertemplate owned by current user
        #lt = self._get_lt_from_user_by_id(c.user, id)
        if lt is None:
            abort(404)
        return lt.to_json()
495578
function (tilePoint) {
    var EMPTY_GIF = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
    this._adjustTilePoint(tilePoint);

    var tiles = [EMPTY_GIF];
    if(this.tilejson) {
      tiles = this.tilejson.tiles;
    }

    var index = (tilePoint.x + tilePoint.y) % tiles.length;

    return L.Util.template(tiles[index], L.Util.extend({
      z: this._getZoomForUrl(),
      x: tilePoint.x,
      y: tilePoint.y
    }, this.options));
  }
967026
function(array) {
            var json;
            var pieces = ['['];
            this.level += 1;
    
            for(var i=0, len=array.length; i<len; ++i) {
                // recursive calls need to allow for sub-classing
                json = OpenLayers.Format.JSON.prototype.write.apply(this,
                                                    [array[i], this.pretty]);
                if(json != null) {
                    if(i > 0) {
                        pieces.push(',');
                    }
                    pieces.push(this.writeNewline(), this.writeIndent(), json);
                }
            }

            this.level -= 1;    
            pieces.push(this.writeNewline(), this.writeIndent(), ']');
            return pieces.join('');
        }
525741
def tile(self, z_x_y):
        
        (z, x, y) = z_x_y
        logger.debug(_("tile method called with %s") % ([z, x, y]))

        output = self.cache.read((z, x, y))
        if output is None:
            output = self.reader.tile(z, x, y)
            # Blend layers
            if len(self._layers) > 0:
                logger.debug(_("Will blend %s layer(s)") % len(self._layers))
                output = self._blend_layers(output, (z, x, y))
            # Apply filters
            for f in self._filters:
                image = f.process(self._tile_image(output))
                output = self._image_tile(image)
            # Save result to cache
            self.cache.save(output, (z, x, y))

            self.rendered += 1
        return output
1215197
def _get_satellite_tile(self, x_tile, y_tile, z_tile):
        """"""
        cache_file = "mapscache/{}.{}.{}.jpg".format(z_tile, x_tile, y_tile)
        if cache_file not in self._tiles:
            if not os.path.isfile(cache_file):
                url = _IMAGE_URL.format(z_tile, x_tile, y_tile, _KEY)
                data = requests.get(url).content
                with open(cache_file, 'wb') as f:
                    f.write(data)
            self._tiles[cache_file] = [
                x_tile, y_tile, z_tile,
                ColourImageFile(self._screen, cache_file, height=_START_SIZE, dither=True,
                                uni=self._screen.unicode_aware),
                True]
            if len(self._tiles) > _CACHE_SIZE:
                self._tiles.popitem(False)
            self._screen.force_update()
942754
function (obj) {
        
        if (obj == null) {
            obj = new OpenLayers.Layer.TileCache(this.name,
                                                 this.url,
                                                 this.layername,
                                                 this.getOptions());
        }

        //get all additions from superclasses
        obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]);

        // copy/set any non-init, non-simple values here

        return obj;
    }
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;
	}
173487
def getTile(self, lat, lon):
        """"""
        global childFileListDownload
        global filelistDownloadActive
        mypid = os.getpid()
        if mypid in childFileListDownload and childFileListDownload[mypid].is_alive():
            if self.debug:
                print("still getting file list")
            return 0
        elif not os.path.isfile(self.filelist_file) and filelistDownloadActive == 0:
            self.createFileList()
            return 0
        elif not self.filelist:
            if self.debug:
                print("Filelist download complete, loading data ", self.filelist_file)
            data = open(self.filelist_file, 'rb')
            self.filelist = pickle.load(data)
            data.close()

        try:
            continent, filename = self.filelist[(int(lat), int(lon))]
        except KeyError:
            if len(self.filelist) > self.min_filelist_len:
                # we appear to have a full filelist - this must be ocean
                return SRTMOceanTile(int(lat), int(lon))
            return 0

        global childTileDownload
        mypid = os.getpid()
        if not os.path.exists(os.path.join(self.cachedir, filename)):
            if not mypid in childTileDownload or not childTileDownload[mypid].is_alive():
                try:
                    childTileDownload[mypid] = multiproc.Process(target=self.downloadTile, args=(str(continent), str(filename)))
                    childTileDownload[mypid].start()
                except Exception as ex:
                    if mypid in childTileDownload:
                        childTileDownload.pop(mypid)
                    return 0
                '''print("Getting Tile")'''
            return 0
        elif mypid in childTileDownload and childTileDownload[mypid].is_alive():
            '''print("Still Getting Tile")'''
            return 0
        # TODO: Currently we create a new tile object each time.
        # Caching is required for improved performance.
        try:
            return SRTMTile(os.path.join(self.cachedir, filename), int(lat), int(lon))
        except InvalidTileError:
            return 0
182958
def tile(self, username, style_id, z, x, y, tile_size=512, retina=False):
        ""
        if tile_size not in (256, 512):
            raise errors.ImageSizeError('tile_size must be 256 or 512 pixels')

        pth = '/{username}/{style_id}/tiles/{tile_size}/{z}/{x}/{y}'

        values = dict(username=username, style_id=style_id,
                      tile_size=tile_size, z=z, x=x, y=y)

        uri = URITemplate(self.baseuri + pth).expand(**values)
        if retina:
            uri += '@2x'
        res = self.session.get(uri)
        self.handle_http_error(res)
        return res
1294784
@Override
    public Tile getTile(int x, int y, int zoom)
    {
        return new Tile(x, y, zoom)
        {
            @Override
            public synchronized boolean isLoaded()
            {
                return true;
            }

            @Override
            public BufferedImage getImage()
            {
                return emptyTile;
            }

        };
    }
363227
def getTileOrigin(self, tileX, tileY, level):
        '''
        
        '''
        pixelX, pixelY = self.convertTileXYToPixelXY(tileX, tileY)
        lng, lat = self.convertPixelXYToLngLat(pixelX, pixelY, level)
        return (lat, lng)
961089
function toGeoJSON(json, options = Options) {
  const collection = featureCollection([])
  collection.features = json.features.map(result => {
    return result
  })
  return collection
}
1364058
def extract_metatile(io, fmt, offset=None):
    

    ext = fmt.extension
    if offset is None:
        tile_name = '0/0/0.%s' % ext
    else:
        tile_name = '%d/%d/%d.%s' % (offset.zoom, offset.column, offset.row,
                                     ext)

    with zipfile.ZipFile(io, mode='r') as zf:
        if tile_name in zf.namelist():
            return zf.read(tile_name)
        else:
            return None
494679
@Override
    public Tile getTile(int x, int y, int zoom)
    {
        return getTile(x, y, zoom, true);
    }
559698
function() {
          return {
            tileCount: tileSpans.length,
            layoutTime: layoutTime,
            mapTime: mapTime,
            reflowTime: reflowTime,
            totalTime: layoutTime + mapTime + reflowTime
          };
        }
993969
function readLayer(map, data, z) {
        var layer = new me.TMXLayer(data, map.tilewidth, map.tileheight, map.orientation, map.tilesets, z);
        // set a renderer
        layer.setRenderer(map.getRenderer());
        return layer;
    }