calculate_geodetic_distance
Calculate accurate distance between geographic coordinates on Earth's surface using geodetic methods for GIS analysis and spatial measurements.
Instructions
Calculate geodetic distance between points.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| point1 | Yes | ||
| point2 | Yes | ||
| ellps | No | WGS84 |
Implementation Reference
- src/gis_mcp/pyproj_functions.py:179-200 (handler)The core handler function that executes the tool logic: calculates geodetic distance, azimuths using pyproj.Geod.inv between two lon/lat points.@gis_mcp.tool() def calculate_geodetic_distance(point1: List[float], point2: List[float], ellps: str = "WGS84") -> Dict[str, Any]: """Calculate geodetic distance between points.""" try: import pyproj geod = pyproj.Geod(ellps=ellps) lon1, lat1 = point1 lon2, lat2 = point2 forward_azimuth, back_azimuth, distance = geod.inv(lon1, lat1, lon2, lat2) return { "status": "success", "distance": distance, "forward_azimuth": forward_azimuth, "back_azimuth": back_azimuth, "ellps": ellps, "unit": "meters", "message": "Geodetic distance calculated successfully" } except Exception as e: logger.error(f"Error calculating geodetic distance: {str(e)}") raise ValueError(f"Failed to calculate geodetic distance: {str(e)}")
- Resource endpoint listing available geodetic tools, including 'calculate_geodetic_distance', serving as tool discovery/schema.@gis_mcp.resource("gis://crs/geodetic") def get_geodetic_operations() -> Dict[str, List[str]]: """List available geodetic operations.""" return { "operations": [ "get_geod_info", "calculate_geodetic_distance", "calculate_geodetic_point", "calculate_geodetic_area" ] }
- src/gis_mcp/mcp.py:2-5 (registration)MCP server instance 'gis_mcp' creation via FastMCP, to which tools are registered via decorators.from fastmcp import FastMCP gis_mcp = FastMCP("GIS MCP")