FeatureCollection.fromJson() should also accept a 'Reader' parameter
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Java
- Estrellas
- 438
- Forks
- 117
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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);
}
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Lee services-geojson/src/main/java/com/mapbox/geojson/FeatureCollection.java y el punto de entrada fromJson(String) existente. Añade la sobrecarga para Reader usando la configuración del adaptador Gson mostrada, ejecuta después las pruebas pertinentes del proyecto y confirma que la entrada Reader produce una FeatureCollection sin cambiar el comportamiento existente de String.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- java
- Área
- api
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 45/100