import type { ThematicRasterSelectionResponse, VectorSelectionResponse } from '../types' export function thematicRasterImageUrl(projectId: string, datasetId: string): string { return `/api/v1/projects/${projectId}/datasets/${datasetId}/raster/thematic/image` } export function walousRasterImageUrl(projectId: string, datasetId: string): string { return `/api/v1/projects/${projectId}/datasets/${datasetId}/raster/walous/image` } export function thematicRasterSelectionToMapSelection(result: ThematicRasterSelectionResponse): VectorSelectionResponse { return { selection_bbox: result.selection_bbox, selection_area_id: result.selection_area_id, feature_count: result.valid_cell_count, total_feature_count: result.valid_cell_count, limit: 0, truncated: false, geojson: { type: 'FeatureCollection', features: [] }, summary: { ...result.summary, feature_count: result.valid_cell_count, is_estimate: true, // A selection finer than one source cell was widened to the cells it // touches; the result then covers more ground than was drawn. warning: [result.cell_selection_warning, result.limitation_message].filter(Boolean).join(' '), selection_edge_warning: result.cell_selection_warning ?? null, metrics: result.summary.metrics.map((metric) => ({ ...metric, is_estimate: metric.is_estimate ?? true, })), }, } }