FeatureCollection.fromJson() should also accept a 'Reader' parameter
还没有人认领这个 Issue。
- 主要语言
- Java
- 星标
- 438
- 派生
- 117
- PR 合并指标
- 30 天内没有已合并 PR
描述
Currently a FeatureCollection can not be instantiated from a Reader.
The only function provided requires a String in JSON format as can be seen here.
Such approach is inefficient when reading larger files since the entire file content has to be read and stored in memory before it can be transformed into a FeatureCollection.
If a FeatureCollection could be instantiated from a Reader aswell, only parts of the read file would have to be stored in memory which makes this the more desirable approach in the presented situation.
As the used GSON library already enables the use of a Reader instead of a String, the implementation would be very simple and could look like this:
@Nullable
public static FeatureCollection fromJson(@NonNull Reader reader) {
GsonBuilder gson = new GsonBuilder();
gson.registerTypeAdapterFactory(GeoJsonAdapterFactory.create());
gson.registerTypeAdapterFactory(GeometryAdapterFactory.create());
return gson.create().fromJson(reader, FeatureCollection.class);
}
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
阅读 services-geojson/src/main/java/com/mapbox/geojson/FeatureCollection.java 和现有的 fromJson(String) 入口点。使用所示的 Gson 适配器设置添加 Reader 重载,然后运行相关的项目测试,并确认 Reader 输入会生成 FeatureCollection,同时不改变现有的 String 行为。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- api
- Issue 类型
- 功能
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100