/** * Writes the collection bounds * * @param featureBounding * @param jsonWriter * @param resultsList * @param hasGeom */ protected void writeCollectionBounds( boolean featureBounding, GeoJSONBuilder jsonWriter, List<FeatureCollection> resultsList, boolean hasGeom) { // Bounding box for featurecollection if (hasGeom && featureBounding) { ReferencedEnvelope e = null; for (int i = 0; i < resultsList.size(); i++) { FeatureCollection collection = resultsList.get(i); if (e == null) { e = collection.getBounds(); } else { e.expandToInclude(collection.getBounds()); } } if (e != null) { jsonWriter.setAxisOrder(CRS.getAxisOrder(e.getCoordinateReferenceSystem())); jsonWriter.writeBoundingBox(e); } } }
jsonWriter.setAxisOrder(CRS.getAxisOrder(crs)); if (crs != null) { } else { jsonWriter.setAxisOrder(CRS.AxisOrder.EAST_NORTH);
public GeoJsonWMSBuilder(Rectangle mapSize, ReferencedEnvelope mapArea) { final int memotyBufferThreshold = 8096; out = new DeferredFileOutputStream(memotyBufferThreshold, "geojson", ".geojson", null); writer = new OutputStreamWriter(out, Charsets.UTF_8); jsonWriter = new org.geoserver.wfs.json.GeoJSONBuilder(writer); jsonWriter.object(); // start root object jsonWriter.key("type").value("FeatureCollection"); jsonWriter.key("totalFeatures").value("unknown"); jsonWriter.key("features"); jsonWriter.array(); CoordinateReferenceSystem mapCrs = mapArea.getCoordinateReferenceSystem(); jsonWriter.setAxisOrder(CRS.getAxisOrder(mapCrs)); Unit<?> unit = mapCrs.getCoordinateSystem().getAxis(0).getUnit(); Unit<?> standardUnit = unit.getSystemUnit(); PrecisionModel pm = null; if (SI.RADIAN.equals(standardUnit)) { pm = new PrecisionModel(1e6); // truncate coords at 6 decimals } else if (SI.METRE.equals(standardUnit)) { pm = new PrecisionModel(100); // truncate coords at 2 decimals } if (pm != null) { precisionReducerFilter = new CoordinatePrecisionReducerFilter(pm); } }
public GeoJsonWMSBuilder(Rectangle mapSize, ReferencedEnvelope mapArea) { final int memotyBufferThreshold = 8096; out = new DeferredFileOutputStream(memotyBufferThreshold, "geojson", ".geojson", null); writer = new OutputStreamWriter(out, Charsets.UTF_8); jsonWriter = new org.geoserver.wfs.json.GeoJSONBuilder(writer); jsonWriter.object();// start root object jsonWriter.key("type").value("FeatureCollection"); jsonWriter.key("totalFeatures").value("unknown"); jsonWriter.key("features"); jsonWriter.array(); CoordinateReferenceSystem mapCrs = mapArea.getCoordinateReferenceSystem(); jsonWriter.setAxisOrder(CRS.getAxisOrder(mapCrs)); Unit<?> unit = mapCrs.getCoordinateSystem().getAxis(0).getUnit(); Unit<?> standardUnit = unit.getStandardUnit(); PrecisionModel pm = null; if (SI.RADIAN.equals(standardUnit)) { pm = new PrecisionModel(1e6);// truncate coords at 6 decimals } else if (SI.METRE.equals(standardUnit)) { pm = new PrecisionModel(100);// truncate coords at 2 decimals } if (pm != null) { precisionReducerFilter = new CoordinatePrecisionReducerFilter(pm); } }
CoordinateReferenceSystem featureCrs = defaultGeomType.getCoordinateReferenceSystem(); jsonWriter.setAxisOrder(CRS.getAxisOrder(featureCrs)); if (crs == null) { crs = featureCrs; jsonWriter.setAxisOrder(CRS.AxisOrder.EAST_NORTH);