# 共用型別 (https://nolantw.github.io/tdx/reference/models/)

## `Records`

```python
class Records(tuple[T, ...]):
    info: RecordsInfo
```

不可變的資料序列，`info` 為發布資訊。

### `to_polars`

```python
def to_polars() -> pl.DataFrame
```

匯出為 Polars 表格，巢狀欄位以點號命名。

### `to_pandas`

```python
def to_pandas() -> pd.DataFrame
```

匯出為 pandas 表格，使用可為空值的 Arrow 欄位。

### `to_arrow`

```python
def to_arrow() -> pa.Table
```

匯出為 Arrow 表格。

## `Timestamp`

```python
type Timestamp = datetime
```

## `MaybeTimestamp`

```python
type MaybeTimestamp = Timestamp | None
```

## `ServiceDate`

```python
type ServiceDate = date
```

## `MaybeDate`

```python
type MaybeDate = ServiceDate | None
```

## `MaybeBool`

```python
type MaybeBool = bool | None
```

## `MaybeFloat`

```python
type MaybeFloat = float | None
```

## `Name`

```python
class Name(BaseModel):
    zh_tw: str | None
    en: str | None
    ja: str | None
    ko: str | None
```

TDX 提供的各語言名稱。

## `Position`

```python
class Position(BaseModel):
    longitude: float
    latitude: float
    geohash: str | None
```

WGS 84 座標。

### `at`

```python
def at(longitude: float, latitude: float) -> Self
```

以經度與緯度建立座標。

### `distance_to`

```python
def distance_to(other: Position) -> float
```

計算與另一座標的測地線距離，單位為公尺。

### `to_shapely`

```python
def to_shapely() -> Point
```

轉換為 Shapely 點。

### `to_geohash`

```python
def to_geohash(precision: int = 9) -> str
```

轉換為 geohash。

## `MaybePosition`

```python
type MaybePosition = Position | None
```

## `ServiceDays`

```python
class ServiceDays(BaseModel):
    tag: str | None
    monday: bool | None
    tuesday: bool | None
    wednesday: bool | None
    thursday: bool | None
    friday: bool | None
    saturday: bool | None
    sunday: bool | None
    national_holidays: bool | None
    typhoon_day: bool | None
```

## `RecordsInfo`

```python
class RecordsInfo(BaseModel):
    authority_code: str | None
    updated_at: MaybeTimestamp
    update_interval: int | None
    source_updated_at: MaybeTimestamp
    source_update_interval: int | None
    version: int | None
    link_version: str | None
    count: int | None
    service_date: MaybeDate
    effective_date: MaybeDate
    expiry_date: MaybeDate
```