Skip to main content
Glama

create-linestring

Generate LineString geometries from coordinate arrays using the PostGIS MCP Server. Input coordinate pairs to create spatial lines for GIS applications.

Instructions

Koordinat dizisinden çizgi geometrisi oluştur

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
coordinatesYesKoordinat dizisi [[lon,lat], [lon,lat], ...]
sridNoSRID (varsayılan: 4326)

Implementation Reference

  • The main handler for the 'create-linestring' tool. Parses input using CreateLineStringSchema, constructs a LINESTRING WKT from the provided coordinates, executes a PostGIS query to generate WKT, GeoJSON representations, and computes the length in meters using ST_Length on geography type.
    case "create-linestring": { const { coordinates, srid } = CreateLineStringSchema.parse(args); const coordString = coordinates .map((coord) => `${coord[0]} ${coord[1]}`) .join(", "); const result = await client.query( ` SELECT ST_AsText(ST_GeomFromText('LINESTRING(${coordString})', $1)) as wkt, ST_AsGeoJSON(ST_GeomFromText('LINESTRING(${coordString})', $1)) as geojson, ST_Length(ST_GeomFromText('LINESTRING(${coordString})', $1)::geography) as length_meters `, [srid] ); return { content: [ { type: "text", text: JSON.stringify( { wkt: result.rows[0].wkt, geojson: JSON.parse(result.rows[0].geojson), coordinates: coordinates, length_meters: parseFloat(result.rows[0].length_meters), srid: srid, }, null, 2 ), }, ], }; }
  • Zod schema for validating the input parameters of the create-linestring tool: array of coordinate pairs/triples and optional SRID.
    const CreateLineStringSchema = z.object({ coordinates: z.array(z.array(z.number().min(2).max(3))), srid: z.number().optional().default(4326), });
  • server.ts:635-649 (registration)
    Tool registration in the ListToolsRequestHandler response, defining the name, description, and JSON input schema for create-linestring.
    name: "create-linestring", description: "Koordinat dizisinden çizgi geometrisi oluştur", inputSchema: { type: "object", properties: { coordinates: { type: "array", description: "Koordinat dizisi [[lon,lat], [lon,lat], ...]", items: { type: "array", items: { type: "number" } }, }, srid: { type: "number", description: "SRID (varsayılan: 4326)" }, }, required: ["coordinates"], }, },

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/receptopalak/postgis-mcp'

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