List of usage examples for org.json.simple JSONStreamAware JSONStreamAware
JSONStreamAware
From source file:at.localhost.vectorworldmap.util.FeatureJSON.java
/** * Writes a feature collection as GeoJSON. * * @param features The feature collection. * @param output The output. See {@link GeoJSONUtil#toWriter(Object)} for details. *//*from w w w . j a va 2s.c o m*/ public void writeFeatureCollection(FeatureCollection features, Object output) throws IOException { LinkedHashMap obj = new LinkedHashMap(); obj.put("type", "FeatureCollection"); if (encodeFeatureCollectionBounds || encodeFeatureCollectionCRS) { final ReferencedEnvelope bounds = features.getBounds(); if (encodeFeatureCollectionBounds) { obj.put("bbox", new JSONStreamAware() { public void writeJSONString(Writer out) throws IOException { JSONArray.writeJSONString(Arrays.asList(bounds.getMinX(), bounds.getMinY(), bounds.getMaxX(), bounds.getMaxY()), out); } }); } if (encodeFeatureCollectionCRS) { obj.put("crs", createCRS(bounds.getCoordinateReferenceSystem())); } } if (encodeDistanceTolerance) { obj.put("tolerance", Double.toString(distanceTolerance)); } obj.put("features", new FeatureCollectionEncoder(features, gjson)); GeoJSONUtil.encode(obj, output); }