Skip to main content
Glama
es3154
by es3154

misc_nearest_point_on_line

Calculate the closest point on a line to any given location and determine the exact distance between them using geographic coordinates.

Instructions

找到线上距离给定点最近的位置。

此功能在线段上找到距离给定点最近的位置,返回该位置坐标及距离信息。

Args: line: 线 GeoJSON 特征或几何图形 - 类型: str (JSON 字符串格式的 GeoJSON) - 格式: 必须符合 GeoJSON LineString 规范 - 坐标系: WGS84 (经度在前,纬度在后) - 示例: '{"type": "LineString", "coordinates": [[-77.031669, 38.878605], [-77.029609, 38.881946], [-77.020339, 38.884084], [-77.025661, 38.885821], [-77.021884, 38.889563], [-77.019824, 38.892368]]}'

point: 点 GeoJSON 特征或几何图形 - 类型: str (JSON 字符串格式的 GeoJSON) - 格式: 必须符合 GeoJSON Point 规范 - 坐标系: WGS84 (经度在前,纬度在后) - 示例: '{"type": "Point", "coordinates": [-77.037076, 38.884017]}' options: 可选参数配置 - 类型: str (JSON 字符串) 或 None - 可选字段: - units: 距离单位 (默认: 'kilometers') - 有效值: 'miles', 'nauticalmiles', 'kilometers', 'meters', 'yards', 'feet', 'inches' - 示例: '{"units": "miles"}'

Returns: str: JSON 字符串格式的 GeoJSON Point 特征 - 类型: GeoJSON Feature with Point geometry - 格式: {"type": "Feature", "geometry": {"type": "Point", "coordinates": [lng, lat]}, "properties": {"location": 距离起点位置, "distance": 距离值}}

Raises: Exception: 当 JavaScript 执行失败、超时或输入数据格式错误时抛出异常

Example: >>> import asyncio >>> line = '{"type": "LineString", "coordinates": [[-77.031669, 38.878605], [-77.029609, 38.881946], [-77.020339, 38.884084], [-77.025661, 38.885821], [-77.021884, 38.889563], [-77.019824, 38.892368]]}' >>> point = '{"type": "Point", "coordinates": [-77.037076, 38.884017]}' >>> options = '{"units": "miles"}' >>> result = asyncio.run(nearest_point_on_line(line, point, options)) >>> print(result) '{"type": "Feature", "geometry": {"type": "Point", "coordinates": [-77.03, 38.883]}, "properties": {"location": 0.5, "distance": 0.2}}'

Notes: - 输入参数 line 和 point 必须是有效的 JSON 字符串 - 坐标顺序为 [经度, 纬度] (WGS84 坐标系) - 返回线上距离给定点最近的位置及相关信息 - 依赖于 Turf.js 库和 Node.js 环境

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
lineYes
optionsNo
pointYes

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/es3154/turf-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server