get_solar_potential
Calculate rooftop solar energy potential for Swiss locations using latitude and longitude coordinates to assess renewable energy feasibility.
Instructions
Get rooftop solar energy potential for a location in Switzerland
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| lat | Yes | Latitude (WGS84) | |
| lng | Yes | Longitude (WGS84) |
Implementation Reference
- src/modules/geodata.ts:199-240 (handler)The implementation of the get_solar_potential tool logic. It queries the swisstopo identify service for the 'ch.bfe.solarenergie-eignung-daecher' layer and aggregates the results by building.
case "get_solar_potential": { const lat = args.lat as number; const lng = args.lng as number; // Use tight tolerance to get only the closest building const extent = `${lng - 0.001},${lat - 0.001},${lng + 0.001},${lat + 0.001}`; const url = buildUrl(`${BASE}/rest/services/all/MapServer/identify`, { geometry: `${lng},${lat}`, geometryType: "esriGeometryPoint", layers: "all:ch.bfe.solarenergie-eignung-daecher", mapExtent: extent, imageDisplay: "500,500,96", tolerance: 10, sr: 4326, returnGeometry: false, }); const data = await fetchJSON<IdentifyResponse>(url); const roofs = data.results.map(slimSolarResult); // Group by building and summarize const buildingMap = new Map<number, typeof roofs>(); for (const r of roofs) { const id = r.buildingId; if (!buildingMap.has(id)) buildingMap.set(id, []); buildingMap.get(id)!.push(r); } const buildings = [...buildingMap.entries()].map(([buildingId, surfaces]) => ({ buildingId, totalArea_m2: Math.round(surfaces.reduce((s, r) => s + (r.area_m2 ?? 0), 0)), totalElectricity_kWh: Math.round(surfaces.reduce((s, r) => s + (r.electricityYield_kWh ?? 0), 0)), totalFinancialReturn_CHF: Math.round(surfaces.reduce((s, r) => s + (r.financialReturn_CHF ?? 0), 0)), roofSurfaces: surfaces.length, bestClass: Math.min(...surfaces.map((r) => r.class).filter((c) => c != null)), surfaces: surfaces.slice(0, 5), // Cap at 5 surfaces per building })); return JSON.stringify({ count: buildings.length, buildings: buildings.slice(0, 10), // Cap at 10 buildings source: "Swiss Federal Office of Energy (BFE)", }); } - src/modules/geodata.ts:127-137 (schema)Tool definition and input schema for 'get_solar_potential' in the geodataTools array.
name: "get_solar_potential", description: "Get rooftop solar energy potential for a location in Switzerland", inputSchema: { type: "object", required: ["lat", "lng"], properties: { lat: { type: "number", description: "Latitude (WGS84)" }, lng: { type: "number", description: "Longitude (WGS84)" }, }, }, }, - src/modules/geodata.ts:90-90 (registration)Registration of geodata tools, including 'get_solar_potential'.
export const geodataTools = [