Search in sources :

Example 91 with Description

use of io.trino.spi.function.Description in project trino by trinodb.

the class BingTileFunctions method bingTilesAround.

@Description("Given a (longitude, latitude) point, returns the surrounding Bing tiles at the specified zoom level")
@ScalarFunction("bing_tiles_around")
@SqlType("array(" + BingTileType.NAME + ")")
public static Block bingTilesAround(@SqlType(StandardTypes.DOUBLE) double latitude, @SqlType(StandardTypes.DOUBLE) double longitude, @SqlType(StandardTypes.INTEGER) long zoomLevel) {
    checkLatitude(latitude, LATITUDE_OUT_OF_RANGE);
    checkLongitude(longitude, LONGITUDE_OUT_OF_RANGE);
    checkZoomLevel(zoomLevel);
    long mapSize = mapSize(toIntExact(zoomLevel));
    long maxTileIndex = (mapSize / TILE_PIXELS) - 1;
    int tileX = longitudeToTileX(longitude, mapSize);
    int tileY = longitudeToTileY(latitude, mapSize);
    BlockBuilder blockBuilder = BIGINT.createBlockBuilder(null, 9);
    for (int i = -1; i <= 1; i++) {
        for (int j = -1; j <= 1; j++) {
            int x = tileX + i;
            int y = tileY + j;
            if (x >= 0 && x <= maxTileIndex && y >= 0 && y <= maxTileIndex) {
                BIGINT.writeLong(blockBuilder, BingTile.fromCoordinates(x, y, toIntExact(zoomLevel)).encode());
            }
        }
    }
    return blockBuilder.build();
}
Also used : Point(com.esri.core.geometry.Point) GeometryUtils.disjoint(io.trino.geospatial.GeometryUtils.disjoint) BlockBuilder(io.trino.spi.block.BlockBuilder) ScalarFunction(io.trino.spi.function.ScalarFunction) Description(io.trino.spi.function.Description) SqlType(io.trino.spi.function.SqlType)

Example 92 with Description

use of io.trino.spi.function.Description in project trino by trinodb.

the class TeradataStringFunctions method char2HexInt.

@Description("Returns the hexadecimal representation of the UTF-16BE encoding of the argument")
@ScalarFunction("char2hexint")
@SqlType(StandardTypes.VARCHAR)
public static Slice char2HexInt(@SqlType(StandardTypes.VARCHAR) Slice string) {
    Slice utf16 = Slices.wrappedBuffer(UTF_16BE.encode(string.toStringUtf8()));
    String encoded = BaseEncoding.base16().encode(utf16.getBytes());
    return Slices.utf8Slice(encoded);
}
Also used : Slice(io.airlift.slice.Slice) ScalarFunction(io.trino.spi.function.ScalarFunction) Description(io.trino.spi.function.Description) SqlType(io.trino.spi.function.SqlType)

Aggregations

Description (io.trino.spi.function.Description)92 ScalarFunction (io.trino.spi.function.ScalarFunction)90 SqlType (io.trino.spi.function.SqlType)90 OGCGeometry (com.esri.core.geometry.ogc.OGCGeometry)46 SqlNullable (io.trino.spi.function.SqlNullable)38 LiteralParameters (io.trino.spi.function.LiteralParameters)19 Constraint (io.trino.type.Constraint)18 Point (com.esri.core.geometry.Point)17 OGCPoint (com.esri.core.geometry.ogc.OGCPoint)17 Slice (io.airlift.slice.Slice)17 BlockBuilder (io.trino.spi.block.BlockBuilder)16 MultiPoint (com.esri.core.geometry.MultiPoint)15 TrinoException (io.trino.spi.TrinoException)15 SliceUtf8.lengthOfCodePoint (io.airlift.slice.SliceUtf8.lengthOfCodePoint)8 SliceUtf8.offsetOfCodePoint (io.airlift.slice.SliceUtf8.offsetOfCodePoint)8 Matcher (io.airlift.joni.Matcher)7 GeometryType (io.trino.geospatial.GeometryType)7 Envelope (com.esri.core.geometry.Envelope)5 MultiPath (com.esri.core.geometry.MultiPath)5 MultiVertexGeometry (com.esri.core.geometry.MultiVertexGeometry)5