- if ("GML3".equals(outputFormat)) {
- String entityType = "apafField";
- URL schemaLocation = new URL("http://localhost:7070/pkg/eu.netiket.on.apaf/apaf.xsd");
- String namespace = "http://apaf.on.netiket.eu/ns/apaf";
-
- GML gml = new GML(Version.WFS1_1);
- gml.setCoordinateReferenceSystem(DefaultGeographicCRS.WGS84);
- gml.setNamespace("local", namespace);
-
- SimpleFeatureType featureType = gml.decodeSimpleFeatureType(schemaLocation,
- new NameImpl(namespace, entityType + "Feature"));
-
-// CoordinateReferenceSystem crs=DefaultGeographicCRS.WGS84;
-// QName featureName = new QName(namespace,"apafFieldFeature");
-// GMLConfiguration configuration = new GMLConfiguration();
-// FeatureType parsed = GTXML.parseFeatureType(configuration, featureName, crs);
-// SimpleFeatureType featureType = DataUtilities.simple(parsed);
-
- SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(featureType);
- GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
-
- DefaultFeatureCollection featureCollection = new DefaultFeatureCollection();
-
- res.forEach((c) -> {
-// boolean gpx = false;
- Geometry the_geom = null;
- Geometry the_area = null;
-// if (gpx) {
- Content area = c.getContent("gpx/area.gpx").orElse(null);
- if (area != null) {
-
- try (InputStream in = area.open(InputStream.class)) {
- SimpleFeature feature = GpxUtils.parseGpxToPolygon(in);
- the_area = (Geometry) feature.getDefaultGeometry();
- } catch (IOException e) {
- throw new UncheckedIOException("Cannot parse " + c, e);
- }
- }
-// } else {
- if (c.hasContentClass(EntityType.geopoint)) {
- double latitude = c.get(WGS84PosName.lat, Double.class).get();
- double longitude = c.get(WGS84PosName.lng, Double.class).get();
+ final int BUFFER_SIZE = 100 * 1024;
+ try (OutputStream out = zipped ? new ZipOutputStream(exchange.getResponseBody())
+ : new BufferedOutputStream(exchange.getResponseBody(), BUFFER_SIZE)) {
+ if (out instanceof ZipOutputStream zipOut) {
+ String unzippedFileName = fileName.substring(0, fileName.length() - ".zip".length());
+ zipOut.putNextEntry(new ZipEntry(unzippedFileName));
+ }
+
+ if ("GML3".equals(outputFormat)) {
+ encodeCollectionAsGML(res, out);
+ } else if ("application/json".equals(outputFormat)) {
+ encodeCollectionAsGeoJSon(res, out, typeNames);
+ }
+ }
+ }