import { OpenAssistantTool } from '@openassistant/utils'; import { z } from 'zod'; import { SpatialToolContext } from '../types'; export type LengthFunctionArgs = z.ZodObject<{ geojson: z.ZodOptional; datasetName: z.ZodOptional; distanceUnit: z.ZodDefault>; }>; export type LengthLlmResult = { success: boolean; result: string; lengths: number[]; distanceUnit: 'KM' | 'Mile'; }; export type LengthAdditionalData = { datasetName?: string; geojson?: string; lengths: number[]; distanceUnit: 'KM' | 'Mile'; }; /** * ## length Tool * * This tool calculates the length of geometries in a GeoJSON dataset. * It supports both direct GeoJSON input and dataset names, and can calculate lengths in either kilometers or miles. * * ### Length Calculation * * The tool calculates lengths for various geometry types: * - **LineStrings**: Calculates the total length of line features * - **MultiLineStrings**: Calculates the total length of multiline features * - **Polygons**: Calculates the perimeter length of polygon boundaries * - **FeatureCollections**: Calculates lengths for all line features in the collection * * ### Parameters * - `datasetName`: Name of the dataset with geometries to calculate length for (optional) * - `geojson`: GeoJSON string of geometries to calculate length for (optional) * - `distanceUnit`: Unit for length calculation - 'KM' for kilometers or 'Mile' for miles * * **Example user prompts:** * - "Calculate the length of these roads in kilometers" * - "What is the total length of the river network in miles?" * - "Measure the length of these boundaries" * * ### Example * ```typescript * import { length } from "@openassistant/geoda"; * import { convertToVercelAiTool } from "@openassistant/utils"; * * const lengthTool = { * ...length, * context: { * getGeometries: async (datasetName: string) => { * // Implementation to retrieve geometries from your data source * return geometries; * }, * }, * }; * * const result = await generateText({ * model: openai('gpt-4.1', { apiKey: key }), * prompt: 'Calculate the length of these roads in kilometers', * tools: { length: convertToVercelAiTool(lengthTool) }, * }); * ``` */ export declare const length: OpenAssistantTool;