pub fn to_json<T: Writer, M: Clone + Serialize, P: Clone + Default + Serialize, D: Clone + Default + Serialize, I: FeatureReader<M, P, D>>(
writer: &mut T,
readers: Vec<&I>,
opts: Option<ToJSONOptions<M, P, D>>,
)Expand description
§To JSON
§Description
Given a writer and an array of readers, write the input features to the writer as a JSON object
§Parameters
writer: the buffer or file to write to. SeeWriterfor what writers are availablereaders: Any reader that implements theFeatureReadertrait can be usedopts: user defined options on how to write the features
§Usage
use gistools::{readers::JSONReader, parsers::{BufferWriter, FileReader}, writers::{to_json, ToJSONOptions}};
use s2json::{MValueCompatible, Projection};
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
#[derive(Debug, Default, Clone, MValueCompatible, PartialEq, Serialize, Deserialize)]
#[serde(default)]
struct Props {
name: String,
}
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path = path.join("tests/writers/fixtures/points.geojson");
let reader: JSONReader<FileReader, (), Props, ()> = JSONReader::new(FileReader::from(path));
let mut writer = BufferWriter::default();
// write
to_json(
&mut writer,
vec![&reader],
Some(ToJSONOptions {
projection: Some(Projection::WG),
geojson: Some(true),
..Default::default()
}),
);