Azure / Azure/data-api-builder

[Enh]: Support `Geospatial` data type in MSSQL

オープン
#3,219 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
2.x mssql needs discussion
主要言語
C#
スター
1.5k
フォーク
370
平均マージ
3日 22時間
マージ済み PR(30日)
9

説明

# Geospatial data types

In SQL Server and Azure SQL Database, geospatial data is represented using the `geometry` and `geography` data types. These types store spatial data such as points, lines, and polygons, and support rich spatial operations like distance, containment, and intersection.

```sql
CREATE TABLE locations (
id INT PRIMARY KEY,
position GEOGRAPHY -- a latitude/longitude point
)
```

* `GEOGRAPHY` is used for Earth-based (ellipsoidal) coordinates (e.g., GPS).
* `GEOMETRY` is used for flat, projected coordinate systems (e.g., CAD/GIS).

## FOR JSON support

When used with `FOR JSON`, spatial columns are **serialized as strings** in SQL Server.

```sql
SELECT id, position FROM locations FOR JSON AUTO;
```

Returns:

```json
[
{
"id": 1,
"position": "POINT(-104.9903 39.7392)"
}
]
```

The output is a well-known text (WKT) representation of the spatial data.

## Inserting geospatial data

```sql
INSERT INTO locations (id, position)
VALUES (
1,
geography::STPointFromText('POINT(-104.9903 39.7392)', 4326)
);
```

* The `STPointFromText` method accepts WKT format and a spatial reference ID (SRID).
* `4326` is the most common SRID, representing GPS coordinates (WGS 84).

## Data API builder behavior

Data API builder (DAB) should treat geospatial columns as **WKT strings** for both reading and writing.

### Query operations

DAB will expose `GEOGRAPHY` or `GEOMETRY` values as WKT strings in REST responses:

```json
{
"value": [
{
"id": 1,
"position": "POINT(-104.9903 39.7392)"
}
]
}
```

### Mutation operations

When creating or updating rows, input should be a WKT string that SQL Server can parse:

```http
POST /locations
Content-Type: application/json

{
"id": 2,
"position": "POINT(-122.4194 37.7749)"
}
```

Internally, DAB should convert this into a call to `geography::STPointFromText(...)` with SRID `4326`.

### Geospatial Considerations

1. DAB must validate or wrap WKT strings using `STGeomFromText` or `STPointFromText`.
2. All values must include a valid SRID, typically `4326` for GPS.
3. DAB does not parse or visualize spatial data—clients are responsible for rendering.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

実装ファイルやテストは指定されていません。まず、DAB の SQL Server 型の処理と REST のミューテーションおよびレスポンスのパスを探し、次に既存のデータベース型がどのように表現されているかを確認します。GEOGRAPHY 列と GEOMETRY 列が読み取りでは WKT 文字列として公開され、書き込みでは受け付けられ、文書化された SQL Server の動作をカバーできれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
azure, sql
領域
api, databases
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。