Geolocation Utilities

Polyline Length

Calculate the total length of a polyline by summing distances between consecutive coordinate points. Use via MCP in Cursor or Windsurf, or call GET /v1/geo/polyline-length with coordinate arrays. Returns precise measurements in meters using the Haversine formula. Perfect for route distance calculations in mapping applications.

API Endpoint

GET /v1/geo/polyline-length

Code Examples

curl "https://tinyfn.io/v1/geo/polyline-length" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/geo/polyline-length', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/geo/polyline-length',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's geolocation tools:

{
  "mcpServers": {
    "tinyfn-geo": {
      "url": "https://tinyfn.io/mcp/geo",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do I calculate polyline length using MCP in AI coding tools?

Call the polyline-length tool with an array of [latitude, longitude] coordinate pairs. The MCP tool returns total distance in meters between all consecutive points.

What coordinate format does the polyline length calculator accept?

Accepts arrays of coordinate pairs in [latitude, longitude] format, where latitude is -90 to 90 and longitude is -180 to 180 decimal degrees.

Does polyline length calculation account for Earth's curvature?

Yes, it uses the Haversine formula to calculate great-circle distances between points, accounting for Earth's spherical shape for accurate results.

Can I calculate length for complex routes with many waypoints?

Yes, the tool handles polylines with any number of coordinate points, calculating cumulative distance by summing all segment lengths between consecutive waypoints.

What's the difference between polyline length and straight-line distance?

Polyline length sums distances between all consecutive coordinate pairs, while straight-line distance only measures between start and end points.

Try Polyline Length Now

Get your free API key and start using Polyline Length in seconds.

Get Free API Key