Skip to main content
Glama
NodeGIS

GeoSpatial MCP Server

by NodeGIS

mcp_geo_convert

Convert coordinates between systems like BD09, GCJ02, WGS84, and Web Mercator using specified methods for accurate geospatial data transformation.

Instructions

在不同坐标系统之间转换坐标。支持BD09(百度)、GCJ02(火星)、WGS84(GPS)和Web Mercator投影坐标系统之间的互相转换。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
latitudeYes纬度
longitudeYes经度
methodYes转换方法

Implementation Reference

  • The handler function for the mcp_geo_convert tool. It receives the conversion method and coordinates, dispatches to the corresponding coordinate transformation method, and returns the result as structured JSON or an error.
    async ({ method, longitude, latitude }) => { try { let result; switch (method) { case "BD09toGCJ02": result = this.BD09toGCJ02(longitude, latitude); break; case "GCJ02toBD09": result = this.GCJ02toBD09(longitude, latitude); break; case "WGS84toGCJ02": result = this.WGS84toGCJ02(longitude, latitude); break; case "GCJ02toWGS84": result = this.GCJ02toWGS84(longitude, latitude); break; case "BD09toWGS84": result = this.BD09toWGS84(longitude, latitude); break; case "WGS84toBD09": result = this.WGS84toBD09(longitude, latitude); break; case "WebMercatortoLngLat": result = this.webMercatorToLngLat(longitude, latitude); break; case "LngLattoWebMercator": result = this.lngLatToWebMercator(longitude, latitude); break; } return { content: [{ type: "text", text: JSON.stringify({ method, input: { longitude, latitude }, output: { longitude: result[0], latitude: result[1] } }, null, 2) }] }; } catch (err) { return { content: [{ type: "text", text: `错误: ${err.message}` }], isError: true }; } }
  • Input schema using Zod for validating the tool parameters: conversion method (enum), longitude (number), and latitude (number).
    { method: z.enum([ "BD09toGCJ02", "GCJ02toBD09", "WGS84toGCJ02", "GCJ02toWGS84", "BD09toWGS84", "WGS84toBD09", "WebMercatortoLngLat", "LngLattoWebMercator" ]).describe("转换方法"), longitude: z.number().describe("经度"), latitude: z.number().describe("纬度") },
  • dist/server.js:163-230 (registration)
    Registration of the mcp_geo_convert tool in the GeoServer's initializeTools method, including name, description, input schema, and handler function.
    this.tool( "mcp_geo_convert", "在不同坐标系统之间转换坐标。支持BD09(百度)、GCJ02(火星)、WGS84(GPS)和Web Mercator投影坐标系统之间的互相转换。", { method: z.enum([ "BD09toGCJ02", "GCJ02toBD09", "WGS84toGCJ02", "GCJ02toWGS84", "BD09toWGS84", "WGS84toBD09", "WebMercatortoLngLat", "LngLattoWebMercator" ]).describe("转换方法"), longitude: z.number().describe("经度"), latitude: z.number().describe("纬度") }, async ({ method, longitude, latitude }) => { try { let result; switch (method) { case "BD09toGCJ02": result = this.BD09toGCJ02(longitude, latitude); break; case "GCJ02toBD09": result = this.GCJ02toBD09(longitude, latitude); break; case "WGS84toGCJ02": result = this.WGS84toGCJ02(longitude, latitude); break; case "GCJ02toWGS84": result = this.GCJ02toWGS84(longitude, latitude); break; case "BD09toWGS84": result = this.BD09toWGS84(longitude, latitude); break; case "WGS84toBD09": result = this.WGS84toBD09(longitude, latitude); break; case "WebMercatortoLngLat": result = this.webMercatorToLngLat(longitude, latitude); break; case "LngLattoWebMercator": result = this.lngLatToWebMercator(longitude, latitude); break; } return { content: [{ type: "text", text: JSON.stringify({ method, input: { longitude, latitude }, output: { longitude: result[0], latitude: result[1] } }, null, 2) }] }; } catch (err) { return { content: [{ type: "text", text: `错误: ${err.message}` }], isError: true }; } } );
  • Example helper function for WGS84 to GCJ02 coordinate transformation, used by the tool handler. Other similar helpers exist for different conversions.
    WGS84toGCJ02(lon, lat) { if (this.isOutOfChina(lon, lat)) { return [lon, lat]; } return this.delta(lon, lat); }
Install Server

Other Tools

Related 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/NodeGIS/geo-mcp-server'

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