{
  "openapi": "3.1.1",
  "info": {
    "title": "RavingDesk GeoJSON Validator & Inspector API",
    "version": "1.0.0",
    "summary": "Validate and repair GeoJSON (RFC 7946) and measure areas and lengths on WGS84.",
    "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://ravingdeskgeojsoninspector.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Validate and repair GeoJSON (RFC 7946) and measure areas and lengths on WGS84.",
        "description": "Checks a GeoJSON file against RFC 7946 with a plain-language problem list (open rings, wrong winding order, swapped longitude/latitude, out-of-range positions, obsolete crs, antimeridian edges), repairs what can be repaired without guessing, and reports geodesic polygon areas, perimeters and line lengths on the WGS84 ellipsoid, the bounding box (antimeridian-aware), centroids, which polygons contain a test point, and an optional geodesic buffer around points and lines. It is the GeoJSON engine of RavingDesk’s Data & charts.\n\nMethodology:\n- Validation follows RFC 7946: object structure, positions of 2–3 numbers within ±180° longitude and ±90° latitude, lines with ≥ 2 positions, closed rings with ≥ 4 positions, Feature members “geometry” and “properties”, bbox shape. The right-hand rule (counter-clockwise outer rings, clockwise holes) is reported as a warning, as the RFC tells parsers not to reject such files.\n- Ring orientation and areas use geodesic polygons on WGS84 (Karney 2013): edges are geodesics, so areas are exact for the polygon with geodesic edges. Holes are subtracted. Line lengths are geodesic too.\n- Point-in-polygon tests treat edges as straight lines in longitude/latitude (the usual GIS convention for GeoJSON) with the even–odd rule, holes respected; edges that jump more than 180° are read as crossing the antimeridian.\n- The bounding box is the smallest longitude interval around all positions, so it may cross the antimeridian (west > east, RFC 7946 §5.2). The centre is the normalised 3D mean of the positions; the area centroid is area-weighted in degrees.\n- Buffers: points get a geodesic circle of 64 vertices; lines get offset vertices at the buffer distance with round joins and caps. They are approximations (the line outline can self-intersect at sharp inner bends) and polygons are not buffered.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "ravingdesk_geojson_inspector",
        "x-owner-app": "ravingdesk",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RavingdeskGeojsonInspectorInput"
              },
              "examples": {
                "example1": {
                  "summary": "Park outline, a street and a monument in Berlin, with a test point",
                  "value": {
                    "geojson": "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{\"name\":\"Tiergarten (rough outline, clockwise)\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[13.3364,52.5145],[13.3499,52.5196],[13.3778,52.5167],[13.3747,52.5099],[13.3491,52.5091],[13.3364,52.5145]]]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"Straße des 17. Juni\"},\"geometry\":{\"type\":\"LineString\",\"coordinates\":[[13.3504,52.5145],[13.3612,52.5143],[13.3777,52.5163]]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"Victory Column\"},\"geometry\":{\"type\":\"Point\",\"coordinates\":[13.350108,52.514543]}}]}",
                    "testPoint": "52.5145, 13.3501"
                  }
                },
                "example2": {
                  "summary": "A broken file: open ring, swapped coordinates, missing properties, crs member",
                  "value": {
                    "geojson": "{\"type\":\"FeatureCollection\",\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}},\"features\":[{\"type\":\"Feature\",\"properties\":{\"name\":\"Unclosed square\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[0,0],[0,1],[1,1],[1,0]]]}},{\"type\":\"Feature\",\"geometry\":{\"type\":\"Point\",\"coordinates\":[52.52,113.4]}},{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"LineString\",\"coordinates\":[[10,10],[10,10],[11,11]]}}]}"
                  }
                },
                "example3": {
                  "summary": "A 1 km buffer around a point and a line",
                  "value": {
                    "geojson": "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{\"name\":\"Victory Column\"},\"geometry\":{\"type\":\"Point\",\"coordinates\":[13.350108,52.514543]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"Straße des 17. Juni\"},\"geometry\":{\"type\":\"LineString\",\"coordinates\":[[13.3504,52.5145],[13.3777,52.5163]]}}]}",
                    "bufferM": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RavingdeskGeojsonInspectorResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "RavingdeskGeojsonInspectorInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "geojson": {
            "title": "GeoJSON",
            "description": "A FeatureCollection, a Feature or a bare geometry (up to 5 MB, 200,000 positions).",
            "type": "string",
            "maxLength": 5000000,
            "default": "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{\"name\":\"Tiergarten (rough outline, clockwise)\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[13.3364,52.5145],[13.3499,52.5196],[13.3778,52.5167],[13.3747,52.5099],[13.3491,52.5091],[13.3364,52.5145]]]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"Straße des 17. Juni\"},\"geometry\":{\"type\":\"LineString\",\"coordinates\":[[13.3504,52.5145],[13.3612,52.5143],[13.3777,52.5163]]}},{\"type\":\"Feature\",\"properties\":{\"name\":\"Victory Column\"},\"geometry\":{\"type\":\"Point\",\"coordinates\":[13.350108,52.514543]}}]}"
          },
          "repair": {
            "title": "Repair what can be repaired (close rings, fix winding, remove repeated positions)",
            "type": "boolean",
            "default": true
          },
          "decimals": {
            "title": "Round coordinates to decimals (optional)",
            "description": "6 decimals ≈ 0.1 m, 7 ≈ 1 cm. Leave empty to keep them.",
            "type": "integer",
            "minimum": 0,
            "maximum": 10
          },
          "testPoint": {
            "title": "Test point (optional)",
            "description": "Latitude/longitude in any notation; the tool lists the polygons that contain it.",
            "type": "string",
            "maxLength": 120
          },
          "bufferM": {
            "title": "Buffer distance (optional)",
            "description": "Adds approximate geodesic buffer polygons around every point and line.",
            "type": "number",
            "minimum": 1,
            "maximum": 1000000,
            "x-unit": "m"
          }
        },
        "required": [
          "geojson"
        ]
      },
      "RavingdeskGeojsonInspectorResult": {
        "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": [
              "valid",
              "type",
              "errors",
              "warnings",
              "problems",
              "stats",
              "repairs",
              "repaired",
              "containing",
              "buffers"
            ],
            "properties": {
              "valid": {
                "type": "boolean"
              },
              "type": {
                "type": "string"
              },
              "errors": {
                "type": "integer"
              },
              "warnings": {
                "type": "integer"
              },
              "problems": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "level",
                    "path",
                    "message",
                    "repairable"
                  ],
                  "properties": {
                    "level": {
                      "type": "string",
                      "enum": [
                        "error",
                        "warning",
                        "note"
                      ]
                    },
                    "path": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "repairable": {
                      "type": "boolean"
                    }
                  }
                }
              },
              "stats": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "features",
                  "geometryCounts",
                  "positions",
                  "lineLengthM",
                  "areaM2",
                  "perimeterM",
                  "bbox",
                  "center",
                  "areaCentroid",
                  "emptyGeometries"
                ],
                "properties": {
                  "features": {
                    "type": "integer"
                  },
                  "geometryCounts": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "integer"
                    }
                  },
                  "positions": {
                    "type": "integer"
                  },
                  "lineLengthM": {
                    "type": "number"
                  },
                  "areaM2": {
                    "type": "number"
                  },
                  "perimeterM": {
                    "type": "number"
                  },
                  "bbox": {
                    "type": [
                      "array",
                      "null"
                    ],
                    "items": {
                      "type": "number"
                    },
                    "description": "[west, south, east, north]; west > east when it crosses the antimeridian."
                  },
                  "center": {
                    "type": [
                      "object",
                      "null"
                    ]
                  },
                  "areaCentroid": {
                    "type": [
                      "object",
                      "null"
                    ]
                  },
                  "emptyGeometries": {
                    "type": "integer"
                  }
                }
              },
              "repairs": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "repaired": {
                "oneOf": [
                  {
                    "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)."
                      }
                    }
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "containing": {
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "type": "string"
                }
              },
              "buffers": {
                "oneOf": [
                  {
                    "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)."
                      }
                    }
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "features": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}