mapbox / mapbox/MapboxGeocoder.swift

Migrate response parsing to Turf

未关闭
#216 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Swift
星标
133
派生
46
PR 合并指标
30 天内没有已合并 PR

描述

This library should add the Swift port of Turf as a dependency. GeocodeResult and much of the Placemark struct’s Codable conformance should be replaced by FeatureCollection.

Rationale

This library has a significant amount of response parsing code. Even parsing something as simple as a set of routable points is a hassle:

https://github.com/mapbox/MapboxGeocoder.swift/blob/9dcd38e8bfb2933912f35cd9ecb6ae6ed97565d6/Sources/MapboxGeocoder/MBPlacemark.swift#L453-L460

The existing code is functional, but it requires manual updates any time the Geocoding API changes. Supporting a companion API such as the Japan Search API requires extra care just to get something functional.

As it happens, both APIs’ response formats are valid GeoJSON by design. The Swift port of Turf contains full-fledged, well-tested GeoJSON parsing functionality and model types. MapboxDirections successfully migrated to Turf for its geometry-related needs in mapbox/mapbox-directions-swift#382.

This library would continue to be a lightweight, maintainable wrapper atop the search APIs for use cases that don’t require the full heft of the search SDK or that require specialty endpoints like batch geocoding. Conversions to other standard iOS libraries like Contacts would remain, but the smaller codebase would make it easier to support additional Swift platforms like Linux and Windows with negligible overhead.

Implementation notes

Much of the metadata for each result is stored in GeoJSON foreign members, which are now supported by Turf: mapbox/turf-swift#175.

Turf doesn’t bridge backwards to Objective-C. In order for this library to retain Objective-C support, it would need to wrap any Turf types in Objective-C-compatible classes. That might not be much of a problem in the short term, since the response parsing is mostly an implementation detail. However, to achieve the long-term maintainability gains described above, we may want to limit Objective-C support to the current functionality or even drop it in future versions.

/ref mapbox/MapboxStatic.swift#112
/cc @OttyLab @tsuz

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 Sources/MapboxGeocoder/MBPlacemark.swift 开始,重点检查链接行附近的响应解析,并查看第 112 行对 MapboxStatic.swift 的引用。将 GeocodeResult 和 Placemark 现有的 Codable 处理与 Turf 对 FeatureCollection 的支持进行比较,然后确认预期的搜索响应以及所述的 Objective-C 兼容性范围都已覆盖。

由索引模型根据 Issue 内容生成。

评估

技术栈
swift
领域
api
Issue 类型
重构
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。