{
  "openapi": "3.1.1",
  "info": {
    "title": "Cartograph True Size of Countries (Mercator comparer) API",
    "version": "1.0.0",
    "summary": "Move a country to another latitude and see its true size against the Mercator map.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://cartographtruesize.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Move a country to another latitude and see its true size against the Mercator map.",
        "description": "Moves a country outline (Natural Earth admin-0) to any place on the globe while keeping its true shape and area, and shows how big it looks on a Web-Mercator map at home and at the new place, next to its real geodesic area and an optional second country. It is the true-size engine of the Cartograph app.\n\nMethodology:\n- Outlines: Natural Earth 1:110m admin-0 countries (public domain), the same file as the Geo Data Visualizer; small countries and islands below that scale are missing.\n- Moving: every vertex keeps its geodesic distance and azimuth from the anchor (Karney’s inverse problem at home, direct problem at the new place, WGS84). On a sphere this is an exact rotation; on the ellipsoid the true area changes by well under 1 % — both areas are reported.\n- True area: geodesic polygon area on WGS84 (outer rings minus holes). Apparent area: planar area of the outline in Web Mercator at equator scale, which grows with sec²(latitude) — 4 × at 60°.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "cartograph_true_size",
        "x-owner-app": "cartograph",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CartographTrueSizeInput"
              },
              "examples": {
                "example1": {
                  "summary": "Greenland moved to the equator, compared with DR Congo",
                  "value": {
                    "country": "GRL",
                    "target": "2, 20",
                    "compare": "COD"
                  }
                },
                "example2": {
                  "summary": "Brazil laid over Europe",
                  "value": {
                    "country": "Brazil",
                    "target": "51, 12"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CartographTrueSizeResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "CartographTrueSizeInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "country": {
            "title": "Country (English name or ISO code)",
            "type": "string",
            "maxLength": 60,
            "default": "GRL"
          },
          "target": {
            "title": "Move it to",
            "description": "Coordinate of the new centre (anchor = centre of the bounding box of the largest part).",
            "type": "string",
            "default": "2, 20"
          },
          "rotationDeg": {
            "title": "Rotation (clockwise)",
            "type": "number",
            "minimum": -180,
            "maximum": 180,
            "default": 0,
            "x-unit": "°"
          },
          "compare": {
            "title": "Compare with (optional)",
            "description": "A second country drawn at home and compared by true area.",
            "type": "string",
            "maxLength": 60,
            "default": ""
          }
        },
        "required": []
      },
      "CartographTrueSizeResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "country",
              "iso3",
              "anchor",
              "target",
              "rotationDeg",
              "trueAreaKm2",
              "movedTrueAreaKm2",
              "apparentHomeKm2",
              "apparentTargetKm2",
              "apparentChange",
              "compare",
              "geojson"
            ],
            "properties": {
              "country": {
                "type": "string"
              },
              "iso3": {
                "type": "string"
              },
              "anchor": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "lat",
                  "lon"
                ],
                "properties": {
                  "lat": {
                    "type": "number"
                  },
                  "lon": {
                    "type": "number"
                  }
                }
              },
              "target": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "lat",
                  "lon"
                ],
                "properties": {
                  "lat": {
                    "type": "number"
                  },
                  "lon": {
                    "type": "number"
                  }
                }
              },
              "rotationDeg": {
                "type": "number"
              },
              "trueAreaKm2": {
                "type": "number"
              },
              "movedTrueAreaKm2": {
                "type": "number"
              },
              "apparentHomeKm2": {
                "type": "number",
                "description": "Planar Web-Mercator area at home, km² at equator scale."
              },
              "apparentTargetKm2": {
                "type": "number"
              },
              "apparentChange": {
                "type": "number",
                "description": "Apparent area at the new place ÷ apparent area at home."
              },
              "compare": {
                "type": [
                  "object",
                  "null"
                ],
                "additionalProperties": false,
                "required": [
                  "country",
                  "iso3",
                  "trueAreaKm2",
                  "ratio"
                ],
                "properties": {
                  "country": {
                    "type": "string"
                  },
                  "iso3": {
                    "type": "string"
                  },
                  "trueAreaKm2": {
                    "type": "number"
                  },
                  "ratio": {
                    "type": "number",
                    "description": "True area of the country ÷ true area of the comparison country."
                  }
                }
              },
              "geojson": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "artifactId",
                  "filename",
                  "mime",
                  "bytes",
                  "sha256",
                  "path"
                ],
                "properties": {
                  "artifactId": {
                    "type": "string"
                  },
                  "filename": {
                    "type": "string"
                  },
                  "mime": {
                    "type": "string"
                  },
                  "bytes": {
                    "type": "integer"
                  },
                  "sha256": {
                    "type": "string"
                  },
                  "path": {
                    "type": "string",
                    "description": "Download path on the same site (valid for about 2 hours)."
                  }
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}