Return the tile image GID for this location

        :param x: x coordinate
        :param y: y coordinate
        :param layer: layer number
        :rtype: surface if found, otherwise ValueError
4466
def get_tile_gid(self, x, y, layer):
        
        try:
            assert (x >= 0 and y >= 0 and layer >= 0)
        except AssertionError:
            raise ValueError

        try:
            return self.layers[int(layer)].data[int(y)][int(x)]
        except (IndexError, ValueError):
            msg = "Coords: ({0},{1}) in layer {2} is invalid"
            logger.debug(msg, (x, y, layer))
            raise ValueError
1007536
public String toWMSURL(int x, int y, int zoom, int tileSize)
    {
        String format = "image/jpeg";
        String styles = "";
        String srs = "EPSG:4326";
        int ts = tileSize;
        int circumference = widthOfWorldInPixels(zoom, tileSize);
        double radius = circumference / (2 * Math.PI);
        double ulx = MercatorUtils.xToLong(x * ts, radius);
        double uly = MercatorUtils.yToLat(y * ts, radius);
        double lrx = MercatorUtils.xToLong((x + 1) * ts, radius);
        double lry = MercatorUtils.yToLat((y + 1) * ts, radius);
        String bbox = ulx + "," + uly + "," + lrx + "," + lry;
        String url = getBaseUrl() + "version=1.1.1&request=" + "GetMap&Layers=" + layer + "&format=" + format
                + "&BBOX=" + bbox + "&width=" + ts + "&height=" + ts + "&SRS=" + srs + "&Styles=" + styles +
                // "&transparent=TRUE"+
                "";
        return url;
    }
411181
def get_tile_url(self, zoom, x, y):
        
        return self.tile_url.format(**{"$z": zoom, "$x": x, "$y": y})
1212476
public static Point layerToScreen(Layer layer, float x, float y) {
    Point into = new Point(x, y);
    return layerToScreen(layer, into, into);
  }
208773
def getPixelValue(self, x, y):
        """"""
        assert x < self.size, "x: %d<%d" % (x, self.size)
        assert y < self.size, "y: %d<%d" % (y, self.size)
        # Same as calcOffset, inlined for performance reasons
        offset = x + self.size * (self.size - y - 1)
        #print offset
        value = self.data[offset]
        if value == -32768:
            return -1 # -32768 is a special value for areas with no data
        return value
245750
def floordiv(x, y, context=None):
    
    return _apply_function_in_current_context(
        BigFloat,
        mpfr_floordiv,
        (
            BigFloat._implicit_convert(x),
            BigFloat._implicit_convert(y),
        ),
        context,
    )
1373597
def _layer_to_path_gen(layer):
    
    draw = False
    for x, y in zip(*layer):
        if np.isnan(x) or np.isnan(y):
            draw = False
        elif not draw:
            yield 'M {} {}'.format(x, y)
            draw = True
        else:
            yield 'L {} {}'.format(x, y)
1172937
function( level, x, y ){

        if(this.emulateLegacyImagePyramid) {
            var url = null;
            if ( this.levels.length > 0 && level >= this.minLevel && level <= this.maxLevel ) {
                url = this.levels[ level ].url;
            }
            return url;
        }

        //# constants
        var IIIF_ROTATION = '0',
            //## get the scale (level as a decimal)
            scale = Math.pow( 0.5, this.maxLevel - level ),

            //# image dimensions at this level
            levelWidth = Math.ceil( this.width * scale ),
            levelHeight = Math.ceil( this.height * scale ),

            //## iiif region
            tileWidth,
            tileHeight,
            iiifTileSizeWidth,
            iiifTileSizeHeight,
            iiifRegion,
            iiifTileX,
            iiifTileY,
            iiifTileW,
            iiifTileH,
            iiifSize,
            iiifSizeW,
            iiifQuality,
            uri,
            isv1;

        tileWidth = this.getTileWidth(level);
        tileHeight = this.getTileHeight(level);
        iiifTileSizeWidth = Math.ceil( tileWidth / scale );
        iiifTileSizeHeight = Math.ceil( tileHeight / scale );
        isv1 = ( this['@context'].indexOf('/1.0/context.json') > -1 ||
             this['@context'].indexOf('/1.1/context.json') > -1 ||
             this['@context'].indexOf('/1/context.json') > -1 );
        if (isv1) {
            iiifQuality = "native." + this.tileFormat;
        } else {
            iiifQuality = "default." + this.tileFormat;
        }
        if ( levelWidth < tileWidth && levelHeight < tileHeight ){
            if ( isv1 || levelWidth !== this.width ) {
                iiifSize = levelWidth + ",";
            } else {
                iiifSize = "max";
            }
            iiifRegion = 'full';
        } else {
            iiifTileX = x * iiifTileSizeWidth;
            iiifTileY = y * iiifTileSizeHeight;
            iiifTileW = Math.min( iiifTileSizeWidth, this.width - iiifTileX );
            iiifTileH = Math.min( iiifTileSizeHeight, this.height - iiifTileY );
            if ( x === 0 && y === 0 && iiifTileW === this.width && iiifTileH === this.height ) {
                iiifRegion = "full";
            } else {
                iiifRegion = [ iiifTileX, iiifTileY, iiifTileW, iiifTileH ].join( ',' );
            }
            iiifSizeW = Math.ceil( iiifTileW * scale );
            if ( (!isv1) && iiifSizeW === this.width ) {
                iiifSize = "max";
            } else {
                iiifSize = iiifSizeW + ",";
            }
        }
        uri = [ this['@id'], iiifRegion, iiifSize, IIIF_ROTATION, iiifQuality ].join( '/' );

        return uri;
    }
