ctc_poc2026/docs/tables/td_grid.md

47 lines
3.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

|字段名称|字段类型|中文说明|注释|是否为主键|
|---|---|---|---|---|
|regionid|varchar(64) NOT NULL|栅格所属区域 ID|栅格所属区域 ID|是|
|x_offset_20|varchar(32) NOT NULL|栅格 X 偏移20m 网格编码)|栅格 X 偏移20m 网格编码)|否|
|y_offset_20|varchar(32) NOT NULL|栅格 Y 偏移20m 网格编码)|栅格 Y 偏移20m 网格编码)|否|
|provincecode|integer NOT NULL|省编码|省编码|否|
|province_name|varchar(64) NOT NULL|省名称|省名称|否|
|citycode|integer NOT NULL|地市编码|地市编码|否|
|city_name|varchar(64) NOT NULL|地市名称|地市名称|否|
|districtcode|integer NOT NULL|区县编码|区县编码|否|
|district_name|varchar(64) NOT NULL|区县名称|区县名称|否|
|center_lon|numeric(10, 6)|栅格中心点经度EPSG:4326|栅格中心点经度EPSG:4326|否|
|center_lat|numeric(10, 6)|栅格中心点纬度EPSG:4326|栅格中心点纬度EPSG:4326|否|
|grid_wkt|text|栅格多边形 WKTEPSG:4326|栅格多边形 WKTEPSG:4326|否|
|grid_geom|geometry(Polygon, 4326)|由 grid_wkt 生成的 Polygon 几何列,用于 GiST 空间索引|由 grid_wkt 生成的 Polygon 几何列,用于 GiST 空间索引|否|
|is_valid|smallint NOT NULL DEFAULT 1|是否有效1=有效 0=无效|是否有效1=有效 0=无效|否|
|updated_time|timestamp without time zone NOT NULL DEFAULT now()|记录更新时间|记录更新时间|否|
---
### 计算逻辑说明
* **实现侧**HiveSQL
* **数据源**:仅从 ODS 层 `OTT_GRID` 提取。
* **计算逻辑**
1. 提取全量不重复的 `regionid` 序列。
2. **WKT 生成**:基于中心点 $(center\_lon, center\_lat)$ 和偏移量 $(x\_offset\_20, y\_offset\_20)$。顶点坐标为 $(center\_lon \pm x\_offset\_20 / 2, center\_lat \pm y\_offset\_20 / 2)$。**严禁进行米/度转换,直接使用坐标偏移值**。
3. 同步至 PostGIS 侧,利用 `ST_GeomFromText` 生成 `grid_geom`
* **索引创建建议 (PostGIS 侧)**
* **空间索引**:必须对 `grid_geom` 建立 `GIST` 索引,以支撑与楼宇/场景面的空间关联。
* **业务索引**:对 `regionid` 建立 `B-TREE` 唯一索引;对 `provincecode`, `citycode`, `districtcode` 建立复合索引。
* **字段全量映射清单**
| 目标字段 | 来源 ODS (OTT_GRID) | 转换逻辑/备注 |
| :--- | :--- | :--- |
| `regionid` | `regionid` | 直接映射 (主键) |
| `x_offset_20` | `x_offset_20` | 直接映射 |
| `y_offset_20` | `y_offset_20` | 直接映射 |
| `provincecode` | `provincecode` | 直接映射 |
| `province_name` | `province_name` | 直接映射 |
| `citycode` | `citycode` | 直接映射 |
| `city_name` | `city_name` | 直接映射 |
| `districtcode` | `districtcode` | 直接映射 |
| `district_name` | `district_name` | 直接映射 |
| `center_lon` | `center_lon` | 直接映射 |
| `center_lat` | `center_lat` | 直接映射 |
| `grid_wkt` | `center_lon/lat`, `offsets` | 依据上述“坐标偏移法”拼接 |
| `grid_geom` | `grid_wkt` | PostGIS: `ST_GeomFromText(..., 4326)` |
| `is_valid` | - | 常量填充 `1` |
| `updated_time` | - | 系统当前时间 `now()` |