mapbox / mapbox/mapbox-java

FeatureCollection.fromJson() should also accept a 'Reader' parameter

Đang mở
#1,136 1 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

GeoJson
Ngôn ngữ chính
Java
Star
438
Fork
117
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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);
}

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Đọc services-geojson/src/main/java/com/mapbox/geojson/FeatureCollection.java và entry point fromJson(String) hiện có. Thêm overload cho Reader bằng thiết lập Gson adapter đã nêu, sau đó chạy các bài kiểm thử liên quan của dự án và xác nhận rằng đầu vào Reader tạo ra một FeatureCollection mà không thay đổi hành vi hiện có của String.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
api
Loại issue
Tính năng
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.