is_valid
Validate geometry accuracy with the GIS MCP Server's tool, ensuring geospatial data integrity for precise geometric operations and analysis.
Instructions
Check if a geometry is valid.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| geometry | Yes |
Implementation Reference
- src/gis_mcp/shapely_functions.py:437-451 (handler)The core handler function for the 'is_valid' MCP tool. It takes a WKT geometry string, loads it with Shapely, checks if it is valid using geom.is_valid, and returns a dictionary with status, is_valid boolean, and message.@gis_mcp.tool() def is_valid(geometry: str) -> Dict[str, Any]: """Check if a geometry is valid.""" try: from shapely import wkt geom = wkt.loads(geometry) return { "status": "success", "is_valid": bool(geom.is_valid), "message": "Geometry validation completed successfully" } except Exception as e: logger.error(f"Error validating geometry: {str(e)}") raise ValueError(f"Failed to validate geometry: {str(e)}")
- Supporting resource that catalogs the available validation operations, including the 'is_valid' tool.@gis_mcp.resource("gis://operations/validation") def get_validation_operations() -> Dict[str, List[str]]: """List available validation operations.""" return { "operations": [ "is_valid", "make_valid", "simplify" ] }