/** * Raster tile rendering for XYZ tiles. * * The OsmixRasterTile class creates and manages pixel buffers for individual * map tiles, providing methods to draw geographic geometries (points, lines, * polygons) into the buffer with automatic projection and clipping. * * @module */ import type { GeoBbox2D, LonLat, Rgba, Tile, XY } from "@osmix/shared/types"; /** Default image type for exported tiles. */ export declare const DEFAULT_RASTER_IMAGE_TYPE = "image/png"; export declare const DEFAULT_LINE_COLOR: Rgba; export declare const DEFAULT_POINT_COLOR: Rgba; export declare const DEFAULT_AREA_COLOR: Rgba; export declare const DEFAULT_RASTER_TILE_SIZE = 256; /** * Construct a an image for a single XYZ tile. The image is a 2D array of RGBA pixels. * Helper methods are provided to draw lines, polygons, and points onto the image. * * Coordinate systems: * - "lon/lat" (or ll): Geographic WGS84 coordinates [longitude, latitude]. * - "tile pixels" (or px): 2D cartesian coordinates relative to the tile's top-left corner. * - [0, 0] is top-left. * - [tileSize, tileSize] is bottom-right. * * This class handles the projection and clipping of geographic geometry into the tile's pixel space. */ export declare class OsmixRasterTile { imageData: Uint8ClampedArray; tile: Tile; tileSize: number; minPixelCoverage: number; constructor({ imageData, tile, tileSize, }: { imageData?: Uint8ClampedArray; tile: Tile; tileSize: number; }); bbox(): GeoBbox2D; llToTilePx(ll: LonLat): XY; tilePxToLonLat(px: XY): LonLat; clampAndRoundPx(px: XY): XY; /** * Project a geographic bounding box to tile pixel space and check if it fits in a single pixel. * Returns the pixel coordinates and coverage ratio if it fits, null otherwise. */ private projectBboxToPixelSpace; getIndex(px: XY): number; drawPoint(ll: LonLat, color?: Rgba): void; /** * Draw a color at a pixel. If the pixel is transparent, the color is drawn. * Otherwise, the color is blended with the existing color. */ drawPixel(px: XY, color: Rgba): void; /** * Draw an entity whose bounding box fits entirely within a single pixel. * Returns true if the entity was drawn as a single pixel, false if it spans multiple pixels. * The alpha channel is scaled by the coverage ratio (percentage of pixel covered by the bbox). */ drawSubpixelEntity(bbox: GeoBbox2D, color: Rgba): boolean; /** * Draw a line between two pixels. * Uses Bresenham's line algorithm. */ drawLine(px0: XY, px1: XY, color?: Rgba): void; /** * Split a line string into a series of line segments and draw each segment. */ drawLineString(coords: LonLat[], color?: Rgba): void; /** * Draw a filled polygon with optional holes. * First ring is the outer boundary, subsequent rings are holes. * Uses even-odd winding rule for fill determination. */ drawPolygon(rings: LonLat[][], color?: Rgba): void; /** * Draw a MultiPolygon (multiple polygons, each with optional holes). */ drawMultiPolygon(polygons: LonLat[][][], color?: Rgba): void; /** * Draw a relation as polygon(s). * Takes an array of polygons (each polygon is an array of rings: [outer, ...inner]). */ drawRelation(polygons: LonLat[][][], color?: Rgba): void; /** * Fill polygon using scanline algorithm with even-odd winding rule. * Handles holes correctly by toggling fill state on each edge crossing. */ private fillPolygonScanline; } //# sourceMappingURL=raster-tile.d.ts.map