import { OpenAssistantTool } from '@openassistant/utils'; import { z } from 'zod'; import { SpatialToolContext } from '../types'; export type PerimeterFunctionArgs = z.ZodObject<{ geojson: z.ZodOptional; datasetName: z.ZodOptional; distanceUnit: z.ZodDefault>; }>; export type PerimeterLlmResult = { success: boolean; result: string; perimeters: number[]; distanceUnit: 'KM' | 'Mile'; }; export type PerimeterAdditionalData = { datasetName?: string; geojson?: string; distanceUnit: 'KM' | 'Mile'; perimeters: number[]; }; /** * ## perimeter Tool * * This tool calculates the perimeter of geometries in a GeoJSON dataset. * It supports both direct GeoJSON input and dataset names, and can calculate perimeters in either kilometers or miles. * * ### Perimeter Calculation * * The tool calculates perimeters for various geometry types: * - **Polygons**: Calculates the perimeter length of polygon boundaries * - **MultiPolygons**: Calculates the total perimeter of multipolygon geometries * - **FeatureCollections**: Calculates perimeters for all polygon features in the collection * * ### Parameters * - `datasetName`: Name of the dataset with geometries to calculate perimeter for (optional) * - `geojson`: GeoJSON string of geometries to calculate perimeter for (optional) * - `distanceUnit`: Unit for perimeter calculation - 'KM' for kilometers or 'Mile' for miles * * **Example user prompts:** * - "Calculate the perimeter of these polygons in kilometers" * - "What is the total perimeter of these boundaries in miles?" * - "Measure the perimeter of these land parcels" * * ### Example * ```typescript * import { perimeter } from "@openassistant/geoda"; * import { convertToVercelAiTool } from "@openassistant/utils"; * * const perimeterTool = { * ...perimeter, * 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 perimeter of these polygons in kilometers', * tools: { perimeter: convertToVercelAiTool(perimeterTool) }, * }); * ``` */ export declare const perimeter: OpenAssistantTool; export type PerimeterTool = typeof perimeter;