Skip to content

Commit 605fde0

Browse files
committed
docs: update doc for reverse geoencoding
1 parent e5d0602 commit 605fde0

File tree

3 files changed

+66
-7
lines changed

3 files changed

+66
-7
lines changed

apps/docs/contents/index.mdx

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Overview
33
createdAt: 2025-07-20T22:35:03+08:00
4-
lastModified: 2025-11-14T21:52:55+08:00
4+
lastModified: 2025-11-15T01:31:13+08:00
55
---
66

77
# Overview
@@ -45,6 +45,7 @@ Live Photo Galleries:
4545
- 🌈 **Blurhash Placeholders** - Elegant image loading experience
4646
- 📱 **Live Photo Support** - Detection and display of iPhone Live Photos
4747
- ☀️ **HDR Image Support** - Display HDR images
48+
- 🌍 **Reverse Geocoding** - Automatic location extraction from GPS coordinates with support for Mapbox and Nominatim providers
4849

4950
### Advanced Features
5051

@@ -126,6 +127,10 @@ This will automatically pull resources from the remote repository, avoiding rebu
126127
- `enableLivePhotoDetection`: Enable Live Photo detection
127128
- `digestSuffixLength`: Digest suffix length for deterministic IDs
128129
- `supportedFormats`: Optional allowlist of file extensions to process
130+
- `enableGeocoding`: Enable reverse geocoding from GPS coordinates (default: `false`)
131+
- `geocodingProvider`: Geocoding service provider (`'mapbox'` | `'nominatim'` | `'auto'`, default: `'auto'`)
132+
- `mapboxToken`: Mapbox access token (required when using Mapbox provider)
133+
- `nominatimBaseUrl`: Custom Nominatim base URL (optional, defaults to OpenStreetMap's public instance)
129134

130135
#### System Observability (`system.observability`)
131136

@@ -138,6 +143,44 @@ This will automatically pull resources from the remote repository, avoiding rebu
138143
- `performance.worker.timeout`: Worker timeout (milliseconds)
139144
- `performance.worker.useClusterMode`: Enable cluster mode
140145

146+
#### Geocoding Configuration Example
147+
148+
To enable reverse geocoding, configure the geocoding provider in your `builder.config.ts`:
149+
150+
**Using Nominatim (Free, but rate-limited):**
151+
152+
```typescript
153+
{
154+
system: {
155+
processing: {
156+
enableGeocoding: true,
157+
// Optional: use custom Nominatim instance
158+
// nominatimBaseUrl: 'https://your-nominatim-instance.com'
159+
}
160+
}
161+
}
162+
163+
```
164+
165+
**Using Mapbox:**
166+
167+
```typescript
168+
{
169+
system: {
170+
processing: {
171+
enableGeocoding: true,
172+
mapboxToken: process.env.MAPBOX_TOKEN
173+
}
174+
}
175+
}
176+
```
177+
178+
**Notes:**
179+
- Mapbox maybe provide higher accuracy and better rate limits but requires an API token
180+
- Nominatim is free but has strict rate limits (1 request/second)
181+
- Both providers support intelligent caching to minimize API calls
182+
- Location data includes country, city, and location name extracted from GPS coordinates
183+
141184
## 📋 CLI Commands
142185

143186
### Build Commands

packages/builder/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ src/core/
2020
│ └── exif.ts # EXIF 数据提取
2121
├── photo/ # 照片处理
2222
│ ├── info-extractor.ts # 照片信息提取
23-
│ └── processor.ts # 照片处理主逻辑
23+
│ ├── processor.ts # 照片处理主逻辑
24+
│ └── geocoding.ts # 反向地理编码
2425
├── manifest/ # Manifest 管理
2526
│ └── manager.ts # Manifest 读写和管理
2627
├── worker/ # 并发处理
@@ -62,6 +63,7 @@ src/core/
6263

6364
- **info-extractor.ts**: 从文件名和 EXIF 提取照片信息
6465
- **processor.ts**: 照片处理主流程,整合所有处理步骤
66+
- **geocoding.ts**: 反向地理编码,支持 Mapbox 和 Nominatim 提供者
6567

6668
### 6. Manifest 管理 (`manifest/`)
6769

@@ -136,6 +138,13 @@ const exif = await extractExifData(buffer)
136138
- 可配置的并发数
137139
- 环境变量配置
138140

141+
### 6. 地理编码支持
142+
143+
- 从 GPS 坐标提取位置信息
144+
- 支持 Mapbox 和 Nominatim 两种提供者
145+
- 智能缓存和速率限制
146+
- 自动重试和并发安全
147+
139148
## 扩展指南
140149

141150
### 添加新的图像处理功能

packages/builder/src/photo/README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- **`live-photo-handler.ts`** - Live Photo 检测和处理
1313
- **`logger-adapter.ts`** - Logger 适配器,实现适配器模式
1414
- **`info-extractor.ts`** - 照片信息提取
15+
- **`geocoding.ts`** - 反向地理编码,从 GPS 坐标提取位置信息
1516

1617
### 设计模式
1718

@@ -43,17 +44,19 @@ class CompatibleLoggerAdapter implements PhotoLogger {
4344
3. 处理缩略图和 blurhash
4445
4. 处理 EXIF 数据
4546
5. 处理影调分析
46-
6. 提取照片信息
47-
7. 处理 Live Photo
48-
8. 构建照片清单项
47+
6. 处理地理编码(从 GPS 坐标反向解析位置信息)
48+
7. 提取照片信息
49+
8. 处理 Live Photo
50+
9. 构建照片清单项
4951

5052
### 主要改进
5153

5254
1. **模块化分离**: 将不同的处理逻辑分离到专门的模块中
5355
2. **Logger 适配器**: 使用异步执行上下文管理 logger,避免全局状态污染
5456
3. **缓存管理**: 统一管理各种数据的缓存和复用逻辑
5557
4. **Live Photo 处理**: 专门的模块处理 Live Photo 检测和匹配
56-
5. **类型安全**: 完善的 TypeScript 类型定义
58+
5. **反向地理编码**: 支持从 GPS 坐标提取位置信息,支持多个地理编码提供商
59+
6. **类型安全**: 完善的 TypeScript 类型定义
5760

5861
### 使用方法
5962

@@ -80,7 +83,8 @@ const result = await processPhoto(
8083
#### 单独使用各个模块
8184

8285
```typescript
83-
import { processLivePhoto, processThumbnailAndBlurhash, processExifData } from './index.js'
86+
import { processLivePhoto, processThumbnailAndBlurhash, processExifData, processLocationData } from './index.js'
87+
import { createGeocodingProvider } from './geocoding.js'
8488

8589
// Live Photo 处理
8690
const livePhotoResult = processLivePhoto(photoKey, livePhotoMap, builder.getStorageManager())
@@ -90,6 +94,9 @@ const thumbnailResult = await processThumbnailAndBlurhash(imageBuffer, photoId,
9094

9195
// EXIF 处理
9296
const exifData = await processExifData(imageBuffer, rawImageBuffer, photoKey, existingItem, options)
97+
98+
// 地理编码处理
99+
const locationInfo = await processLocationData(exifData, photoKey, existingItem, options)
93100
```
94101

95102
### 扩展性

0 commit comments

Comments
 (0)