10820
function getTilesetByGid(gid) {
         var invalidRange = -1; // clear the gid of all flip/rotation flags

         gid &= TMX_CLEAR_BIT_MASK; // cycle through all tilesets

         for (var i = 0, len = this.tilesets.length; i < len; i++) {
           // return the corresponding tileset if matching
           if (this.tilesets[i].contains(gid)) {
             return this.tilesets[i];
           } // typically indicates a layer with no asset loaded (collision?)


           if (this.tilesets[i].firstgid === this.tilesets[i].lastgid && gid >= this.tilesets[i].firstgid) {
             // store the id if the [firstgid .. lastgid] is invalid
             invalidRange = i;
           }
         } // return the tileset with the invalid range


         if (invalidRange !== -1) {
           return this.tilesets[invalidRange];
         } else {
           throw new Error("no matching tileset found for gid " + gid);
         }
       }
548296
def tileAddress(self, zoom, point):
        ""
        [x, y] = point
        assert x <= self.MAXX and x >= self.MINX
        assert y <= self.MAXY and y >= self.MINY
        assert zoom in range(0, len(self.RESOLUTIONS))

        tileS = self.tileSize(zoom)
        offsetX = abs(x - self.MINX)
        if self.originCorner == 'bottom-left':
            offsetY = abs(y - self.MINY)
        elif self.originCorner == 'top-left':
            offsetY = abs(self.MAXY - y)
        col = offsetX / tileS
        row = offsetY / tileS
        # We are exactly on the edge of a tile and the extent
        if x in (self.MINX, self.MAXX) and col.is_integer():
            col = max(0, col - 1)
        if y in (self.MINY, self.MAXY) and row.is_integer():
            row = max(0, row - 1)
        return [
            int(math.floor(col)),
            int(math.floor(row))
        ]
363227
def getTileOrigin(self, tileX, tileY, level):
        '''
        
        '''
        pixelX, pixelY = self.convertTileXYToPixelXY(tileX, tileY)
        lng, lat = self.convertPixelXYToLngLat(pixelX, pixelY, level)
        return (lat, lng)
926277
def _draw_tile_layer(self, tile, layer_name, c_filters, colour, t_filters, x, y, bg):
        """"""
        # Don't bother rendering if the tile is not visible
        left = (x + self._screen.width // 4) * 2
        top = y + self._screen.height // 2
        if (left > self._screen.width or left + self._size * 2 < 0 or
                top > self._screen.height or top + self._size < 0):
            return 0

        # Not all layers are available in every tile.
        try:
            _layer = tile[layer_name]
            _extent = float(_layer["extent"])
        except KeyError:
            return 0

        for _feature in _layer["features"]:
            try:
                if c_filters and _feature["properties"]["class"] not in c_filters:
                    continue
                if (t_filters and _feature["type"] not in t_filters and
                        _feature["properties"]["type"] not in t_filters):
                    continue
                self._draw_feature(
                    _feature, _extent, colour, bg,
                    (x + self._screen.width // 4) * 2, y + self._screen.height // 2)
            except KeyError:
                pass
        return 1
645412
def get_layer(self, x, layer, **kwargs):
    
    return self.fprop(x, **kwargs)[layer]
855283
def fit_texture(layer):
    
    x, y = layer
    x = (x - np.nanmin(x)) / (np.nanmax(x) - np.nanmin(x))
    y = (y - np.nanmin(y)) / (np.nanmax(y) - np.nanmin(y))
    return x, y
161693
public static Point getPixelRelativeToTile(LatLong latLong, Tile tile) {
        return getPixelRelative(latLong, tile.mapSize, tile.getOrigin());
    }
881801
public byte[] drawTileBytes(int x, int y, int zoom) {

		BufferedImage image = drawTile(x, y, zoom);

		byte[] tileData = null;

		// Convert the image to bytes
		if (image != null) {
			try {
				tileData = ImageUtils.writeImageToBytes(image, compressFormat);
			} catch (IOException e) {
				LOGGER.log(Level.SEVERE, "Failed to create tile. x: " + x
						+ ", y: " + y + ", zoom: " + zoom, e);
			}
		}

		return tileData;
	}
699234
def findlayer(self, z):
        '''
        '''
        if z > self.z[0]:
            modellayer, ltype = -1, 'above'
            layernumber = None
        elif z < self.z[-1]:
            modellayer, ltype = len(self.layernumber), 'below'
            layernumber = None
        else:
            modellayer = np.argwhere((z <= self.z[:-1]) & (z >= self.z[1:]))[0, 0]
            layernumber = self.layernumber[modellayer]
            ltype = self.ltype[modellayer] 
        return layernumber, ltype, modellayer