{
  "openapi": "3.1.0",
  "info": {
    "description": "独立测试工作台。匿名读取初始样例或单次计算可省略会话。写操作与保存外部运行记录必须带 X-WebGIS-Test-Session；会话失效返回 410，必填头缺失返回 428。",
    "title": "第三类 GIS · 香港地图、空间查询与图形",
    "version": "1.1.0"
  },
  "servers": [
    {
      "url": "https://workbench-test.scri-digital-twin-cctv.com"
    }
  ],
  "security": [
    {},
    {
      "TestSession": []
    }
  ],
  "paths": {
    "/api/v1/test-sessions/history": {
      "get": {
        "summary": "读取本轮历史，最新在前，每页最多 50 条",
        "security": [
          {
            "TestSession": []
          }
        ],
        "parameters": [
          {
            "in": "query",
            "name": "before",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "records 数组，每条含 sequence、method、path、time、status、请求和响应"
          }
        }
      }
    },
    "/api/v1/test-sessions": {
      "post": {
        "operationId": "createTestSession",
        "summary": "开始一次独立测试（无请求体）",
        "security": [],
        "responses": {
          "201": {
            "description": "新会话",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "sessionId",
                    "idleTimeoutSeconds"
                  ],
                  "properties": {
                    "sessionId": {
                      "type": "string",
                      "description": "测试历史访问凭证，持有者可继续读写本轮。"
                    },
                    "persistent": {
                      "type": "boolean",
                      "example": true
                    },
                    "idleTimeoutSeconds": {
                      "type": "integer",
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "当前并行会话已满"
          }
        }
      }
    },
    "/api/v1/test-sessions/current": {
      "get": {
        "operationId": "getTestSession",
        "summary": "读取当前测试历史身份",
        "security": [
          {
            "TestSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "会话有效",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "sessionId",
                    "idleTimeoutSeconds"
                  ],
                  "properties": {
                    "sessionId": {
                      "type": "string",
                      "description": "测试历史访问凭证，持有者可继续读写本轮。"
                    },
                    "persistent": {
                      "type": "boolean",
                      "example": true
                    },
                    "idleTimeoutSeconds": {
                      "type": "integer",
                      "nullable": true,
                      "example": null
                    }
                  }
                }
              }
            }
          },
          "410": {
            "description": "会话已失效"
          },
          "428": {
            "description": "缺少会话请求头"
          }
        }
      },
      "delete": {
        "operationId": "endTestSession",
        "summary": "确认本轮测试已保存",
        "security": [
          {
            "TestSession": []
          }
        ],
        "responses": {
          "200": {
            "description": "已结束",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "closed"
                  ],
                  "properties": {
                    "closed": {
                      "type": "boolean",
                      "example": true
                    }
                  }
                }
              }
            }
          },
          "410": {
            "description": "会话已失效"
          },
          "428": {
            "description": "缺少会话请求头"
          }
        }
      }
    },
    "/api/v1/map/runs": {
      "get": {
        "operationId": "listMapRuns",
        "summary": "列出外部程序主动标记的地图测试批次",
        "description": "在 GET /api/v1/map/features、POST /api/v1/map/measure 或 POST /api/v1/map/buffer 请求中传入 X-WebGIS-Run，例如 acceptance-01。返回最近完成请求的批次，最新在前。未指定运行号的普通请求可在本轮历史接口中查看。历史保存在独立数据库。",
        "responses": {
          "200": {
            "description": "运行清单及当前保留策略",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "retention"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "runId",
                          "createdAt",
                          "updatedAt",
                          "expiresAt",
                          "count",
                          "dropped"
                        ],
                        "properties": {
                          "runId": {
                            "type": "string"
                          },
                          "createdAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "updatedAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "expiresAt": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "count": {
                            "type": "integer"
                          },
                          "dropped": {
                            "type": "integer"
                          }
                        }
                      }
                    },
                    "retention": {
                      "type": "object",
                      "properties": {
                        "ttlMs": {
                          "type": "integer"
                        },
                        "maxRuns": {
                          "type": "integer"
                        },
                        "maxRecordsPerRun": {
                          "type": "integer"
                        },
                        "maxBytesPerRecord": {
                          "type": "integer"
                        },
                        "maxBytesPerRun": {
                          "type": "integer"
                        },
                        "maxBytes": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "410": {
            "description": "指定会话已失效"
          }
        }
      }
    },
    "/api/v1/map/runs/{runId}": {
      "get": {
        "operationId": "readMapRun",
        "summary": "按运行编号读回实际请求和原始服务结果",
        "parameters": [
          {
            "name": "runId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$"
            }
          }
        ],
        "description": "records 按请求完成顺序返回。每项包含实际 method、含查询串的 path、body、status、ms、time 和 response。单条最多约 1 MiB，超限部分设为 null，并提供 bodyOmitted 或 responseOmitted、字节数和 note。不能解析的请求含 rawBody（若可保留）。服务错误的原始 HTTP 状态和响应正文也可查看。",
        "responses": {
          "200": {
            "description": "批次摘要与可复核记录",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "runId",
                    "createdAt",
                    "updatedAt",
                    "expiresAt",
                    "count",
                    "dropped",
                    "records"
                  ],
                  "properties": {
                    "runId": {
                      "type": "string"
                    },
                    "createdAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "updatedAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "expiresAt": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "dropped": {
                      "type": "integer"
                    },
                    "records": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": [
                          "sequence",
                          "time",
                          "method",
                          "path",
                          "body",
                          "status",
                          "ms",
                          "response"
                        ],
                        "properties": {
                          "runId": {
                            "type": "string"
                          },
                          "sequence": {
                            "type": "integer"
                          },
                          "time": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "method": {
                            "enum": [
                              "GET",
                              "POST"
                            ]
                          },
                          "path": {
                            "type": "string"
                          },
                          "body": {},
                          "status": {
                            "type": "integer"
                          },
                          "ms": {
                            "type": "integer"
                          },
                          "response": {},
                          "bodyBytes": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "responseBytes": {
                            "type": "integer"
                          },
                          "bodyOmitted": {
                            "type": "boolean"
                          },
                          "responseOmitted": {
                            "type": "boolean"
                          },
                          "note": {
                            "type": "string"
                          },
                          "rawBody": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "运行编号格式无效"
          },
          "404": {
            "description": "当前历史中没有该运行编号"
          },
          "410": {
            "description": "指定会话已失效"
          }
        }
      }
    },
    "/api/v1/map/features/{id}": {
      "get": {
        "operationId": "readMapFeatureGeometry",
        "summary": "读取一条基础或用户要素的完整 WGS84 GeoJSON 几何",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "roads:26890",
            "description": "要素查询返回的唯一编号。作为单个路径段时请 URL 编码。"
          }
        ],
        "responses": {
          "200": {
            "description": "含 id、图层、名称、完整坐标、bbox 和原始属性的 GeoJSON Feature。用户图形的原始 id（如有）保存在 sourceId。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MapFeature"
                }
              }
            }
          },
          "404": {
            "description": "没有此要素"
          },
          "410": {
            "description": "指定会话已失效"
          }
        }
      }
    },
    "/api/v1/view": {
      "get": {
        "summary": "读回共享视图",
        "operationId": "readView",
        "parameters": [],
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ViewReceipt"
                }
              }
            }
          },
          "410": {
            "description": "指定会话已失效"
          },
          "default": {
            "description": "参数、身份、限流或上游错误。参见接口说明。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "security": [
          {
            "TestSession": []
          }
        ],
        "summary": "切回室内、返回香港总览或指定经纬度定位",
        "operationId": "setView",
        "parameters": [],
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ViewReceipt"
                }
              }
            }
          },
          "410": {
            "description": "指定会话已失效"
          },
          "428": {
            "description": "此操作或运行记录缺少会话请求头"
          },
          "default": {
            "description": "参数、身份、限流或上游错误。参见接口说明。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ViewCommand"
              },
              "examples": {
                "overview": {
                  "value": {
                    "mode": "hong-kong"
                  }
                },
                "pin": {
                  "value": {
                    "mode": "hong-kong",
                    "longitude": 114.179649968,
                    "latitude": 22.304508609,
                    "span": 0.012,
                    "label": "香港理工大学"
                  }
                },
                "indoor": {
                  "value": {
                    "mode": "indoor"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/hk/search": {
      "get": {
        "summary": "获取香港地名候选及 HK80 坐标",
        "operationId": "searchPlaces",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 100
            },
            "required": true
          },
          {
            "name": "source",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "official",
                "sample"
              ],
              "default": "official"
            },
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Search"
                }
              }
            }
          },
          "410": {
            "description": "指定会话已失效"
          },
          "default": {
            "description": "参数、身份、限流或上游错误。参见接口说明。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/hk/transform": {
      "get": {
        "summary": "将 HK80 东距、北距转换为 WGS84 经纬度",
        "operationId": "convertPoint",
        "parameters": [
          {
            "name": "x",
            "in": "query",
            "schema": {
              "type": "number",
              "minimum": 799500,
              "maximum": 867500
            },
            "required": true
          },
          {
            "name": "y",
            "in": "query",
            "schema": {
              "type": "number",
              "minimum": 799000,
              "maximum": 848000
            },
            "required": true
          },
          {
            "name": "source",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "official",
                "sample"
              ],
              "default": "official"
            },
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Conversion"
                }
              }
            }
          },
          "410": {
            "description": "指定会话已失效"
          },
          "default": {
            "description": "参数、身份、限流或上游错误。参见接口说明。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/map/layers": {
      "get": {
        "summary": "图层清单和当前要素数",
        "operationId": "mapLayers",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "count": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  },
                  "required": [
                    "items"
                  ]
                }
              }
            }
          },
          "410": {
            "description": "指定会话已失效"
          },
          "default": {
            "description": "请求无效或要素不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/map/features": {
      "get": {
        "summary": "查询属性、点识别或矩形选择",
        "operationId": "mapFeatures",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "layer": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          },
                          "bbox": {
                            "type": "array",
                            "items": {
                              "type": "number"
                            },
                            "minItems": 4,
                            "maxItems": 4
                          },
                          "geometryType": {
                            "type": "string"
                          },
                          "properties": {
                            "type": "object"
                          },
                          "distanceM": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "items",
                    "total",
                    "offset",
                    "limit"
                  ]
                }
              }
            }
          },
          "410": {
            "description": "指定会话已失效"
          },
          "428": {
            "description": "此操作或运行记录缺少会话请求头"
          },
          "default": {
            "description": "请求无效或要素不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/MapRun"
          },
          {
            "in": "query",
            "name": "layers",
            "description": "可见图层编号，用逗号分隔。land、roads、places、drawings",
            "schema": {
              "type": "string"
            },
            "required": false
          },
          {
            "in": "query",
            "name": "q",
            "description": "匹配名称或编号",
            "schema": {
              "type": "string"
            },
            "required": false
          },
          {
            "in": "query",
            "name": "id",
            "description": "精确要素编号",
            "schema": {
              "type": "string"
            },
            "required": false
          },
          {
            "in": "query",
            "name": "field",
            "description": "属性字段名，例如 districtZH",
            "schema": {
              "type": "string"
            },
            "required": false
          },
          {
            "in": "query",
            "name": "value",
            "description": "属性文本包含值，例如 油尖旺",
            "schema": {
              "type": "string"
            },
            "required": false
          },
          {
            "in": "query",
            "name": "bbox",
            "description": "框选范围，西,南,东,北",
            "schema": {
              "type": "string"
            },
            "required": false
          },
          {
            "in": "query",
            "name": "point",
            "description": "识别坐标，经度,纬度",
            "schema": {
              "type": "string"
            },
            "required": false
          },
          {
            "in": "query",
            "name": "toleranceM",
            "description": "识别容差（米）",
            "schema": {
              "type": "number"
            },
            "required": false
          },
          {
            "in": "query",
            "name": "offset",
            "description": "跳过的记录数",
            "schema": {
              "type": "integer"
            },
            "required": false
          },
          {
            "in": "query",
            "name": "limit",
            "description": "每页 1 至 100 条",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            },
            "required": false
          }
        ]
      }
    },
    "/api/v1/map/buffer": {
      "post": {
        "parameters": [
          {
            "$ref": "#/components/parameters/MapRun"
          }
        ],
        "operationId": "bufferMapPoint",
        "summary": "以米为单位生成点缓冲区",
        "description": "在中心纬度的局部平面中生成 128 段边界。可将同一 center 与 radiusM 作为 map/features 的 point 和 toleranceM，指定 layers=roads，按距中心的最近距离查询相交道路。中心及整个范围须在两极和日期变更线之内。",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "center",
                  "radiusM"
                ],
                "properties": {
                  "center": {
                    "type": "array",
                    "minItems": 2,
                    "maxItems": 2,
                    "prefixItems": [
                      {
                        "type": "number",
                        "minimum": -180,
                        "maximum": 180
                      },
                      {
                        "type": "number",
                        "exclusiveMinimum": -90,
                        "exclusiveMaximum": 90
                      }
                    ]
                  },
                  "radiusM": {
                    "type": "number",
                    "exclusiveMinimum": 0,
                    "maximum": 100000
                  }
                }
              },
              "example": {
                "center": [
                  114.179649968,
                  22.304508609
                ],
                "radiusM": 300
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "缓冲中心、米制半径、包围框与可直接用于地图的 GeoJSON 多边形",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "center",
                    "radiusM",
                    "coordinateSystem",
                    "method",
                    "bbox",
                    "geometry"
                  ],
                  "properties": {
                    "center": {
                      "type": "array",
                      "minItems": 2,
                      "maxItems": 2,
                      "items": {
                        "type": "number"
                      }
                    },
                    "radiusM": {
                      "type": "number"
                    },
                    "coordinateSystem": {
                      "const": "EPSG:4326"
                    },
                    "method": {
                      "type": "string"
                    },
                    "bbox": {
                      "type": "array",
                      "minItems": 4,
                      "maxItems": 4,
                      "items": {
                        "type": "number"
                      }
                    },
                    "geometry": {
                      "type": "object",
                      "required": [
                        "type",
                        "coordinates"
                      ],
                      "properties": {
                        "type": {
                          "const": "Polygon"
                        },
                        "coordinates": {
                          "type": "array",
                          "minItems": 1,
                          "maxItems": 1,
                          "items": {
                            "type": "array",
                            "minItems": 129,
                            "maxItems": 129,
                            "items": {
                              "type": "array",
                              "minItems": 2,
                              "maxItems": 2,
                              "items": {
                                "type": "number"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "中心、半径或范围无效",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "410": {
            "description": "指定会话已失效"
          },
          "428": {
            "description": "此操作或运行记录缺少会话请求头"
          }
        }
      }
    },
    "/api/v1/map/measure": {
      "post": {
        "parameters": [
          {
            "$ref": "#/components/parameters/MapRun"
          }
        ],
        "summary": "计算 WGS84 线长或面面积与周长",
        "operationId": "mapMeasure",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "geometryType": {
                      "type": "string"
                    },
                    "lengthM": {
                      "type": "number"
                    },
                    "areaM2": {
                      "type": "number"
                    },
                    "perimeterM": {
                      "type": "number"
                    },
                    "method": {
                      "type": "string"
                    },
                    "radiusM": {
                      "type": "number"
                    }
                  }
                }
              }
            }
          },
          "410": {
            "description": "指定会话已失效"
          },
          "428": {
            "description": "此操作或运行记录缺少会话请求头"
          },
          "default": {
            "description": "请求无效或要素不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "geometry": {
                    "$ref": "#/components/schemas/MapGeometry"
                  }
                },
                "required": [
                  "geometry"
                ]
              },
              "example": {
                "geometry": {
                  "type": "LineString",
                  "coordinates": [
                    [
                      114.179649968,
                      22.304508609
                    ],
                    [
                      114.180348713,
                      22.304048034
                    ]
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/map/graphics": {
      "get": {
        "summary": "读回所有已保存的用户图形",
        "operationId": "readGraphics",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MapFeatureCollection"
                }
              }
            }
          },
          "410": {
            "description": "指定会话已失效"
          },
          "default": {
            "description": "请求无效或要素不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "security": [
          {
            "TestSession": []
          }
        ],
        "summary": "追加 WGS84 图形，可导入单一几何、要素或要素集合；最大 2 MiB",
        "operationId": "addGraphics",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "added": {
                      "type": "integer"
                    },
                    "featureCollection": {
                      "$ref": "#/components/schemas/MapFeatureCollection"
                    }
                  }
                }
              }
            }
          },
          "410": {
            "description": "指定会话已失效"
          },
          "428": {
            "description": "此操作或运行记录缺少会话请求头"
          },
          "default": {
            "description": "请求无效或要素不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/MapGeometry"
                  },
                  {
                    "$ref": "#/components/schemas/MapFeature"
                  },
                  {
                    "$ref": "#/components/schemas/MapFeatureCollection"
                  }
                ]
              },
              "example": {
                "type": "Feature",
                "properties": {
                  "name": "理工大学测试线"
                },
                "geometry": {
                  "type": "LineString",
                  "coordinates": [
                    [
                      114.179649968,
                      22.304508609
                    ],
                    [
                      114.180348713,
                      22.304048034
                    ]
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/map/graphics/{workbenchId}": {
      "patch": {
        "security": [
          {
            "TestSession": []
          }
        ],
        "summary": "更新一条用户图形的显示名称",
        "operationId": "renameMapGraphic",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "workbenchId": {
                      "type": "string"
                    },
                    "feature": {
                      "$ref": "#/components/schemas/MapFeature"
                    }
                  }
                }
              }
            }
          },
          "410": {
            "description": "指定会话已失效"
          },
          "428": {
            "description": "此操作或运行记录缺少会话请求头"
          },
          "default": {
            "description": "请求无效或要素不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "workbenchId",
            "description": "服务返回的唯一图形编号，如 drawings:1",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "name"
                ]
              },
              "example": {
                "name": "已核对理工大学"
              }
            }
          }
        }
      },
      "delete": {
        "security": [
          {
            "TestSession": []
          }
        ],
        "summary": "移除一条用户图形",
        "operationId": "removeMapGraphic",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "workbenchId": {
                      "type": "string"
                    },
                    "deleted": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "410": {
            "description": "指定会话已失效"
          },
          "428": {
            "description": "此操作或运行记录缺少会话请求头"
          },
          "default": {
            "description": "请求无效或要素不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "path",
            "name": "workbenchId",
            "description": "服务返回的唯一图形编号，如 drawings:1",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ]
      }
    },
    "/api/v1/map/bookmarks": {
      "get": {
        "summary": "读回范围书签",
        "operationId": "mapBookmarks",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MapBookmark"
                      }
                    }
                  },
                  "required": [
                    "items"
                  ]
                }
              }
            }
          },
          "410": {
            "description": "指定会话已失效"
          },
          "default": {
            "description": "请求无效或要素不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "security": [
          {
            "TestSession": []
          }
        ],
        "summary": "保存范围书签，相同名称更新范围",
        "operationId": "saveMapBookmark",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MapBookmark"
                      }
                    }
                  },
                  "required": [
                    "items"
                  ]
                }
              }
            }
          },
          "410": {
            "description": "指定会话已失效"
          },
          "428": {
            "description": "此操作或运行记录缺少会话请求头"
          },
          "default": {
            "description": "请求无效或要素不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MapBookmark"
              },
              "example": {
                "name": "理工大学",
                "center": [
                  114.179649968,
                  22.304508609
                ],
                "span": 0.012
              }
            }
          }
        }
      },
      "delete": {
        "security": [
          {
            "TestSession": []
          }
        ],
        "summary": "按名称删除单个书签",
        "operationId": "deleteMapBookmark",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MapBookmark"
                      }
                    }
                  },
                  "required": [
                    "items"
                  ]
                }
              }
            }
          },
          "410": {
            "description": "指定会话已失效"
          },
          "428": {
            "description": "此操作或运行记录缺少会话请求头"
          },
          "default": {
            "description": "请求无效或要素不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "query",
            "name": "name",
            "description": "已有书签名称",
            "schema": {
              "type": "string"
            },
            "required": true
          }
        ]
      }
    },
    "/api/v1/map/sample.geojson": {
      "get": {
        "summary": "下载三个真实地点的 GeoJSON 导入样例",
        "operationId": "sampleGeoJSON",
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MapFeatureCollection"
                }
              }
            }
          },
          "410": {
            "description": "指定会话已失效"
          },
          "default": {
            "description": "请求无效或要素不存在",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "MapRun": {
        "name": "X-WebGIS-Run",
        "in": "header",
        "required": false,
        "schema": {
          "type": "string"
        },
        "description": "记录本次调用时传入自选运行号，同时必须带 X-WebGIS-Test-Session。核对网址为 /?run=<运行号>#session=<sessionId>，勿将凭证存入回执。"
      }
    },
    "securitySchemes": {
      "TestSession": {
        "type": "apiKey",
        "in": "header",
        "name": "X-WebGIS-Test-Session",
        "description": "POST /api/v1/test-sessions 后取得 sessionId。读写同一轮结果时带此头。仅持有者可操作；重启和结束操作后仍可重开。"
      }
    },
    "schemas": {
      "ViewCommand": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "indoor"
                ]
              }
            },
            "required": [
              "mode"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "hong-kong"
                ]
              },
              "span": {
                "type": "number",
                "minimum": 0.002,
                "maximum": 1
              },
              "label": {
                "type": "string",
                "maxLength": 100
              }
            },
            "required": [
              "mode"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "hong-kong"
                ]
              },
              "longitude": {
                "type": "number",
                "minimum": 113.8,
                "maximum": 114.5
              },
              "latitude": {
                "type": "number",
                "minimum": 22.1,
                "maximum": 22.6
              },
              "span": {
                "type": "number",
                "minimum": 0.002,
                "maximum": 1
              },
              "label": {
                "type": "string",
                "maxLength": 100
              }
            },
            "required": [
              "mode",
              "longitude",
              "latitude"
            ],
            "additionalProperties": false
          }
        ]
      },
      "ViewReceipt": {
        "type": "object",
        "properties": {
          "revision": {
            "type": "integer",
            "minimum": 0
          },
          "view": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "indoor"
                    ]
                  },
                  "objectId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "mode",
                  "objectId"
                ],
                "additionalProperties": false
              },
              {
                "type": "object",
                "properties": {
                  "mode": {
                    "type": "string",
                    "enum": [
                      "hong-kong"
                    ]
                  },
                  "objectId": {
                    "type": "null"
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "overview",
                      "point"
                    ]
                  },
                  "longitude": {
                    "type": "number",
                    "minimum": 113.8,
                    "maximum": 114.5
                  },
                  "latitude": {
                    "type": "number",
                    "minimum": 22.1,
                    "maximum": 22.6
                  },
                  "span": {
                    "type": "number",
                    "minimum": 0.002,
                    "maximum": 1
                  },
                  "label": {
                    "type": "string",
                    "maxLength": 100
                  }
                },
                "required": [
                  "mode",
                  "objectId",
                  "kind",
                  "longitude",
                  "latitude",
                  "span",
                  "label"
                ],
                "additionalProperties": false
              }
            ]
          }
        },
        "required": [
          "revision",
          "view"
        ],
        "additionalProperties": false
      },
      "Search": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string"
          },
          "capturedAt": {
            "type": "string"
          },
          "dataMode": {
            "type": "string",
            "enum": [
              "official",
              "sample"
            ]
          },
          "coordinateSystem": {
            "type": "string",
            "enum": [
              "EPSG:2326"
            ]
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "nameZH": {
                  "type": "string"
                },
                "nameEN": {
                  "type": "string"
                },
                "addressZH": {
                  "type": "string"
                },
                "addressEN": {
                  "type": "string"
                },
                "districtZH": {
                  "type": "string"
                },
                "districtEN": {
                  "type": "string"
                },
                "x": {
                  "type": [
                    "number",
                    "string"
                  ]
                },
                "y": {
                  "type": [
                    "number",
                    "string"
                  ]
                }
              },
              "required": [
                "x",
                "y"
              ],
              "additionalProperties": true
            }
          }
        },
        "required": [
          "source",
          "dataMode",
          "coordinateSystem",
          "items"
        ],
        "additionalProperties": false
      },
      "Conversion": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string"
          },
          "capturedAt": {
            "type": "string"
          },
          "dataMode": {
            "type": "string",
            "enum": [
              "official",
              "sample"
            ]
          },
          "coordinateSystem": {
            "type": "string",
            "enum": [
              "EPSG:4326"
            ]
          },
          "longitude": {
            "type": "number",
            "minimum": 113.8,
            "maximum": 114.5
          },
          "latitude": {
            "type": "number",
            "minimum": 22.1,
            "maximum": 22.6
          }
        },
        "required": [
          "source",
          "dataMode",
          "coordinateSystem",
          "longitude",
          "latitude"
        ],
        "additionalProperties": false
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      },
      "MapGeometry": {
        "type": "object",
        "properties": {
          "type": {
            "enum": [
              "Point",
              "MultiPoint",
              "LineString",
              "MultiLineString",
              "Polygon",
              "MultiPolygon",
              "GeometryCollection"
            ]
          },
          "coordinates": {
            "type": "array"
          },
          "geometries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MapGeometry"
            }
          }
        },
        "required": [
          "type"
        ]
      },
      "MapFeature": {
        "type": "object",
        "properties": {
          "type": {
            "const": "Feature"
          },
          "id": {
            "type": [
              "string",
              "number"
            ]
          },
          "geometry": {
            "$ref": "#/components/schemas/MapGeometry"
          },
          "properties": {
            "type": [
              "object",
              "null"
            ]
          },
          "workbenchId": {
            "type": "string"
          }
        },
        "required": [
          "type",
          "geometry",
          "properties"
        ]
      },
      "MapFeatureCollection": {
        "type": "object",
        "properties": {
          "type": {
            "const": "FeatureCollection"
          },
          "features": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MapFeature"
            }
          }
        },
        "required": [
          "type",
          "features"
        ]
      },
      "MapBookmark": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "center": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "minItems": 2,
            "maxItems": 2
          },
          "span": {
            "type": "number"
          }
        },
        "required": [
          "name",
          "center",
          "span"
        ]
      }
    }
  }
}