triangulate_geometry
Create a triangulation of a geometry to enable accurate geospatial analysis and spatial measurements for GIS operations.
Instructions
Create a triangulation of a geometry.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| geometry | Yes |
Implementation Reference
- src/gis_mcp/shapely_functions.py:354-369 (handler)The primary handler function for the 'triangulate_geometry' MCP tool. It accepts a WKT geometry string, uses Shapely's triangulate operation to generate triangles, and returns a dictionary with the resulting geometries in WKT format and a success message.@gis_mcp.tool() def triangulate_geometry(geometry: str) -> Dict[str, Any]: """Create a triangulation of a geometry.""" try: from shapely import wkt from shapely.ops import triangulate geom = wkt.loads(geometry) triangles = triangulate(geom) return { "status": "success", "geometries": [tri.wkt for tri in triangles], "message": "Triangulation created successfully" } except Exception as e: logger.error(f"Error creating triangulation: {str(e)}") raise ValueError(f"Failed to create triangulation: {str(e)}")
- src/gis_mcp/shapely_functions.py:50-59 (registration)A resource endpoint that lists 'triangulate_geometry' among available advanced GIS operations, serving as a catalog or indirect registration reference for the tool.@gis_mcp.resource("gis://operations/advanced") def get_advanced_operations() -> Dict[str, List[str]]: """List available advanced operations.""" return { "operations": [ "triangulate_geometry", "voronoi", "unary_union_geometries" ] }